Skip to content

Commit 1db193b

Browse files
committed
random starting index for RoundRobin
1 parent d0bafcb commit 1db193b

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

chain/chain.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package chain
33
import (
44
"context"
55
"fmt"
6+
"math/rand"
67
"strings"
78

89
"github.com/wzshiming/bridge"
@@ -80,7 +81,7 @@ func (b *BridgeChain) Dial(ctx context.Context, dialer bridge.Dialer, addresses
8081
return b.dialOne(ctx, dialer, addresses[0])
8182
}
8283
plugins := []schedialer.Plugin{
83-
roundrobin.NewRoundRobin(100),
84+
roundrobin.NewRoundRobinWithIndex(100, rand.Uint64()%uint64(len(addresses))),
8485
}
8586
if probeUrl != "" {
8687
plugins = append(plugins, probe.NewProbe(100, probeUrl))

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ require (
1414
github.com/wzshiming/httpproxy v0.5.5
1515
github.com/wzshiming/notify v0.1.1
1616
github.com/wzshiming/permuteproxy v0.0.2
17-
github.com/wzshiming/schedialer v0.6.0
17+
github.com/wzshiming/schedialer v0.6.1
1818
github.com/wzshiming/shadowsocks v0.4.0
1919
github.com/wzshiming/socks4 v0.3.2
2020
github.com/wzshiming/socks5 v0.5.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ github.com/wzshiming/notify v0.1.1 h1:rJXoszrkNglhCVyn/IfW500f5cW03q1q7YzL8hsLch
2626
github.com/wzshiming/notify v0.1.1/go.mod h1:SFhsQKZJznzsDcj/Qfo9A65k5IRcpUrpgbLRzZEa/DI=
2727
github.com/wzshiming/permuteproxy v0.0.2 h1:svedMueotlxJk9oJfA0gs8WzRYOdgd0DER9XvKpjwlY=
2828
github.com/wzshiming/permuteproxy v0.0.2/go.mod h1:Ny08A1JbuljB8FeJAOiB7dfvRGCVD8PB9hwrALIvYI8=
29-
github.com/wzshiming/schedialer v0.6.0 h1:U3plhiljDYO0q+3nnK9ntcfSl46HSDauqe2UBm35X7Y=
30-
github.com/wzshiming/schedialer v0.6.0/go.mod h1:TvVxg4QZIBTJzRfmL/G7g6CzynFQKPmtXtSeJ2c4Lus=
29+
github.com/wzshiming/schedialer v0.6.1 h1:4VwtIjVF3uMoWqjbyw3oqYi7WGOEYvDu3L9OYT8sbGY=
30+
github.com/wzshiming/schedialer v0.6.1/go.mod h1:TvVxg4QZIBTJzRfmL/G7g6CzynFQKPmtXtSeJ2c4Lus=
3131
github.com/wzshiming/shadowsocks v0.4.0 h1:Yi+4J/DK15qdKlssNEMoWjtmc8wyY8ByIBbC5Ft29bQ=
3232
github.com/wzshiming/shadowsocks v0.4.0/go.mod h1:xYRRSKR+hTihSDUOE+evavx0wkLVODTWVXEcz5vosoE=
3333
github.com/wzshiming/socks4 v0.3.2 h1:w87nwfgRWteVwIH39nqTur8c+2dcODeLgLrWspcUkSc=

0 commit comments

Comments
 (0)