diff --git a/proxy/http.go b/proxy/http.go index b41fd31..3d39f2f 100644 --- a/proxy/http.go +++ b/proxy/http.go @@ -33,11 +33,13 @@ import ( "net/http" "net/url" + "io/ioutil" + "strings" ) var ( HttpProxyProtocol = []string{"http", "https"} - WebUrl = "http://www.163.com" + WebUrl = "http://email.163.com/" ) func CheckHttpProxy(ip string, port int, protocol string) (err error, isProxy bool, proxyInfo models.ProxyInfo) { @@ -53,8 +55,12 @@ func CheckHttpProxy(ip string, port int, protocol string) (err error, isProxy bo util.Log.Debugf("Checking proxy: %v", rawProxyUrl) resp, err := client.Get(WebUrl) if err == nil { - if resp.StatusCode >= http.StatusOK { - isProxy = true + if resp.StatusCode == http.StatusOK { + body, err := ioutil.ReadAll(resp.Body) + if err == nil && strings.Contains(string(body), "网易免费邮箱") { + isProxy = true + } + } } } diff --git a/proxy/socks.go b/proxy/socks.go index 6203e99..a6dcd5d 100644 --- a/proxy/socks.go +++ b/proxy/socks.go @@ -25,13 +25,16 @@ THE SOFTWARE. package proxy import ( - "net/http" "h12.me/socks" "proxy_scanner/models" "proxy_scanner/util" + "fmt" "time" + "net/http" + "io/ioutil" + "strings" ) var ( @@ -53,8 +56,11 @@ func CheckSockProxy(ip string, port, protocol int) (err error, isProxy bool, pro util.Log.Debugf("Checking proxy: %v", fmt.Sprintf("%v://%v:%v", SockProxyProtocol[protocol], ip, port)) resp, err := httpClient.Get(WebUrl) if err == nil { - if resp.StatusCode >= http.StatusOK { - isProxy = true + if resp.StatusCode == http.StatusOK { + body, err := ioutil.ReadAll(resp.Body) + if err == nil && strings.Contains(string(body), "网易免费邮箱") { + isProxy = true + } } } return err, isProxy, proxyInfo