-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Porting ss-redir
to go
#473
base: master
Are you sure you want to change the base?
Conversation
@@ -18,7 +18,7 @@ import ( | |||
"syscall" | |||
"time" | |||
|
|||
ss "github.com/shadowsocks/shadowsocks-go/shadowsocks" | |||
ss "github.com/bonafideyan/shadowsocks-go/shadowsocks" |
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.
pls fix the dependency
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.
Done.
cmd/shadowsocks-local/guess.go
Outdated
@@ -0,0 +1,138 @@ | |||
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.
this file should be in shadowsocks
package but not the client main
package
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.
Done.
cmd/shadowsocks-httpget/httpget.go
Outdated
@@ -76,9 +81,94 @@ func get(connid int, uri, serverAddr string, rawAddr []byte, cipher *ss.Cipher, | |||
} | |||
} | |||
|
|||
func dialSocks5(targetAddr, proxy string) (conn net.Conn, err 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.
this should be added into shadowsocks
package
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.
Done.
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.
Thx for your contribution.
Have you got and Document about this PR? Pls put it up here or another issue.
Add command line parameter
and set iptables rules, refererence here. |
@@ -14,6 +13,8 @@ import ( | |||
"strconv" | |||
"strings" | |||
"time" | |||
|
|||
ss "github.com/bonafideyan/shadowsocks-go/shadowsocks" |
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.
fix your dependency.
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.
your can add your branch as a reference for git
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.
Sorry, I don't know how to do it, could you please give me some steps in detail?
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.
request changes
@@ -77,8 +82,9 @@ func get(connid int, uri, serverAddr string, rawAddr []byte, cipher *ss.Cipher, | |||
} | |||
|
|||
func main() { | |||
flag.StringVar(&config.server, "s", "127.0.0.1", "server:port") | |||
flag.IntVar(&config.port, "p", 0, "server:port") | |||
server := flag.String("s", "127.0.0.1", "server:port") |
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.
keey the code style
@@ -89,8 +95,17 @@ func main() { | |||
|
|||
flag.Parse() | |||
|
|||
if config.server == "" || config.port == 0 || config.passwd == "" || len(flag.Args()) != 1 { | |||
fmt.Printf("Usage: %s -s <server> -p <port> -k <password> <url>\n", os.Args[0]) | |||
config.server = "127.0.0.1" |
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.
default config can be set with flag
@@ -280,7 +281,7 @@ func createServerConn(rawaddr []byte, addr string) (remote *ss.Conn, err error) | |||
return nil, err | |||
} | |||
|
|||
func handleConnection(conn net.Conn) { | |||
func handleConnection(conn net.Conn, redir bool) { |
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.
need a new function called redirectConnection
|
||
flag.BoolVar(&printVer, "version", false, "print version") | ||
flag.BoolVar(&redirect, "redirect", false, "Redirect normal request to socks server.") |
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.
same
@@ -78,6 +80,91 @@ func Dial(addr, server string, cipher *Cipher) (c *Conn, err error) { | |||
return DialWithRawAddr(ra, server, cipher) | |||
} | |||
|
|||
// DialAsClient dials in client's position. | |||
func DialAsClient(server, proxy string) (conn net.Conn, err 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.
add unit test for this function
Only socks proxy is a bit inconvenient, so ...