mirror of
https://github.com/DanMcInerney/LANs.py.git
synced 2025-07-06 13:02:20 -07:00
improved router IP finding function
This commit is contained in:
parent
0f1893d6a1
commit
0807b24fea
1 changed files with 7 additions and 8 deletions
15
LANs.py
15
LANs.py
|
@ -166,17 +166,16 @@ def LANsMain(args):
|
|||
ipr = Popen(['/sbin/ip', 'route'], stdout=PIPE, stderr=DN)
|
||||
ipr = ipr.communicate()[0]
|
||||
iprs = ipr.split('\n')
|
||||
ipr = ipr.split()
|
||||
if args.routerip:
|
||||
routerIP = args.routerip
|
||||
else:
|
||||
try:
|
||||
routerIP = ipr[2]
|
||||
except:
|
||||
exit("You must be connected to the internet to use this.")
|
||||
routerIP = None
|
||||
for r in iprs:
|
||||
if '/' in r:
|
||||
IPprefix = r.split()[0]
|
||||
if r.startswith('default') and not args.routerip:
|
||||
routerIP = r.split()[2]
|
||||
if args.routerip:
|
||||
routerIP = args.routerip
|
||||
if not routerIP:
|
||||
exit("You must be connected to the internet to use this.")
|
||||
if args.interface:
|
||||
interface = args.interface
|
||||
else:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue