Browse Source

fixing go.mod go.sum issues / fixing compile errors in tests

forward-proxy
forest 2 months ago
parent
commit
54fd606ec2
5 changed files with 41 additions and 18 deletions
  1. +3
    -3
      go.mod
  2. +19
    -0
      go.sum
  3. +3
    -3
      main_client.go
  4. +1
    -1
      tunnel-lib/tunnel_test.go
  5. +15
    -11
      tunnel-lib/tunneltest/tunneltest.go

+ 3
- 3
go.mod View File

@ -3,11 +3,11 @@ module git.sequentialread.com/forest/threshold
go 1.14
require (
git.sequentialread.com/forest/pkg-errors v0.9.2 // indirect
git.sequentialread.com/forest/pkg-errors v0.9.2
github.com/armon/go-proxyproto v0.0.0-20210323213023-7e956b284f0a
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 // indirect
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5
github.com/cenkalti/backoff v2.1.0+incompatible
github.com/gorilla/websocket v1.4.0
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d
golang.org/x/net v0.0.0-20210614182718-04defd469f4e // indirect
golang.org/x/net v0.0.0-20210614182718-04defd469f4e
)

+ 19
- 0
go.sum View File

@ -0,0 +1,19 @@
git.sequentialread.com/forest/pkg-errors v0.9.2 h1:j6pwbL6E+TmE7TD0tqRtGwuoCbCfO6ZR26Nv5nest9g=
git.sequentialread.com/forest/pkg-errors v0.9.2/go.mod h1:8TkJ/f8xLWFIAid20aoqgDZcCj9QQt+FU+rk415XO1w=
github.com/armon/go-proxyproto v0.0.0-20210323213023-7e956b284f0a h1:AP/vsCIvJZ129pdm9Ek7bH7yutN3hByqsMoNrWAxRQc=
github.com/armon/go-proxyproto v0.0.0-20210323213023-7e956b284f0a/go.mod h1:QmP9hvJ91BbJmGVGSbutW19IC0Q9phDCLGaomwTJbgU=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
github.com/cenkalti/backoff v2.1.0+incompatible h1:FIRvWBZrzS4YC7NT5cOuZjexzFvIr+Dbi6aD1cZaNBk=
github.com/cenkalti/backoff v2.1.0+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q=
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d h1:kJCB4vdITiW1eC1vq2e6IsrXKrZit1bv/TDYFGMp4BQ=
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM=
golang.org/x/net v0.0.0-20210614182718-04defd469f4e h1:XpT3nA5TvE525Ne3hInMh6+GETgn27Zfm9dxsThnX2Q=
golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
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/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=

+ 3
- 3
main_client.go View File

@ -130,13 +130,13 @@ func runClient(configFileName *string) {
config.GreenhouseThresholdPort = 9056
}
if config.TunneledOutboundSOCKS5ListenAddress == "" {
config.TunneledOutboundSOCKS5ListenAddress = "127.0.0.1:8000"
config.TunneledOutboundSOCKS5ListenAddress = "127.0.0.1:1080"
}
TunneledOutboundSOCKS5ListenAddress, err := net.ResolveTCPAddr("tcp", config.TunneledOutboundSOCKS5ListenAddress)
tunneledOutboundSOCKS5ListenAddress, err := net.ResolveTCPAddr("tcp", config.TunneledOutboundSOCKS5ListenAddress)
if err != nil {
log.Fatalf("runClient(): can't net.ResolveTCPAddr(TunneledOutboundSOCKS5ListenAddress) because %s \n", err)
}
forwardProxyListener, err := net.ListenTCP("tcp", TunneledOutboundSOCKS5ListenAddress)
forwardProxyListener, err := net.ListenTCP("tcp", tunneledOutboundSOCKS5ListenAddress)
if err != nil {
log.Fatalf("runClient(): can't net.ListenTCP(\"tcp\", TunneledOutboundSOCKS5ListenAddress) because %s \n", err)
}


+ 1
- 1
tunnel-lib/tunnel_test.go View File

@ -177,7 +177,7 @@ func TestNoHost(t *testing.T) {
Identifier: "unknown",
ServerAddr: tt.ServerAddr().String(),
Backoff: noBackoff,
Debug: testing.Verbose(),
DebugLog: true,
})
if err != nil {
t.Fatalf("client error: %s", err)


+ 15
- 11
tunnel-lib/tunneltest/tunneltest.go View File

@ -185,7 +185,7 @@ func NewTunnelTest() (*TunnelTest, error) {
cfg := &tunnel.ServerConfig{
StateChanges: rec.C(),
Debug: testing.Verbose(),
DebugLog: true,
}
s, err := tunnel.NewServer(cfg)
if err != nil {
@ -266,7 +266,7 @@ func (tt *TunnelTest) serveSingle(ident string, t *Tunnel) (bool, error) {
l = dbgListener{l}
}
localAddr := l.Addr().String()
//localAddr := l.Addr().String()
tcpProxy := &tunnel.TCPProxy{FetchLocalAddr: tt.fetchLocalAddr}
cfg := &tunnel.ClientConfig{
@ -274,7 +274,7 @@ func (tt *TunnelTest) serveSingle(ident string, t *Tunnel) (bool, error) {
ServerAddr: tt.ServerAddr().String(),
Proxy: tcpProxy.Proxy,
StateChanges: t.StateChanges,
Debug: testing.Verbose(),
DebugLog: true,
}
// Register tunnel:
@ -313,6 +313,7 @@ func (tt *TunnelTest) serveSingle(ident string, t *Tunnel) (bool, error) {
remote = tt.Listeners[t.RemoteAddrIdent][1]
tt.mu.Unlock()
} else {
net.ResolveTCPAddr("tcp", t.RemoteAddr)
remote, err = net.Listen("tcp", t.RemoteAddr)
if err != nil {
return false, fmt.Errorf("failed to listen on %q for %q tunnel: %s", t.RemoteAddr, ident, err)
@ -327,7 +328,9 @@ func (tt *TunnelTest) serveSingle(ident string, t *Tunnel) (bool, error) {
addrIdent = t.ClientIdent
}
tt.Server.AddAddr(remote, t.IP, addrIdent)
// TODO this whole thing needs to be refactored because tt.Server.AddAddr does not accept a listener as an argument any more.
// Used to be like: tt.Server.AddAddr(remote, blahblahblah)
tt.Server.AddAddr(t.IP, 8080, "*", addrIdent, true, t.RemoteAddr)
tt.mu.Lock()
tt.Listeners[ident] = [2]net.Listener{l, remote}
@ -428,7 +431,7 @@ func (tt *TunnelTest) popServedDeps(tunnels map[string]*Tunnel) error {
return nil
}
func (tt *TunnelTest) fetchLocalAddr(port int) (string, error) {
func (tt *TunnelTest) fetchLocalAddr(service string) (string, error) {
tt.mu.Lock()
defer tt.mu.Unlock()
@ -438,17 +441,18 @@ func (tt *TunnelTest) fetchLocalAddr(port int) (string, error) {
continue
}
_, remotePort, err := parseHostPort(l[1].Addr().String())
if err != nil {
return "", err
}
remotePort := l[1].Addr().String()
// _, remotePort, err := parseHostPort()
// if err != nil {
// return "", err
// }
if port == remotePort {
if service == remotePort {
return l[0].Addr().String(), nil
}
}
return "", fmt.Errorf("no route for %d port", port)
return "", fmt.Errorf("no route for %s service string", service)
}
func (tt *TunnelTest) ServerAddr() net.Addr {


Loading…
Cancel
Save