Skip to content

Commit 49b6b9c

Browse files
committed
Revert "Finished Mac OS X porting"
This reverts commit 6a4d033.
1 parent 6a4d033 commit 49b6b9c

File tree

1 file changed

+17
-31
lines changed

1 file changed

+17
-31
lines changed

netcmd.py

+17-31
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ def find_alive_hosts( self ):
8787

8888
# broadcast arping ftw
8989
ans,unans = srp( Ether( dst = "ff:ff:ff:ff:ff:ff" ) / ARP( pdst = self.network ),
90-
verbose = False,
91-
filter = "arp and arp[7] = 2",
92-
timeout = 2,
90+
verbose = False,
91+
filter = "arp and arp[7] = 2",
92+
timeout = 2,
9393
iface_hint = self.network )
9494

9595
for snd,rcv in ans:
@@ -120,32 +120,21 @@ def __init__( self, interface, gateway = None, network = None, kill = False, all
120120
raise Exception( "Only root can run this script." )
121121

122122
self.__preload_mac_table()
123-
123+
124124
print "@ Searching for the network gateway address ..."
125-
125+
126126
# for route in conf.route.routes:
127127
for net, msk, gw, iface, addr in conf.route.routes:
128128
# found a route for given interface
129129
if iface == self.interface:
130130
network = ltoa( net )
131-
132-
# Mac OS X
133-
if sys.platform == 'darwin':
134-
if self.gateway is None:
135-
if gw != '0.0.0.0':
136-
self.gateway = gw
137-
elif self.network is None and network != '0.0.0.0':
138-
bits = self.__bit_count( msk )
139-
self.network = "%s/%d" % ( network, bits )
140-
# Linux
141-
else:
142-
# compute network representation if not yet done
143-
if network.split('.')[0] == addr.split('.')[0]:
144-
bits = self.__bit_count( msk )
145-
self.network = "%s/%d" % ( network, bits )
146-
# search for a valid network gateway
147-
if self.gateway is None and gw != '0.0.0.0':
148-
self.gateway = gw
131+
# compute network representation if not yet done
132+
if network.split('.')[0] == addr.split('.')[0]:
133+
bits = self.__bit_count( msk )
134+
self.network = "%s/%d" % ( network, bits )
135+
# search for a valid network gateway
136+
if self.gateway is None and gw != '0.0.0.0':
137+
self.gateway = gw
149138

150139
if self.gateway is not None and self.network is not None:
151140
print "@ Gateway is %s on network %s ." % ( self.gateway, self.network )
@@ -161,13 +150,12 @@ def __init__( self, interface, gateway = None, network = None, kill = False, all
161150
self.targets = self.endpoints
162151
else:
163152
while choice is None:
153+
for i, item in enumerate( self.endpoints ):
154+
( mac, ip ) = item
155+
vendor = self.__find_mac_vendor( mac )
156+
print " [%d] %s %s %s" % ( i, mac, ip, "( %s )" % vendor if vendor else '' )
157+
choice = raw_input( "@ Choose [0-%d] (* to select all, r to refresh): " % (len(self.endpoints) - 1) )
164158
try:
165-
for i, item in enumerate( self.endpoints ):
166-
( mac, ip ) = item
167-
vendor = self.__find_mac_vendor( mac )
168-
print " [%d] %s %s %s" % ( i, mac, ip, "( %s )" % vendor if vendor else '' )
169-
170-
choice = raw_input( "@ Choose [0-%d] (* to select all, r to refresh): " % (len(self.endpoints) - 1) )
171159
choice = choice.strip()
172160
if choice == '*':
173161
self.targets = self.endpoints
@@ -176,8 +164,6 @@ def __init__( self, interface, gateway = None, network = None, kill = False, all
176164
self.find_alive_hosts()
177165
else:
178166
self.targets.append( self.endpoints[ int(choice) ] )
179-
except KeyboardInterrupt:
180-
quit()
181167
except Exception as e:
182168
print "@ Invalid choice!"
183169
choice = None

0 commit comments

Comments
 (0)