@@ -137,7 +137,7 @@ def options():
137
137
select = raw_input ("Select an option: " )
138
138
139
139
if select == "1" :
140
- #Unset the boolean since we're setting it again.
140
+ #Unset the boolean if it's set since we're setting it again.
141
141
optionSet [0 ] = False
142
142
goodLen = False
143
143
goodDigits = False
@@ -209,10 +209,41 @@ def options():
209
209
print "Invalid selection"
210
210
211
211
elif select == "5" :
212
- myIP = raw_input ("Enter host IP for my Mongo/Shells: " )
213
- print "Shell IP set to " + myIP + "\n "
214
- optionSet [4 ] = True
212
+ #Unset the setting boolean since we're setting it again.
213
+ optionSet [4 ] = False
214
+ goodLen = False
215
+ goodDigits = False
216
+ while optionSet [4 ] == False :
217
+ myIP = raw_input ("Enter the host IP for my Mongo/Shells: " )
218
+ #make sure we got a valid IP
219
+ octets = myIP .split ("." )
220
+ #If there aren't 4 octets, toss an error.
221
+ if len (octets ) != 4 :
222
+ print "Invalid IP length."
223
+
224
+ else :
225
+ goodLen = True
226
+
227
+ if goodLen == True :
228
+ #If the format of the IP is good, check and make sure the octets are all within acceptable ranges.
229
+ for item in octets :
230
+ if int (item ) < 0 or int (item ) > 255 :
231
+ print "Bad octet in IP address."
232
+ goodDigits = False
233
+
234
+ else :
235
+ goodDigits = True
236
+
237
+
238
+ #If everything checks out set the IP and break the loop
239
+ if goodLen == True and goodDigits == True :
240
+ print "\n Shell/DB listener set to " + myIP + "\n "
241
+ optionSet [4 ] = True
215
242
options ()
243
+ #myIP = raw_input("Enter host IP for my Mongo/Shells: ")
244
+ #print "Shell IP set to " + myIP + "\n"
245
+ #optionSet[4] = True
246
+ #options()
216
247
217
248
elif select == "6" :
218
249
myPort = raw_input ("Enter TCP listener for shells: " )
0 commit comments