@@ -26,6 +26,7 @@ import (
2626 "io"
2727 "math"
2828 "net"
29+ "os"
2930 "reflect"
3031 "regexp"
3132 "sort"
@@ -48,6 +49,7 @@ import (
4849 "github.com/projectdiscovery/gologger"
4950 "github.com/projectdiscovery/gostruct"
5051 "github.com/projectdiscovery/mapcidr"
52+ "github.com/projectdiscovery/utils/conn/connpool"
5153 jarm "github.com/projectdiscovery/utils/crypto/jarm"
5254 "github.com/projectdiscovery/utils/errkit"
5355 hexutil "github.com/projectdiscovery/utils/hex"
8486 faker = gofakeit .New (0 )
8587)
8688
89+ // firstNonEmptyEnv returns the first non-empty environment variable value
90+ // from the provided list of keys (checked in order).
91+ func firstNonEmptyEnv (keys ... string ) string {
92+ for _ , key := range keys {
93+ if v := os .Getenv (key ); v != "" {
94+ return v
95+ }
96+ }
97+ return ""
98+ }
99+
87100var PrintDebugCallback func (args ... interface {}) error
88101
89102var functions []dslFunction
@@ -1447,6 +1460,15 @@ func init() {
14471460 if err != nil {
14481461 return nil , err
14491462 }
1463+ // pick the first available proxy from common env vars (case-insensitive)
1464+ proxy := firstNonEmptyEnv ("HTTP_PROXY" , "http_proxy" , "HTTPS_PROXY" , "https_proxy" )
1465+ if proxy != "" {
1466+ socks5Dialer , err := connpool .NewCreateSOCKS5Dialer (proxy )
1467+ if err != nil {
1468+ return nil , err
1469+ }
1470+ return jarm .HashWithDialer (socks5Dialer , hostname , port , 10 )
1471+ }
14501472 return jarm .HashWithDialer (nil , hostname , port , 10 )
14511473 }))
14521474
0 commit comments