-
Notifications
You must be signed in to change notification settings - Fork 189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add websocket tunneling support #131
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution and navigating our code!
"time" | ||
|
||
onet "github.com/Jigsaw-Code/outline-ss-server/net" | ||
"github.com/gorilla/websocket" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use https://pkg.go.dev/golang.org/x/net/websocket instead if it provides the features we need.
@@ -0,0 +1,27 @@ | |||
-----BEGIN CERTIFICATE----- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this file? Just a test example? If so, give a clearer name. Also, move it to the websocket folder.
@@ -0,0 +1,131 @@ | |||
package main |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move to the websocket folder.
@@ -212,19 +212,25 @@ func readConfig(filename string) (*Config, error) { | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert the service.
@@ -143,6 +143,8 @@ type TCPService interface { | |||
Stop() error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert
return nil, err | ||
} | ||
|
||
ssw := ss.NewShadowsocksWriter(proxyConn, c.cipher) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Websocket code shouldn't know about Shadowsocks.
Instead, make the Shadowsocks client code take a server Dialer.
Then the server dialer could be a direct connection, or a Websocket connection.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With that approach, we don't need to worry about the wiring here. outline-go-tun2socks will have the code that takes a config and translates that to object wiring.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will need to check how much bigger outline-go-tun2socks will be with this change, and how it will affect memory on iOS.
@@ -0,0 +1,59 @@ | |||
package main |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may have a server here for testing, but I'd rather have something simple that does tcp over websocket.
Three main things here:
websocket/websocket.go
: Takes thewebsocket.Conn
from the gorilla/websocket package and wraps it in a struct that implements theonet.DuplexConn
interface. With this, we can treat a websocket connection as a normal streaming protocol similar to TCP.websocket.go
: ImplementsRunWebsocketServer
which starts a websocket server on 443. The websocket server expects to see a port number in the URL path of connections, and it uses that to multiplex the connection to their respectiveTCPServices
.client/websocket.go
: Implementsclient.NewWebsocketClient
which is similar toclient.NewClient
except that instead of a plain TCP connection, it sends the Shadowsocks content over a websocket connection.--
This is only TCP for now, however a similar thing can be done for UDP in a separate PR.