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 command line client with SOCKS #130

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

ha-D
Copy link

@ha-D ha-D commented Oct 30, 2022

Adds a command line client for the outline-ss-server. This should help with easier prototyping of features without having to go through the whole stack.

It starts a SOCKS server, accepts TCP connections and proxies them to the configured outline server.
Non-goals for this PR (can be added later):

  • UDP
  • Automatically setting the system proxy

--

Two decisions I made which are worth discussing:

  • Should it have a separate main or should we implement it as part of the same (server) binary and distinguish between running the server and client using a flag (similar to what go-shadowsocks2 does). I prefer separate myself and thats what I went with (though maybe we want to restructure packages a bit), let me know if you think it's better to go with a single binary.

  • How should the client take in the server configurations (e.g, host, port, password)

    • Using separate flags
      go run cmd/client -p port -s server -m cipher -k password
    • Using configuration file
      go run cmd/client -c config.yaml
      This will have to be a different config format that the one used for the server since the client can't take multiple keys
    • Using a single flag to pass in key url
      go run cmd/client -k ss://[email protected]:8080
      This is the one I'm going with right now. I'm not sure if the way I parse the key is fully compilable with SIP002 but I think its compilable enough (?).

@ha-D ha-D requested a review from a team as a code owner October 30, 2022 21:10
Copy link

@bemasc bemasc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking good!

cmd/client/client.go Outdated Show resolved Hide resolved
cmd/client/client.go Outdated Show resolved Hide resolved
cmd/client/client.go Outdated Show resolved Hide resolved
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!

host string
port int
cipher string
secret string
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be []bytes

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to have to string it again when passing to client.NewClient. Do you think I should still keep it []byte here?

cmd/client/client.go Outdated Show resolved Hide resolved
cmd/client/client.go Outdated Show resolved Hide resolved
cmd/client/client.go Outdated Show resolved Hide resolved
cmd/client/client.go Outdated Show resolved Hide resolved
return s.listener.Close()
}

func main() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you create a README.md file explaining how to run the socks proxy? Mention it only supports TCP.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you rather have a separate README in cmd/client or do you think I should update the original README to change the go-shadowsocks2 client to this one?

cmd/client/client.go Outdated Show resolved Hide resolved
cmd/client/client.go Outdated Show resolved Hide resolved
cmd/client/client.go Outdated Show resolved Hide resolved
cmd/client/client.go Outdated Show resolved Hide resolved
@ha-D
Copy link
Author

ha-D commented Oct 31, 2022

Thanks for the quick reviews!!

@fortuna
Copy link

fortuna commented Dec 6, 2022

@ha-D I found https://github.com/things-go/go-socks5. It seems it's a lot easier to use that library, and it supports UDP too.
I think all you need to do is call NewServer with https://pkg.go.dev/github.com/things-go/go-socks5#WithDial, taking a wrapped Shadowsocks client as the Dialer.

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.

None yet

3 participants