Skip to content

Commit d66ecd3

Browse files
committed
Update documentation and code to follow coding convention
ProjectDiscovery code usually follows the rule "Words in names that are initialisms or acronyms (e.g., URL and NATO) should have the same case." (defined in https://google.github.io/styleguide/ go/decisions.html#initialisms) SOCKS5 is most commonly written in all-caps, just like HTTP. This commit updates the documentation and code to all use the same style when refering to SOCKS5 as well as adhere to the coding convention. This commit also updates some other style errors. Signed-off-by: MJ Kim <mjkim610@gmail.com>
1 parent 7c6bae9 commit d66ecd3

5 files changed

Lines changed: 52 additions & 52 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<a href="https://discord.gg/projectdiscovery">Join Discord</a>
2323
</p>
2424

25-
Swiss Army Knife Proxy for rapid deployments. Supports multiple operations such as request/response dump, filtering and manipulation via DSL language, upstream HTTP/Socks5 proxy.
25+
Swiss Army Knife Proxy for rapid deployments. Supports multiple operations such as request/response dump, filtering and manipulation via DSL language, upstream HTTP/SOCKS5 proxy.
2626
Additionally, a replay utility allows to import the dumped traffic (request/responses with correct domain name) into BurpSuite or any other proxy by simply setting the upstream proxy to proxify.
2727

2828
# Features
@@ -60,7 +60,7 @@ proxify -h
6060
This will display help for the tool. Here are all the switches it supports.
6161

6262
```console
63-
Swiss Army Knife Proxy for rapid deployments. Supports multiple operations such as request/response dump,filtering and manipulation via DSL language, upstream HTTP/Socks5 proxy
63+
Swiss Army Knife Proxy for rapid deployments. Supports multiple operations such as request/response dump,filtering and manipulation via DSL language, upstream HTTP/SOCKS5 proxy
6464

6565
Usage:
6666
./proxify [flags]

internal/runner/options.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ type Options struct {
3737
Verbosity types.Verbosity
3838
Version bool
3939
ListenAddrHTTP string
40-
ListenAddrSocks5 string
40+
ListenAddrSOCKS5 string
4141
ListenDNSAddr string
4242
DNSMapping string // DNSMapping contains user provided hosts
4343
DNSFallbackResolver string // Listen DNS Ip and port (ip:port)
@@ -47,7 +47,7 @@ type Options struct {
4747
ResponseDSL goflags.StringSlice // Response Filter DSL
4848
ResponseMatchReplaceDSL goflags.StringSlice // Request Match-Replace DSL
4949
UpstreamHTTPProxies goflags.StringSlice // Upstream HTTP comma separated Proxies (e.g. http://proxyip:proxyport)
50-
UpstreamSocks5Proxies goflags.StringSlice // Upstream SOCKS5 comma separated Proxies (e.g. socks5://proxyip:proxyport)
50+
UpstreamSOCKS5Proxies goflags.StringSlice // Upstream SOCKS5 comma separated Proxies (e.g. socks5://proxyip:proxyport)
5151
UpstreamProxyRequestsNumber int // Number of requests before switching upstream proxy
5252
DumpRequest bool // Dump requests in separate files
5353
DumpResponse bool // Dump responses in separate files
@@ -71,7 +71,7 @@ func ParseOptions() (*Options, error) {
7171
options := &Options{}
7272

7373
flagSet := goflags.NewFlagSet()
74-
flagSet.SetDescription(`Swiss Army Knife Proxy for rapid deployments. Supports multiple operations such as request/response dump,filtering and manipulation via DSL language, upstream HTTP/Socks5 proxy`)
74+
flagSet.SetDescription(`Swiss Army Knife Proxy for rapid deployments. Supports multiple operations such as request/response dump,filtering and manipulation via DSL language, upstream HTTP/SOCKS5 proxy`)
7575

7676
flagSet.CreateGroup("output", "Output",
7777
// Todo: flagSet.BoolVar(&options.Dump, "dump", true, "Dump HTTP requests/response to output file"),
@@ -98,15 +98,15 @@ func ParseOptions() (*Options, error) {
9898

9999
flagSet.CreateGroup("network", "Network",
100100
flagSet.StringVarP(&options.ListenAddrHTTP, "http-addr", "ha", "127.0.0.1:8888", "Listening HTTP IP and Port address (ip:port)"),
101-
flagSet.StringVarP(&options.ListenAddrSocks5, "socks-addr", "sa", "127.0.0.1:10080", "Listening SOCKS IP and Port address (ip:port)"),
101+
flagSet.StringVarP(&options.ListenAddrSOCKS5, "socks-addr", "sa", "127.0.0.1:10080", "Listening SOCKS IP and Port address (ip:port)"),
102102
flagSet.StringVarP(&options.ListenDNSAddr, "dns-addr", "da", "", "Listening DNS IP and Port address (ip:port)"),
103103
flagSet.StringVarP(&options.DNSMapping, "dns-mapping", "dm", "", "Domain to IP DNS mapping (eg domain:ip,domain:ip,..)"),
104104
flagSet.StringVarP(&options.DNSFallbackResolver, "resolver", "r", "", "Custom DNS resolvers to use (ip:port)"),
105105
)
106106

107107
flagSet.CreateGroup("proxy", "Proxy",
108108
flagSet.StringSliceVarP(&options.UpstreamHTTPProxies, "http-proxy", "hp", nil, "Upstream HTTP Proxies (eg http://proxy-ip:proxy-port)", goflags.NormalizedStringSliceOptions),
109-
flagSet.StringSliceVarP(&options.UpstreamSocks5Proxies, "socks5-proxy", "sp", nil, "Upstream SOCKS5 Proxies (eg socks5://proxy-ip:proxy-port)", goflags.NormalizedStringSliceOptions),
109+
flagSet.StringSliceVarP(&options.UpstreamSOCKS5Proxies, "socks5-proxy", "sp", nil, "Upstream SOCKS5 Proxies (eg socks5://proxy-ip:proxy-port)", goflags.NormalizedStringSliceOptions),
110110
flagSet.IntVar(&options.UpstreamProxyRequestsNumber, "c", 1, "Number of requests before switching to the next upstream proxy"),
111111
)
112112

internal/runner/runner.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ func NewRunner(options *Options) (*Runner, error) {
3737
CertCacheSize: options.CertCacheSize,
3838
Verbosity: options.Verbosity,
3939
ListenAddrHTTP: options.ListenAddrHTTP,
40-
ListenAddrSocks5: options.ListenAddrSocks5,
40+
ListenAddrSOCKS5: options.ListenAddrSOCKS5,
4141
OutputFile: options.OutputFile,
4242
OutputFormat: options.OutputFormat,
4343
OutputDirectory: options.OutputDirectory,
4444
OutputHar: options.OutputHar,
4545
RequestDSL: options.RequestDSL,
4646
ResponseDSL: options.ResponseDSL,
4747
UpstreamHTTPProxies: options.UpstreamHTTPProxies,
48-
UpstreamSock5Proxies: options.UpstreamSocks5Proxies,
48+
UpstreamSOCKS5Proxies: options.UpstreamSOCKS5Proxies,
4949
ListenDNSAddr: options.ListenDNSAddr,
5050
DNSMapping: options.DNSMapping,
5151
DNSFallbackResolver: options.DNSFallbackResolver,
@@ -91,8 +91,8 @@ func (r *Runner) Run() error {
9191
if r.options.ListenAddrHTTP != "" {
9292
gologger.Info().Msgf("HTTP Proxy Listening on %s\n", r.options.ListenAddrHTTP)
9393
}
94-
if r.options.ListenAddrSocks5 != "" {
95-
gologger.Info().Msgf("Socks5 Proxy Listening on %s\n", r.options.ListenAddrSocks5)
94+
if r.options.ListenAddrSOCKS5 != "" {
95+
gologger.Info().Msgf("SOCKS5 Proxy Listening on %s\n", r.options.ListenAddrSOCKS5)
9696
}
9797

9898
if r.options.OutputFile != "" {
@@ -112,8 +112,8 @@ func (r *Runner) Run() error {
112112

113113
if len(r.options.UpstreamHTTPProxies) > 0 {
114114
gologger.Info().Msgf("Using upstream HTTP proxies: %s\n", r.options.UpstreamHTTPProxies)
115-
} else if len(r.options.UpstreamSocks5Proxies) > 0 {
116-
gologger.Info().Msgf("Using upstream SOCKS5 proxies: %s\n", r.options.UpstreamSocks5Proxies)
115+
} else if len(r.options.UpstreamSOCKS5Proxies) > 0 {
116+
gologger.Info().Msgf("Using upstream SOCKS5 proxies: %s\n", r.options.UpstreamSOCKS5Proxies)
117117
}
118118

119119
if r.options.DNSMapping != "" {

proxy.go

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ type Options struct {
5252
CertCacheSize int
5353
Directory string
5454
ListenAddrHTTP string
55-
ListenAddrSocks5 string
55+
ListenAddrSOCKS5 string
5656
OutputDirectory string
5757
OutputFile string
5858
OutputFormat string
5959
OutputHar string
6060
RequestDSL []string
6161
ResponseDSL []string
6262
UpstreamHTTPProxies []string
63-
UpstreamSock5Proxies []string
63+
UpstreamSOCKS5Proxies []string
6464
ListenDNSAddr string
6565
DNSMapping string
6666
DNSFallbackResolver string
@@ -81,12 +81,12 @@ type Proxy struct {
8181
options *Options
8282
logger *logger.Logger
8383
httpProxy *martian.Proxy
84-
socks5proxy *socks5.Server
85-
socks5tunnel *superproxy.SuperProxy
84+
socks5Proxy *socks5.Server
85+
socks5Tunnel *superproxy.SuperProxy
8686
bufioPool *bufiopool.Pool
87-
tinydns *tinydns.TinyDNS
88-
rbhttp *rbtransport.RoundTransport
89-
rbsocks5 *rbtransport.RoundTransport
87+
tinyDNS *tinydns.TinyDNS
88+
rbHTTP *rbtransport.RoundTransport
89+
rbSOCKS5 *rbtransport.RoundTransport
9090
proxifyMux *http.ServeMux // serve banner page and static files
9191
listenAddr string
9292
}
@@ -117,27 +117,27 @@ func NewProxy(options *Options) (*Proxy, error) {
117117
Kafka: options.Kafka,
118118
})
119119

120-
var tdns *tinydns.TinyDNS
120+
var tDNS *tinydns.TinyDNS
121121

122122
fastdialerOptions := fastdialer.DefaultOptions
123123
fastdialerOptions.EnableFallback = true
124124
fastdialerOptions.Deny = options.Deny
125125
fastdialerOptions.Allow = options.Allow
126126
if options.ListenDNSAddr != "" {
127-
dnsmapping := make(map[string]*tinydns.DnsRecord)
127+
dnsMapping := make(map[string]*tinydns.DnsRecord)
128128
for _, record := range strings.Split(options.DNSMapping, ",") {
129129
data := strings.Split(record, ":")
130130
if len(data) != 2 {
131131
continue
132132
}
133-
dnsmapping[data[0]] = &tinydns.DnsRecord{A: []string{data[1]}}
133+
dnsMapping[data[0]] = &tinydns.DnsRecord{A: []string{data[1]}}
134134
}
135135
var err error
136-
tdns, err = tinydns.New(&tinydns.Options{
136+
tDNS, err = tinydns.New(&tinydns.Options{
137137
ListenAddress: options.ListenDNSAddr,
138138
Net: "udp",
139139
UpstreamServers: []string{options.DNSFallbackResolver},
140-
DnsRecords: dnsmapping,
140+
DnsRecords: dnsMapping,
141141
})
142142
if err != nil {
143143
return nil, err
@@ -149,20 +149,20 @@ func NewProxy(options *Options) (*Proxy, error) {
149149
return nil, err
150150
}
151151

152-
var rbhttp, rbsocks5 *rbtransport.RoundTransport
152+
var rbHTTP, rbSOCKS5 *rbtransport.RoundTransport
153153
if len(options.UpstreamHTTPProxies) > 0 {
154-
rbhttp, err = rbtransport.NewWithOptions(options.UpstreamProxyRequestsNumber, options.UpstreamHTTPProxies...)
154+
rbHTTP, err = rbtransport.NewWithOptions(options.UpstreamProxyRequestsNumber, options.UpstreamHTTPProxies...)
155155
if err != nil {
156156
return nil, err
157157
}
158158
}
159-
if len(options.UpstreamSock5Proxies) > 0 {
160-
rbsocks5, err = rbtransport.NewWithOptions(options.UpstreamProxyRequestsNumber, options.UpstreamSock5Proxies...)
159+
if len(options.UpstreamSOCKS5Proxies) > 0 {
160+
rbSOCKS5, err = rbtransport.NewWithOptions(options.UpstreamProxyRequestsNumber, options.UpstreamSOCKS5Proxies...)
161161
if err != nil {
162162
return nil, err
163163
}
164164
}
165-
pmux, err := getProxifyServerMux()
165+
pMux, err := getProxifyServerMux()
166166
if err != nil {
167167
return nil, err
168168
}
@@ -171,31 +171,31 @@ func NewProxy(options *Options) (*Proxy, error) {
171171
logger: logger,
172172
options: options,
173173
Dialer: dialer,
174-
tinydns: tdns,
175-
rbhttp: rbhttp,
176-
rbsocks5: rbsocks5,
177-
proxifyMux: pmux,
174+
tinyDNS: tDNS,
175+
rbHTTP: rbHTTP,
176+
rbSOCKS5: rbSOCKS5,
177+
proxifyMux: pMux,
178178
}
179179

180180
if err := proxy.setupHTTPProxy(); err != nil {
181181
return nil, err
182182
}
183183

184-
var socks5proxy *socks5.Server
185-
if options.ListenAddrSocks5 != "" {
184+
var socks5Proxy *socks5.Server
185+
if options.ListenAddrSOCKS5 != "" {
186186
if options.Verbosity <= types.VerbositySilent {
187-
socks5proxy = socks5.NewServer(
187+
socks5Proxy = socks5.NewServer(
188188
socks5.WithLogger(socks5.NewLogger(log.New(io.Discard, "", log.Ltime|log.Lshortfile))),
189189
socks5.WithDial(proxy.httpTunnelDialer),
190190
)
191191
} else {
192-
socks5proxy = socks5.NewServer(
192+
socks5Proxy = socks5.NewServer(
193193
socks5.WithDial(proxy.httpTunnelDialer),
194194
)
195195
}
196196
}
197197

198-
proxy.socks5proxy = socks5proxy
198+
proxy.socks5Proxy = socks5Proxy
199199

200200
return proxy, nil
201201
}
@@ -404,11 +404,11 @@ func (p *Proxy) MatchReplaceResponse(resp *http.Response) error {
404404
func (p *Proxy) Run() error {
405405
var wg sync.WaitGroup
406406

407-
if p.tinydns != nil {
407+
if p.tinyDNS != nil {
408408
wg.Add(1)
409409
go func() {
410410
defer wg.Done()
411-
if err := p.tinydns.Run(); err != nil {
411+
if err := p.tinyDNS.Run(); err != nil {
412412
gologger.Warning().Msgf("Could not start dns server: %s\n", err)
413413
}
414414
}()
@@ -437,7 +437,7 @@ func (p *Proxy) Run() error {
437437
}
438438

439439
// socks5 proxy
440-
if p.socks5proxy != nil {
440+
if p.socks5Proxy != nil {
441441
if p.httpProxy != nil {
442442
httpProxyIP, httpProxyPort, err := net.SplitHostPort(p.options.ListenAddrHTTP)
443443
if err != nil {
@@ -447,7 +447,7 @@ func (p *Proxy) Run() error {
447447
if err != nil {
448448
return err
449449
}
450-
p.socks5tunnel, err = superproxy.NewSuperProxy(httpProxyIP, uint16(httpProxyPortUint), superproxy.ProxyTypeHTTP, "", "", "")
450+
p.socks5Tunnel, err = superproxy.NewSuperProxy(httpProxyIP, uint16(httpProxyPortUint), superproxy.ProxyTypeHTTP, "", "", "")
451451
if err != nil {
452452
return err
453453
}
@@ -458,7 +458,7 @@ func (p *Proxy) Run() error {
458458
go func() {
459459
defer wg.Done()
460460

461-
gologger.Fatal().Msgf("%v", p.socks5proxy.ListenAndServe("tcp", p.options.ListenAddrSocks5))
461+
gologger.Fatal().Msgf("%v", p.socks5Proxy.ListenAndServe("tcp", p.options.ListenAddrSOCKS5))
462462
}()
463463
}
464464

@@ -504,21 +504,21 @@ func (p *Proxy) getRoundTripper() (http.RoundTripper, error) {
504504

505505
if len(p.options.UpstreamHTTPProxies) > 0 {
506506
roundtrip = &http.Transport{Proxy: func(req *http.Request) (*url.URL, error) {
507-
return url.Parse(p.rbhttp.Next())
507+
return url.Parse(p.rbHTTP.Next())
508508
}, TLSClientConfig: &tls.Config{InsecureSkipVerify: true}}
509-
} else if len(p.options.UpstreamSock5Proxies) > 0 {
509+
} else if len(p.options.UpstreamSOCKS5Proxies) > 0 {
510510
// for each socks5 proxy create a dialer
511511
socks5Dialers := make(map[string]proxy.Dialer)
512-
for _, socks5proxy := range p.options.UpstreamSock5Proxies {
513-
dialer, err := proxy.SOCKS5("tcp", socks5proxy, nil, proxy.Direct)
512+
for _, socks5Proxy := range p.options.UpstreamSOCKS5Proxies {
513+
dialer, err := proxy.SOCKS5("tcp", socks5Proxy, nil, proxy.Direct)
514514
if err != nil {
515515
return nil, err
516516
}
517-
socks5Dialers[socks5proxy] = dialer
517+
socks5Dialers[socks5Proxy] = dialer
518518
}
519519
roundtrip = &http.Transport{Dial: func(network, addr string) (net.Conn, error) {
520520
// lookup next dialer
521-
socks5Proxy := p.rbsocks5.Next()
521+
socks5Proxy := p.rbSOCKS5.Next()
522522
socks5Dialer := socks5Dialers[socks5Proxy]
523523
// use it to perform the request
524524
return socks5Dialer.Dial(network, addr)
@@ -528,7 +528,7 @@ func (p *Proxy) getRoundTripper() (http.RoundTripper, error) {
528528
}
529529

530530
func (p *Proxy) httpTunnelDialer(ctx context.Context, network, addr string) (net.Conn, error) {
531-
return p.socks5tunnel.MakeTunnel(nil, nil, p.bufioPool, addr)
531+
return p.socks5Tunnel.MakeTunnel(nil, nil, p.bufioPool, addr)
532532
}
533533

534534
func (p *Proxy) hijackNServe(req *http.Request, ctx *martian.Context) error {

static/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@
162162
<div class="center-text">
163163
Swiss Army Knife Proxy for rapid deployments. <br>
164164
Supports multiple operations such as request/response dump,<br>
165-
filtering and manipulation via DSL language, upstream HTTP/Socks5 proxy.<br>
165+
filtering and manipulation via DSL language, upstream HTTP/SOCKS5 proxy.<br>
166166
Additionally, a replay utility allows to import the dumped traffic <br>
167167
(request/responses with correct domain name) into BurpSuite or <br>
168168
any other proxy by simply setting the upstream proxy to proxify.

0 commit comments

Comments
 (0)