1
0
mirror of https://github.com/gryf/wicd.git synced 2025-12-22 05:48:03 +01:00

Fix issues with the way disconnect scripts work.

Make flushing the route table more likely to work.
This commit is contained in:
Dan O'Reilly
2009-01-26 18:46:57 -05:00
parent ed9a0d63dc
commit d20dafa088
4 changed files with 25 additions and 15 deletions

View File

@@ -484,7 +484,7 @@ class WirelessInterface(Interface, wnettools.BaseWirelessInterface):
if self.verbose: print cmd
misc.Run(cmd)
def GetBSSID(self):
def GetBSSID(self, iwconfig=None):
""" Get the MAC address for the interface. """
if not self.iface: return ""
data = (self.iface + '\0' * 32)[:32]

View File

@@ -527,6 +527,7 @@ class appGui(object):
instruct_label = self.wTree.get_widget("label_instructions")
if num_networks > 0:
instruct_label.show()
dbus_ifaces = dbusmanager.get_dbus_ifaces()
for x in range(0, num_networks):
if printLine:
sep = gtk.HSeparator()
@@ -535,7 +536,7 @@ class appGui(object):
sep.show()
else:
printLine = True
tempnet = WirelessNetworkEntry(x, dbusmanager.get_dbus_ifaces())
tempnet = WirelessNetworkEntry(x, dbus_ifaces)
self.network_list.pack_start(tempnet, False, False)
tempnet.connect_button.connect("button-press-event",
self.connect, "wireless", x,

View File

@@ -174,16 +174,12 @@ class Controller(object):
"""
return self.iface.GetIP(ifconfig)
def Disconnect(self):
def Disconnect(self, *args, **kargs):
""" Disconnect from the network. """
iface = self.iface
if self.disconnect_script != None:
print 'Running wired disconnect script'
iwconfig = self.GetIwconfig()
misc.ExecuteScript(expand_script_macros(self.disconnect_script, 'disconnection',
self.wiface.GetBSSID( iwconfig ),
self.wiface.GetCurrentNetwork( iwconfig ) ))
print 'Running disconnect script'
misc.ExecuteScript(expand_script_macros(self.disconnect_script, 'disconnection', *args))
iface.ReleaseDHCP()
iface.SetAddress('0.0.0.0')
iface.Down()
@@ -685,7 +681,14 @@ class Wireless(Controller):
Resets it's IP address, and puts the interface down then up.
"""
Controller.Disconnect(self)
if BACKEND.NeedsExternalCalls():
iwconfig = self.GetIwconfig()
else:
iwconfig = None
bssid = self.wiface.GetBSSID(iwconfig),
essid = self.wiface.GetCurrentNetwork(iwconfig)
Controller.Disconnect(self, bssid, essid)
self.StopWPA()
def SetWPADriver(self, driver):
@@ -894,6 +897,9 @@ class Wired(Controller):
self.connecting_thread.start()
return self.connecting_thread
def Disconnect(self):
Controller.Disconnect(self, 'wired', 'wired')
def DetectWiredInterface(self):
""" Attempts to automatically detect a wired interface. """
try:

View File

@@ -483,12 +483,15 @@ class BaseInterface(object):
def FlushRoutes(self):
""" Flush all network routes. """
if not self.iface: return False
if self.IP_FOUND and self.flush_tool != misc.ROUTE:
cmd = "ip route flush dev " + self.iface
if self.IP_FOUND and self.flush_tool == misc.IP:
#cmd = "ip route flush dev " + self.iface
cmds = ['ip route flush all']
else:
cmd = 'route del dev ' + self.iface
if self.verbose: print cmd
misc.Run(cmd)
cmds = ['route del default']
cmds.append('route del dev %s' % self.iface)
for cmd in cmds:
if self.verbose: print cmd
misc.Run(cmd)
def SetDefaultRoute(self, gw):
""" Add a default route with the specified gateway.