We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
这个项目应该是所有代理项目中最适合入门的一个,尽管这个项目中存在一些难以避免的BUG,但是好在它的代码足够简洁、明了。使用原生go实现了端口转发和解析socks协议,感谢作者,祝工作顺利~ 最后附上socks服务账号密码验证功能的概念性代码: func isValidAccount(conn *TCPInteractive) (err error) { version := make([]byte, 1) _, err = conn.Read(version) if err != nil { common.Debug("Parsing socks protocol version error:%v", err) return err } if version[0] != 0x01 { common.Debug("not supported ver:%v", version) return errors.New(fmt.Sprintf("not supported ver:%v", version)) } ulen := make([]byte, 1) _, err = conn.Read(ulen) if err != nil { common.Debug("Analyzing the length of socks protocol username:%v", err) return err } uname := make([]byte, ulen[0]) _, err = ReadFull(*conn, uname) if err != nil { common.Debug("Reading socks protocol username error:%v", err) return err } plen := make([]byte, 1) _, err = conn.Read(plen) if err != nil { common.Debug("Analyzing the length of socks protocol password:%v", err) return err } passwd := make([]byte, plen[0]) _, err = ReadFull(*conn, passwd) if err != nil { common.Debug("Reading socks protocol password error:%v", err) return err } common.Debug("Socks protocol username:%v、password:%v", string(uname), string(passwd)) if string(uname) != structs.Param.Username || string(passwd) != structs.Param.Password { common.Debug("Socks5 account authentication failed") _, err = conn.Write([]byte{0x01, 0x01}) return errAccountError } else { common.Debug("Socks5 account authentication successfully") _, err = conn.Write([]byte{0x01, 0x00}) } if err != nil { common.Debug("Response to socks error:%v", err) return err } return nil }
func isValidAccount(conn *TCPInteractive) (err error) { version := make([]byte, 1) _, err = conn.Read(version) if err != nil { common.Debug("Parsing socks protocol version error:%v", err) return err } if version[0] != 0x01 { common.Debug("not supported ver:%v", version) return errors.New(fmt.Sprintf("not supported ver:%v", version)) } ulen := make([]byte, 1) _, err = conn.Read(ulen) if err != nil { common.Debug("Analyzing the length of socks protocol username:%v", err) return err } uname := make([]byte, ulen[0]) _, err = ReadFull(*conn, uname) if err != nil { common.Debug("Reading socks protocol username error:%v", err) return err } plen := make([]byte, 1) _, err = conn.Read(plen) if err != nil { common.Debug("Analyzing the length of socks protocol password:%v", err) return err } passwd := make([]byte, plen[0]) _, err = ReadFull(*conn, passwd) if err != nil { common.Debug("Reading socks protocol password error:%v", err) return err } common.Debug("Socks protocol username:%v、password:%v", string(uname), string(passwd)) if string(uname) != structs.Param.Username || string(passwd) != structs.Param.Password { common.Debug("Socks5 account authentication failed") _, err = conn.Write([]byte{0x01, 0x01}) return errAccountError } else { common.Debug("Socks5 account authentication successfully") _, err = conn.Write([]byte{0x01, 0x00}) } if err != nil { common.Debug("Response to socks error:%v", err) return err } return nil }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
这个项目应该是所有代理项目中最适合入门的一个,尽管这个项目中存在一些难以避免的BUG,但是好在它的代码足够简洁、明了。使用原生go实现了端口转发和解析socks协议,感谢作者,祝工作顺利~
最后附上socks服务账号密码验证功能的概念性代码:
func isValidAccount(conn *TCPInteractive) (err error) { version := make([]byte, 1) _, err = conn.Read(version) if err != nil { common.Debug("Parsing socks protocol version error:%v", err) return err } if version[0] != 0x01 { common.Debug("not supported ver:%v", version) return errors.New(fmt.Sprintf("not supported ver:%v", version)) } ulen := make([]byte, 1) _, err = conn.Read(ulen) if err != nil { common.Debug("Analyzing the length of socks protocol username:%v", err) return err } uname := make([]byte, ulen[0]) _, err = ReadFull(*conn, uname) if err != nil { common.Debug("Reading socks protocol username error:%v", err) return err } plen := make([]byte, 1) _, err = conn.Read(plen) if err != nil { common.Debug("Analyzing the length of socks protocol password:%v", err) return err } passwd := make([]byte, plen[0]) _, err = ReadFull(*conn, passwd) if err != nil { common.Debug("Reading socks protocol password error:%v", err) return err } common.Debug("Socks protocol username:%v、password:%v", string(uname), string(passwd)) if string(uname) != structs.Param.Username || string(passwd) != structs.Param.Password { common.Debug("Socks5 account authentication failed") _, err = conn.Write([]byte{0x01, 0x01}) return errAccountError } else { common.Debug("Socks5 account authentication successfully") _, err = conn.Write([]byte{0x01, 0x00}) } if err != nil { common.Debug("Response to socks error:%v", err) return err } return nil }
The text was updated successfully, but these errors were encountered: