Skip to content

Commit e068c73

Browse files
small refactoting ifelse -> switchcase, added sanity check for default case
1 parent 0a492d9 commit e068c73

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

gohpts.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,11 +226,14 @@ func (p *proxyApp) getSocks() (proxy.Dialer, *http.Client, error) {
226226
chainLength = p.proxychain.Chain.Length
227227
}
228228
copyProxyList := make([]proxyEntry, 0, len(p.availProxyList))
229-
if chainType == "random" {
229+
switch chainType {
230+
case "strict", "dynamic":
231+
copyProxyList = p.availProxyList
232+
case "random":
230233
copy(copyProxyList, p.availProxyList)
231234
shuffle(copyProxyList)
232235
copyProxyList = copyProxyList[:chainLength]
233-
} else if chainType == "round_robin" {
236+
case "round_robin":
234237
var start uint32
235238
for {
236239
start = atomic.LoadUint32(&p.rrIndex)
@@ -248,8 +251,8 @@ func (p *proxyApp) getSocks() (proxy.Dialer, *http.Client, error) {
248251
idx := (startIdx + i) % len(p.availProxyList)
249252
copyProxyList = append(copyProxyList, p.availProxyList[idx])
250253
}
251-
} else {
252-
copyProxyList = p.availProxyList
254+
default:
255+
p.logger.Fatal().Msg("Unreachable")
253256
}
254257
if len(copyProxyList) == 0 {
255258
p.logger.Error().Msgf("[%s] No SOCKS5 Proxy available", chainType)

0 commit comments

Comments
 (0)