From 72b6a3ad0b3e5bd42c607b6de2760dfd9f1d4e62 Mon Sep 17 00:00:00 2001 From: notsure2 Date: Fri, 21 Apr 2023 15:39:42 +0200 Subject: [PATCH] Merge --- README.md | 9 ++++-- cmd/ck-client/ck-client.go | 4 ++- cmd/ck-client/log.go | 1 + cmd/ck-client/log_android.go | 4 ++- cmd/ck-client/protector.go | 1 + cmd/ck-client/protector_android.go | 4 ++- cmd/ck-server/ck-server.go | 7 +++-- cmd/ck-server/ck-server_test.go | 3 +- cmd/ck-server/keygen.go | 1 + go.mod | 3 +- go.sum | 30 ++++++++++++++----- internal/client/TLS.go | 3 +- internal/client/TLS_test.go | 3 +- internal/client/auth.go | 1 + internal/client/auth_test.go | 5 ++-- internal/client/chrome.go | 1 + internal/client/connector.go | 3 +- internal/client/firefox.go | 1 + internal/client/piper.go | 3 +- internal/client/state.go | 11 +++++-- internal/client/state_test.go | 3 +- internal/client/websocket.go | 11 +++---- internal/common/crypto_test.go | 3 +- internal/common/websocket.go | 3 +- .../multiplex/datagramBufferedPipe_test.go | 3 +- internal/multiplex/mux_test.go | 7 +++-- internal/multiplex/obfs.go | 1 + internal/multiplex/obfs_test.go | 5 ++-- internal/multiplex/session.go | 3 +- internal/multiplex/session_fuzz.go | 1 + internal/multiplex/session_test.go | 5 ++-- internal/multiplex/stream.go | 3 +- internal/multiplex/streamBuffer_test.go | 1 + internal/multiplex/streamBufferedPipe_test.go | 3 +- internal/multiplex/stream_test.go | 5 ++-- internal/multiplex/switchboard.go | 3 +- internal/multiplex/switchboard_test.go | 5 ++-- internal/server/TLS.go | 5 ++-- internal/server/TLSAux.go | 1 + internal/server/activeuser.go | 3 +- internal/server/activeuser_test.go | 7 +++-- internal/server/auth.go | 3 +- internal/server/auth_test.go | 5 ++-- internal/server/dispatcher.go | 5 ++-- internal/server/dispatcher_test.go | 5 ++-- internal/server/first_packet_fuzz.go | 6 ++-- internal/server/state.go | 7 +++-- .../server/usermanager/api_router_test.go | 3 +- internal/server/usermanager/localmanager.go | 1 + .../server/usermanager/localmanager_test.go | 5 ++-- .../server/usermanager/voidmanager_test.go | 3 +- internal/server/userpanel.go | 3 +- internal/server/userpanel_test.go | 5 ++-- internal/server/websocket.go | 5 ++-- internal/server/websocketAux.go | 5 ++-- internal/server/websocketAux_test.go | 3 +- internal/test/integration_test.go | 13 ++++---- 57 files changed, 169 insertions(+), 87 deletions(-) diff --git a/README.md b/README.md index e2dff6a..0eb2966 100644 --- a/README.md +++ b/README.md @@ -155,8 +155,13 @@ Example: `CDNOriginHost` is the domain name of the _origin_ server (i.e. the server running Cloak) under `CDN` mode. This only has effect when `Transport` is set to `CDN`. If unset, it will default to the remote hostname supplied via the commandline argument (in standalone mode), or by Shadowsocks (in plugin mode). After a TLS session is established with -the CDN server, this domain name will be used in the HTTP request to ask the CDN server to establish a WebSocket -connection with this host. +the CDN server, this domain name will be used in the `Host` header of the HTTP request to ask the CDN server to +establish a WebSocket connection with this host. + +`CDNWsUrlPath` is the url path used to build websocket request sent under `CDN` mode, and also only has effect +when `Transport` is set to `CDN`. If unset, it will default to "/". This option is used to build the first line of the +HTTP request after a TLS session is extablished. It's mainly for a Cloak server behind a reverse proxy, while only +requests under specific url path are forwarded. `NumConn` is the amount of underlying TCP connections you want to use. The default of 4 should be appropriate for most people. Setting it too high will hinder the performance. Setting it to 0 will disable connection multiplexing and each diff --git a/cmd/ck-client/ck-client.go b/cmd/ck-client/ck-client.go index 38bf95d..1a43651 100644 --- a/cmd/ck-client/ck-client.go +++ b/cmd/ck-client/ck-client.go @@ -1,3 +1,4 @@ +//go:build go1.11 // +build go1.11 package main @@ -7,10 +8,11 @@ import ( "encoding/binary" "flag" "fmt" - "github.com/cbeuw/Cloak/internal/common" "net" "os" + "github.com/cbeuw/Cloak/internal/common" + "github.com/cbeuw/Cloak/internal/client" mux "github.com/cbeuw/Cloak/internal/multiplex" log "github.com/sirupsen/logrus" diff --git a/cmd/ck-client/log.go b/cmd/ck-client/log.go index 4fc5dec..e44b066 100644 --- a/cmd/ck-client/log.go +++ b/cmd/ck-client/log.go @@ -1,3 +1,4 @@ +//go:build !android // +build !android package main diff --git a/cmd/ck-client/log_android.go b/cmd/ck-client/log_android.go index 7c7b967..301b35e 100644 --- a/cmd/ck-client/log_android.go +++ b/cmd/ck-client/log_android.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build android // +build android package main @@ -28,9 +29,10 @@ import "C" import ( "bufio" - log "github.com/sirupsen/logrus" "os" "unsafe" + + log "github.com/sirupsen/logrus" ) var ( diff --git a/cmd/ck-client/protector.go b/cmd/ck-client/protector.go index 3af0dde..89fbf76 100644 --- a/cmd/ck-client/protector.go +++ b/cmd/ck-client/protector.go @@ -1,3 +1,4 @@ +//go:build !android // +build !android package main diff --git a/cmd/ck-client/protector_android.go b/cmd/ck-client/protector_android.go index fbaea7b..4b6e6d1 100644 --- a/cmd/ck-client/protector_android.go +++ b/cmd/ck-client/protector_android.go @@ -1,3 +1,4 @@ +//go:build android // +build android package main @@ -65,8 +66,9 @@ void set_timeout(int sock) { import "C" import ( - log "github.com/sirupsen/logrus" "syscall" + + log "github.com/sirupsen/logrus" ) // In Android, once an app starts the VpnService, all outgoing traffic are routed by the system diff --git a/cmd/ck-server/ck-server.go b/cmd/ck-server/ck-server.go index b83460c..b1c0bb0 100644 --- a/cmd/ck-server/ck-server.go +++ b/cmd/ck-server/ck-server.go @@ -3,15 +3,16 @@ package main import ( "flag" "fmt" - "github.com/cbeuw/Cloak/internal/common" - "github.com/cbeuw/Cloak/internal/server" - log "github.com/sirupsen/logrus" "net" "net/http" _ "net/http/pprof" "os" "runtime" "strings" + + "github.com/cbeuw/Cloak/internal/common" + "github.com/cbeuw/Cloak/internal/server" + log "github.com/sirupsen/logrus" ) var version string diff --git a/cmd/ck-server/ck-server_test.go b/cmd/ck-server/ck-server_test.go index 87427ee..1afdc9c 100644 --- a/cmd/ck-server/ck-server_test.go +++ b/cmd/ck-server/ck-server_test.go @@ -1,9 +1,10 @@ package main import ( - "github.com/stretchr/testify/assert" "net" "testing" + + "github.com/stretchr/testify/assert" ) func TestParseBindAddr(t *testing.T) { diff --git a/cmd/ck-server/keygen.go b/cmd/ck-server/keygen.go index 78fffd5..7361e67 100644 --- a/cmd/ck-server/keygen.go +++ b/cmd/ck-server/keygen.go @@ -3,6 +3,7 @@ package main import ( "crypto/rand" "encoding/base64" + "github.com/cbeuw/Cloak/internal/common" "github.com/cbeuw/Cloak/internal/ecdh" ) diff --git a/go.mod b/go.mod index f7b5575..4b3e218 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,6 @@ require ( github.com/stretchr/testify v1.6.1 gitlab.com/yawning/utls.git v0.0.12-1 go.etcd.io/bbolt v1.3.6 - golang.org/x/crypto v0.0.0-20220131195533-30dcbda58838 - golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27 // indirect + golang.org/x/crypto v0.1.0 gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect ) diff --git a/go.sum b/go.sum index ae4c070..41987ff 100644 --- a/go.sum +++ b/go.sum @@ -34,6 +34,7 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/ulikunitz/xz v0.5.6/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4ABRW8= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= gitlab.com/yawning/bsaes.git v0.0.0-20190805113838-0a714cd429ec h1:FpfFs4EhNehiVfzQttTuxanPIT43FtkkCFypIod8LHo= gitlab.com/yawning/bsaes.git v0.0.0-20190805113838-0a714cd429ec/go.mod h1:BZ1RAoRPbCxum9Grlv5aeksu2H8BiKehBYooU2LFiOQ= gitlab.com/yawning/utls.git v0.0.12-1 h1:RL6O0MP2YI0KghuEU/uGN6+8b4183eqNWoYgx7CXD0U= @@ -42,23 +43,38 @@ go.etcd.io/bbolt v1.3.6 h1:/ecaJf0sk1l4l6V4awd65v2C3ILy7MSj+s/x1ADCIMU= go.etcd.io/bbolt v1.3.6/go.mod h1:qXsaaIqmgQH0T+OPdb99Bf+PKfBBQVAdyD6TY9G8XM4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20220131195533-30dcbda58838 h1:71vQrMauZZhcTVK6KdYM+rklehEEwb3E+ZhaE5jrPrE= -golang.org/x/crypto v0.0.0-20220131195533-30dcbda58838/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.1.0 h1:MDRAIl0xIo9Io2xV565hzXHw3zVseKrJKodhohM5CjU= +golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/net v0.0.0-20190328230028-74de082e2cca/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190804053845-51ab0e2deafa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200923182605-d9f96fdee20d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27 h1:XDXtA5hveEEV8JB2l7nhMTp3t3cHp9ZpwcdjqyEWLlo= -golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/internal/client/TLS.go b/internal/client/TLS.go index 7e21724..d30c982 100644 --- a/internal/client/TLS.go +++ b/internal/client/TLS.go @@ -2,9 +2,10 @@ package client import ( "encoding/binary" + "net" + "github.com/cbeuw/Cloak/internal/common" log "github.com/sirupsen/logrus" - "net" ) const appDataMaxLength = 16401 diff --git a/internal/client/TLS_test.go b/internal/client/TLS_test.go index bd3b051..4aca82b 100644 --- a/internal/client/TLS_test.go +++ b/internal/client/TLS_test.go @@ -2,8 +2,9 @@ package client import ( "encoding/hex" - "github.com/stretchr/testify/assert" "testing" + + "github.com/stretchr/testify/assert" ) func htob(s string) []byte { diff --git a/internal/client/auth.go b/internal/client/auth.go index 4925541..9053c14 100644 --- a/internal/client/auth.go +++ b/internal/client/auth.go @@ -2,6 +2,7 @@ package client import ( "encoding/binary" + "github.com/cbeuw/Cloak/internal/common" "github.com/cbeuw/Cloak/internal/ecdh" log "github.com/sirupsen/logrus" diff --git a/internal/client/auth_test.go b/internal/client/auth_test.go index 4c7da33..a7a14f5 100644 --- a/internal/client/auth_test.go +++ b/internal/client/auth_test.go @@ -2,11 +2,12 @@ package client import ( "bytes" + "testing" + "time" + "github.com/cbeuw/Cloak/internal/common" "github.com/cbeuw/Cloak/internal/multiplex" "github.com/stretchr/testify/assert" - "testing" - "time" ) func TestMakeAuthenticationPayload(t *testing.T) { diff --git a/internal/client/chrome.go b/internal/client/chrome.go index 067473c..032a4ea 100644 --- a/internal/client/chrome.go +++ b/internal/client/chrome.go @@ -5,6 +5,7 @@ package client import ( "encoding/binary" "encoding/hex" + "github.com/cbeuw/Cloak/internal/common" ) diff --git a/internal/client/connector.go b/internal/client/connector.go index 863f049..660862e 100644 --- a/internal/client/connector.go +++ b/internal/client/connector.go @@ -1,12 +1,13 @@ package client import ( - "github.com/cbeuw/Cloak/internal/common" "net" "sync" "sync/atomic" "time" + "github.com/cbeuw/Cloak/internal/common" + mux "github.com/cbeuw/Cloak/internal/multiplex" log "github.com/sirupsen/logrus" ) diff --git a/internal/client/firefox.go b/internal/client/firefox.go index a7862cc..239dbaf 100644 --- a/internal/client/firefox.go +++ b/internal/client/firefox.go @@ -5,6 +5,7 @@ package client import ( "encoding/binary" "encoding/hex" + "github.com/cbeuw/Cloak/internal/common" ) diff --git a/internal/client/piper.go b/internal/client/piper.go index 4bb9fc0..43186ac 100644 --- a/internal/client/piper.go +++ b/internal/client/piper.go @@ -1,12 +1,13 @@ package client import ( - "github.com/cbeuw/Cloak/internal/common" "io" "net" "sync" "time" + "github.com/cbeuw/Cloak/internal/common" + mux "github.com/cbeuw/Cloak/internal/multiplex" log "github.com/sirupsen/logrus" ) diff --git a/internal/client/state.go b/internal/client/state.go index 550f002..0533609 100644 --- a/internal/client/state.go +++ b/internal/client/state.go @@ -4,13 +4,14 @@ import ( "crypto" "encoding/json" "fmt" - "github.com/cbeuw/Cloak/internal/common" - log "github.com/sirupsen/logrus" "io/ioutil" "net" "strings" "time" + "github.com/cbeuw/Cloak/internal/common" + log "github.com/sirupsen/logrus" + "github.com/cbeuw/Cloak/internal/ecdh" mux "github.com/cbeuw/Cloak/internal/multiplex" ) @@ -36,6 +37,7 @@ type RawConfig struct { BrowserSig string // nullable Transport string // nullable CDNOriginHost string // nullable + CDNWsUrlPath string // nullable StreamTimeout int // nullable KeepAlive int // nullable } @@ -224,10 +226,13 @@ func (raw *RawConfig) ProcessRawConfig(worldState common.WorldState) (local Loca } else { cdnDomainPort = net.JoinHostPort(raw.CDNOriginHost, raw.RemotePort) } + if raw.CDNWsUrlPath == "" { + raw.CDNWsUrlPath = "/" + } remote.TransportMaker = func() Transport { return &WSOverTLS{ - cdnDomainPort: cdnDomainPort, + wsUrl: "ws://" + cdnDomainPort + raw.CDNWsUrlPath, } } case "direct": diff --git a/internal/client/state_test.go b/internal/client/state_test.go index f473187..f63ff54 100644 --- a/internal/client/state_test.go +++ b/internal/client/state_test.go @@ -1,9 +1,10 @@ package client import ( - "github.com/stretchr/testify/assert" "io/ioutil" "testing" + + "github.com/stretchr/testify/assert" ) func TestParseConfig(t *testing.T) { diff --git a/internal/client/websocket.go b/internal/client/websocket.go index fbb5619..bddee23 100644 --- a/internal/client/websocket.go +++ b/internal/client/websocket.go @@ -4,17 +4,18 @@ import ( "encoding/base64" "errors" "fmt" - "github.com/cbeuw/Cloak/internal/common" - "github.com/gorilla/websocket" - utls "gitlab.com/yawning/utls.git" "net" "net/http" "net/url" + + "github.com/cbeuw/Cloak/internal/common" + "github.com/gorilla/websocket" + utls "gitlab.com/yawning/utls.git" ) type WSOverTLS struct { *common.WebSocketConn - cdnDomainPort string + wsUrl string } func (ws *WSOverTLS) Handshake(rawConn net.Conn, authInfo AuthInfo) (sessionKey [32]byte, err error) { @@ -40,7 +41,7 @@ func (ws *WSOverTLS) Handshake(rawConn net.Conn, authInfo AuthInfo) (sessionKey return } - u, err := url.Parse("ws://" + ws.cdnDomainPort) + u, err := url.Parse(ws.wsUrl) if err != nil { return sessionKey, fmt.Errorf("failed to parse ws url: %v", err) } diff --git a/internal/common/crypto_test.go b/internal/common/crypto_test.go index 4f8a186..0a72862 100644 --- a/internal/common/crypto_test.go +++ b/internal/common/crypto_test.go @@ -4,10 +4,11 @@ import ( "bytes" "encoding/hex" "errors" - "github.com/stretchr/testify/assert" "io" "math/rand" "testing" + + "github.com/stretchr/testify/assert" ) const gcmTagSize = 16 diff --git a/internal/common/websocket.go b/internal/common/websocket.go index e2a7096..cb5057b 100644 --- a/internal/common/websocket.go +++ b/internal/common/websocket.go @@ -2,10 +2,11 @@ package common import ( "errors" - "github.com/gorilla/websocket" "io" "sync" "time" + + "github.com/gorilla/websocket" ) // WebSocketConn implements io.ReadWriteCloser diff --git a/internal/multiplex/datagramBufferedPipe_test.go b/internal/multiplex/datagramBufferedPipe_test.go index 8d7a07b..6c52460 100644 --- a/internal/multiplex/datagramBufferedPipe_test.go +++ b/internal/multiplex/datagramBufferedPipe_test.go @@ -1,9 +1,10 @@ package multiplex import ( - "github.com/stretchr/testify/assert" "testing" "time" + + "github.com/stretchr/testify/assert" ) func TestDatagramBuffer_RW(t *testing.T) { diff --git a/internal/multiplex/mux_test.go b/internal/multiplex/mux_test.go index 6bb57ed..e4c9f77 100644 --- a/internal/multiplex/mux_test.go +++ b/internal/multiplex/mux_test.go @@ -2,14 +2,15 @@ package multiplex import ( "bytes" - "github.com/cbeuw/Cloak/internal/common" - "github.com/cbeuw/connutil" - "github.com/stretchr/testify/assert" "io" "math/rand" "net" "sync" "testing" + + "github.com/cbeuw/Cloak/internal/common" + "github.com/cbeuw/connutil" + "github.com/stretchr/testify/assert" ) func serveEcho(l net.Listener) { diff --git a/internal/multiplex/obfs.go b/internal/multiplex/obfs.go index 9fa614d..6821f86 100644 --- a/internal/multiplex/obfs.go +++ b/internal/multiplex/obfs.go @@ -6,6 +6,7 @@ import ( "encoding/binary" "errors" "fmt" + "github.com/cbeuw/Cloak/internal/common" "golang.org/x/crypto/chacha20poly1305" "golang.org/x/crypto/salsa20" diff --git a/internal/multiplex/obfs_test.go b/internal/multiplex/obfs_test.go index 76ba3bc..f07d101 100644 --- a/internal/multiplex/obfs_test.go +++ b/internal/multiplex/obfs_test.go @@ -3,12 +3,13 @@ package multiplex import ( "crypto/aes" "crypto/cipher" - "github.com/stretchr/testify/assert" - "golang.org/x/crypto/chacha20poly1305" "math/rand" "reflect" "testing" "testing/quick" + + "github.com/stretchr/testify/assert" + "golang.org/x/crypto/chacha20poly1305" ) func TestGenerateObfs(t *testing.T) { diff --git a/internal/multiplex/session.go b/internal/multiplex/session.go index f530f19..e176343 100644 --- a/internal/multiplex/session.go +++ b/internal/multiplex/session.go @@ -3,12 +3,13 @@ package multiplex import ( "errors" "fmt" - "github.com/cbeuw/Cloak/internal/common" "net" "sync" "sync/atomic" "time" + "github.com/cbeuw/Cloak/internal/common" + log "github.com/sirupsen/logrus" ) diff --git a/internal/multiplex/session_fuzz.go b/internal/multiplex/session_fuzz.go index 1eb6932..9cdb9a1 100644 --- a/internal/multiplex/session_fuzz.go +++ b/internal/multiplex/session_fuzz.go @@ -1,3 +1,4 @@ +//go:build gofuzz // +build gofuzz package multiplex diff --git a/internal/multiplex/session_test.go b/internal/multiplex/session_test.go index 88572a6..eac7482 100644 --- a/internal/multiplex/session_test.go +++ b/internal/multiplex/session_test.go @@ -2,8 +2,6 @@ package multiplex import ( "bytes" - "github.com/cbeuw/connutil" - "github.com/stretchr/testify/assert" "io" "io/ioutil" "math/rand" @@ -13,6 +11,9 @@ import ( "sync/atomic" "testing" "time" + + "github.com/cbeuw/connutil" + "github.com/stretchr/testify/assert" ) var seshConfigs = map[string]SessionConfig{ diff --git a/internal/multiplex/stream.go b/internal/multiplex/stream.go index 8c2ea15..f7e0376 100644 --- a/internal/multiplex/stream.go +++ b/internal/multiplex/stream.go @@ -6,9 +6,10 @@ import ( "net" "time" - log "github.com/sirupsen/logrus" "sync" "sync/atomic" + + log "github.com/sirupsen/logrus" ) var ErrBrokenStream = errors.New("broken stream") diff --git a/internal/multiplex/streamBuffer_test.go b/internal/multiplex/streamBuffer_test.go index b36bb6a..c390513 100644 --- a/internal/multiplex/streamBuffer_test.go +++ b/internal/multiplex/streamBuffer_test.go @@ -3,6 +3,7 @@ package multiplex import ( "encoding/binary" "io" + //"log" "sort" "testing" diff --git a/internal/multiplex/streamBufferedPipe_test.go b/internal/multiplex/streamBufferedPipe_test.go index 6cdbff1..7e4d168 100644 --- a/internal/multiplex/streamBufferedPipe_test.go +++ b/internal/multiplex/streamBufferedPipe_test.go @@ -1,10 +1,11 @@ package multiplex import ( - "github.com/stretchr/testify/assert" "math/rand" "testing" "time" + + "github.com/stretchr/testify/assert" ) const readBlockTime = 500 * time.Millisecond diff --git a/internal/multiplex/stream_test.go b/internal/multiplex/stream_test.go index eb13bc8..ceb0835 100644 --- a/internal/multiplex/stream_test.go +++ b/internal/multiplex/stream_test.go @@ -2,14 +2,15 @@ package multiplex import ( "bytes" - "github.com/cbeuw/Cloak/internal/common" - "github.com/stretchr/testify/assert" "io" "io/ioutil" "math/rand" "testing" "time" + "github.com/cbeuw/Cloak/internal/common" + "github.com/stretchr/testify/assert" + "github.com/cbeuw/connutil" ) diff --git a/internal/multiplex/switchboard.go b/internal/multiplex/switchboard.go index fa35567..52ee77b 100644 --- a/internal/multiplex/switchboard.go +++ b/internal/multiplex/switchboard.go @@ -2,12 +2,13 @@ package multiplex import ( "errors" - log "github.com/sirupsen/logrus" "math/rand" "net" "sync" "sync/atomic" "time" + + log "github.com/sirupsen/logrus" ) type switchboardStrategy int diff --git a/internal/multiplex/switchboard_test.go b/internal/multiplex/switchboard_test.go index 5e95afe..f8947b6 100644 --- a/internal/multiplex/switchboard_test.go +++ b/internal/multiplex/switchboard_test.go @@ -1,13 +1,14 @@ package multiplex import ( - "github.com/cbeuw/connutil" - "github.com/stretchr/testify/assert" "math/rand" "sync" "sync/atomic" "testing" "time" + + "github.com/cbeuw/connutil" + "github.com/stretchr/testify/assert" ) func TestSwitchboard_Send(t *testing.T) { diff --git a/internal/server/TLS.go b/internal/server/TLS.go index 0e66387..88e8f19 100644 --- a/internal/server/TLS.go +++ b/internal/server/TLS.go @@ -4,12 +4,13 @@ import ( "crypto" "errors" "fmt" - "github.com/cbeuw/Cloak/internal/common" - "github.com/cbeuw/Cloak/internal/ecdh" "io" "math/rand" "net" + "github.com/cbeuw/Cloak/internal/common" + "github.com/cbeuw/Cloak/internal/ecdh" + log "github.com/sirupsen/logrus" ) diff --git a/internal/server/TLSAux.go b/internal/server/TLSAux.go index 33ac3cd..da634d3 100644 --- a/internal/server/TLSAux.go +++ b/internal/server/TLSAux.go @@ -5,6 +5,7 @@ import ( "encoding/binary" "errors" "fmt" + "github.com/cbeuw/Cloak/internal/common" ) diff --git a/internal/server/activeuser.go b/internal/server/activeuser.go index 2bf212c..4be2954 100644 --- a/internal/server/activeuser.go +++ b/internal/server/activeuser.go @@ -1,9 +1,10 @@ package server import ( - "github.com/cbeuw/Cloak/internal/server/usermanager" "sync" + "github.com/cbeuw/Cloak/internal/server/usermanager" + mux "github.com/cbeuw/Cloak/internal/multiplex" ) diff --git a/internal/server/activeuser_test.go b/internal/server/activeuser_test.go index e6aeab4..20f61bf 100644 --- a/internal/server/activeuser_test.go +++ b/internal/server/activeuser_test.go @@ -3,12 +3,13 @@ package server import ( "crypto/rand" "encoding/base64" - "github.com/cbeuw/Cloak/internal/common" - mux "github.com/cbeuw/Cloak/internal/multiplex" - "github.com/cbeuw/Cloak/internal/server/usermanager" "io/ioutil" "os" "testing" + + "github.com/cbeuw/Cloak/internal/common" + mux "github.com/cbeuw/Cloak/internal/multiplex" + "github.com/cbeuw/Cloak/internal/server/usermanager" ) func getSeshConfig(unordered bool) mux.SessionConfig { diff --git a/internal/server/auth.go b/internal/server/auth.go index c7e6d1b..d6941c2 100644 --- a/internal/server/auth.go +++ b/internal/server/auth.go @@ -5,9 +5,10 @@ import ( "encoding/binary" "errors" "fmt" - "github.com/cbeuw/Cloak/internal/common" "time" + "github.com/cbeuw/Cloak/internal/common" + log "github.com/sirupsen/logrus" ) diff --git a/internal/server/auth_test.go b/internal/server/auth_test.go index 9218b82..e353de4 100644 --- a/internal/server/auth_test.go +++ b/internal/server/auth_test.go @@ -4,10 +4,11 @@ import ( "crypto" "encoding/hex" "fmt" - "github.com/cbeuw/Cloak/internal/common" - "github.com/cbeuw/Cloak/internal/ecdh" "testing" "time" + + "github.com/cbeuw/Cloak/internal/common" + "github.com/cbeuw/Cloak/internal/ecdh" ) func TestDecryptClientInfo(t *testing.T) { diff --git a/internal/server/dispatcher.go b/internal/server/dispatcher.go index 20eae5f..4285ed3 100644 --- a/internal/server/dispatcher.go +++ b/internal/server/dispatcher.go @@ -6,13 +6,14 @@ import ( "encoding/binary" "errors" "fmt" - "github.com/cbeuw/Cloak/internal/common" - "github.com/cbeuw/Cloak/internal/server/usermanager" "io" "net" "net/http" "time" + "github.com/cbeuw/Cloak/internal/common" + "github.com/cbeuw/Cloak/internal/server/usermanager" + mux "github.com/cbeuw/Cloak/internal/multiplex" log "github.com/sirupsen/logrus" ) diff --git a/internal/server/dispatcher_test.go b/internal/server/dispatcher_test.go index c98a81b..7e57184 100644 --- a/internal/server/dispatcher_test.go +++ b/internal/server/dispatcher_test.go @@ -2,12 +2,13 @@ package server import ( "encoding/hex" - "github.com/cbeuw/connutil" - "github.com/stretchr/testify/assert" "io" "net" "testing" "time" + + "github.com/cbeuw/connutil" + "github.com/stretchr/testify/assert" ) type rfpReturnValue struct { diff --git a/internal/server/first_packet_fuzz.go b/internal/server/first_packet_fuzz.go index 2003508..243f5f9 100644 --- a/internal/server/first_packet_fuzz.go +++ b/internal/server/first_packet_fuzz.go @@ -1,13 +1,15 @@ +//go:build gofuzz // +build gofuzz package server import ( "errors" - "github.com/cbeuw/Cloak/internal/common" - "github.com/cbeuw/connutil" "net" "time" + + "github.com/cbeuw/Cloak/internal/common" + "github.com/cbeuw/connutil" ) type rfpReturnValue_fuzz struct { diff --git a/internal/server/state.go b/internal/server/state.go index ca5cfd7..66ed480 100644 --- a/internal/server/state.go +++ b/internal/server/state.go @@ -5,15 +5,16 @@ import ( "encoding/json" "errors" "fmt" - "github.com/cbeuw/Cloak/internal/common" - "github.com/cbeuw/Cloak/internal/server/usermanager" - log "github.com/sirupsen/logrus" "io/ioutil" "net" "strings" "sync" "syscall" "time" + + "github.com/cbeuw/Cloak/internal/common" + "github.com/cbeuw/Cloak/internal/server/usermanager" + log "github.com/sirupsen/logrus" ) type RawConfig struct { diff --git a/internal/server/usermanager/api_router_test.go b/internal/server/usermanager/api_router_test.go index 9f957c8..0e4dbaa 100644 --- a/internal/server/usermanager/api_router_test.go +++ b/internal/server/usermanager/api_router_test.go @@ -4,12 +4,13 @@ import ( "bytes" "encoding/base64" "encoding/json" - "github.com/stretchr/testify/assert" "io/ioutil" "net/http" "net/http/httptest" "os" "testing" + + "github.com/stretchr/testify/assert" ) var mockUIDb64 = base64.URLEncoding.EncodeToString(mockUID) diff --git a/internal/server/usermanager/localmanager.go b/internal/server/usermanager/localmanager.go index 4b3096b..ed466cb 100644 --- a/internal/server/usermanager/localmanager.go +++ b/internal/server/usermanager/localmanager.go @@ -2,6 +2,7 @@ package usermanager import ( "encoding/binary" + "github.com/cbeuw/Cloak/internal/common" log "github.com/sirupsen/logrus" bolt "go.etcd.io/bbolt" diff --git a/internal/server/usermanager/localmanager_test.go b/internal/server/usermanager/localmanager_test.go index 40873cc..6b28e8f 100644 --- a/internal/server/usermanager/localmanager_test.go +++ b/internal/server/usermanager/localmanager_test.go @@ -2,8 +2,6 @@ package usermanager import ( "encoding/binary" - "github.com/cbeuw/Cloak/internal/common" - "github.com/stretchr/testify/assert" "io/ioutil" "math/rand" "os" @@ -12,6 +10,9 @@ import ( "sync" "testing" "time" + + "github.com/cbeuw/Cloak/internal/common" + "github.com/stretchr/testify/assert" ) var mockUID = []byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15} diff --git a/internal/server/usermanager/voidmanager_test.go b/internal/server/usermanager/voidmanager_test.go index 55ab2b4..ffde3d1 100644 --- a/internal/server/usermanager/voidmanager_test.go +++ b/internal/server/usermanager/voidmanager_test.go @@ -1,8 +1,9 @@ package usermanager import ( - "github.com/stretchr/testify/assert" "testing" + + "github.com/stretchr/testify/assert" ) var v = &Voidmanager{} diff --git a/internal/server/userpanel.go b/internal/server/userpanel.go index 953179e..0a9ff0f 100644 --- a/internal/server/userpanel.go +++ b/internal/server/userpanel.go @@ -2,11 +2,12 @@ package server import ( "encoding/base64" - "github.com/cbeuw/Cloak/internal/server/usermanager" "sync" "sync/atomic" "time" + "github.com/cbeuw/Cloak/internal/server/usermanager" + mux "github.com/cbeuw/Cloak/internal/multiplex" log "github.com/sirupsen/logrus" ) diff --git a/internal/server/userpanel_test.go b/internal/server/userpanel_test.go index b28744c..bc39b4e 100644 --- a/internal/server/userpanel_test.go +++ b/internal/server/userpanel_test.go @@ -2,12 +2,13 @@ package server import ( "encoding/base64" - "github.com/cbeuw/Cloak/internal/common" - "github.com/cbeuw/Cloak/internal/server/usermanager" "io/ioutil" "os" "testing" "time" + + "github.com/cbeuw/Cloak/internal/common" + "github.com/cbeuw/Cloak/internal/server/usermanager" ) func TestUserPanel_BypassUser(t *testing.T) { diff --git a/internal/server/websocket.go b/internal/server/websocket.go index 1c9e940..5880240 100644 --- a/internal/server/websocket.go +++ b/internal/server/websocket.go @@ -7,11 +7,12 @@ import ( "encoding/base64" "errors" "fmt" - "github.com/cbeuw/Cloak/internal/common" - "github.com/cbeuw/Cloak/internal/ecdh" "io" "net" "net/http" + + "github.com/cbeuw/Cloak/internal/common" + "github.com/cbeuw/Cloak/internal/ecdh" ) type WebSocket struct{} diff --git a/internal/server/websocketAux.go b/internal/server/websocketAux.go index 345c2a8..e4d949d 100644 --- a/internal/server/websocketAux.go +++ b/internal/server/websocketAux.go @@ -2,11 +2,12 @@ package server import ( "errors" - "github.com/cbeuw/Cloak/internal/common" - "github.com/gorilla/websocket" "net" "net/http" + "github.com/cbeuw/Cloak/internal/common" + "github.com/gorilla/websocket" + log "github.com/sirupsen/logrus" ) diff --git a/internal/server/websocketAux_test.go b/internal/server/websocketAux_test.go index b075ec7..d78a241 100644 --- a/internal/server/websocketAux_test.go +++ b/internal/server/websocketAux_test.go @@ -2,8 +2,9 @@ package server import ( "bytes" - "github.com/cbeuw/connutil" "testing" + + "github.com/cbeuw/connutil" ) func TestFirstBuffedConn_Read(t *testing.T) { diff --git a/internal/test/integration_test.go b/internal/test/integration_test.go index 187507f..04e9099 100644 --- a/internal/test/integration_test.go +++ b/internal/test/integration_test.go @@ -5,12 +5,6 @@ import ( "encoding/base64" "encoding/binary" "fmt" - "github.com/cbeuw/Cloak/internal/client" - "github.com/cbeuw/Cloak/internal/common" - mux "github.com/cbeuw/Cloak/internal/multiplex" - "github.com/cbeuw/Cloak/internal/server" - "github.com/cbeuw/connutil" - "github.com/stretchr/testify/assert" "io" "math/rand" "net" @@ -18,6 +12,13 @@ import ( "testing" "time" + "github.com/cbeuw/Cloak/internal/client" + "github.com/cbeuw/Cloak/internal/common" + mux "github.com/cbeuw/Cloak/internal/multiplex" + "github.com/cbeuw/Cloak/internal/server" + "github.com/cbeuw/connutil" + "github.com/stretchr/testify/assert" + log "github.com/sirupsen/logrus" )