fix typo in main() and add random ip generation
This commit is contained in:
28
proxychain/requestmodifers/bot/bot_test.go
Normal file
28
proxychain/requestmodifers/bot/bot_test.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package bot
|
||||
|
||||
import (
|
||||
"net"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestRandomIPFromSubnet(t *testing.T) {
|
||||
subnets := []string{"34.100.182.96/28", "207.46.13.0/24", "2001:4860:4801:10::/64", "2001:4860:4801:c::/64"}
|
||||
|
||||
for _, subnet := range subnets {
|
||||
t.Run(subnet, func(t *testing.T) {
|
||||
_, ipnet, err := net.ParseCIDR(subnet)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
ip, err := randomIPFromSubnet(subnet)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if !ipnet.Contains(ip) {
|
||||
t.Fail()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user