Skip to content
This repository has been archived by the owner on Apr 9, 2020. It is now read-only.

Porting ss-redir to go #473

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

Conversation

bonafideyan
Copy link

Only socks proxy is a bit inconvenient, so ...

@@ -18,7 +18,7 @@ import (
"syscall"
"time"

ss "github.com/shadowsocks/shadowsocks-go/shadowsocks"
ss "github.com/bonafideyan/shadowsocks-go/shadowsocks"
Copy link
Collaborator

Choose a reason for hiding this comment

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

pls fix the dependency

Copy link
Author

Choose a reason for hiding this comment

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

Done.

@@ -0,0 +1,138 @@
package main
Copy link
Collaborator

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

Copy link
Author

Choose a reason for hiding this comment

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

Done.

@@ -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) {
Copy link
Collaborator

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

Copy link
Author

Choose a reason for hiding this comment

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

Done.

Copy link
Collaborator

@arthurkiller arthurkiller left a 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.

@bonafideyan
Copy link
Author

Add command line parameter

-redirect,

and set iptables rules, refererence here.

@@ -14,6 +13,8 @@ import (
"strconv"
"strings"
"time"

ss "github.com/bonafideyan/shadowsocks-go/shadowsocks"
Copy link
Collaborator

Choose a reason for hiding this comment

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

fix your dependency.

Copy link
Collaborator

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

Copy link
Author

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?

Copy link
Collaborator

@arthurkiller arthurkiller left a 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")
Copy link
Collaborator

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

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

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.")
Copy link
Collaborator

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

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

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

Successfully merging this pull request may close these issues.

2 participants