Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

ha-D
Copy link

@ha-D ha-D commented Nov 1, 2022

Three main things here:

  • websocket/websocket.go: Takes the websocket.Conn from the gorilla/websocket package and wraps it in a struct that implements the onet.DuplexConn interface. With this, we can treat a websocket connection as a normal streaming protocol similar to TCP.

  • websocket.go: Implements RunWebsocketServer 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 respective TCPServices.

  • client/websocket.go: Implements client.NewWebsocketClient which is similar to client.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.

@ha-D ha-D requested a review from a team as a code owner November 1, 2022 22:12
Copy link

@fortuna fortuna left a 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"
Copy link

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-----
Copy link

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
Copy link

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) {

Copy link

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
Copy link

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)
Copy link

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.

Copy link

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.

Copy link

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
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants