From d5a003d6d6e29936d2581517bc3cbdefd0e7b1f0 Mon Sep 17 00:00:00 2001 From: Andy Wang Date: Sat, 12 Dec 2020 17:51:54 +0000 Subject: [PATCH] Remove StreamTimeout from server completely --- README.md | 8 +++----- internal/server/state.go | 27 +++++++++------------------ internal/test/integration_test.go | 19 +++++++++---------- 3 files changed, 21 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 633a504..d5330f0 100644 --- a/README.md +++ b/README.md @@ -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 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 `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 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 -terminated. Default is 300 seconds. +`StreamTimeout` is the number of seconds of Cloak waits for an incoming connection from a proxy program to send any +data, after which the connection will be closed by Cloak. Cloak will not enforce any timeout on TCP connections after it +is established. ## Setup diff --git a/internal/server/state.go b/internal/server/state.go index b364783..66541f5 100644 --- a/internal/server/state.go +++ b/internal/server/state.go @@ -15,16 +15,15 @@ import ( ) type RawConfig struct { - ProxyBook map[string][]string - BindAddr []string - BypassUID [][]byte - RedirAddr string - PrivateKey []byte - AdminUID []byte - DatabasePath string - StreamTimeout int - KeepAlive int - CncMode bool + ProxyBook map[string][]string + BindAddr []string + BypassUID [][]byte + RedirAddr string + PrivateKey []byte + AdminUID []byte + DatabasePath string + KeepAlive int + CncMode bool } // State type stores the global state of the program @@ -34,8 +33,6 @@ type State struct { WorldState common.WorldState AdminUID []byte - Timeout time.Duration - //KeepAlive time.Duration BypassUID map[[16]byte]struct{} StaticPv crypto.PrivateKey @@ -153,12 +150,6 @@ func InitState(preParse RawConfig, worldState common.WorldState) (sta *State, er 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 { sta.ProxyDialer = &net.Dialer{KeepAlive: -1} } else { diff --git a/internal/test/integration_test.go b/internal/test/integration_test.go index 211092a..9f086c1 100644 --- a/internal/test/integration_test.go +++ b/internal/test/integration_test.go @@ -138,16 +138,15 @@ func generateClientConfigs(rawConfig client.RawConfig, state common.WorldState) func basicServerState(ws common.WorldState, db *os.File) *server.State { var serverConfig = server.RawConfig{ - ProxyBook: map[string][]string{"shadowsocks": {"tcp", "fake.com:9999"}, "openvpn": {"udp", "fake.com:9999"}}, - BindAddr: []string{"fake.com:9999"}, - BypassUID: [][]byte{bypassUID[:]}, - RedirAddr: "fake.com:9999", - PrivateKey: privateKey, - AdminUID: nil, - DatabasePath: db.Name(), - StreamTimeout: 300, - KeepAlive: 15, - CncMode: false, + ProxyBook: map[string][]string{"shadowsocks": {"tcp", "fake.com:9999"}, "openvpn": {"udp", "fake.com:9999"}}, + BindAddr: []string{"fake.com:9999"}, + BypassUID: [][]byte{bypassUID[:]}, + RedirAddr: "fake.com:9999", + PrivateKey: privateKey, + AdminUID: nil, + DatabasePath: db.Name(), + KeepAlive: 15, + CncMode: false, } state, err := server.InitState(serverConfig, ws) if err != nil {