TUN-3895: Tests for socks stream handler

This commit is contained in:
cthuang
2021-02-10 16:19:55 +00:00
committed by Nuno Diegues
parent e20c4f8752
commit 63a29f421a
5 changed files with 131 additions and 22 deletions

View File

@@ -38,10 +38,9 @@ func (d *wsdialer) Dial(address string) (io.ReadWriteCloser, *socks.AddrSpec, er
}
// NewWSConnection returns a new connection object
func NewWSConnection(log *zerolog.Logger, isSocks bool) Connection {
func NewWSConnection(log *zerolog.Logger) Connection {
return &Websocket{
log: log,
isSocks: isSocks,
log: log,
}
}
@@ -55,15 +54,7 @@ func (ws *Websocket) ServeStream(options *StartOptions, conn io.ReadWriter) erro
}
defer wsConn.Close()
if ws.isSocks {
dialer := &wsdialer{conn: wsConn}
requestHandler := socks.NewRequestHandler(dialer)
socksServer := socks.NewConnectionHandler(requestHandler)
_ = socksServer.Serve(conn)
} else {
ingress.Stream(wsConn, conn, ws.log)
}
ingress.Stream(wsConn, conn, ws.log)
return nil
}