@@ -1338,11 +1338,11 @@ def stealDBs(myDB):
1338
1338
def accessCheck (ip ,port ,pingIt ):
1339
1339
1340
1340
if pingIt == True :
1341
- test = os .system ("ping -w 0. 1 -c 1 " + ip + ">/dev/null" )
1341
+ test = os .system ("ping -c 1 -n -W 1 " + ip + ">/dev/null" )
1342
1342
1343
1343
if test == 0 :
1344
1344
try :
1345
- conn = pymongo .MongoClient (ip ,port )
1345
+ conn = pymongo .MongoClient (ip ,port , connectTimeoutMS = 4000 , socketTimeoutMS = 4000 )
1346
1346
1347
1347
try :
1348
1348
dbList = conn .database_names ()
@@ -1365,7 +1365,7 @@ def accessCheck(ip,port,pingIt):
1365
1365
return 4
1366
1366
else :
1367
1367
try :
1368
- conn = pymongo .MongoClient (ip ,port )
1368
+ conn = pymongo .MongoClient (ip ,port , connectTimeoutMS = 2000 )
1369
1369
1370
1370
try :
1371
1371
dbList = conn .database_names ()
@@ -1442,25 +1442,25 @@ def massMongo():
1442
1442
1443
1443
print "\n "
1444
1444
for target in ipList :
1445
- result = accessCheck (target ,27017 ,ping )
1445
+ result = accessCheck (target . rstrip () ,27017 ,ping )
1446
1446
1447
1447
if result == 0 :
1448
- print "Successful default access on " + target + "."
1448
+ print "Successful default access on " + target . rstrip () + "."
1449
1449
success .append (target )
1450
1450
1451
1451
elif result == 1 :
1452
- print "MongoDB running but credentials required on " + target + "."
1452
+ print "MongoDB running but credentials required on " + target . rstrip () + "."
1453
1453
success .append (target )
1454
1454
1455
1455
elif result == 2 :
1456
1456
print "Successful MongoDB connection but error executing command."
1457
1457
success .append (target )
1458
1458
1459
1459
elif result == 3 :
1460
- print "Couldn't connect to " + target + "."
1460
+ print "Couldn't connect to " + target . rstrip () + "."
1461
1461
1462
1462
elif result == 4 :
1463
- print target + " didn't respond to ping."
1463
+ print target . rstrip () + " didn't respond to ping."
1464
1464
1465
1465
1466
1466
print "\n \n "
0 commit comments