Signed-off-by: arraykeys@gmail.com <arraykeys@gmail.com>
This commit is contained in:
@ -1,4 +1,7 @@
|
|||||||
proxy更新日志
|
proxy更新日志
|
||||||
|
v3.4
|
||||||
|
1.tcp代理增加了kcp协议传输数据.
|
||||||
|
|
||||||
v3.4
|
v3.4
|
||||||
1.socks5代理新增了用户名密码验证支持.
|
1.socks5代理新增了用户名密码验证支持.
|
||||||
2.socks5,http(s)代理增加了kcp传输协议支持.
|
2.socks5,http(s)代理增加了kcp传输协议支持.
|
||||||
|
|||||||
@ -13,8 +13,8 @@ Proxy是golang实现的高性能http,https,websocket,tcp,udp,socks5代理服务
|
|||||||
- 跨平台性,无论你是widows,linux,还是mac,甚至是树莓派,都可以很好的运行proxy.
|
- 跨平台性,无论你是widows,linux,还是mac,甚至是树莓派,都可以很好的运行proxy.
|
||||||
- 多协议支持,支持HTTP(S),TCP,UDP,Websocket,SOCKS5代理.
|
- 多协议支持,支持HTTP(S),TCP,UDP,Websocket,SOCKS5代理.
|
||||||
- 支持内网穿透,协议支持TCP和UDP.
|
- 支持内网穿透,协议支持TCP和UDP.
|
||||||
- HTTP(S),SOCKS5代理支持SSH中转,上级Linux服务器不需要任何服务端,本地一个proxy即可开心上网.
|
- SSH中转,HTTP(S),SOCKS5代理支持SSH中转,上级Linux服务器不需要任何服务端,本地一个proxy即可开心上网.
|
||||||
- HTTP(S),SOCKS5代理支持[KCP](https://github.com/xtaci/kcp-go)协议传输数据,降低延迟,提升浏览体验.
|
- 支持[KCP](https://github.com/xtaci/kcp-go)协议,HTTP(S),SOCKS5代理支持KCP协议传输数据,降低延迟,提升浏览体验.
|
||||||
|
|
||||||
### Why need these?
|
### Why need these?
|
||||||
- 当由于安全因素或者限制,我们不能顺畅的访问我们在其它地方的服务,我们可以通过多个相连的proxy节点建立起一个安全的隧道,顺畅的访问我们的服务.
|
- 当由于安全因素或者限制,我们不能顺畅的访问我们在其它地方的服务,我们可以通过多个相连的proxy节点建立起一个安全的隧道,顺畅的访问我们的服务.
|
||||||
|
|||||||
@ -66,12 +66,14 @@ func initConfig() (err error) {
|
|||||||
tcpArgs.Parent = tcp.Flag("parent", "parent address, such as: \"23.32.32.19:28008\"").Default("").Short('P').String()
|
tcpArgs.Parent = tcp.Flag("parent", "parent address, such as: \"23.32.32.19:28008\"").Default("").Short('P').String()
|
||||||
tcpArgs.CertFile = tcp.Flag("cert", "cert file for tls").Short('C').Default("proxy.crt").String()
|
tcpArgs.CertFile = tcp.Flag("cert", "cert file for tls").Short('C').Default("proxy.crt").String()
|
||||||
tcpArgs.KeyFile = tcp.Flag("key", "key file for tls").Short('K').Default("proxy.key").String()
|
tcpArgs.KeyFile = tcp.Flag("key", "key file for tls").Short('K').Default("proxy.key").String()
|
||||||
tcpArgs.Timeout = tcp.Flag("timeout", "tcp timeout milliseconds when connect to real server or parent proxy").Short('t').Default("2000").Int()
|
tcpArgs.Timeout = tcp.Flag("timeout", "tcp timeout milliseconds when connect to real server or parent proxy").Short('e').Default("2000").Int()
|
||||||
tcpArgs.ParentType = tcp.Flag("parent-type", "parent protocol type <tls|tcp|udp>").Short('T').Enum("tls", "tcp", "udp")
|
tcpArgs.ParentType = tcp.Flag("parent-type", "parent protocol type <tls|tcp|kcp|udp>").Short('T').Enum("tls", "tcp", "udp", "kcp")
|
||||||
tcpArgs.IsTLS = tcp.Flag("tls", "proxy on tls mode").Default("false").Bool()
|
tcpArgs.LocalType = tcp.Flag("local-type", "local protocol type <tls|tcp|kcp>").Default("tcp").Short('t').Enum("tls", "tcp", "kcp")
|
||||||
tcpArgs.PoolSize = tcp.Flag("pool-size", "conn pool size , which connect to parent proxy, zero: means turn off pool").Short('L').Default("0").Int()
|
tcpArgs.PoolSize = tcp.Flag("pool-size", "conn pool size , which connect to parent proxy, zero: means turn off pool").Short('L').Default("0").Int()
|
||||||
tcpArgs.CheckParentInterval = tcp.Flag("check-parent-interval", "check if proxy is okay every interval seconds,zero: means no check").Short('I').Default("3").Int()
|
tcpArgs.CheckParentInterval = tcp.Flag("check-parent-interval", "check if proxy is okay every interval seconds,zero: means no check").Short('I').Default("3").Int()
|
||||||
tcpArgs.Local = tcp.Flag("local", "local ip:port to listen").Short('p').Default(":33080").String()
|
tcpArgs.Local = tcp.Flag("local", "local ip:port to listen").Short('p').Default(":33080").String()
|
||||||
|
tcpArgs.KCPKey = tcp.Flag("kcp-key", "key for kcp encrypt/decrypt data").Short('B').Default("encrypt").String()
|
||||||
|
tcpArgs.KCPMethod = tcp.Flag("kcp-method", "kcp encrypt/decrypt method").Short('M').Default("3des").String()
|
||||||
|
|
||||||
//########udp#########
|
//########udp#########
|
||||||
udp := app.Command("udp", "proxy on udp mode")
|
udp := app.Command("udp", "proxy on udp mode")
|
||||||
|
|||||||
@ -58,10 +58,12 @@ type TCPArgs struct {
|
|||||||
KeyBytes []byte
|
KeyBytes []byte
|
||||||
Local *string
|
Local *string
|
||||||
ParentType *string
|
ParentType *string
|
||||||
IsTLS *bool
|
LocalType *string
|
||||||
Timeout *int
|
Timeout *int
|
||||||
PoolSize *int
|
PoolSize *int
|
||||||
CheckParentInterval *int
|
CheckParentInterval *int
|
||||||
|
KCPMethod *string
|
||||||
|
KCPKey *string
|
||||||
}
|
}
|
||||||
|
|
||||||
type HTTPArgs struct {
|
type HTTPArgs struct {
|
||||||
@ -133,8 +135,13 @@ type SocksArgs struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *TCPArgs) Protocol() string {
|
func (a *TCPArgs) Protocol() string {
|
||||||
if *a.IsTLS {
|
switch *a.LocalType {
|
||||||
return "tls"
|
case TYPE_TLS:
|
||||||
|
return TYPE_TLS
|
||||||
|
case TYPE_TCP:
|
||||||
|
return TYPE_TCP
|
||||||
|
case TYPE_KCP:
|
||||||
|
return TYPE_KCP
|
||||||
}
|
}
|
||||||
return "tcp"
|
return "unknown"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -223,7 +223,7 @@ func (s *HTTP) OutToTCP(useProxy bool, address string, inConn *net.Conn, req *ut
|
|||||||
}
|
}
|
||||||
|
|
||||||
outAddr := outConn.RemoteAddr().String()
|
outAddr := outConn.RemoteAddr().String()
|
||||||
outLocalAddr := outConn.LocalAddr().String()
|
//outLocalAddr := outConn.LocalAddr().String()
|
||||||
|
|
||||||
if req.IsHTTPS() && (!useProxy || *s.cfg.ParentType == "ssh") {
|
if req.IsHTTPS() && (!useProxy || *s.cfg.ParentType == "ssh") {
|
||||||
//https无上级或者上级非代理,proxy需要响应connect请求,并直连目标
|
//https无上级或者上级非代理,proxy需要响应connect请求,并直连目标
|
||||||
|
|||||||
@ -29,9 +29,9 @@ func (s *TCP) CheckArgs() {
|
|||||||
log.Fatalf("parent required for %s %s", s.cfg.Protocol(), *s.cfg.Local)
|
log.Fatalf("parent required for %s %s", s.cfg.Protocol(), *s.cfg.Local)
|
||||||
}
|
}
|
||||||
if *s.cfg.ParentType == "" {
|
if *s.cfg.ParentType == "" {
|
||||||
log.Fatalf("parent type unkown,use -T <tls|tcp>")
|
log.Fatalf("parent type unkown,use -T <tls|tcp|kcp|udp>")
|
||||||
}
|
}
|
||||||
if *s.cfg.ParentType == "tls" || *s.cfg.IsTLS {
|
if *s.cfg.ParentType == TYPE_TLS || *s.cfg.LocalType == TYPE_TLS {
|
||||||
s.cfg.CertBytes, s.cfg.KeyBytes = utils.TlsBytes(*s.cfg.CertFile, *s.cfg.KeyFile)
|
s.cfg.CertBytes, s.cfg.KeyBytes = utils.TlsBytes(*s.cfg.CertFile, *s.cfg.KeyFile)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -52,10 +52,13 @@ func (s *TCP) Start(args interface{}) (err error) {
|
|||||||
host, port, _ := net.SplitHostPort(*s.cfg.Local)
|
host, port, _ := net.SplitHostPort(*s.cfg.Local)
|
||||||
p, _ := strconv.Atoi(port)
|
p, _ := strconv.Atoi(port)
|
||||||
sc := utils.NewServerChannel(host, p)
|
sc := utils.NewServerChannel(host, p)
|
||||||
if !*s.cfg.IsTLS {
|
|
||||||
|
if *s.cfg.LocalType == TYPE_TCP {
|
||||||
err = sc.ListenTCP(s.callback)
|
err = sc.ListenTCP(s.callback)
|
||||||
} else {
|
} else if *s.cfg.LocalType == TYPE_TLS {
|
||||||
err = sc.ListenTls(s.cfg.CertBytes, s.cfg.KeyBytes, s.callback)
|
err = sc.ListenTls(s.cfg.CertBytes, s.cfg.KeyBytes, s.callback)
|
||||||
|
} else if *s.cfg.LocalType == TYPE_KCP {
|
||||||
|
err = sc.ListenKCP(*s.cfg.KCPMethod, *s.cfg.KCPKey, s.callback)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
@ -75,6 +78,8 @@ func (s *TCP) callback(inConn net.Conn) {
|
|||||||
}()
|
}()
|
||||||
var err error
|
var err error
|
||||||
switch *s.cfg.ParentType {
|
switch *s.cfg.ParentType {
|
||||||
|
case TYPE_KCP:
|
||||||
|
fallthrough
|
||||||
case TYPE_TCP:
|
case TYPE_TCP:
|
||||||
fallthrough
|
fallthrough
|
||||||
case TYPE_TLS:
|
case TYPE_TLS:
|
||||||
@ -162,13 +167,14 @@ func (s *TCP) OutToUDP(inConn *net.Conn) (err error) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
func (s *TCP) InitOutConnPool() {
|
func (s *TCP) InitOutConnPool() {
|
||||||
if *s.cfg.ParentType == TYPE_TLS || *s.cfg.ParentType == TYPE_TCP {
|
if *s.cfg.ParentType == TYPE_TLS || *s.cfg.ParentType == TYPE_TCP || *s.cfg.ParentType == TYPE_KCP {
|
||||||
//dur int, isTLS bool, certBytes, keyBytes []byte,
|
//dur int, isTLS bool, certBytes, keyBytes []byte,
|
||||||
//parent string, timeout int, InitialCap int, MaxCap int
|
//parent string, timeout int, InitialCap int, MaxCap int
|
||||||
s.outPool = utils.NewOutPool(
|
s.outPool = utils.NewOutPool(
|
||||||
*s.cfg.CheckParentInterval,
|
*s.cfg.CheckParentInterval,
|
||||||
*s.cfg.ParentType,
|
*s.cfg.ParentType,
|
||||||
"", "",
|
*s.cfg.KCPMethod,
|
||||||
|
*s.cfg.KCPKey,
|
||||||
s.cfg.CertBytes, s.cfg.KeyBytes,
|
s.cfg.CertBytes, s.cfg.KeyBytes,
|
||||||
*s.cfg.Parent,
|
*s.cfg.Parent,
|
||||||
*s.cfg.Timeout,
|
*s.cfg.Timeout,
|
||||||
|
|||||||
Reference in New Issue
Block a user