Remove StreamTimeout from server completely

This commit is contained in:
Andy Wang 2020-12-12 17:51:54 +00:00
parent e77fd4c446
commit d5a003d6d6
No known key found for this signature in database
GPG Key ID: 181B49F9F38F3374
3 changed files with 21 additions and 33 deletions

View File

@ -116,9 +116,6 @@ and will raise an error. See Issue #13.**
`KeepAlive` is the number of seconds to tell the OS to wait after no activity before sending TCP KeepAlive probes to the `KeepAlive` is the number of seconds to tell the OS to wait after no activity before sending TCP KeepAlive probes to the
upstream proxy server. Zero or negative value disables it. Default is 0 (disabled). upstream proxy server. Zero or negative value disables it. Default is 0 (disabled).
`StreamTimeout` is the number of seconds of no data *sent* after which the incoming Cloak client connection will be
terminated. Default is 300 seconds.
### Client ### Client
`UID` is your UID in base64. `UID` is your UID in base64.
@ -152,8 +149,9 @@ Currently, `chrome` and `firefox` are supported.
Cloak server. Zero or negative value disables it. Default is 0 (disabled). Warning: Enabling it might make your server Cloak server. Zero or negative value disables it. Default is 0 (disabled). Warning: Enabling it might make your server
more detectable as a proxy, but it will make the Cloak client detect internet interruption more quickly. more detectable as a proxy, but it will make the Cloak client detect internet interruption more quickly.
`StreamTimeout` is the number of seconds of no data *received* after which the incoming proxy connection will be `StreamTimeout` is the number of seconds of Cloak waits for an incoming connection from a proxy program to send any
terminated. Default is 300 seconds. data, after which the connection will be closed by Cloak. Cloak will not enforce any timeout on TCP connections after it
is established.
## Setup ## Setup

View File

@ -15,16 +15,15 @@ import (
) )
type RawConfig struct { type RawConfig struct {
ProxyBook map[string][]string ProxyBook map[string][]string
BindAddr []string BindAddr []string
BypassUID [][]byte BypassUID [][]byte
RedirAddr string RedirAddr string
PrivateKey []byte PrivateKey []byte
AdminUID []byte AdminUID []byte
DatabasePath string DatabasePath string
StreamTimeout int KeepAlive int
KeepAlive int CncMode bool
CncMode bool
} }
// State type stores the global state of the program // State type stores the global state of the program
@ -34,8 +33,6 @@ type State struct {
WorldState common.WorldState WorldState common.WorldState
AdminUID []byte AdminUID []byte
Timeout time.Duration
//KeepAlive time.Duration
BypassUID map[[16]byte]struct{} BypassUID map[[16]byte]struct{}
StaticPv crypto.PrivateKey StaticPv crypto.PrivateKey
@ -153,12 +150,6 @@ func InitState(preParse RawConfig, worldState common.WorldState) (sta *State, er
sta.Panel = MakeUserPanel(manager) sta.Panel = MakeUserPanel(manager)
} }
if preParse.StreamTimeout == 0 {
sta.Timeout = time.Duration(300) * time.Second
} else {
sta.Timeout = time.Duration(preParse.StreamTimeout) * time.Second
}
if preParse.KeepAlive <= 0 { if preParse.KeepAlive <= 0 {
sta.ProxyDialer = &net.Dialer{KeepAlive: -1} sta.ProxyDialer = &net.Dialer{KeepAlive: -1}
} else { } else {

View File

@ -138,16 +138,15 @@ func generateClientConfigs(rawConfig client.RawConfig, state common.WorldState)
func basicServerState(ws common.WorldState, db *os.File) *server.State { func basicServerState(ws common.WorldState, db *os.File) *server.State {
var serverConfig = server.RawConfig{ var serverConfig = server.RawConfig{
ProxyBook: map[string][]string{"shadowsocks": {"tcp", "fake.com:9999"}, "openvpn": {"udp", "fake.com:9999"}}, ProxyBook: map[string][]string{"shadowsocks": {"tcp", "fake.com:9999"}, "openvpn": {"udp", "fake.com:9999"}},
BindAddr: []string{"fake.com:9999"}, BindAddr: []string{"fake.com:9999"},
BypassUID: [][]byte{bypassUID[:]}, BypassUID: [][]byte{bypassUID[:]},
RedirAddr: "fake.com:9999", RedirAddr: "fake.com:9999",
PrivateKey: privateKey, PrivateKey: privateKey,
AdminUID: nil, AdminUID: nil,
DatabasePath: db.Name(), DatabasePath: db.Name(),
StreamTimeout: 300, KeepAlive: 15,
KeepAlive: 15, CncMode: false,
CncMode: false,
} }
state, err := server.InitState(serverConfig, ws) state, err := server.InitState(serverConfig, ws)
if err != nil { if err != nil {