Skip to content

Commit bae3e9b

Browse files
WillowSauceRWillowSauceR
authored andcommitted
fix getIpList()
1 parent 125260f commit bae3e9b

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

scan.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,12 @@ def getIpList(ip: str):
2727
if os.path.exists(TargetAddr):
2828
with open(TargetAddr, "r") as file:
2929
for ip in file.readlines():
30-
# ipList.append(ip.split(" | ")[2])
31-
ipList.append(ip[:-1])
30+
if "|" in ip:
31+
if ip.split(" | ")[2] not in ipList:
32+
ipList.append(ip.split(" | ")[2])
33+
else:
34+
if ip[:-1] not in ipList:
35+
ipList.append(ip[:-1])
3236
return ipList
3337
try:
3438
int(ip[-1])
@@ -97,7 +101,8 @@ def startThreads():
97101
# time.sleep(1)
98102
# while mp.active_children():
99103
# time.sleep(1)
100-
# mp.active_children()[0].terminate()
104+
mp.active_children()[0].terminate()
105+
time.sleep(1)
101106
log(f"BE Server Count: {scanResult['serverCount']}", info="I")
102107
log(f"BDS Count: {scanResult['bdsCount']}", info="I")
103108
log(f"NK Count: {scanResult['nkCount']}", info="I")
@@ -114,19 +119,19 @@ def recvPackets(socketSendRecv: socket.socket, verboseMode: str, fileName: str,
114119
data, addr = socketSendRecv.recvfrom(10240)
115120
date = getTime()
116121
if len(data) <= 30:
117-
skipped += 1
122+
scanResult['skipped'] += 1
118123
log(
119124
f"data length <= 30, may not motd packet, skipped. Source: {addr[0]}:{addr[1]}", info="R")
120125
continue
121126
if b"MCPE" not in data:
122-
skipped += 1
127+
scanResult['skipped'] += 1
123128
log(
124129
f"metadata \"MCPE\" not in packet, may not motd packet, skipped. Source: {addr[0]}:{addr[1]}", info="R")
125130
continue
126131
if addr not in scanResult['serverList']:
127132
scanResult['serverList'].append(addr)
128133
else:
129-
skipped += 1
134+
scanResult['skipped'] += 1
130135
log(
131136
f"Duplicate server found, skipped. Source: {addr[0]}:{addr[1]}", info="R")
132137
continue

0 commit comments

Comments
 (0)