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 dialer interface according to golang.org/x/net/proxy. #42

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

Conversation

jackyyf
Copy link

@jackyyf jackyyf commented Apr 29, 2017

This allow us to use shadowsocks as upstream proxy in go program more easily, and a (like-to-be) standard interface would be nice.

I've attached some testcases with pull request, and all tests passed with forked version.

@riobard
Copy link

riobard commented May 6, 2017

I actually regret to have the core providing the helper functions since they assume too much of the use case. I was hoping the repo stays barely minimal so others could easily embed it into their own projects. Do you think the dialer is absolutely necessary given the minimalism philosophy?

@jackyyf
Copy link
Author

jackyyf commented May 6, 2017

You are right, it could be moved to another separate package, I'll refactor my code, thanks for pointing that out :)

@riobard
Copy link

riobard commented May 6, 2017

I think your code could be organized into a standalone package providing proxy support via e.g. Shadowsocks, SOCKS5, HTTP proxy, etc. That will be more compatible with the design of golang.org/x/net/proxy. Let me know if there's anything I can do to help.

Also, I'm thinking about separating the reusable packages and the demo server/client to use them.

Now you may use github.com/shadowsocks/go-shadowsocks2/proxy to use the
dialer interface.
@jackyyf
Copy link
Author

jackyyf commented May 8, 2017

I've moved dialer interface to a separate package named proxy. I don't know if this is ok, and please comment for change if this name is too generic or too ambiguous.

@riobard
Copy link

riobard commented Jun 18, 2017

The code looks pretty good now. What do you think if you make it available as its own repo on GitHub?

@jackyyf
Copy link
Author

jackyyf commented Jul 17, 2017

Sorry for the looooong delay, I had some serious about my graduation design and it took whole June to get around with it, and I just have spare time now to reply this issue.

Making as own repo is fine, but I would recommend to include this within primary repo, or at least as a project under shadowsocks organization to make this interface used by more people. Anyway, thanks for the review :)

return
}

func (dialer *ProxyDialer) Dial(network, addr string) (c net.Conn, err error) {
Copy link

Choose a reason for hiding this comment

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

You should call this DialTCP, as in net.DialTCP.
Unless you also support UDP or other networks.

In any case, you should be checking the value of the network parameter.

Dial: dialer.Dial,
},
}
resp, err := client.Get("http://ifconfig.co")
Copy link

Choose a reason for hiding this comment

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

Your unit tests shouldn't depend on external services.

Why don't you run a simple TCP service locally instead?
Here is an example where I do that: https://github.com/Jigsaw-Code/outline-ss-server/blob/master/shadowsocks/tcp_test.go

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.

3 participants