优化 IP最后一段完全随机

This commit is contained in:
xiu2
2020-11-10 19:22:55 +08:00
parent 8c0e8732cc
commit 3de6b38e00
4 changed files with 32 additions and 15 deletions

View File

@@ -21,8 +21,9 @@ func loadFirstIPOfRangeFromFile(ipFile string) []net.IPAddr {
if err != nil {
log.Fatal(err)
}
firstIP[15] = ipEndWith
for IPRange.Contains(firstIP) {
randipEndWith() // 随机 IP 的最后一段
firstIP[15] = ipEndWith
firstIPCopy := make([]byte, len(firstIP))
copy(firstIPCopy, firstIP)
firstIPs = append(firstIPs, net.IPAddr{IP: firstIPCopy})