Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
44909ea6c6 | ||
|
|
a0cd66e319 | ||
|
|
8c4e5025ed | ||
|
|
442e7b7c01 | ||
|
|
05dfbe6f8a | ||
|
|
c64324227b | ||
|
|
1388f2e008 | ||
|
|
2752d79248 | ||
|
|
7aa24afcf2 | ||
|
|
b3622e709c | ||
|
|
02a58189ad | ||
|
|
f42184daaf |
@ -1,5 +1,13 @@
|
|||||||
proxy更新日志
|
proxy更新日志
|
||||||
|
|
||||||
|
v6.6
|
||||||
|
1.优化了limitconn的关闭逻辑,释放更多资源.
|
||||||
|
2.http(s)\socks代理增加了--intelligent,智能模式设置,可以是intelligent|direct|parent三者之一,
|
||||||
|
默认是:intelligent.每个值的含义如下.
|
||||||
|
--intelligent=direct,不在blocked里面的目标都直连.
|
||||||
|
--intelligent=parent,不在direct里面的目标都走上级.
|
||||||
|
--intelligent=intelligent,blocked和direct里面都没有的目标,智能判断是否使用上级访问目标.
|
||||||
|
|
||||||
v6.5
|
v6.5
|
||||||
1.修复了合并企业版遗留的一些bug.
|
1.修复了合并企业版遗留的一些bug.
|
||||||
|
|
||||||
|
|||||||
@ -323,7 +323,7 @@ accessing the local 8080 port is accessing the proxy port 38080 above VPS.
|
|||||||
|
|
||||||
HTTP second level proxy(local windows)
|
HTTP second level proxy(local windows)
|
||||||
`./proxy.exe http -t tcp -p ":8080" -T tls -P "22.22.22.22:38080" -C proxy.crt -K proxy.key`
|
`./proxy.exe http -t tcp -p ":8080" -T tls -P "22.22.22.22:38080" -C proxy.crt -K proxy.key`
|
||||||
In your windos system, the mode of the program that needs to surf the Internet by proxy is setted up as HTTP mode, the address is 127.0.0.1, the port is: 8080, the program can go through the encrypted channel through VPS to surf on the internet.
|
In your windows system, the mode of the program that needs to surf the Internet by proxy is setted up as HTTP mode, the address is 127.0.0.1, the port is: 8080, the program can go through the encrypted channel through VPS to surf on the internet.
|
||||||
|
|
||||||
#### **1.4.HTTP third level encrypted proxy**
|
#### **1.4.HTTP third level encrypted proxy**
|
||||||

|

