44 "flag"
55 "fmt"
66 "log"
7+ "math"
78 "net"
89 "net/http"
910 "net/http/pprof"
@@ -94,7 +95,8 @@ func main() {
9495 defer server .Close ()
9596 if * flLimits != "" {
9697 n := daze .SizeParser (* flLimits )
97- server .Limits = rate .NewLimiter (rate .Limit (n ), 1024 * 1024 )
98+ doa .Doa (n <= math .MaxInt )
99+ server .Limits = rate .NewLimiter (rate .Limit (n ), int (n ))
98100 }
99101 doa .Nil (server .Run ())
100102 case "baboon" :
@@ -105,23 +107,26 @@ func main() {
105107 }
106108 if * flLimits != "" {
107109 n := daze .SizeParser (* flLimits )
108- server .Limits = rate .NewLimiter (rate .Limit (n ), 1024 * 1024 )
110+ doa .Doa (n <= math .MaxInt )
111+ server .Limits = rate .NewLimiter (rate .Limit (n ), int (n ))
109112 }
110113 doa .Nil (server .Run ())
111114 case "czar" :
112115 server := czar .NewServer (* flListen , * flCipher )
113116 defer server .Close ()
114117 if * flLimits != "" {
115118 n := daze .SizeParser (* flLimits )
116- server .Limits = rate .NewLimiter (rate .Limit (n ), 1024 * 1024 )
119+ doa .Doa (n <= math .MaxInt )
120+ server .Limits = rate .NewLimiter (rate .Limit (n ), int (n ))
117121 }
118122 doa .Nil (server .Run ())
119123 case "dahlia" :
120124 server := dahlia .NewServer (* flListen , * flExtend , * flCipher )
121125 defer server .Close ()
122126 if * flLimits != "" {
123127 n := daze .SizeParser (* flLimits )
124- server .Limits = rate .NewLimiter (rate .Limit (n ), 1024 * 1024 )
128+ doa .Doa (n <= math .MaxInt )
129+ server .Limits = rate .NewLimiter (rate .Limit (n ), int (n ))
125130 }
126131 doa .Nil (server .Run ())
127132 }
@@ -140,6 +145,7 @@ func main() {
140145 flFilter = flag .String ("f" , "rule" , "filter {rule, remote, locale}" )
141146 flGpprof = flag .String ("g" , "" , "specify an address to enable net/http/pprof" )
142147 flCipher = flag .String ("k" , "daze" , "password, should be same with the one specified by server" )
148+ flLimits = flag .String ("b" , "" , "set the maximum bandwidth in bytes per second, for example, 128k or 1.5m" )
143149 flListen = flag .String ("l" , "127.0.0.1:1080" , "listen address" )
144150 flProtoc = flag .String ("p" , "ashe" , "protocol {ashe, baboon, czar, dahlia}" )
145151 flRulels = flag .String ("r" , filepath .Join (resExec , Conf .PathRule ), "rule path" )
@@ -163,6 +169,11 @@ func main() {
163169 switch * flProtoc {
164170 case "ashe" :
165171 client := ashe .NewClient (* flServer , * flCipher )
172+ if * flLimits != "" {
173+ n := daze .SizeParser (* flLimits )
174+ doa .Doa (n <= math .MaxInt )
175+ client .Limits = rate .NewLimiter (rate .Limit (n ), int (n ))
176+ }
166177 locale := daze .NewLocale (* flListen , daze .NewAimbot (client , & daze.AimbotOption {
167178 Type : * flFilter ,
168179 Rule : * flRulels ,
@@ -172,6 +183,11 @@ func main() {
172183 doa .Nil (locale .Run ())
173184 case "baboon" :
174185 client := baboon .NewClient (* flServer , * flCipher )
186+ if * flLimits != "" {
187+ n := daze .SizeParser (* flLimits )
188+ doa .Doa (n <= math .MaxInt )
189+ client .Limits = rate .NewLimiter (rate .Limit (n ), int (n ))
190+ }
175191 locale := daze .NewLocale (* flListen , daze .NewAimbot (client , & daze.AimbotOption {
176192 Type : * flFilter ,
177193 Rule : * flRulels ,
@@ -182,6 +198,11 @@ func main() {
182198 case "czar" :
183199 client := czar .NewClient (* flServer , * flCipher )
184200 defer client .Close ()
201+ if * flLimits != "" {
202+ n := daze .SizeParser (* flLimits )
203+ doa .Doa (n <= math .MaxInt )
204+ client .Limits = rate .NewLimiter (rate .Limit (n ), int (n ))
205+ }
185206 locale := daze .NewLocale (* flListen , daze .NewAimbot (client , & daze.AimbotOption {
186207 Type : * flFilter ,
187208 Rule : * flRulels ,
@@ -192,6 +213,11 @@ func main() {
192213 case "dahlia" :
193214 client := dahlia .NewClient (* flListen , * flServer , * flCipher )
194215 defer client .Close ()
216+ if * flLimits != "" {
217+ n := daze .SizeParser (* flLimits )
218+ doa .Doa (n <= math .MaxInt )
219+ client .Limits = rate .NewLimiter (rate .Limit (n ), int (n ))
220+ }
195221 doa .Nil (client .Run ())
196222 }
197223 if * flGpprof != "" {
0 commit comments