commit fee0c7d845a865cd6c3f3df8324bce66db253b4d Author: iuu <2167162990@qq.com> Date: Wed Jan 8 14:41:07 2025 +0800 https 节点检测 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4e4029d --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +go_build_httppp +gost-master \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..35410ca --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml +# 基于编辑器的 HTTP 客户端请求 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/httppp.iml b/.idea/httppp.iml new file mode 100644 index 0000000..5e764c4 --- /dev/null +++ b/.idea/httppp.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..f9aeb03 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/common/common.go b/common/common.go new file mode 100644 index 0000000..08a3b32 --- /dev/null +++ b/common/common.go @@ -0,0 +1,21 @@ +package common + +const ( + AppEnv = "dev" + EnvConfig = "config.json" +) + +type Config struct { + Debug bool `mapstructure:"debug" json:"debug" yaml:"debug"` + TargetURL string `mapstructure:"target_url" json:"target_url" yaml:"target_url"` + Nodes []Node `mapstructure:"nodes" json:"nodes" yaml:"nodes"` +} + +type Node struct { + Protocol string `mapstructure:"protocol" yaml:"protocol" json:"protocol"` + Username string `mapstructure:"username" yaml:"username" json:"username"` + Password string `mapstructure:"password" yaml:"password" json:"password"` + Addr string `mapstructure:"addr" yaml:"addr" json:"addr"` + Port int `mapstructure:"port" yaml:"port" json:"port"` + Ports []int `mapstructure:"ports" yaml:"ports" json:"ports"` +} diff --git a/common/viper/viper.go b/common/viper/viper.go new file mode 100644 index 0000000..edd7917 --- /dev/null +++ b/common/viper/viper.go @@ -0,0 +1,54 @@ +package viper + +import ( + "flag" + "fmt" + "github.com/fsnotify/fsnotify" + "github.com/spf13/viper" + "httppp/common" + "httppp/global" + "os" +) + +func InitViper(path ...string) { + var confPath string + if len(path) == 0 { + flag.StringVar(&confPath, "c", "", "choose config file.") + flag.Parse() + if confPath == "" { + if AppEnv := os.Getenv(common.AppEnv); AppEnv == "" { + confPath = common.EnvConfig + } else { + confPath = AppEnv + } + } else { + } + } else { + confPath = path[0] + } + + v := viper.New() + v.SetConfigFile(confPath) + v.SetConfigType("json") + err := v.ReadInConfig() + if err != nil { + fmt.Printf("[-]读取配置文件错误: %s \n", err) + os.Exit(0) + } + v.WatchConfig() + v.OnConfigChange(func(e fsnotify.Event) { + if err = v.Unmarshal(&global.Conf); err != nil { + fmt.Printf("[-]重新解析配置文件失败: %s \n", err) + os.Exit(0) + } + fmt.Println("[+]重新加载配置文件完成") + }) + if err = v.Unmarshal(&global.Conf); err != nil { + fmt.Printf("[-]解析配置文件失败: %s \n", err) + os.Exit(0) + } + fmt.Println("[+]加载配置文件完成") + + //dump.P(global.AppConf) + +} diff --git a/config.json b/config.json new file mode 100644 index 0000000..8926ab0 --- /dev/null +++ b/config.json @@ -0,0 +1,16 @@ +{ + "debug": false, + "target_url": "https://www.google.com", + "nodes": [ + { + "protocol": "https", + "username": "mrwdfNTD8M79LCukCieldrqZWqs=", + "password": "exaxgqkKkd0TAMrCxeonWg==", + "addr": "jpgmo101-cdn-route.couldflare-cdn.com", + "ports": [ + "443", + "1443" + ] + } + ] +} diff --git a/core/check.go b/core/check.go new file mode 100644 index 0000000..e77702d --- /dev/null +++ b/core/check.go @@ -0,0 +1,124 @@ +package core + +import ( + "context" + "fmt" + "httppp/common" + "httppp/global" + "io" + "net" + "net/http" + "net/url" + "time" +) + +//for _, node := range global.Conf.Nodes { +//for _, port := range node.Ports { +//node.Port = port +//success, message := core.CheckHttpsProxy(&node, global.Conf.TargetURL) +//if success { +//fmt.Printf("代理 %s 端口 %d 可用.\n", node.Addr, node.Port) +//} else { +//fmt.Printf("代理 %s 端口 %d 不可用: %s\n", node.Addr, node.Port, message) +//} +//} +//} + +// CheckHttpsProxy 检测代理是否可用的函数 +func CheckHttpsProxy(node *common.Node, targetURL string) (bool, string) { + proxyURL, err := Node2ProxyURL(node) + if err != nil { + fmt.Printf("节点转换代理URL失败: %v\n", err) + return false, err.Error() + } + // 解析代理 URL + proxy, err := url.Parse(proxyURL) + if err != nil { + fmt.Printf("代理解析失败: %v\n", err) + return false, err.Error() + } + + // 创建自定义 Transport,用于调试代理信息 + transport := &http.Transport{ + Proxy: http.ProxyURL(proxy), // 设置代理 + DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) { + if global.Conf.Debug { + fmt.Printf("网络拨号: %s, 地址: %s\n", network, addr) + } + conn, err := net.Dial(network, addr) + if err != nil { + fmt.Printf("网络拨号失败: %v\n", err) + } + return conn, err + }, + } + + // 创建 HTTP 客户端并使用自定义 Transport + client := &http.Client{ + Transport: transport, + Timeout: 30 * time.Second, // 设置超时时间 + } + + if global.Conf.Debug { + fmt.Printf("发送请求到: %s 使用代理: %s\n", targetURL, proxyURL) + } + // 发起 GET 请求 + resp, err := client.Get(targetURL) + if err != nil { + fmt.Printf("通过代理发送请求失败 %s: %v\n", proxyURL, err) + return false, err.Error() + } + defer resp.Body.Close() + + if global.Conf.Debug { + // 打印响应状态 + fmt.Printf("Response 状态码: %s\n", resp.Status) + // 打印响应头 + fmt.Printf("Response 响应头: \n") + for key, value := range resp.Header { + fmt.Printf("\t%s: %s\n", key, value) + } + } + + if global.Conf.Debug { + // 创建一个缓冲区,用于分块读取响应体 + buffer := make([]byte, 4096) // 4KB 缓冲区 + fmt.Printf("分块读取响应正文:\n") + // 分块读取响应体 + for { + n, err := resp.Body.Read(buffer) + if err == io.EOF { + fmt.Println("响应正文读取完毕.") + break + } + if err != nil { + fmt.Printf("响应正文读取错误: %v\n", err) + return false, err.Error() + } + // 打印每次读取的内容 + fmt.Printf("%s\n", string(buffer[:n])) // 不打印内容,只检测可用性 + } + } + + // 检查是否发生了重定向 + if resp.StatusCode == 301 || resp.StatusCode == 302 { + redirectURL := resp.Header.Get("Location") + if global.Conf.Debug { + fmt.Printf("重定向到: %s\n", redirectURL) + } + // 如果需要处理重定向,可以发起新的请求 + newResp, err := client.Get(redirectURL) + if err != nil { + fmt.Printf("重定向失败: %v\n", err) + return false, err.Error() + } + defer newResp.Body.Close() + + // 打印重定向后的响应状态 + if global.Conf.Debug { + fmt.Printf("重定向响应状态: %s\n", newResp.Status) + } + } + + return true, "代理可用" +} diff --git a/core/tools.go b/core/tools.go new file mode 100644 index 0000000..3a3ad7b --- /dev/null +++ b/core/tools.go @@ -0,0 +1,27 @@ +package core + +import ( + "fmt" + "httppp/common" + "net/url" +) + +// Node2ProxyURL 将 Node 结构体转为代理 URL +func Node2ProxyURL(node *common.Node) (string, error) { + // 如果代理需要认证,构造用户名:密码@部分 + var authPart string + if node.Username != "" && node.Password != "" { + authPart = fmt.Sprintf("%s:%s@", node.Username, node.Password) + } + + // 使用 "protocol://username:password@addr:port" 格式构建代理 URL + proxyURL := fmt.Sprintf("%s://%s%s:%d", node.Protocol, authPart, node.Addr, node.Port) + + // 解析代理 URL + parsedURL, err := url.Parse(proxyURL) + if err != nil { + return "", fmt.Errorf("failed to parse proxy URL: %v", err) + } + + return parsedURL.String(), nil +} diff --git a/curl.txt b/curl.txt new file mode 100644 index 0000000..88a75a9 --- /dev/null +++ b/curl.txt @@ -0,0 +1,93 @@ +iuu@iuudeMac-Studio ~ % curl -x https://mrwdfNTD8M79LCukCieldrqZWqs=:exaxgqkKkd0TAMrCxeonWg==@jpgmo101-cdn-route.couldflare-cdn.com:443 https://google.com -vvv +* Host jpgmo101-cdn-route.couldflare-cdn.com:443 was resolved. +* IPv6: (none) +* IPv4: 198.18.0.13 +* Trying 198.18.0.13:443... +* Connected to jpgmo101-cdn-route.couldflare-cdn.com (198.18.0.13) port 443 +* ALPN: curl offers http/1.1 +* (304) (OUT), TLS handshake, Client hello (1): +* CAfile: /etc/ssl/cert.pem +* CApath: none +* (304) (IN), TLS handshake, Server hello (2): +* (304) (IN), TLS handshake, Unknown (8): +* (304) (IN), TLS handshake, Certificate (11): +* (304) (IN), TLS handshake, CERT verify (15): +* (304) (IN), TLS handshake, Finished (20): +* (304) (OUT), TLS handshake, Finished (20): +* SSL connection using TLSv1.3 / AEAD-AES128-GCM-SHA256 / [blank] / UNDEF +* ALPN: server accepted http/1.1 +* Proxy certificate: +* subject: CN=jpgmo101-cdn-route.couldflare-cdn.com +* start date: Nov 10 18:02:52 2024 GMT +* expire date: Feb 8 18:02:51 2025 GMT +* subjectAltName: host "jpgmo101-cdn-route.couldflare-cdn.com" matched cert's "jpgmo101-cdn-route.couldflare-cdn.com" +* issuer: C=US; O=Let's Encrypt; CN=E5 +* SSL certificate verify ok. +* CONNECT tunnel: HTTP/1.1 negotiated +* allocate connect buffer +* Proxy auth using Basic with user 'mrwdfNTD8M79LCukCieldrqZWqs=' +* Establish HTTP proxy tunnel to google.com:443 +> CONNECT google.com:443 HTTP/1.1 +> Host: google.com:443 +> Proxy-Authorization: Basic bXJ3ZGZOVEQ4TTc5TEN1a0NpZWxkcnFaV3FzPTpleGF4Z3FrS2tkMFRBTXJDeGVvbldnPT0= +> User-Agent: curl/8.6.0 +> Proxy-Connection: Keep-Alive +> +< HTTP/1.1 200 OK +< Server: Caddy +< Content-Length: 0 +* Ignoring Content-Length in CONNECT 200 response +< +* CONNECT phase completed +* CONNECT tunnel established, response 200 +* ALPN: curl offers h2,http/1.1 +* (304) (OUT), TLS handshake, Client hello (1): +* (304) (IN), TLS handshake, Server hello (2): +* (304) (IN), TLS handshake, Unknown (8): +* (304) (IN), TLS handshake, Certificate (11): +* (304) (IN), TLS handshake, CERT verify (15): +* (304) (IN), TLS handshake, Finished (20): +* (304) (OUT), TLS handshake, Finished (20): +* SSL connection using TLSv1.3 / AEAD-CHACHA20-POLY1305-SHA256 / [blank] / UNDEF +* ALPN: server accepted h2 +* Server certificate: +* subject: CN=*.google.com +* start date: Dec 2 08:35:57 2024 GMT +* expire date: Feb 24 08:35:56 2025 GMT +* subjectAltName: host "google.com" matched cert's "google.com" +* issuer: C=US; O=Google Trust Services; CN=WR2 +* SSL certificate verify ok. +* using HTTP/2 +* [HTTP/2] [1] OPENED stream for https://google.com/ +* [HTTP/2] [1] [:method: GET] +* [HTTP/2] [1] [:scheme: https] +* [HTTP/2] [1] [:authority: google.com] +* [HTTP/2] [1] [:path: /] +* [HTTP/2] [1] [user-agent: curl/8.6.0] +* [HTTP/2] [1] [accept: */*] +> GET / HTTP/2 +> Host: google.com +> User-Agent: curl/8.6.0 +> Accept: */* +> +< HTTP/2 301 +< location: https://www.google.com/ +< content-type: text/html; charset=UTF-8 +< content-security-policy-report-only: object-src 'none';base-uri 'self';script-src 'nonce-7Oarq-3IfmUUGXNyKzGIBg' 'strict-dynamic' 'report-sample' 'unsafe-eval' 'unsafe-inline' https: http:;report-uri https://csp.withgoogle.com/csp/gws/other-hp +< date: Wed, 08 Jan 2025 04:56:07 GMT +< expires: Fri, 07 Feb 2025 04:56:07 GMT +< cache-control: public, max-age=2592000 +< server: gws +< content-length: 220 +< x-xss-protection: 0 +< x-frame-options: SAMEORIGIN +< alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000 +< + +301 Moved +