|
||||||
@ -513,7 +513,7 @@ The speed limit is 100K, which can be specified through the `-l` parameter, for
|
|||||||
`proxy http -t tcp -p 2.2.2.2:33080 -l 100K`
|
`proxy http -t tcp -p 2.2.2.2:33080 -l 100K`
|
||||||
|
|
||||||
### **1.16 Designated exporting IP**
|
### **1.16 Designated exporting IP**
|
||||||
The `- bind-listen` parameter opens the client's ability to access the target site with an entry IP connection, using the entry IP as the exporting IP. If the entry IP is the intranet IP, the exporting IP will not use the entry IP..
|
The `--bind-listen` parameter open the client's ability to access the target site with an entry IP connection, using the entry IP as the exporting IP. If the entry IP is the intranet IP, the exporting IP will not use the entry IP..
|
||||||
`proxy http -t tcp -p 2.2.2.2:33080 --bind-listen`
|
`proxy http -t tcp -p 2.2.2.2:33080 --bind-listen`
|
||||||
|
|
||||||
### **1.17 Certificate parameters using Base64 data**
|
### **1.17 Certificate parameters using Base64 data**
|
||||||
|
|||||||
28
README_ZH.md
28
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,7 +378,7 @@ 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`
|
||||||
|
|
||||||
#### **1.7.HTTP(S)通过SSH中转**
|
#### **1.7.HTTP(S)通过SSH中转**
|
||||||

|

|
||||||
说明:ssh中转的原理是利用了ssh的转发功能,就是你连接上ssh之后,可以通过ssh代理访问目标地址.
|
说明:ssh中转的原理是利用了ssh的转发功能,就是你连接上ssh之后,可以通过ssh代理访问目标地址.
|
||||||
@ -551,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代理**
|
||||||
@ -1030,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,6 +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.Intelligent = http.Flag("intelligent", "settting intelligent HTTP, SOCKS5 proxy mode, can be <intelligent|direct|parent>").Default("intelligent").Enum("intelligent", "direct", "parent")
|
||||||
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()
|
||||||
@ -221,7 +222,7 @@ func initConfig() (err error) {
|
|||||||
tunnelBridgeArgs.Timeout = tunnelBridge.Flag("timeout", "tcp timeout with milliseconds").Short('t').Default("2000").Int()
|
tunnelBridgeArgs.Timeout = tunnelBridge.Flag("timeout", "tcp timeout with milliseconds").Short('t').Default("2000").Int()
|
||||||
tunnelBridgeArgs.Local = tunnelBridge.Flag("local", "local ip:port to listen").Short('p').Default(":33080").String()
|
tunnelBridgeArgs.Local = tunnelBridge.Flag("local", "local ip:port to listen").Short('p').Default(":33080").String()
|
||||||
|
|
||||||
//########ssh#########
|
//########socks#########
|
||||||
socks := app.Command("socks", "proxy on ssh mode")
|
socks := app.Command("socks", "proxy on ssh mode")
|
||||||
socksArgs.Parent = socks.Flag("parent", "parent ssh address, such as: \"23.32.32.19:22\"").Default("").Short('P').Strings()
|
socksArgs.Parent = socks.Flag("parent", "parent ssh address, such as: \"23.32.32.19:22\"").Default("").Short('P').Strings()
|
||||||
socksArgs.ParentType = socks.Flag("parent-type", "parent protocol type <tls|tcp|kcp|ssh>").Default("tcp").Short('T').Enum("tls", "tcp", "kcp", "ssh")
|
socksArgs.ParentType = socks.Flag("parent-type", "parent protocol type <tls|tcp|kcp|ssh>").Default("tcp").Short('T').Enum("tls", "tcp", "kcp", "ssh")
|
||||||
@ -253,6 +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.Intelligent = socks.Flag("intelligent", "settting intelligent HTTP, SOCKS5 proxy mode, can be <intelligent|direct|parent>").Default("intelligent").Enum("intelligent", "direct", "parent")
|
||||||
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()
|
||||||
@ -262,7 +264,7 @@ func initConfig() (err error) {
|
|||||||
socksArgs.BindListen = socks.Flag("bind-listen", "using listener binding IP when connect to target").Short('B').Default("false").Bool()
|
socksArgs.BindListen = socks.Flag("bind-listen", "using listener binding IP when connect to target").Short('B').Default("false").Bool()
|
||||||
socksArgs.Debug = isDebug
|
socksArgs.Debug = isDebug
|
||||||
|
|
||||||
//########socks+http(s)#########
|
//########sps#########
|
||||||
sps := app.Command("sps", "proxy on socks+http(s) mode")
|
sps := app.Command("sps", "proxy on socks+http(s) mode")
|
||||||
spsArgs.Parent = sps.Flag("parent", "parent address, such as: \"23.32.32.19:28008\"").Default("").Short('P').Strings()
|
spsArgs.Parent = sps.Flag("parent", "parent address, such as: \"23.32.32.19:28008\"").Default("").Short('P').Strings()
|
||||||
spsArgs.CertFile = sps.Flag("cert", "cert file for tls").Short('C').Default("proxy.crt").String()
|
spsArgs.CertFile = sps.Flag("cert", "cert file for tls").Short('C').Default("proxy.crt").String()
|
||||||
|
|||||||
@ -134,6 +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.Intelligent = http.Flag("intelligent", "settting intelligent HTTP, SOCKS5 proxy mode, can be <intelligent|direct|parent>").Default("intelligent").Enum("intelligent", "direct", "parent")
|
||||||
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()
|
||||||
@ -270,6 +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.Intelligent = socks.Flag("intelligent", "settting intelligent HTTP, SOCKS5 proxy mode, can be <intelligent|direct|parent>").Default("intelligent").Enum("intelligent", "direct", "parent")
|
||||||
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,6 +66,7 @@ type HTTPArgs struct {
|
|||||||
ParentKey *string
|
ParentKey *string
|
||||||
LocalCompress *bool
|
LocalCompress *bool
|
||||||
ParentCompress *bool
|
ParentCompress *bool
|
||||||
|
Intelligent *string
|
||||||
LoadBalanceMethod *string
|
LoadBalanceMethod *string
|
||||||
LoadBalanceTimeout *int
|
LoadBalanceTimeout *int
|
||||||
LoadBalanceRetryTime *int
|
LoadBalanceRetryTime *int
|
||||||
@ -185,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.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,6 +64,7 @@ type SocksArgs struct {
|
|||||||
ParentKey *string
|
ParentKey *string
|
||||||
LocalCompress *bool
|
LocalCompress *bool
|
||||||
ParentCompress *bool
|
ParentCompress *bool
|
||||||
|
Intelligent *string
|
||||||
LoadBalanceMethod *string
|
LoadBalanceMethod *string
|
||||||
LoadBalanceTimeout *int
|
LoadBalanceTimeout *int
|
||||||
LoadBalanceRetryTime *int
|
LoadBalanceRetryTime *int
|
||||||
@ -180,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.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" {
|
||||||
|
|||||||
@ -102,6 +102,19 @@ func (s *conn) Write(p []byte) (int, error) {
|
|||||||
}
|
}
|
||||||
return n, err
|
return n, err
|
||||||
}
|
}
|
||||||
|
func (s *conn) Close() error {
|
||||||
|
if s.Conn != nil {
|
||||||
|
e := s.Conn.Close()
|
||||||
|
s.Conn = nil
|
||||||
|
s.r = nil
|
||||||
|
s.w = nil
|
||||||
|
s.readLimiter = nil
|
||||||
|
s.writeLimiter = nil
|
||||||
|
s.ctx = nil
|
||||||
|
return e
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// NewReader returns a reader that implements io.Reader with rate limiting.
|
// NewReader returns a reader that implements io.Reader with rate limiting.
|
||||||
func NewReader(r io.Reader) *Reader {
|
func NewReader(r io.Reader) *Reader {
|
||||||
|
|||||||
@ -24,13 +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
|
||||||
log *logger.Logger
|
intelligent string
|
||||||
|
log *logger.Logger
|
||||||
}
|
}
|
||||||
type CheckerItem struct {
|
type CheckerItem struct {
|
||||||
Domain string
|
Domain string
|
||||||
@ -43,13 +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) 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,
|
||||||
log: log,
|
intelligent: intelligent,
|
||||||
|
log: log,
|
||||||
}
|
}
|
||||||
ch.blockedMap = ch.loadMap(blockedFile)
|
ch.blockedMap = ch.loadMap(blockedFile)
|
||||||
ch.directMap = ch.loadMap(directFile)
|
ch.directMap = ch.loadMap(directFile)
|
||||||
@ -164,9 +166,16 @@ 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
|
||||||
}
|
}
|
||||||
item := _item.(CheckerItem)
|
switch c.intelligent {
|
||||||
|
case "direct":
|
||||||
return (item.FailCount >= item.SuccessCount) && (time.Now().Unix()-item.Lasttime < 1800), true, item.FailCount, item.SuccessCount
|
return false, true, 0, 0
|
||||||
|
case "parent":
|
||||||
|
return true, true, 0, 0
|
||||||
|
case "intelligent":
|
||||||
|
item := _item.(CheckerItem)
|
||||||
|
return (item.FailCount >= item.SuccessCount) && (time.Now().Unix()-item.Lasttime < 1800), true, item.FailCount, item.SuccessCount
|
||||||
|
}
|
||||||
|
return true, false, 0, 0
|
||||||
}
|
}
|
||||||
func (c *Checker) domainIsInMap(address string, blockedMap bool) bool {
|
func (c *Checker) domainIsInMap(address string, blockedMap bool) bool {
|
||||||
u, err := url.Parse("http://" + address)
|
u, err := url.Parse("http://" + address)
|
||||||
|
|||||||
Reference in New Issue
Block a user