Skip to content

Commit c2e8ddf

Browse files
added basic duplication check for proxy in config
1 parent f4318aa commit c2e8ddf

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

gohpts.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,20 @@ func New(conf *Config) *proxyApp {
621621
if len(p.proxychain.ProxyList) == 0 {
622622
p.logger.Fatal().Msg("[proxychain config] Proxy list is empty")
623623
}
624+
seen := make(map[string]struct{})
625+
for _, pr := range p.proxychain.ProxyList {
626+
var addr string
627+
if strings.HasPrefix(pr.Address, ":") {
628+
addr = fmt.Sprintf("127.0.0.1%s", pr.Address)
629+
} else {
630+
addr = pr.Address
631+
}
632+
if _, ok := seen[addr]; !ok {
633+
seen[addr] = struct{}{}
634+
} else {
635+
p.logger.Fatal().Msgf("[proxychain config] Duplicate entry `%s`", addr)
636+
}
637+
}
624638
chainType := p.proxychain.Chain.Type
625639
if !slices.Contains(supportedChainTypes, chainType) {
626640
p.logger.Fatal().Msgf("[proxychain config] Chain type `%s` is not supported", chainType)

0 commit comments

Comments
 (0)