301 Moved

+The document has moved +here. + +* Connection #0 to host jpgmo101-cdn-route.couldflare-cdn.com left intact +iuu@iuudeMac-Studio ~ % diff --git a/global/var.go b/global/var.go new file mode 100644 index 0000000..e5f0899 --- /dev/null +++ b/global/var.go @@ -0,0 +1,7 @@ +package global + +import "httppp/common" + +var ( + Conf *common.Config +) diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..73d305b --- /dev/null +++ b/go.mod @@ -0,0 +1,32 @@ +module httppp + +go 1.23.3 + +require ( + github.com/fsnotify/fsnotify v1.8.0 + github.com/gookit/goutil v0.6.18 + github.com/spf13/viper v1.19.0 +) + +require ( + github.com/gookit/color v1.5.4 // indirect + github.com/hashicorp/hcl v1.0.0 // indirect + github.com/magiconair/properties v1.8.7 // indirect + github.com/mitchellh/mapstructure v1.5.0 // indirect + github.com/pelletier/go-toml/v2 v2.2.2 // indirect + github.com/sagikazarmark/locafero v0.4.0 // indirect + github.com/sagikazarmark/slog-shim v0.1.0 // indirect + github.com/sourcegraph/conc v0.3.0 // indirect + github.com/spf13/afero v1.11.0 // indirect + github.com/spf13/cast v1.6.0 // indirect + github.com/spf13/pflag v1.0.5 // indirect + github.com/subosito/gotenv v1.6.0 // indirect + github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect + go.uber.org/atomic v1.9.0 // indirect + go.uber.org/multierr v1.9.0 // indirect + golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect + golang.org/x/sys v0.28.0 // indirect + golang.org/x/text v0.21.0 // indirect + gopkg.in/ini.v1 v1.67.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..fa6af7e --- /dev/null +++ b/go.sum @@ -0,0 +1,77 @@ +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= +github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= +github.com/fsnotify/fsnotify v1.8.0 h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/8M= +github.com/fsnotify/fsnotify v1.8.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/gookit/color v1.5.4 h1:FZmqs7XOyGgCAxmWyPslpiok1k05wmY3SJTytgvYFs0= +github.com/gookit/color v1.5.4/go.mod h1:pZJOeOS8DM43rXbp4AZo1n9zCU2qjpcRko0b6/QJi9w= +github.com/gookit/goutil v0.6.18 h1:MUVj0G16flubWT8zYVicIuisUiHdgirPAkmnfD2kKgw= +github.com/gookit/goutil v0.6.18/go.mod h1:AY/5sAwKe7Xck+mEbuxj0n/bc3qwrGNe3Oeulln7zBA= +github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= +github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= +github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= +github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= +github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= +github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= +github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ= +github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4= +github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE= +github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ= +github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo= +github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0= +github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8= +github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY= +github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0= +github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/spf13/viper v1.19.0 h1:RWq5SEjt8o25SROyN3z2OrDB9l7RPd3lwTWU8EcEdcI= +github.com/spf13/viper v1.19.0/go.mod h1:GQUN9bilAbhU/jgc1bKs99f/suXKeUMct8Adx5+Ntkg= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= +github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= +github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no= +github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM= +go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= +go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI= +go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ= +golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g= +golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k= +golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= +golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= +golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= +gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/main.go b/main.go new file mode 100644 index 0000000..86963b7 --- /dev/null +++ b/main.go @@ -0,0 +1,28 @@ +package main + +import ( + "fmt" + "httppp/common/viper" + "httppp/core" + "httppp/global" +) + +func init() { + viper.InitViper() +} + +// 主程序,遍历多个代理地址 +func main() { + //dump.P(global.Conf) + for _, node := range global.Conf.Nodes { + for _, port := range node.Ports { + node.Port = port + success, message := core.CheckHttpsProxy(&node, global.Conf.TargetURL) + if success { + fmt.Printf("代理 %s 端口 %d 可用.\n", node.Addr, node.Port) + } else { + fmt.Printf("代理 %s 端口 %d 不可用: %s\n", node.Addr, node.Port, message) + } + } + } +}