Skip to content

Commit 32e29b5

Browse files
authored
Merge pull request #277 from projectdiscovery/feat-jarm-proxy
adding proxy support to jarm
2 parents c3f3fcc + 9fe48df commit 32e29b5

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

dsl.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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"
@@ -84,6 +86,17 @@ var (
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+
87100
var PrintDebugCallback func(args ...interface{}) error
88101

89102
var 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

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ require (
1616
github.com/projectdiscovery/gologger v1.1.59
1717
github.com/projectdiscovery/gostruct v0.0.2
1818
github.com/projectdiscovery/mapcidr v1.1.96
19-
github.com/projectdiscovery/utils v0.6.1-0.20251028094546-b46e3278c921
19+
github.com/projectdiscovery/utils v0.6.1-0.20251030144701-ce5c4b44e1e6
2020
github.com/sashabaranov/go-openai v1.37.0
2121
github.com/spaolacci/murmur3 v1.1.0
2222
github.com/stretchr/testify v1.11.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ github.com/projectdiscovery/gostruct v0.0.2 h1:s8gP8ApugGM4go1pA+sVlPDXaWqNP5BBD
155155
github.com/projectdiscovery/gostruct v0.0.2/go.mod h1:H86peL4HKwMXcQQtEa6lmC8FuD9XFt6gkNR0B/Mu5PE=
156156
github.com/projectdiscovery/mapcidr v1.1.96 h1:MHDKi7rxrTVYsQWzLxfYcop/EPYa3ldUjB+oMbmuLBI=
157157
github.com/projectdiscovery/mapcidr v1.1.96/go.mod h1:be4kT3vBPxsJeeu3e50/0ZuhhfPMNjxOCCEeD4bryqE=
158-
github.com/projectdiscovery/utils v0.6.1-0.20251028094546-b46e3278c921 h1:mtJobYueXn1hAh8ZI67aZPYjoELNFmGZfyqS0eYOWnM=
159-
github.com/projectdiscovery/utils v0.6.1-0.20251028094546-b46e3278c921/go.mod h1:6XB0NE4/B2s72vfgrb2HnTpz1Z+Nr2dZYRUieNgDFRk=
158+
github.com/projectdiscovery/utils v0.6.1-0.20251030144701-ce5c4b44e1e6 h1:nvszzYNHYnc8X+Dm68zMuYNNesZJp7QWfe8EEyL4azc=
159+
github.com/projectdiscovery/utils v0.6.1-0.20251030144701-ce5c4b44e1e6/go.mod h1:GOjhpPLmpMHcYJKI0vhjvjdczMQf3jWdUgYiBeKkwVk=
160160
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
161161
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
162162
github.com/rwcarlsen/goexif v0.0.0-20190401172101-9e8deecbddbd/go.mod h1:hPqNNc0+uJM6H+SuU8sEs5K5IQeKccPqeSjfgcKGgPk=

0 commit comments

Comments
 (0)