增加智能模式参数
This commit is contained in:
@ -2,9 +2,11 @@ proxy更新日志
|
|||||||
|
|
||||||
v6.6
|
v6.6
|
||||||
1.优化了limitconn的关闭逻辑,释放更多资源.
|
1.优化了limitconn的关闭逻辑,释放更多资源.
|
||||||
2.http(s)\socks代理增加了--close-intelligent,关闭智能判断,
|
2.http(s)\socks代理增加了--intelligent,智能模式设置,可以是intelligent|direct|parent三者之一,
|
||||||
默认情况下,如果访问的目标不在direct里面,proxy会智能判断是否使用上级访问目标,
|
默认是:intelligent.每个值的含义如下.
|
||||||
现在可以使用参数--close-intelligent关闭这个特性,使不在direct里面的目标都走上级.
|
--intelligent=direct,不在blocked里面的目标都直连.
|
||||||
|
--intelligent=parent,不在direct里面的目标都走上级.
|
||||||
|
--intelligent=intelligent,blocked和direct里面都没有的目标,智能判断是否使用上级访问目标.
|
||||||
|
|
||||||
v6.5
|
v6.5
|
||||||
1.修复了合并企业版遗留的一些bug.
|
1.修复了合并企业版遗留的一些bug.
|
||||||
|
|||||||
31
README_ZH.md
31
README_ZH.md
@ -99,7 +99,8 @@ Proxy是golang实现的高性能http,https,websocket,tcp,udp,socks5,ss代理服
|
|||||||
- [1.15 限速](#115-限速)
|
- [1.15 限速](#115-限速)
|
||||||
- [1.16 指定出口IP](#116-指定出口ip)
|
- [1.16 指定出口IP](#116-指定出口ip)
|
||||||
- [1.17 证书参数使用base64数据](#117-证书参数使用base64数据)
|
- [1.17 证书参数使用base64数据](#117-证书参数使用base64数据)
|
||||||
- [1.18 查看帮助](#118-查看帮助)
|
- [1.18 智能模式](#118-智能模式)
|
||||||
|
- [1.19 查看帮助](#119-查看帮助)
|
||||||
- [2. TCP代理(端口映射)](#2tcp代理)
|
- [2. TCP代理(端口映射)](#2tcp代理)
|
||||||
- [2.1 普通一级TCP代理](#21普通一级tcp代理)
|
- [2.1 普通一级TCP代理](#21普通一级tcp代理)
|
||||||
- [2.2 普通二级TCP代理](#22普通二级tcp代理)
|
- [2.2 普通二级TCP代理](#22普通二级tcp代理)
|
||||||
@ -144,7 +145,8 @@ Proxy是golang实现的高性能http,https,websocket,tcp,udp,socks5,ss代理服
|
|||||||
- [5.14 指定出口IP](#514-指定出口ip)
|
- [5.14 指定出口IP](#514-指定出口ip)
|
||||||
- [5.15 级联认证](#515-级联认证)
|
- [5.15 级联认证](#515-级联认证)
|
||||||
- [5.16 证书参数使用base64数据](#516-证书参数使用base64数据)
|
- [5.16 证书参数使用base64数据](#516-证书参数使用base64数据)
|
||||||
- [5.17 查看帮助](#517查看帮助)
|
- [5.17 智能模式](#517-智能模式)
|
||||||
|
- [5.18 查看帮助](#518-查看帮助)
|
||||||
- [6. 代理协议转换](#6代理协议转换)
|
- [6. 代理协议转换](#6代理协议转换)
|
||||||
- [6.1 功能介绍](#61-功能介绍)
|
- [6.1 功能介绍](#61-功能介绍)
|
||||||
- [6.2 HTTP(S)转HTTP(S)+SOCKS5+SS](#62-https转httpssocks5ss)
|
- [6.2 HTTP(S)转HTTP(S)+SOCKS5+SS](#62-https转httpssocks5ss)
|
||||||
@ -376,11 +378,6 @@ target:用户访问的URL,比如:http://demo.com:80/1.html或https://www.baidu.c
|
|||||||
#### **1.6.HTTP代理流量强制走上级HTTP代理**
|
#### **1.6.HTTP代理流量强制走上级HTTP代理**
|
||||||
默认情况下,proxy会智能判断一个网站域名是否无法访问,如果无法访问才走上级HTTP代理.通过--always可以使全部HTTP代理流量强制走上级HTTP代理.
|
默认情况下,proxy会智能判断一个网站域名是否无法访问,如果无法访问才走上级HTTP代理.通过--always可以使全部HTTP代理流量强制走上级HTTP代理.
|
||||||
`./proxy http --always -t tls -p ":28080" -T tls -P "22.22.22.22:38080" -C proxy.crt -K proxy.key`
|
`./proxy http --always -t tls -p ":28080" -T tls -P "22.22.22.22:38080" -C proxy.crt -K proxy.key`
|
||||||
|
|
||||||
默认情况下,如果访问的目标不在direct里面,proxy会智能判断是否使用上级访问目标.
|
|
||||||
现在可以使用参数--close-intelligent关闭这个特性,使不在direct里面的目标都走上级.
|
|
||||||
|
|
||||||
`./proxy http --close-intelligent -t tls -p ":28080" -T tls -P "22.22.22.22:38080" -C proxy.crt -K proxy.key`
|
|
||||||
|
|
||||||
#### **1.7.HTTP(S)通过SSH中转**
|
#### **1.7.HTTP(S)通过SSH中转**
|
||||||

|

|
||||||
@ -556,7 +553,15 @@ HTTP(S)代理支持上级负载均衡,多个上级重复-P参数即可.
|
|||||||
|
|
||||||
如果是base64://开头,那么就认为后面的数据是base64编码的,会解码后使用.
|
如果是base64://开头,那么就认为后面的数据是base64编码的,会解码后使用.
|
||||||
|
|
||||||
#### **1.18 查看帮助**
|
#### **1.18 智能模式**
|
||||||
|
智能模式设置,可以是intelligent|direct|parent三者之一.
|
||||||
|
默认是:intelligent.
|
||||||
|
每个值的含义如下:
|
||||||
|
`--intelligent=direct`,不在blocked里面的目标都直连.
|
||||||
|
`--intelligent=parent`,不在direct里面的目标都走上级.
|
||||||
|
`--intelligent=intelligent`,blocked和direct里面都没有的目标,智能判断是否使用上级访问目标.
|
||||||
|
|
||||||
|
#### **1.19 查看帮助**
|
||||||
`./proxy help http`
|
`./proxy help http`
|
||||||
|
|
||||||
### **2.TCP代理**
|
### **2.TCP代理**
|
||||||
@ -1035,7 +1040,15 @@ SOCKS5支持级联认证,-A可以设置上级认证信息.
|
|||||||
如果是base64://开头,那么就认为后面的数据是base64编码的,会解码后使用.
|
如果是base64://开头,那么就认为后面的数据是base64编码的,会解码后使用.
|
||||||
|
|
||||||
|
|
||||||
#### **5.17.查看帮助**
|
#### **5.17 智能模式**
|
||||||
|
智能模式设置,可以是intelligent|direct|parent三者之一.
|
||||||
|
默认是:intelligent.
|
||||||
|
每个值的含义如下:
|
||||||
|
`--intelligent=direct`,不在blocked里面的目标都直连.
|
||||||
|
`--intelligent=parent`,不在direct里面的目标都走上级.
|
||||||
|
`--intelligent=intelligent`,blocked和direct里面都没有的目标,智能判断是否使用上级访问目标.
|
||||||
|
|
||||||
|
#### **5.18.查看帮助**
|
||||||
`./proxy help socks`
|
`./proxy help socks`
|
||||||
|
|
||||||
### **6.代理协议转换**
|
### **6.代理协议转换**
|
||||||
|
|||||||
@ -117,7 +117,7 @@ func initConfig() (err error) {
|
|||||||
httpArgs.ParentKey = http.Flag("parent-key", "the password for auto encrypt/decrypt parent connection data").Short('Z').Default("").String()
|
httpArgs.ParentKey = http.Flag("parent-key", "the password for auto encrypt/decrypt parent connection data").Short('Z').Default("").String()
|
||||||
httpArgs.LocalCompress = http.Flag("local-compress", "auto compress/decompress data on local connection").Short('m').Default("false").Bool()
|
httpArgs.LocalCompress = http.Flag("local-compress", "auto compress/decompress data on local connection").Short('m').Default("false").Bool()
|
||||||
httpArgs.ParentCompress = http.Flag("parent-compress", "auto compress/decompress data on parent connection").Short('M').Default("false").Bool()
|
httpArgs.ParentCompress = http.Flag("parent-compress", "auto compress/decompress data on parent connection").Short('M').Default("false").Bool()
|
||||||
httpArgs.CloseIntelligent = http.Flag("close-intelligent", "close intelligent HTTP, SOCKS5 proxy").Default("false").Bool()
|
httpArgs.Intelligent = http.Flag("intelligent", "settting intelligent HTTP, SOCKS5 proxy mode, can be <intelligent|direct|parent>").Default("intelligent").Enmu("intelligent","direct","parent").String()
|
||||||
httpArgs.LoadBalanceMethod = http.Flag("lb-method", "load balance method when use multiple parent,can be <roundrobin|leastconn|leasttime|hash|weight>").Default("roundrobin").Enum("roundrobin", "weight", "leastconn", "leasttime", "hash")
|
httpArgs.LoadBalanceMethod = http.Flag("lb-method", "load balance method when use multiple parent,can be <roundrobin|leastconn|leasttime|hash|weight>").Default("roundrobin").Enum("roundrobin", "weight", "leastconn", "leasttime", "hash")
|
||||||
httpArgs.LoadBalanceTimeout = http.Flag("lb-timeout", "tcp milliseconds timeout of connecting to parent").Default("500").Int()
|
httpArgs.LoadBalanceTimeout = http.Flag("lb-timeout", "tcp milliseconds timeout of connecting to parent").Default("500").Int()
|
||||||
httpArgs.LoadBalanceRetryTime = http.Flag("lb-retrytime", "sleep time milliseconds after checking").Default("1000").Int()
|
httpArgs.LoadBalanceRetryTime = http.Flag("lb-retrytime", "sleep time milliseconds after checking").Default("1000").Int()
|
||||||
@ -254,7 +254,7 @@ func initConfig() (err error) {
|
|||||||
socksArgs.ParentKey = socks.Flag("parent-key", "the password for auto encrypt/decrypt parent connection data").Short('Z').Default("").String()
|
socksArgs.ParentKey = socks.Flag("parent-key", "the password for auto encrypt/decrypt parent connection data").Short('Z').Default("").String()
|
||||||
socksArgs.LocalCompress = socks.Flag("local-compress", "auto compress/decompress data on local connection").Short('m').Default("false").Bool()
|
socksArgs.LocalCompress = socks.Flag("local-compress", "auto compress/decompress data on local connection").Short('m').Default("false").Bool()
|
||||||
socksArgs.ParentCompress = socks.Flag("parent-compress", "auto compress/decompress data on parent connection").Short('M').Default("false").Bool()
|
socksArgs.ParentCompress = socks.Flag("parent-compress", "auto compress/decompress data on parent connection").Short('M').Default("false").Bool()
|
||||||
socksArgs.CloseIntelligent = socks.Flag("close-intelligent", "Close intelligent HTTP, SOCKS5 proxy").Default("false").Bool()
|
socksArgs.Intelligent = socks.Flag("intelligent", "settting intelligent HTTP, SOCKS5 proxy mode, can be <intelligent|direct|parent>").Default("intelligent").Enmu("intelligent","direct","parent").String()
|
||||||
socksArgs.LoadBalanceMethod = socks.Flag("lb-method", "load balance method when use multiple parent,can be <roundrobin|leastconn|leasttime|hash|weight>").Default("roundrobin").Enum("roundrobin", "weight", "leastconn", "leasttime", "hash")
|
socksArgs.LoadBalanceMethod = socks.Flag("lb-method", "load balance method when use multiple parent,can be <roundrobin|leastconn|leasttime|hash|weight>").Default("roundrobin").Enum("roundrobin", "weight", "leastconn", "leasttime", "hash")
|
||||||
socksArgs.LoadBalanceTimeout = socks.Flag("lb-timeout", "tcp milliseconds timeout of connecting to parent").Default("500").Int()
|
socksArgs.LoadBalanceTimeout = socks.Flag("lb-timeout", "tcp milliseconds timeout of connecting to parent").Default("500").Int()
|
||||||
socksArgs.LoadBalanceRetryTime = socks.Flag("lb-retrytime", "sleep time milliseconds after checking").Default("1000").Int()
|
socksArgs.LoadBalanceRetryTime = socks.Flag("lb-retrytime", "sleep time milliseconds after checking").Default("1000").Int()
|
||||||
|
|||||||
@ -134,7 +134,7 @@ func StartWithLog(serviceID, serviceArgsStr string, loggerCallback LogCallback)
|
|||||||
httpArgs.ParentKey = http.Flag("parent-key", "the password for auto encrypt/decrypt parent connection data").Short('Z').Default("").String()
|
httpArgs.ParentKey = http.Flag("parent-key", "the password for auto encrypt/decrypt parent connection data").Short('Z').Default("").String()
|
||||||
httpArgs.LocalCompress = http.Flag("local-compress", "auto compress/decompress data on local connection").Short('m').Default("false").Bool()
|
httpArgs.LocalCompress = http.Flag("local-compress", "auto compress/decompress data on local connection").Short('m').Default("false").Bool()
|
||||||
httpArgs.ParentCompress = http.Flag("parent-compress", "auto compress/decompress data on parent connection").Short('M').Default("false").Bool()
|
httpArgs.ParentCompress = http.Flag("parent-compress", "auto compress/decompress data on parent connection").Short('M').Default("false").Bool()
|
||||||
httpArgs.CloseIntelligent = http.Flag("close-intelligent", "Close intelligent HTTP, SOCKS5 proxy").Default("false").Bool()
|
httpArgs.Intelligent = http.Flag("intelligent", "settting intelligent HTTP, SOCKS5 proxy mode, can be <intelligent|direct|parent>").Default("intelligent").Enmu("intelligent", "direct", "parent").String()
|
||||||
httpArgs.LoadBalanceMethod = http.Flag("lb-method", "load balance method when use multiple parent,can be <roundrobin|leastconn|leasttime|hash|weight>").Default("roundrobin").Enum("roundrobin", "weight", "leastconn", "leasttime", "hash")
|
httpArgs.LoadBalanceMethod = http.Flag("lb-method", "load balance method when use multiple parent,can be <roundrobin|leastconn|leasttime|hash|weight>").Default("roundrobin").Enum("roundrobin", "weight", "leastconn", "leasttime", "hash")
|
||||||
httpArgs.LoadBalanceTimeout = http.Flag("lb-timeout", "tcp milliseconds timeout of connecting to parent").Default("500").Int()
|
httpArgs.LoadBalanceTimeout = http.Flag("lb-timeout", "tcp milliseconds timeout of connecting to parent").Default("500").Int()
|
||||||
httpArgs.LoadBalanceRetryTime = http.Flag("lb-retrytime", "sleep time milliseconds after checking").Default("1000").Int()
|
httpArgs.LoadBalanceRetryTime = http.Flag("lb-retrytime", "sleep time milliseconds after checking").Default("1000").Int()
|
||||||
@ -271,7 +271,7 @@ func StartWithLog(serviceID, serviceArgsStr string, loggerCallback LogCallback)
|
|||||||
socksArgs.ParentKey = socks.Flag("parent-key", "the password for auto encrypt/decrypt parent connection data").Short('Z').Default("").String()
|
socksArgs.ParentKey = socks.Flag("parent-key", "the password for auto encrypt/decrypt parent connection data").Short('Z').Default("").String()
|
||||||
socksArgs.LocalCompress = socks.Flag("local-compress", "auto compress/decompress data on local connection").Short('m').Default("false").Bool()
|
socksArgs.LocalCompress = socks.Flag("local-compress", "auto compress/decompress data on local connection").Short('m').Default("false").Bool()
|
||||||
socksArgs.ParentCompress = socks.Flag("parent-compress", "auto compress/decompress data on parent connection").Short('M').Default("false").Bool()
|
socksArgs.ParentCompress = socks.Flag("parent-compress", "auto compress/decompress data on parent connection").Short('M').Default("false").Bool()
|
||||||
socksArgs.CloseIntelligent = socks.Flag("close-intelligent", "Close intelligent HTTP, SOCKS5 proxy").Default("false").Bool()
|
socksArgs.Intelligent = socks.Flag("intelligent", "settting intelligent HTTP, SOCKS5 proxy mode, can be <intelligent|direct|parent>").Default("intelligent").Enmu("intelligent", "direct", "parent").String()
|
||||||
socksArgs.LoadBalanceMethod = socks.Flag("lb-method", "load balance method when use multiple parent,can be <roundrobin|leastconn|leasttime|hash|weight>").Default("roundrobin").Enum("roundrobin", "weight", "leastconn", "leasttime", "hash")
|
socksArgs.LoadBalanceMethod = socks.Flag("lb-method", "load balance method when use multiple parent,can be <roundrobin|leastconn|leasttime|hash|weight>").Default("roundrobin").Enum("roundrobin", "weight", "leastconn", "leasttime", "hash")
|
||||||
socksArgs.LoadBalanceTimeout = socks.Flag("lb-timeout", "tcp milliseconds timeout of connecting to parent").Default("500").Int()
|
socksArgs.LoadBalanceTimeout = socks.Flag("lb-timeout", "tcp milliseconds timeout of connecting to parent").Default("500").Int()
|
||||||
socksArgs.LoadBalanceRetryTime = socks.Flag("lb-retrytime", "sleep time milliseconds after checking").Default("1000").Int()
|
socksArgs.LoadBalanceRetryTime = socks.Flag("lb-retrytime", "sleep time milliseconds after checking").Default("1000").Int()
|
||||||
|
|||||||
@ -66,7 +66,7 @@ type HTTPArgs struct {
|
|||||||
ParentKey *string
|
ParentKey *string
|
||||||
LocalCompress *bool
|
LocalCompress *bool
|
||||||
ParentCompress *bool
|
ParentCompress *bool
|
||||||
CloseIntelligent *bool
|
Intelligent *string
|
||||||
LoadBalanceMethod *string
|
LoadBalanceMethod *string
|
||||||
LoadBalanceTimeout *int
|
LoadBalanceTimeout *int
|
||||||
LoadBalanceRetryTime *int
|
LoadBalanceRetryTime *int
|
||||||
@ -186,7 +186,7 @@ func (s *HTTP) InitService() (err error) {
|
|||||||
s.InitBasicAuth()
|
s.InitBasicAuth()
|
||||||
//init lb
|
//init lb
|
||||||
if len(*s.cfg.Parent) > 0 {
|
if len(*s.cfg.Parent) > 0 {
|
||||||
s.checker = utils.NewChecker(*s.cfg.HTTPTimeout, int64(*s.cfg.Interval), *s.cfg.Blocked, *s.cfg.Direct, s.log, *s.cfg.CloseIntelligent)
|
s.checker = utils.NewChecker(*s.cfg.HTTPTimeout, int64(*s.cfg.Interval), *s.cfg.Blocked, *s.cfg.Direct, s.log, *s.cfg.Intelligent)
|
||||||
s.InitLB()
|
s.InitLB()
|
||||||
}
|
}
|
||||||
if *s.cfg.DNSAddress != "" {
|
if *s.cfg.DNSAddress != "" {
|
||||||
|
|||||||
@ -64,7 +64,7 @@ type SocksArgs struct {
|
|||||||
ParentKey *string
|
ParentKey *string
|
||||||
LocalCompress *bool
|
LocalCompress *bool
|
||||||
ParentCompress *bool
|
ParentCompress *bool
|
||||||
CloseIntelligent *bool
|
Intelligent *string
|
||||||
LoadBalanceMethod *string
|
LoadBalanceMethod *string
|
||||||
LoadBalanceTimeout *int
|
LoadBalanceTimeout *int
|
||||||
LoadBalanceRetryTime *int
|
LoadBalanceRetryTime *int
|
||||||
@ -181,7 +181,7 @@ func (s *Socks) InitService() (err error) {
|
|||||||
(*s).domainResolver = dnsx.NewDomainResolver(*s.cfg.DNSAddress, *s.cfg.DNSTTL, s.log)
|
(*s).domainResolver = dnsx.NewDomainResolver(*s.cfg.DNSAddress, *s.cfg.DNSTTL, s.log)
|
||||||
}
|
}
|
||||||
if len(*s.cfg.Parent) > 0 {
|
if len(*s.cfg.Parent) > 0 {
|
||||||
s.checker = utils.NewChecker(*s.cfg.Timeout, int64(*s.cfg.Interval), *s.cfg.Blocked, *s.cfg.Direct, s.log, *s.cfg.CloseIntelligent)
|
s.checker = utils.NewChecker(*s.cfg.Timeout, int64(*s.cfg.Interval), *s.cfg.Blocked, *s.cfg.Direct, s.log, *s.cfg.Intelligent)
|
||||||
s.InitLB()
|
s.InitLB()
|
||||||
}
|
}
|
||||||
if *s.cfg.ParentType == "ssh" {
|
if *s.cfg.ParentType == "ssh" {
|
||||||
|
|||||||
@ -24,14 +24,14 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Checker struct {
|
type Checker struct {
|
||||||
data mapx.ConcurrentMap
|
data mapx.ConcurrentMap
|
||||||
blockedMap mapx.ConcurrentMap
|
blockedMap mapx.ConcurrentMap
|
||||||
directMap mapx.ConcurrentMap
|
directMap mapx.ConcurrentMap
|
||||||
interval int64
|
interval int64
|
||||||
timeout int
|
timeout int
|
||||||
isStop bool
|
isStop bool
|
||||||
closeIntelligent bool
|
intelligent string
|
||||||
log *logger.Logger
|
log *logger.Logger
|
||||||
}
|
}
|
||||||
type CheckerItem struct {
|
type CheckerItem struct {
|
||||||
Domain string
|
Domain string
|
||||||
@ -44,14 +44,14 @@ type CheckerItem struct {
|
|||||||
//NewChecker args:
|
//NewChecker args:
|
||||||
//timeout : tcp timeout milliseconds ,connect to host
|
//timeout : tcp timeout milliseconds ,connect to host
|
||||||
//interval: recheck domain interval seconds
|
//interval: recheck domain interval seconds
|
||||||
func NewChecker(timeout int, interval int64, blockedFile, directFile string, log *logger.Logger, closeIntelligent bool) Checker {
|
func NewChecker(timeout int, interval int64, blockedFile, directFile string, log *logger.Logger, intelligent string) Checker {
|
||||||
ch := Checker{
|
ch := Checker{
|
||||||
data: mapx.NewConcurrentMap(),
|
data: mapx.NewConcurrentMap(),
|
||||||
interval: interval,
|
interval: interval,
|
||||||
timeout: timeout,
|
timeout: timeout,
|
||||||
isStop: false,
|
isStop: false,
|
||||||
closeIntelligent: closeIntelligent,
|
intelligent: intelligent,
|
||||||
log: log,
|
log: log,
|
||||||
}
|
}
|
||||||
ch.blockedMap = ch.loadMap(blockedFile)
|
ch.blockedMap = ch.loadMap(blockedFile)
|
||||||
ch.directMap = ch.loadMap(directFile)
|
ch.directMap = ch.loadMap(directFile)
|
||||||
@ -166,7 +166,12 @@ func (c *Checker) IsBlocked(domain string) (blocked, isInMap bool, failN, succes
|
|||||||
//log.Printf("%s not in map, blocked true", address)
|
//log.Printf("%s not in map, blocked true", address)
|
||||||
return true, false, 0, 0
|
return true, false, 0, 0
|
||||||
}
|
}
|
||||||
if !c.closeIntelligent {
|
switch c.intelligent {
|
||||||
|
case "direct":
|
||||||
|
return false, true, 0, 0
|
||||||
|
case "parent":
|
||||||
|
return true, true, 0, 0
|
||||||
|
case "intelligent":
|
||||||
item := _item.(CheckerItem)
|
item := _item.(CheckerItem)
|
||||||
return (item.FailCount >= item.SuccessCount) && (time.Now().Unix()-item.Lasttime < 1800), true, item.FailCount, item.SuccessCount
|
return (item.FailCount >= item.SuccessCount) && (time.Now().Unix()-item.Lasttime < 1800), true, item.FailCount, item.SuccessCount
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user