Signed-off-by: arraykeys@gmail.com <arraykeys@gmail.com>
This commit is contained in:
@ -1,6 +1,7 @@
|
|||||||
proxy更新日志
|
proxy更新日志
|
||||||
v5.2
|
v5.2
|
||||||
1.修复了HTTP(S)\SPS反向代理无法正常工作的问题.
|
1.修复了HTTP(S)\SPS反向代理无法正常工作的问题.
|
||||||
|
2.优化了智能判断,减少不必要的DNS解析.
|
||||||
|
|
||||||
v5.1
|
v5.1
|
||||||
1.优化了kcp默认mtu配置,调整为450.
|
1.优化了kcp默认mtu配置,调整为450.
|
||||||
|
|||||||
@ -76,7 +76,7 @@ func (s *DNS) InitService() (err error) {
|
|||||||
nil,
|
nil,
|
||||||
&net.Dialer{
|
&net.Dialer{
|
||||||
Timeout: 5 * time.Second,
|
Timeout: 5 * time.Second,
|
||||||
KeepAlive: 5 * time.Second,
|
KeepAlive: 2 * time.Second,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@ -277,10 +277,11 @@ func (s *HTTP) callback(inConn net.Conn) {
|
|||||||
} else if *s.cfg.Always {
|
} else if *s.cfg.Always {
|
||||||
useProxy = true
|
useProxy = true
|
||||||
} else {
|
} else {
|
||||||
k := s.Resolve(address)
|
var isInMap bool
|
||||||
s.checker.Add(address, k)
|
useProxy, isInMap, _, _ = s.checker.IsBlocked(address)
|
||||||
//var n, m uint
|
if !isInMap {
|
||||||
useProxy, _, _ = s.checker.IsBlocked(k)
|
s.checker.Add(address, s.Resolve(address))
|
||||||
|
}
|
||||||
//s.log.Printf("blocked ? : %v, %s , fail:%d ,success:%d", useProxy, address, n, m)
|
//s.log.Printf("blocked ? : %v, %s , fail:%d ,success:%d", useProxy, address, n, m)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -562,9 +562,11 @@ func (s *Socks) proxyTCP(inConn *net.Conn, methodReq socks.MethodsRequest, reque
|
|||||||
if utils.IsIternalIP(host, *s.cfg.Always) {
|
if utils.IsIternalIP(host, *s.cfg.Always) {
|
||||||
useProxy = false
|
useProxy = false
|
||||||
} else {
|
} else {
|
||||||
k := s.Resolve(request.Addr())
|
var isInMap bool
|
||||||
s.checker.Add(request.Addr(), k)
|
useProxy, isInMap, _, _ = s.checker.IsBlocked(request.Addr())
|
||||||
useProxy, _, _ = s.checker.IsBlocked(k)
|
if !isInMap {
|
||||||
|
s.checker.Add(request.Addr(), s.Resolve(request.Addr()))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if useProxy {
|
if useProxy {
|
||||||
outConn, err = s.getOutConn(methodReq.Bytes(), request.Bytes(), request.Addr())
|
outConn, err = s.getOutConn(methodReq.Bytes(), request.Bytes(), request.Addr())
|
||||||
|
|||||||
@ -132,24 +132,24 @@ func (c *Checker) isNeedCheck(item CheckerItem) bool {
|
|||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
func (c *Checker) IsBlocked(address string) (blocked bool, failN, successN uint) {
|
func (c *Checker) IsBlocked(address string) (blocked, isInMap bool, failN, successN uint) {
|
||||||
if c.domainIsInMap(address, true) {
|
if c.domainIsInMap(address, true) {
|
||||||
//log.Printf("%s in blocked ? true", address)
|
//log.Printf("%s in blocked ? true", address)
|
||||||
return true, 0, 0
|
return true, true, 0, 0
|
||||||
}
|
}
|
||||||
if c.domainIsInMap(address, false) {
|
if c.domainIsInMap(address, false) {
|
||||||
//log.Printf("%s in direct ? true", address)
|
//log.Printf("%s in direct ? true", address)
|
||||||
return false, 0, 0
|
return false, true, 0, 0
|
||||||
}
|
}
|
||||||
|
|
||||||
_item, ok := c.data.Get(address)
|
_item, ok := c.data.Get(address)
|
||||||
if !ok {
|
if !ok {
|
||||||
//log.Printf("%s not in map, blocked true", address)
|
//log.Printf("%s not in map, blocked true", address)
|
||||||
return true, 0, 0
|
return true, false, 0, 0
|
||||||
}
|
}
|
||||||
item := _item.(CheckerItem)
|
item := _item.(CheckerItem)
|
||||||
|
|
||||||
return item.FailCount >= item.SuccessCount, item.FailCount, item.SuccessCount
|
return item.FailCount >= item.SuccessCount, true, item.FailCount, item.SuccessCount
|
||||||
}
|
}
|
||||||
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