@@ -23,15 +23,15 @@ func execCommandContext(ctx context.Context, name string, args ...string) *exec.
2323}
2424
2525// DnsttCheckBin is like DnsttCheck but uses an explicit binary path.
26- func DnsttCheckBin (bin , domain , pubkey , testURL string , ports chan int ) CheckFunc {
27- return dnsttCheck (bin , domain , pubkey , testURL , ports )
26+ func DnsttCheckBin (bin , domain , pubkey , testURL , proxyAuth string , ports chan int ) CheckFunc {
27+ return dnsttCheck (bin , domain , pubkey , testURL , proxyAuth , ports )
2828}
2929
3030func DnsttCheck (domain , pubkey , testURL string , ports chan int ) CheckFunc {
31- return dnsttCheck ("dnstt-client" , domain , pubkey , testURL , ports )
31+ return dnsttCheck ("dnstt-client" , domain , pubkey , testURL , "" , ports )
3232}
3333
34- func dnsttCheck (bin , domain , pubkey , testURL string , ports chan int ) CheckFunc {
34+ func dnsttCheck (bin , domain , pubkey , testURL , proxyAuth string , ports chan int ) CheckFunc {
3535 return func (ip string , timeout time.Duration ) (bool , Metrics ) {
3636 ctx , cancel := context .WithTimeout (context .Background (), timeout )
3737 defer cancel ()
@@ -74,7 +74,7 @@ func dnsttCheck(bin, domain, pubkey, testURL string, ports chan int) CheckFunc {
7474 return false , nil
7575 }
7676
77- if ! testSOCKS (ctx , port , testURL ) {
77+ if ! testSOCKS (ctx , port , testURL , proxyAuth ) {
7878 return false , nil
7979 }
8080 ms := roundMs (float64 (time .Since (start ).Microseconds ()) / 1000.0 )
@@ -83,15 +83,15 @@ func dnsttCheck(bin, domain, pubkey, testURL string, ports chan int) CheckFunc {
8383}
8484
8585// SlipstreamCheckBin is like SlipstreamCheck but uses an explicit binary path.
86- func SlipstreamCheckBin (bin , domain , certPath , testURL string , ports chan int ) CheckFunc {
87- return slipstreamCheck (bin , domain , certPath , testURL , ports )
86+ func SlipstreamCheckBin (bin , domain , certPath , testURL , proxyAuth string , ports chan int ) CheckFunc {
87+ return slipstreamCheck (bin , domain , certPath , testURL , proxyAuth , ports )
8888}
8989
9090func SlipstreamCheck (domain , certPath , testURL string , ports chan int ) CheckFunc {
91- return slipstreamCheck ("slipstream-client" , domain , certPath , testURL , ports )
91+ return slipstreamCheck ("slipstream-client" , domain , certPath , testURL , "" , ports )
9292}
9393
94- func slipstreamCheck (bin , domain , certPath , testURL string , ports chan int ) CheckFunc {
94+ func slipstreamCheck (bin , domain , certPath , testURL , proxyAuth string , ports chan int ) CheckFunc {
9595 return func (ip string , timeout time.Duration ) (bool , Metrics ) {
9696 ctx , cancel := context .WithTimeout (context .Background (), timeout )
9797 defer cancel ()
@@ -137,7 +137,7 @@ func slipstreamCheck(bin, domain, certPath, testURL string, ports chan int) Chec
137137 return false , nil
138138 }
139139
140- if ! testSOCKS (ctx , port , testURL ) {
140+ if ! testSOCKS (ctx , port , testURL , proxyAuth ) {
141141 return false , nil
142142 }
143143 ms := roundMs (float64 (time .Since (start ).Microseconds ()) / 1000.0 )
@@ -152,11 +152,16 @@ func nullDevice() string {
152152 return "/dev/null"
153153}
154154
155- func testSOCKS (ctx context.Context , port int , testURL string ) bool {
156- cmd := execCommandContext ( ctx , "curl" ,
155+ func testSOCKS (ctx context.Context , port int , testURL , proxyAuth string ) bool {
156+ args := [] string {
157157 "-x" , fmt .Sprintf ("socks5h://127.0.0.1:%d" , port ),
158158 "-s" , "-o" , nullDevice (), "-w" , "%{http_code}" ,
159- testURL )
159+ }
160+ if proxyAuth != "" {
161+ args = append (args , "--proxy-user" , proxyAuth )
162+ }
163+ args = append (args , testURL )
164+ cmd := execCommandContext (ctx , "curl" , args ... )
160165 output , err := cmd .Output ()
161166 if err != nil {
162167 return false
0 commit comments