This commit is contained in:
arraykeys@gmail.com
2018-06-27 11:30:44 +08:00
5 changed files with 14 additions and 4 deletions

View File

@ -1,6 +1,8 @@
proxy更新日志 proxy更新日志
v5.1 v5.1
1.优化了kcp默认mtu配置,调整为450. 1.优化了kcp默认mtu配置,调整为450.
2.优化了HTTP(S)\SOCKS5代理智能判断更加精确。
3.fix #97 , 修复了RemoveProxyHeaders方法忽略了第一行的bug。
v5.0 v5.0
1.修复了SPS多端口无效的bug. 1.修复了SPS多端口无效的bug.

View File

@ -278,7 +278,7 @@ func (s *HTTP) callback(inConn net.Conn) {
useProxy = true useProxy = true
} else { } else {
k := s.Resolve(address) k := s.Resolve(address)
s.checker.Add(k) s.checker.Add(address, k)
//var n, m uint //var n, m uint
useProxy, _, _ = s.checker.IsBlocked(k) useProxy, _, _ = s.checker.IsBlocked(k)
//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)

View File

@ -563,7 +563,7 @@ func (s *Socks) proxyTCP(inConn *net.Conn, methodReq socks.MethodsRequest, reque
useProxy = false useProxy = false
} else { } else {
k := s.Resolve(request.Addr()) k := s.Resolve(request.Addr())
s.checker.Add(k) s.checker.Add(request.Addr(), k)
useProxy, _, _ = s.checker.IsBlocked(k) useProxy, _, _ = s.checker.IsBlocked(k)
} }
if useProxy { if useProxy {

View File

@ -640,12 +640,18 @@ func RemoveProxyHeaders(head []byte) []byte {
var keys = map[string]bool{} var keys = map[string]bool{}
lines := bytes.Split(head, []byte("\r\n")) lines := bytes.Split(head, []byte("\r\n"))
IsBody := false IsBody := false
i := -1
for _, line := range lines { for _, line := range lines {
i++
if len(line) == 0 || IsBody { if len(line) == 0 || IsBody {
newLines = append(newLines, line) newLines = append(newLines, line)
IsBody = true IsBody = true
} else { } else {
hline := bytes.SplitN(line, []byte(":"), 2) hline := bytes.SplitN(line, []byte(":"), 2)
if i == 0 && IsHTTP(head) {
newLines = append(newLines, line)
continue
}
if len(hline) != 2 { if len(hline) != 2 {
continue continue
} }

View File

@ -41,6 +41,7 @@ type CheckerItem struct {
Data []byte Data []byte
SuccessCount uint SuccessCount uint
FailCount uint FailCount uint
Key string
} }
//NewChecker args: //NewChecker args:
@ -173,13 +174,14 @@ func (c *Checker) domainIsInMap(address string, blockedMap bool) bool {
} }
return false return false
} }
func (c *Checker) Add(address string) { func (c *Checker) Add(key, address string) {
if c.domainIsInMap(address, false) || c.domainIsInMap(address, true) { if c.domainIsInMap(key, false) || c.domainIsInMap(key, true) {
return return
} }
var item CheckerItem var item CheckerItem
item = CheckerItem{ item = CheckerItem{
Host: address, Host: address,
Key: key,
} }
c.data.SetIfAbsent(item.Host, item) c.data.SetIfAbsent(item.Host, item)
} }