Signed-off-by: arraykeys@gmail.com <arraykeys@gmail.com>
This commit is contained in:
@ -76,13 +76,20 @@ func (s *HTTP) callback(inConn net.Conn) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
address := req.Host
|
address := req.Host
|
||||||
|
if req.IsHTTPS() {
|
||||||
|
s.checker.Add(address, true, req.Method, "", nil)
|
||||||
|
} else {
|
||||||
|
s.checker.Add(address, false, req.Method, req.URL, req.HeadBuf)
|
||||||
|
}
|
||||||
useProxy := true
|
useProxy := true
|
||||||
if *s.cfg.Parent == "" {
|
if *s.cfg.Parent == "" {
|
||||||
useProxy = false
|
useProxy = false
|
||||||
} else if *s.cfg.Always {
|
} else if *s.cfg.Always {
|
||||||
useProxy = true
|
useProxy = true
|
||||||
} else {
|
} else {
|
||||||
|
//var n, m uint
|
||||||
useProxy, _, _ = s.checker.IsBlocked(req.Host)
|
useProxy, _, _ = s.checker.IsBlocked(req.Host)
|
||||||
|
//log.Printf("blocked ? : %v, %s , fail:%d ,success:%d", useProxy, address, n, m)
|
||||||
}
|
}
|
||||||
log.Printf("use proxy : %v, %s", useProxy, address)
|
log.Printf("use proxy : %v, %s", useProxy, address)
|
||||||
//os.Exit(0)
|
//os.Exit(0)
|
||||||
|
|||||||
@ -113,14 +113,17 @@ func (c *Checker) isNeedCheck(item CheckerItem) bool {
|
|||||||
}
|
}
|
||||||
func (c *Checker) IsBlocked(address string) (blocked bool, failN, successN uint) {
|
func (c *Checker) IsBlocked(address string) (blocked bool, failN, successN uint) {
|
||||||
if c.domainIsInMap(address, true) {
|
if c.domainIsInMap(address, true) {
|
||||||
|
//log.Printf("%s in blocked ? true", address)
|
||||||
return true, 0, 0
|
return true, 0, 0
|
||||||
}
|
}
|
||||||
if c.domainIsInMap(address, false) {
|
if c.domainIsInMap(address, false) {
|
||||||
|
//log.Printf("%s in direct ? true", address)
|
||||||
return false, 0, 0
|
return false, 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)
|
||||||
return true, 0, 0
|
return true, 0, 0
|
||||||
}
|
}
|
||||||
item := _item.(CheckerItem)
|
item := _item.(CheckerItem)
|
||||||
|
|||||||
Reference in New Issue
Block a user