mirror of
https://github.com/gryf/wicd.git
synced 2025-12-20 04:48:00 +01:00
Added support for ralink legacy cards, implemented a debug mode option, swapped order that autoconnect uses, fixed some indentation issues, changed/added some comments
This commit is contained in:
103
daemon.py
103
daemon.py
@@ -252,6 +252,23 @@ class ConnectionWizard(dbus.service.Object):
|
|||||||
return str(self.wifi.wireless_interface)
|
return str(self.wifi.wireless_interface)
|
||||||
#end function GetWirelessInterface
|
#end function GetWirelessInterface
|
||||||
|
|
||||||
|
<<<<<<< .mine
|
||||||
|
@dbus.service.method('org.wicd.daemon')
|
||||||
|
def SetDebugMode(self,debug):
|
||||||
|
'''sets if debugging mode is on or off'''
|
||||||
|
config = ConfigParser.ConfigParser()
|
||||||
|
config.read(self.app_conf)
|
||||||
|
config.set("Settings","debug_mode",debug)
|
||||||
|
configfile = open(self.app_conf,"w")
|
||||||
|
config.write(configfile)
|
||||||
|
self.debug_mode = debug
|
||||||
|
|
||||||
|
@dbus.service.method('org.wicd.daemon')
|
||||||
|
def GetDebugMode(self):
|
||||||
|
'''returns whether debugging is enabled'''
|
||||||
|
return bool(int(self.debug_mode))
|
||||||
|
|
||||||
|
=======
|
||||||
@dbus.service.method('org.wicd.daemon')
|
@dbus.service.method('org.wicd.daemon')
|
||||||
def GetGlobalDNSAddresses(self):
|
def GetGlobalDNSAddresses(self):
|
||||||
'''returns the global dns addresses'''
|
'''returns the global dns addresses'''
|
||||||
@@ -259,6 +276,7 @@ class ConnectionWizard(dbus.service.Object):
|
|||||||
return (self.dns1,self.dns2,self.dns3)
|
return (self.dns1,self.dns2,self.dns3)
|
||||||
#end function GetWirelessInterface
|
#end function GetWirelessInterface
|
||||||
|
|
||||||
|
>>>>>>> .r63
|
||||||
########## WIRELESS FUNCTIONS
|
########## WIRELESS FUNCTIONS
|
||||||
#################################
|
#################################
|
||||||
|
|
||||||
@@ -284,6 +302,7 @@ class ConnectionWizard(dbus.service.Object):
|
|||||||
|
|
||||||
@dbus.service.method('org.wicd.daemon.wireless')
|
@dbus.service.method('org.wicd.daemon.wireless')
|
||||||
def DisconnectWireless(self):
|
def DisconnectWireless(self):
|
||||||
|
'''disconnects all wireless networks'''
|
||||||
self.SetForcedDisconnect(True)
|
self.SetForcedDisconnect(True)
|
||||||
self.wifi.Disconnect()
|
self.wifi.Disconnect()
|
||||||
#end function DisconnectWireless
|
#end function DisconnectWireless
|
||||||
@@ -307,28 +326,21 @@ class ConnectionWizard(dbus.service.Object):
|
|||||||
|
|
||||||
@dbus.service.method('org.wicd.daemon.wireless')
|
@dbus.service.method('org.wicd.daemon.wireless')
|
||||||
def CreateAdHocNetwork(self,essid,channel,ip,enctype,key,encused,ics):
|
def CreateAdHocNetwork(self,essid,channel,ip,enctype,key,encused,ics):
|
||||||
|
'''creates an ad-hoc network using user inputted settings'''
|
||||||
print 'attempting to create ad-hoc network...'
|
print 'attempting to create ad-hoc network...'
|
||||||
self.wifi.CreateAdHocNetwork(essid,channel,ip,enctype,key,encused,ics)
|
self.wifi.CreateAdHocNetwork(essid,channel,ip,enctype,key,encused,ics)
|
||||||
#end function CreateAdHocNetwork
|
#end function CreateAdHocNetwork
|
||||||
|
|
||||||
@dbus.service.method('org.wicd.daemon.wireless')
|
|
||||||
def GetHideDupeAPs(self):
|
|
||||||
return self.hide_dupe_aps
|
|
||||||
#end function GetHideDupeAPs
|
|
||||||
|
|
||||||
@dbus.service.method('org.wicd.daemon.wireless')
|
|
||||||
def SetHideDupeAPs(self,value):
|
|
||||||
self.hide_dupe_aps = value
|
|
||||||
#end function SetHideDupeAPs
|
|
||||||
|
|
||||||
@dbus.service.method('org.wicd.daemon.wireless')
|
@dbus.service.method('org.wicd.daemon.wireless')
|
||||||
def GetAutoReconnect(self):
|
def GetAutoReconnect(self):
|
||||||
|
'''returns if wicd should automatically try to reconnect is connection is lost'''
|
||||||
do = bool(int(self.auto_reconnect))
|
do = bool(int(self.auto_reconnect))
|
||||||
return self.__printReturn('returning automatically reconnect when connection drops',do)
|
return self.__printReturn('returning automatically reconnect when connection drops',do)
|
||||||
#end function GetAutoReconnect
|
#end function GetAutoReconnect
|
||||||
|
|
||||||
@dbus.service.method('org.wicd.daemon.wireless')
|
@dbus.service.method('org.wicd.daemon.wireless')
|
||||||
def SetAutoReconnect(self,value):
|
def SetAutoReconnect(self,value):
|
||||||
|
'''sets if wicd should try to reconnect with connection drops'''
|
||||||
print 'setting automatically reconnect when connection drops'
|
print 'setting automatically reconnect when connection drops'
|
||||||
config = ConfigParser.ConfigParser()
|
config = ConfigParser.ConfigParser()
|
||||||
config.read(self.app_conf)
|
config.read(self.app_conf)
|
||||||
@@ -339,7 +351,21 @@ class ConnectionWizard(dbus.service.Object):
|
|||||||
|
|
||||||
@dbus.service.method('org.wicd.daemon.wireless')
|
@dbus.service.method('org.wicd.daemon.wireless')
|
||||||
def AutoConnect(self,fresh):
|
def AutoConnect(self,fresh):
|
||||||
'''autoconnects to a wireless network'''
|
'''first tries to autoconnect to a wireled network, if that fails it tries a wireless connection'''
|
||||||
|
if fresh and self.CheckPluggedIn() == True:
|
||||||
|
defaultNetwork = self.GetDefaultWiredNetwork()
|
||||||
|
if defaultNetwork != None:
|
||||||
|
self.ReadWiredNetworkProfile(defaultNetwork)
|
||||||
|
self.ConnectWired()
|
||||||
|
time.sleep(1)
|
||||||
|
print "Attempting to autoconnect with wired interface..."
|
||||||
|
while self.CheckIfWiredConnecting(): # Keeps us from going into an infinite connecting loop
|
||||||
|
time.sleep(1)
|
||||||
|
print "...done autoconnecting."
|
||||||
|
else:
|
||||||
|
print "couldn't find a default wired connection, wired autoconnect failed"
|
||||||
|
else:
|
||||||
|
print "no wired connection present, wired autoconnect failed"
|
||||||
print 'attempting to autoconnect to wireless network'
|
print 'attempting to autoconnect to wireless network'
|
||||||
if fresh:
|
if fresh:
|
||||||
self.Scan()
|
self.Scan()
|
||||||
@@ -350,7 +376,7 @@ class ConnectionWizard(dbus.service.Object):
|
|||||||
if bool(self.LastScan[x].get('automatic')):
|
if bool(self.LastScan[x].get('automatic')):
|
||||||
print 'automatically connecting to...',str(self.LastScan[x]["essid"])
|
print 'automatically connecting to...',str(self.LastScan[x]["essid"])
|
||||||
self.ConnectWireless(x)
|
self.ConnectWireless(x)
|
||||||
time.sleep(1)
|
time.sleep(3)
|
||||||
while self.CheckIfWirelessConnecting():
|
while self.CheckIfWirelessConnecting():
|
||||||
print "autoconnecting... hold"
|
print "autoconnecting... hold"
|
||||||
#not sure why I need to get IPs, but
|
#not sure why I need to get IPs, but
|
||||||
@@ -370,26 +396,10 @@ class ConnectionWizard(dbus.service.Object):
|
|||||||
# think? -- adam
|
# think? -- adam
|
||||||
###
|
###
|
||||||
#self.GetWiredIP()
|
#self.GetWiredIP()
|
||||||
time.sleep(1)
|
time.sleep(2)
|
||||||
print "autoconnecting... done"
|
print "autoconnecting... done"
|
||||||
return
|
return
|
||||||
print "unable to find a network to autoconnect to, checking for a wired connection"
|
print "unable to autoconnect, you'll have to manually connect"
|
||||||
if self.CheckPluggedIn() == True:
|
|
||||||
defaultNetwork = self.GetDefaultWiredNetwork()
|
|
||||||
if defaultNetwork != None:
|
|
||||||
self.ReadWiredNetworkProfile(defaultNetwork)
|
|
||||||
self.ConnectWired()
|
|
||||||
time.sleep(1)
|
|
||||||
print "Attempting to autoconnect with wired interface..."
|
|
||||||
while self.CheckIfWiredConnecting(): # Keeps us from going into an infinite connecting loop
|
|
||||||
#I didn't include a self.GetWired/WirelessIP call and it seems
|
|
||||||
#to work for me...could it cause problems? - Dan
|
|
||||||
time.sleep(1)
|
|
||||||
print "...done autoconnecting."
|
|
||||||
else:
|
|
||||||
print "couldn't find a default wired connection, couldn't autoconnect"
|
|
||||||
else:
|
|
||||||
print "no wired connection present, couldn't autoconnect."
|
|
||||||
else:
|
else:
|
||||||
print 'autoconnect failed because wireless interface == None'
|
print 'autoconnect failed because wireless interface == None'
|
||||||
#end function AutoConnect
|
#end function AutoConnect
|
||||||
@@ -843,10 +853,18 @@ class ConnectionWizard(dbus.service.Object):
|
|||||||
else:
|
else:
|
||||||
config.set("Settings","auto_reconnect","False")
|
config.set("Settings","auto_reconnect","False")
|
||||||
self.auto_reconnect = False
|
self.auto_reconnect = False
|
||||||
|
<<<<<<< .mine
|
||||||
|
if config.has_option("Settings","debug_mode"):
|
||||||
|
self.debug_mode = config.get("Settings","debug_mode")
|
||||||
|
else:
|
||||||
|
self.debug_mode = False
|
||||||
|
config.set("Settings","debug_mode","False")
|
||||||
|
=======
|
||||||
if config.has_option('Settings','dns1') and config.has_option('Settings','dns2') and config.has_option('Settings','dns3'):
|
if config.has_option('Settings','dns1') and config.has_option('Settings','dns2') and config.has_option('Settings','dns3'):
|
||||||
self.SetGlobalDNS(config.get('Settings','dns1'),config.get('Settings','dns2'),config.get('Settings','dns3'))
|
self.SetGlobalDNS(config.get('Settings','dns1'),config.get('Settings','dns2'),config.get('Settings','dns3'))
|
||||||
else:
|
else:
|
||||||
self.SetGlobalDNS("None","None","None")
|
self.SetGlobalDNS("None","None","None")
|
||||||
|
>>>>>>> .r63
|
||||||
else:
|
else:
|
||||||
print "configuration file exists, no settings found, adding defaults..."
|
print "configuration file exists, no settings found, adding defaults..."
|
||||||
configfile = open(self.app_conf,"w")
|
configfile = open(self.app_conf,"w")
|
||||||
@@ -856,6 +874,15 @@ class ConnectionWizard(dbus.service.Object):
|
|||||||
config.set("Settings","wpa_driver","wext")
|
config.set("Settings","wpa_driver","wext")
|
||||||
config.set("Settings","always_show_wired_interface","False")
|
config.set("Settings","always_show_wired_interface","False")
|
||||||
config.set("Settings","auto_reconnect","False")
|
config.set("Settings","auto_reconnect","False")
|
||||||
|
<<<<<<< .mine
|
||||||
|
config.set("Settings","debug_mode","False")
|
||||||
|
self.SetWirelessInterface("wlan0")
|
||||||
|
self.SetWiredInterface("eth0")
|
||||||
|
self.SetWPADriver("wext")
|
||||||
|
self.SetAlwaysShowWiredInterface(False)
|
||||||
|
self.SetAutoReconnect(True)
|
||||||
|
self.SetDebugMode(False)
|
||||||
|
=======
|
||||||
config.set("Settings","use_global_dns","False")
|
config.set("Settings","use_global_dns","False")
|
||||||
config.set("Settings","dns1","None")
|
config.set("Settings","dns1","None")
|
||||||
config.set("Settings","dns2","None")
|
config.set("Settings","dns2","None")
|
||||||
@@ -864,6 +891,7 @@ class ConnectionWizard(dbus.service.Object):
|
|||||||
self.SetWirelessInterface(config.get("Settings","wireless_interface"))
|
self.SetWirelessInterface(config.get("Settings","wireless_interface"))
|
||||||
self.SetWiredInterface(config.get("Settings","wired_interface"))
|
self.SetWiredInterface(config.get("Settings","wired_interface"))
|
||||||
self.SetWPADriver(config.get("Settings","wpa_driver"))
|
self.SetWPADriver(config.get("Settings","wpa_driver"))
|
||||||
|
>>>>>>> .r63
|
||||||
config.write(configfile)
|
config.write(configfile)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
@@ -876,9 +904,13 @@ class ConnectionWizard(dbus.service.Object):
|
|||||||
config.set("Settings","wired_interface","eth0")
|
config.set("Settings","wired_interface","eth0")
|
||||||
config.set("Settings","always_show_wired_interface","False")
|
config.set("Settings","always_show_wired_interface","False")
|
||||||
config.set("Settings","auto_reconnect","False")
|
config.set("Settings","auto_reconnect","False")
|
||||||
|
<<<<<<< .mine
|
||||||
|
config.set("Settings","debug_mode","False")
|
||||||
|
=======
|
||||||
config.set("Settings","dns1","None")
|
config.set("Settings","dns1","None")
|
||||||
config.set("Settings","dns2","None")
|
config.set("Settings","dns2","None")
|
||||||
config.set("Settings","dns3","None")
|
config.set("Settings","dns3","None")
|
||||||
|
>>>>>>> .r63
|
||||||
iface = self.DetectWirelessInterface()
|
iface = self.DetectWirelessInterface()
|
||||||
if iface:
|
if iface:
|
||||||
config.set("Settings","wireless_interface",iface)
|
config.set("Settings","wireless_interface",iface)
|
||||||
@@ -892,7 +924,11 @@ class ConnectionWizard(dbus.service.Object):
|
|||||||
self.SetWPADriver(config.get("Settings","wpa_driver"))
|
self.SetWPADriver(config.get("Settings","wpa_driver"))
|
||||||
self.SetAlwaysShowWiredInterface(False)
|
self.SetAlwaysShowWiredInterface(False)
|
||||||
self.SetAutoReconnect(True)
|
self.SetAutoReconnect(True)
|
||||||
|
<<<<<<< .mine
|
||||||
|
self.SetDebugMode(False)
|
||||||
|
=======
|
||||||
self.SetGlobalDNS(None,None,None)
|
self.SetGlobalDNS(None,None,None)
|
||||||
|
>>>>>>> .r63
|
||||||
#end If
|
#end If
|
||||||
|
|
||||||
if os.path.isfile( self.wireless_conf ):
|
if os.path.isfile( self.wireless_conf ):
|
||||||
@@ -933,12 +969,13 @@ class ConnectionWizard(dbus.service.Object):
|
|||||||
|
|
||||||
## fork from the parent terminal
|
## fork from the parent terminal
|
||||||
|
|
||||||
if not True: #for easy disabling
|
if True: #for easy disabling
|
||||||
try:
|
try:
|
||||||
pid = os.fork()
|
pid = os.fork()
|
||||||
if pid > 0:
|
if pid > 0:
|
||||||
# exit first parent
|
# exit first parent
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
except OSError, e:
|
except OSError, e:
|
||||||
print >>sys.stderr, "fork #1 failed: %d (%s)" % (e.errno, e.strerror)
|
print >>sys.stderr, "fork #1 failed: %d (%s)" % (e.errno, e.strerror)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
@@ -960,8 +997,8 @@ if not True: #for easy disabling
|
|||||||
#kill output
|
#kill output
|
||||||
#POI:500 stdout redirection
|
#POI:500 stdout redirection
|
||||||
output = FlushWriter()
|
output = FlushWriter()
|
||||||
#sys.stdout = output #open("data/wicd.log","w")
|
sys.stdout = output #open("data/wicd.log","w")
|
||||||
#sys.stderr = output
|
sys.stderr = output
|
||||||
|
|
||||||
print "---------------------------"
|
print "---------------------------"
|
||||||
print "wicd initalizing..."
|
print "wicd initalizing..."
|
||||||
|
|||||||
137
edgy.py
137
edgy.py
@@ -40,7 +40,7 @@ except:
|
|||||||
proxy_obj = bus.get_object('org.wicd.daemon', '/org/wicd/daemon')
|
proxy_obj = bus.get_object('org.wicd.daemon', '/org/wicd/daemon')
|
||||||
except:
|
except:
|
||||||
print 'daemon still not running, aborting.'
|
print 'daemon still not running, aborting.'
|
||||||
#daemon = dbus.Interface(proxy_obj, 'org.wicd.daemon')
|
daemon = dbus.Interface(proxy_obj, 'org.wicd.daemon') # Had to uncomment it
|
||||||
wireless = dbus.Interface(proxy_obj, 'org.wicd.daemon.wireless')
|
wireless = dbus.Interface(proxy_obj, 'org.wicd.daemon.wireless')
|
||||||
wired = dbus.Interface(proxy_obj, 'org.wicd.daemon.wired')
|
wired = dbus.Interface(proxy_obj, 'org.wicd.daemon.wired')
|
||||||
config = dbus.Interface(proxy_obj, 'org.wicd.daemon.config')
|
config = dbus.Interface(proxy_obj, 'org.wicd.daemon.config')
|
||||||
@@ -78,71 +78,76 @@ def open_wicd_gui():
|
|||||||
lastWinId = os.spawnlpe(os.P_NOWAIT, './gui.py', os.environ)
|
lastWinId = os.spawnlpe(os.P_NOWAIT, './gui.py', os.environ)
|
||||||
|
|
||||||
def set_signal_image():
|
def set_signal_image():
|
||||||
global LastStrength
|
global LastStrength
|
||||||
global stillWired #keeps us from resetting the wired info over and over (I think?)
|
global stillWired #keeps us from resetting the wired info over and over
|
||||||
global network #declared as global so it is initialized once before it gets used in the if statement below
|
global network #declared as global so it gets initialized before initial use
|
||||||
|
|
||||||
config.DisableLogging()
|
# Disable logging if debugging isn't on to prevent log spam
|
||||||
|
if not daemon.GetDebugMode():
|
||||||
|
config.DisableLogging()
|
||||||
|
|
||||||
wired_ip = wired.GetWiredIP()
|
wired_ip = wired.GetWiredIP()
|
||||||
if wired.CheckPluggedIn() == True and wired_ip:
|
if wired.CheckPluggedIn() == True and wired_ip:
|
||||||
if stillWired == False:
|
if stillWired == False: # Only set image/tooltip if it hasn't been set already
|
||||||
tr.set_from_file("images/wired.png")
|
tr.set_from_file("images/wired.png")
|
||||||
tr.set_tooltip(language['connected_to_wired'].replace('$A',wired_ip))
|
tr.set_tooltip(language['connected_to_wired'].replace('$A',wired_ip))
|
||||||
stillWired = True
|
stillWired = True
|
||||||
lock = ''
|
lock = ''
|
||||||
else:
|
else:
|
||||||
stillWired = False
|
stillWired = False
|
||||||
wireless_ip = wireless.GetWirelessIP()
|
|
||||||
#If ip returns as None, we are probably returning from hibernation and need to force signal to 0 to avoid crashing
|
|
||||||
if wireless_ip != None:
|
|
||||||
signal = int(wireless.GetCurrentSignalStrength())
|
|
||||||
else:
|
|
||||||
signal = 0
|
|
||||||
|
|
||||||
#only update if the signal strength has changed because doing I/O calls is expensive,
|
wireless_ip = wireless.GetWirelessIP()
|
||||||
#and the icon flickers
|
#If ip returns as None, we are probably returning from hibernation and need to force signal to 0 to avoid crashing
|
||||||
if (signal != LastStrength or network != wireless.GetCurrentNetwork()) and wireless_ip != None:
|
if wireless_ip != None:
|
||||||
LastStrength = signal
|
signal = int(wireless.GetCurrentSignalStrength())
|
||||||
lock = '' #set the string to '' so that when it is put in "high-signal" + lock + ".png", there will be nothing
|
else:
|
||||||
curNetID = wireless.GetCurrentNetworkID() #the network ID needs to be checked because a negative value here will break the tray
|
signal = 0
|
||||||
if signal > 0 and curNetID > -1 and wireless.GetWirelessProperty(curNetID,"encryption"):
|
|
||||||
lock = '-lock' #set the string to '-lock' so that it will display the lock picture
|
|
||||||
|
|
||||||
network = str(wireless.GetCurrentNetwork())
|
#only update if the signal strength has changed because doing I/O calls is expensive,
|
||||||
tr.set_tooltip(language['connected_to_wireless'].replace('$A',network).replace('$B',str(signal)).replace('$C',str(wireless_ip)))
|
#and the icon flickers
|
||||||
if signal > 75:
|
if (signal != LastStrength or network != wireless.GetCurrentNetwork()) and wireless_ip != None:
|
||||||
tr.set_from_file("images/high-signal" + lock + ".png")
|
LastStrength = signal
|
||||||
elif signal > 50:
|
lock = '' #set the string to '' so that when it is put in "high-signal" + lock + ".png", there will be nothing
|
||||||
tr.set_from_file("images/good-signal" + lock + ".png")
|
curNetID = wireless.GetCurrentNetworkID() #the network ID needs to be checked because a negative value here will break the tray
|
||||||
elif signal > 25:
|
if signal > 0 and curNetID > -1 and wireless.GetWirelessProperty(curNetID,"encryption"):
|
||||||
tr.set_from_file("images/low-signal" + lock + ".png")
|
lock = '-lock' #set the string to '-lock' so that it will display the lock picture
|
||||||
elif signal > 0:
|
network = str(wireless.GetCurrentNetwork())
|
||||||
tr.set_from_file("images/bad-signal" + lock + ".png")
|
tr.set_tooltip(language['connected_to_wireless'].replace('$A',network).replace('$B',str(signal)).replace('$C',str(wireless_ip)))
|
||||||
elif signal == 0:
|
if signal > 75:
|
||||||
tr.set_from_file("images/no-signal.png")
|
tr.set_from_file("images/high-signal" + lock + ".png")
|
||||||
elif wireless_ip == None:
|
elif signal > 50:
|
||||||
tr.set_from_file("images/no-signal.png")
|
tr.set_from_file("images/good-signal" + lock + ".png")
|
||||||
tr.set_tooltip(language['not_connected'])
|
elif signal > 25:
|
||||||
#Auto-reconnect code - not sure how well this works. I know that without the ForcedDisconnect check it reconnects you when
|
tr.set_from_file("images/low-signal" + lock + ".png")
|
||||||
#a disconnect is forced. People who have disconnection problems need to test it to determine if it actually works.
|
elif signal > 0:
|
||||||
#First it will attempt to reconnect to the last known wireless network, and if that fails it should run a scan and try to
|
tr.set_from_file("images/bad-signal" + lock + ".png")
|
||||||
#connect to any network set to autoconnect. It will continuously rescan until a network is found or the user manually reconnects
|
elif signal == 0:
|
||||||
#This behavior could prove to be annoying, so we'll keep it in the experimental build for now
|
tr.set_from_file("images/no-signal.png")
|
||||||
if wireless.GetAutoReconnect() == True and wireless.CheckIfWirelessConnecting() == False and wireless.GetForcedDisconnect() == False:
|
elif wireless_ip == None:
|
||||||
curNetID = wireless.GetCurrentNetworkID()
|
tr.set_from_file("images/no-signal.png")
|
||||||
if curNetID > -1:
|
tr.set_tooltip(language['not_connected'])
|
||||||
wireless.ConnectWireless(wireless.GetCurrentNetworkID())
|
#Auto-reconnect code - not sure how well this works. I know that without the ForcedDisconnect check it reconnects you when
|
||||||
if wireless.GetCurrentSignalStrength() != 0:
|
#a disconnect is forced. People who have disconnection problems need to test it to determine if it actually works.
|
||||||
print "Successfully autoreconnected."
|
#First it will attempt to reconnect to the last known wireless network, and if that fails it should run a scan and try to
|
||||||
else:
|
#connect to any network set to autoconnect. It will continuously rescan until a network is found or the user manually reconnects
|
||||||
print "Couldn't reconnect to last used network, scanning for an autoconnect network..."
|
#This behavior could prove to be annoying, so we'll keep it in the experimental build for now
|
||||||
print wireless.AutoConnect(True)
|
if wireless.GetAutoReconnect() == True and wireless.CheckIfWirelessConnecting() == False and wireless.GetForcedDisconnect() == False:
|
||||||
else:
|
curNetID = wireless.GetCurrentNetworkID()
|
||||||
print "Scanning for an autoconnect network..."
|
if curNetID > -1: #value of -1 is typically caused by hibernation and breaks the tray if passed to daemon
|
||||||
print wireless.AutoConnect(True)
|
wireless.ConnectWireless(wireless.GetCurrentNetworkID())
|
||||||
config.EnableLogging()
|
if wireless.GetCurrentSignalStrength() != 0:
|
||||||
return True
|
print "Successfully autoreconnected."
|
||||||
|
else:
|
||||||
|
print "Couldn't reconnect to last used network, scanning for an autoconnect network..."
|
||||||
|
print wireless.AutoConnect(True)
|
||||||
|
else:
|
||||||
|
print "Scanning for an autoconnect network..."
|
||||||
|
print wireless.AutoConnect(True)
|
||||||
|
|
||||||
|
if not daemon.GetDebugMode():
|
||||||
|
config.EnableLogging()
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
class TrackerStatusIcon(gtk.StatusIcon):
|
class TrackerStatusIcon(gtk.StatusIcon):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@@ -172,7 +177,7 @@ class TrackerStatusIcon(gtk.StatusIcon):
|
|||||||
self.manager.insert_action_group(ag, 0)
|
self.manager.insert_action_group(ag, 0)
|
||||||
self.manager.add_ui_from_string(menu)
|
self.manager.add_ui_from_string(menu)
|
||||||
self.menu = self.manager.get_widget('/Menubar/Menu/About').props.parent
|
self.menu = self.manager.get_widget('/Menubar/Menu/About').props.parent
|
||||||
self.current_icon_path = ''
|
self.current_icon_path = ''
|
||||||
self.set_from_file("images/no-signal.png")
|
self.set_from_file("images/no-signal.png")
|
||||||
self.set_visible(True)
|
self.set_visible(True)
|
||||||
self.connect('activate', self.on_activate)
|
self.connect('activate', self.on_activate)
|
||||||
@@ -200,9 +205,9 @@ class TrackerStatusIcon(gtk.StatusIcon):
|
|||||||
dialog.destroy()
|
dialog.destroy()
|
||||||
|
|
||||||
def set_from_file(self,path):
|
def set_from_file(self,path):
|
||||||
if path != self.current_icon_path:
|
if path != self.current_icon_path:
|
||||||
self.current_icon_path = path
|
self.current_icon_path = path
|
||||||
gtk.StatusIcon.set_from_file(self,path)
|
gtk.StatusIcon.set_from_file(self,path)
|
||||||
|
|
||||||
LastStrength = -2
|
LastStrength = -2
|
||||||
stillWired = False
|
stillWired = False
|
||||||
|
|||||||
27
gui.py
27
gui.py
@@ -129,7 +129,11 @@ language['after_script'] = _('Run script after connect')
|
|||||||
language['script_settings'] = _('Scripts')
|
language['script_settings'] = _('Scripts')
|
||||||
language['use_ics'] = _('Activate Internet Connection Sharing')
|
language['use_ics'] = _('Activate Internet Connection Sharing')
|
||||||
language['default_wired'] = _('Use as default profile (overwrites any previous default)')
|
language['default_wired'] = _('Use as default profile (overwrites any previous default)')
|
||||||
|
<<<<<<< .mine
|
||||||
|
language['use_debug_mode'] = _('Enable debug mode')
|
||||||
|
=======
|
||||||
language['use_global_dns'] = _('Use global DNS servers')
|
language['use_global_dns'] = _('Use global DNS servers')
|
||||||
|
>>>>>>> .r63
|
||||||
|
|
||||||
language['0'] = _('0')
|
language['0'] = _('0')
|
||||||
language['1'] = _('1')
|
language['1'] = _('1')
|
||||||
@@ -145,6 +149,7 @@ language['9'] = _('9')
|
|||||||
language['interface_down'] = _('Putting interface down...')
|
language['interface_down'] = _('Putting interface down...')
|
||||||
language['resetting_ip_address'] = _('Resetting IP address...')
|
language['resetting_ip_address'] = _('Resetting IP address...')
|
||||||
language['interface_up'] = _('Putting interface up...')
|
language['interface_up'] = _('Putting interface up...')
|
||||||
|
language['setting_encryption_info'] = _('Setting encryption info')
|
||||||
language['removing_old_connection'] = _('Removing old connection...')
|
language['removing_old_connection'] = _('Removing old connection...')
|
||||||
language['generating_psk'] = _('Generating PSK...')
|
language['generating_psk'] = _('Generating PSK...')
|
||||||
language['generating_wpa_config'] = _('Generating WPA configuration file...')
|
language['generating_wpa_config'] = _('Generating WPA configuration file...')
|
||||||
@@ -838,10 +843,12 @@ class appGui:
|
|||||||
wiredcheckbox.set_active(wired.GetAlwaysShowWiredInterface())
|
wiredcheckbox.set_active(wired.GetAlwaysShowWiredInterface())
|
||||||
reconnectcheckbox = gtk.CheckButton(language['auto_reconnect'])
|
reconnectcheckbox = gtk.CheckButton(language['auto_reconnect'])
|
||||||
reconnectcheckbox.set_active(wireless.GetAutoReconnect())
|
reconnectcheckbox.set_active(wireless.GetAutoReconnect())
|
||||||
|
debugmodecheckbox = gtk.CheckButton(language['use_debug_mode'])
|
||||||
|
debugmodecheckbox.set_active(daemon.GetDebugMode())
|
||||||
wpadriverlabel = SmallLabel(language['wpa_supplicant_driver'] + ':')
|
wpadriverlabel = SmallLabel(language['wpa_supplicant_driver'] + ':')
|
||||||
wpadrivercombo = gtk.combo_box_new_text()
|
wpadrivercombo = gtk.combo_box_new_text()
|
||||||
wpadrivercombo.set_size_request(50,-1)
|
wpadrivercombo.set_size_request(50,-1)
|
||||||
wpadrivers = [ "hostap","hermes","madwifi","atmel","wext","ndiswrapper","broadcom","ipw" ]
|
wpadrivers = [ "hostap","hermes","madwifi","atmel","wext","ndiswrapper","broadcom","ipw","ralink legacy" ]
|
||||||
i = 0
|
i = 0
|
||||||
found = False
|
found = False
|
||||||
for x in wpadrivers:
|
for x in wpadrivers:
|
||||||
@@ -892,6 +899,7 @@ class appGui:
|
|||||||
|
|
||||||
dialog.vbox.pack_start(wiredcheckbox)
|
dialog.vbox.pack_start(wiredcheckbox)
|
||||||
dialog.vbox.pack_start(reconnectcheckbox)
|
dialog.vbox.pack_start(reconnectcheckbox)
|
||||||
|
dialog.vbox.pack_start(debugmodecheckbox)
|
||||||
dialog.vbox.set_spacing(5)
|
dialog.vbox.set_spacing(5)
|
||||||
dialog.show_all()
|
dialog.show_all()
|
||||||
response = dialog.run()
|
response = dialog.run()
|
||||||
@@ -904,8 +912,7 @@ class appGui:
|
|||||||
daemon.SetWPADriver(wpadrivers[wpadrivercombo.get_active()])
|
daemon.SetWPADriver(wpadrivers[wpadrivercombo.get_active()])
|
||||||
wired.SetAlwaysShowWiredInterface(wiredcheckbox.get_active())
|
wired.SetAlwaysShowWiredInterface(wiredcheckbox.get_active())
|
||||||
wireless.SetAutoReconnect(reconnectcheckbox.get_active())
|
wireless.SetAutoReconnect(reconnectcheckbox.get_active())
|
||||||
print wiredcheckbox.get_active()
|
daemon.SetDebugMode(debugmodecheckbox.get_active())
|
||||||
print reconnectcheckbox.get_active()
|
|
||||||
dialog.destroy()
|
dialog.destroy()
|
||||||
else:
|
else:
|
||||||
dialog.destroy()
|
dialog.destroy()
|
||||||
@@ -944,9 +951,10 @@ class appGui:
|
|||||||
def update_statusbar(self):
|
def update_statusbar(self):
|
||||||
#should update the status bar
|
#should update the status bar
|
||||||
#every couple hundred milliseconds
|
#every couple hundred milliseconds
|
||||||
config.DisableLogging() #stop log file spam
|
if not daemon.GetDebugMode():
|
||||||
|
config.DisableLogging() #stop log file spam
|
||||||
wireless_ip = wireless.GetWirelessIP() #do this so that it doesn't lock up. don't know how or why this works
|
wireless_ip = wireless.GetWirelessIP() #do this so that it doesn't lock up. don't know how or why this works
|
||||||
#but it does so we leave it alone :)
|
#but it does so we leave it alone :)
|
||||||
wiredConnecting = wired.CheckIfWiredConnecting()
|
wiredConnecting = wired.CheckIfWiredConnecting()
|
||||||
wirelessConnecting = wireless.CheckIfWirelessConnecting()
|
wirelessConnecting = wireless.CheckIfWirelessConnecting()
|
||||||
if wirelessConnecting == True or wiredConnecting == True:
|
if wirelessConnecting == True or wiredConnecting == True:
|
||||||
@@ -974,16 +982,19 @@ class appGui:
|
|||||||
strength = str(strength)
|
strength = str(strength)
|
||||||
ip = str(wireless_ip)
|
ip = str(wireless_ip)
|
||||||
self.statusID=self.status_bar.push(1,language['connected_to_wireless'].replace('$A',network).replace('$B',strength).replace('$C',wireless_ip))
|
self.statusID=self.status_bar.push(1,language['connected_to_wireless'].replace('$A',network).replace('$B',strength).replace('$C',wireless_ip))
|
||||||
config.EnableLogging() #reenable logging
|
if not daemon.GetDebugMode():
|
||||||
|
config.EnableLogging()
|
||||||
return True
|
return True
|
||||||
wired_ip = wired.GetWiredIP()
|
wired_ip = wired.GetWiredIP()
|
||||||
if wired_ip:
|
if wired_ip:
|
||||||
if wired.GetAlwaysShowWiredInterface() or wired.CheckPluggedIn():
|
if wired.GetAlwaysShowWiredInterface() or wired.CheckPluggedIn():
|
||||||
self.statusID = self.status_bar.push(1,language['connected_to_wired'].replace('$A',wired_ip))
|
self.statusID = self.status_bar.push(1,language['connected_to_wired'].replace('$A',wired_ip))
|
||||||
config.EnableLogging() #reenable logging
|
if not daemon.GetDebugMode():
|
||||||
|
config.EnableLogging()
|
||||||
return True
|
return True
|
||||||
self.statusID = self.status_bar.push(1,language['not_connected'])
|
self.statusID = self.status_bar.push(1,language['not_connected'])
|
||||||
config.EnableLogging() #reenable logging
|
if not daemon.GetDebugMode():
|
||||||
|
config.EnableLogging()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def refresh_networks(self,widget=None,fresh=True,hidden=None):
|
def refresh_networks(self,widget=None,fresh=True,hidden=None):
|
||||||
|
|||||||
162
networking.py
162
networking.py
@@ -31,7 +31,6 @@ class Wireless:
|
|||||||
|
|
||||||
#Create a function to scan for wireless networks
|
#Create a function to scan for wireless networks
|
||||||
def Scan(self,essid=None):
|
def Scan(self,essid=None):
|
||||||
|
|
||||||
#we ask for an essid, because then we can see hidden networks
|
#we ask for an essid, because then we can see hidden networks
|
||||||
|
|
||||||
#####
|
#####
|
||||||
@@ -120,26 +119,47 @@ class Wireless:
|
|||||||
#since encryption needs a True or False
|
#since encryption needs a True or False
|
||||||
#we have to do a simple if then to set it
|
#we have to do a simple if then to set it
|
||||||
if misc.RunRegex(wep_pattern,cell) == "on":
|
if misc.RunRegex(wep_pattern,cell) == "on":
|
||||||
CurrentNetwork["encryption"] = True
|
if self.wpa_driver != 'ralink legacy':
|
||||||
#set this, because if it is something else this will be overwritten
|
CurrentNetwork["encryption"] = True
|
||||||
CurrentNetwork["encryption_method"] = "WEP"
|
#set this, because if it is something else this will be overwritten
|
||||||
|
CurrentNetwork["encryption_method"] = "WEP"
|
||||||
|
|
||||||
if misc.RunRegex(wpa1_pattern,cell) == "WPA Version 1":
|
if misc.RunRegex(wpa1_pattern,cell) == "WPA Version 1":
|
||||||
CurrentNetwork["encryption_method"] = "WPA"
|
CurrentNetwork["encryption_method"] = "WPA"
|
||||||
|
|
||||||
if misc.RunRegex(wpa2_pattern,cell) == "WPA2":
|
if misc.RunRegex(wpa2_pattern,cell) == "WPA2":
|
||||||
CurrentNetwork["encryption_method"] = "WPA2"
|
CurrentNetwork["encryption_method"] = "WPA2"
|
||||||
|
|
||||||
|
else: #support for ralink legacy drivers, may not work w/ hidden networks
|
||||||
|
iwpriv = misc.Run("iwpriv " + self.wireless_interface + " get_site_survey")
|
||||||
|
lines = iwpriv.splitlines()
|
||||||
|
lines = lines[2:]
|
||||||
|
for x in lines:
|
||||||
|
info = x.split()
|
||||||
|
if len(info) < 5 or info == None or info == '':
|
||||||
|
break;
|
||||||
|
if info[2] == CurrentNetwork["essid"]:
|
||||||
|
if info[5] == 'WEP' or info[5] == 'OPEN': # Needs to be tested
|
||||||
|
CurrentNetwork["encryption_method"] = 'WEP'
|
||||||
|
elif info[5] == 'WPA-PSK':
|
||||||
|
CurrentNetwork["encrytion_method"] = 'WPA'
|
||||||
|
elif info[5] == 'WPA2-PSK':
|
||||||
|
CurrentNetwork["encryption_method"] = 'WPA2'
|
||||||
|
else:
|
||||||
|
print 'Unknown AuthMode, can\'t assign encryption_method!!'
|
||||||
|
CurrentNetwork["encryption_method"] = 'Unknown'
|
||||||
|
CurrentNetwork["quality"] = info[1][1:] #set link strength here
|
||||||
else:
|
else:
|
||||||
CurrentNetwork["encryption"] = False
|
CurrentNetwork["encryption"] = False
|
||||||
#end If
|
#end If
|
||||||
|
|
||||||
#since stength needs a -1 if the quality isn't found
|
if self.wpa_driver != 'ralink legacy':
|
||||||
#we need a simple if then to set it
|
#since stength needs a -1 if the quality isn't found
|
||||||
if misc.RunRegex(strength_pattern,cell):
|
#we need a simple if then to set it
|
||||||
CurrentNetwork["quality"] = misc.RunRegex(strength_pattern,cell)
|
if misc.RunRegex(strength_pattern,cell):
|
||||||
else:
|
CurrentNetwork["quality"] = misc.RunRegex(strength_pattern,cell)
|
||||||
CurrentNetwork["quality"] = -1
|
else:
|
||||||
#end If
|
CurrentNetwork["quality"] = -1
|
||||||
|
|
||||||
#add this network to the list of networks
|
#add this network to the list of networks
|
||||||
aps[ i ] = CurrentNetwork
|
aps[ i ] = CurrentNetwork
|
||||||
@@ -210,6 +230,7 @@ class Wireless:
|
|||||||
self.IsConnecting = False
|
self.IsConnecting = False
|
||||||
self.before_script = before_script
|
self.before_script = before_script
|
||||||
self.after_script = after_script
|
self.after_script = after_script
|
||||||
|
|
||||||
self.lock.acquire()
|
self.lock.acquire()
|
||||||
self.ConnectingMessage = 'interface_down'
|
self.ConnectingMessage = 'interface_down'
|
||||||
self.lock.release()
|
self.lock.release()
|
||||||
@@ -259,14 +280,6 @@ class Wireless:
|
|||||||
misc.Run("ifconfig " + self.wired_interface + " 0.0.0.0")
|
misc.Run("ifconfig " + self.wired_interface + " 0.0.0.0")
|
||||||
misc.Run("ifconfig " + self.wireless_interface + " 0.0.0.0")
|
misc.Run("ifconfig " + self.wireless_interface + " 0.0.0.0")
|
||||||
|
|
||||||
#bring it up
|
|
||||||
print "interface up..."
|
|
||||||
self.lock.acquire()
|
|
||||||
self.ConnectingMessage = 'interface_up'
|
|
||||||
self.lock.release()
|
|
||||||
|
|
||||||
print misc.Run("ifconfig " + self.wireless_interface + " up")
|
|
||||||
|
|
||||||
print "killing wpa_supplicant, dhclient, dhclient3"
|
print "killing wpa_supplicant, dhclient, dhclient3"
|
||||||
self.lock.acquire()
|
self.lock.acquire()
|
||||||
self.ConnectingMessage = 'removing_old_connection'
|
self.ConnectingMessage = 'removing_old_connection'
|
||||||
@@ -275,29 +288,28 @@ class Wireless:
|
|||||||
misc.Run("killall dhclient dhclient3 wpa_supplicant")
|
misc.Run("killall dhclient dhclient3 wpa_supplicant")
|
||||||
|
|
||||||
#check to see if we need to generate a PSK
|
#check to see if we need to generate a PSK
|
||||||
|
if self.wpa_driver != "ralink legacy": # Enhanced Ralink legacy drivers are handled later
|
||||||
|
if not network.get('key')== None:
|
||||||
|
self.lock.acquire()
|
||||||
|
self.ConnectingMessage = 'generating_psk'
|
||||||
|
self.lock.release()
|
||||||
|
|
||||||
if not network.get('key')== None:
|
print "generating psk..."
|
||||||
self.lock.acquire()
|
key_pattern = re.compile('network={.*?\spsk=(.*?)\n}.*',re.DOTALL | re.I | re.M | re.S)
|
||||||
self.ConnectingMessage = 'generating_psk'
|
network["psk"] = misc.RunRegex(key_pattern,misc.Run('wpa_passphrase "' + network["essid"] + '" "' + network["key"] + '"'))
|
||||||
self.lock.release()
|
#generate the wpa_supplicant file...
|
||||||
|
if not network.get('enctype') == None:
|
||||||
|
self.lock.acquire()
|
||||||
|
self.ConnectingMessage = 'generating_wpa_config'
|
||||||
|
self.lock.release()
|
||||||
|
|
||||||
print "generating psk..."
|
print "generating wpa_supplicant configuration file..."
|
||||||
key_pattern = re.compile('network={.*?\spsk=(.*?)\n}.*',re.DOTALL | re.I | re.M | re.S)
|
misc.ParseEncryption(network)
|
||||||
network["psk"] = misc.RunRegex(key_pattern,misc.Run('wpa_passphrase "' + network["essid"] + '" "' + network["key"] + '"'))
|
print "wpa_supplicant -B -i " + self.wireless_interface + " -c \"encryption/configurations/" + network["bssid"].replace(":","").lower() + "\" -D " + self.wpa_driver
|
||||||
#generate the wpa_supplicant file...
|
misc.Run("wpa_supplicant -B -i " + self.wireless_interface + " -c \"encryption/configurations/" + network["bssid"].replace(":","").lower() + "\" -D " + self.wpa_driver)
|
||||||
if not network.get('enctype') == None:
|
|
||||||
self.lock.acquire()
|
|
||||||
self.ConnectingMessage = 'generating_wpa_config'
|
|
||||||
self.lock.release()
|
|
||||||
|
|
||||||
print "generating wpa_supplicant configuration file..."
|
|
||||||
misc.ParseEncryption(network)
|
|
||||||
print "wpa_supplicant -B -i " + self.wireless_interface + " -c \"encryption/configurations/" + network["bssid"].replace(":","").lower() + "\" -D " + self.wpa_driver
|
|
||||||
misc.Run("wpa_supplicant -B -i " + self.wireless_interface + " -c \"encryption/configurations/" + network["bssid"].replace(":","").lower() + "\" -D " + self.wpa_driver)
|
|
||||||
|
|
||||||
print "flushing the routing table..."
|
print "flushing the routing table..."
|
||||||
self.lock.acquire()
|
self.lock.acquire()
|
||||||
|
|
||||||
self.ConnectingMessage = 'flushing_routing_table'
|
self.ConnectingMessage = 'flushing_routing_table'
|
||||||
self.lock.release()
|
self.lock.release()
|
||||||
|
|
||||||
@@ -306,10 +318,17 @@ class Wireless:
|
|||||||
|
|
||||||
print "configuring the wireless interface..."
|
print "configuring the wireless interface..."
|
||||||
self.lock.acquire()
|
self.lock.acquire()
|
||||||
|
|
||||||
self.ConnectingMessage = 'configuring_interface'
|
self.ConnectingMessage = 'configuring_interface'
|
||||||
self.lock.release()
|
self.lock.release()
|
||||||
|
|
||||||
|
#bring it up
|
||||||
|
print "interface up..."
|
||||||
|
self.lock.acquire()
|
||||||
|
self.ConnectingMessage = 'interface_up'
|
||||||
|
self.lock.release()
|
||||||
|
|
||||||
|
print misc.Run("ifconfig " + self.wireless_interface + " up")
|
||||||
|
|
||||||
if network["mode"].lower() == "master":
|
if network["mode"].lower() == "master":
|
||||||
misc.Run("iwconfig " + self.wireless_interface + " mode managed")
|
misc.Run("iwconfig " + self.wireless_interface + " mode managed")
|
||||||
else:
|
else:
|
||||||
@@ -317,9 +336,46 @@ class Wireless:
|
|||||||
|
|
||||||
misc.Run("iwconfig " + self.wireless_interface + " essid \"" + network["essid"] + "\" channel " + str(network["channel"])) + " ap " + network["bssid"]
|
misc.Run("iwconfig " + self.wireless_interface + " essid \"" + network["essid"] + "\" channel " + str(network["channel"])) + " ap " + network["bssid"]
|
||||||
|
|
||||||
|
if self.wpa_driver == "ralink legacy": #Adds support for ralink cards that can't use wpasupplicant
|
||||||
|
if network.get('key') != None:
|
||||||
|
self.lock.acquire()
|
||||||
|
self.ConnectingMessage = 'setting_encryption_info'
|
||||||
|
self.lock.release()
|
||||||
|
|
||||||
|
print 'setting up ralink encryption'
|
||||||
|
iwpriv = misc.Run("iwpriv " + self.wireless_interface + " get_site_survey")
|
||||||
|
lines = iwpriv.splitlines()
|
||||||
|
lines = lines[2:]
|
||||||
|
for x in lines:
|
||||||
|
info = x.split()
|
||||||
|
if len(info) < 5 or info == None or info == '': #probably overkill, but the last 2 won't get run anyways
|
||||||
|
break;
|
||||||
|
if info[2] == network.get("essid"):
|
||||||
|
if info[5] == 'WEP' or info[5] == 'OPEN': # Needs to be tested
|
||||||
|
print 'setting up WEP'
|
||||||
|
misc.Run("iwconfig " + self.wireless_interface + " key " + network.get('key'))
|
||||||
|
elif info[5] == 'WPA-PSK':
|
||||||
|
print 'setting up WPA-PSK'
|
||||||
|
misc.Run("iwpriv " + self.wireless_interface + " set NetworkType=" + info[6])
|
||||||
|
misc.Run("iwpriv " + self.wireless_interface + " set AuthMode=WPAPSK")
|
||||||
|
misc.Run("iwpriv " + self.wireless_interface + " set EncrypType=" + info[4])
|
||||||
|
misc.Run("iwpriv " + self.wireless_interface + " set SSID=" + info[2])
|
||||||
|
misc.Run("iwpriv " + self.wireless_interface + " set WPAPSK=" + network.get('key'))
|
||||||
|
misc.Run("iwpriv " + self.wireless_interface + " set SSID=" + info[2])
|
||||||
|
elif info[5] == 'WPA2-PSK':
|
||||||
|
print 'setting up WPA2-PSK'
|
||||||
|
misc.Run("iwpriv " + self.wireless_interface + " set NetworkType=" + info[6])
|
||||||
|
misc.Run("iwpriv " + self.wireless_interface + " set AuthMode=WPA2PSK")
|
||||||
|
misc.Run("iwpriv " + self.wireless_interface + " set EncrypType=" + info[4])
|
||||||
|
misc.Run("iwpriv " + self.wireless_interface + " set SSID=" + info[2])
|
||||||
|
misc.Run("iwpriv " + self.wireless_interface + " set WPAPSK=" + network.get('key'))
|
||||||
|
misc.Run("iwpriv " + self.wireless_interface + " set SSID=" + info[2])
|
||||||
|
else:
|
||||||
|
print 'Unknown AuthMode, can\'t complete connection process!!!'
|
||||||
|
print "done setting encryption info"
|
||||||
|
|
||||||
if not network.get('broadcast') == None:
|
if not network.get('broadcast') == None:
|
||||||
self.lock.acquire()
|
self.lock.acquire()
|
||||||
|
|
||||||
self.ConnectingMessage = 'setting_broadcast_address'
|
self.ConnectingMessage = 'setting_broadcast_address'
|
||||||
self.lock.release()
|
self.lock.release()
|
||||||
|
|
||||||
@@ -327,6 +383,22 @@ class Wireless:
|
|||||||
misc.Run("ifconfig " + self.wireless_interface + " broadcast " + network["broadcast"])
|
misc.Run("ifconfig " + self.wireless_interface + " broadcast " + network["broadcast"])
|
||||||
|
|
||||||
|
|
||||||
|
<<<<<<< .mine
|
||||||
|
if not network.get("dns1") == None:
|
||||||
|
self.lock.acquire()
|
||||||
|
self.ConnectingMessage = 'setting_static_dns'
|
||||||
|
self.lock.release()
|
||||||
|
|
||||||
|
print "setting the first dns server...", network["dns1"]
|
||||||
|
resolv = open("/etc/resolv.conf","w")
|
||||||
|
misc.WriteLine(resolv,"nameserver " + network["dns1"])
|
||||||
|
if not network.get("dns2") == None:
|
||||||
|
print "setting the second dns server...", network["dns2"]
|
||||||
|
misc.WriteLine(resolv,"nameserver " + network["dns2"])
|
||||||
|
if not network.get("dns3") == None:
|
||||||
|
print "setting the third dns server..."
|
||||||
|
misc.WriteLine(resolv,"nameserver " + network["dns3"])
|
||||||
|
=======
|
||||||
if network.get('static_dns') == True and network.get('global_dns') == False:
|
if network.get('static_dns') == True and network.get('global_dns') == False:
|
||||||
if not network.get("dns1") == None:
|
if not network.get("dns1") == None:
|
||||||
self.lock.acquire()
|
self.lock.acquire()
|
||||||
@@ -355,10 +427,10 @@ class Wireless:
|
|||||||
if not self.global_dns_3 == None:
|
if not self.global_dns_3 == None:
|
||||||
print "setting the third dns server..."
|
print "setting the third dns server..."
|
||||||
misc.WriteLine(resolv,"nameserver " + self.global_dns_3)
|
misc.WriteLine(resolv,"nameserver " + self.global_dns_3)
|
||||||
|
>>>>>>> .r63
|
||||||
|
|
||||||
if not network.get('ip') == None:
|
if not network.get('ip') == None:
|
||||||
self.lock.acquire()
|
self.lock.acquire()
|
||||||
|
|
||||||
self.ConnectingMessage = 'setting_static_ip'
|
self.ConnectingMessage = 'setting_static_ip'
|
||||||
self.lock.release()
|
self.lock.release()
|
||||||
|
|
||||||
@@ -370,7 +442,6 @@ class Wireless:
|
|||||||
else:
|
else:
|
||||||
#run dhcp...
|
#run dhcp...
|
||||||
self.lock.acquire()
|
self.lock.acquire()
|
||||||
|
|
||||||
self.ConnectingMessage = 'running_dhcp'
|
self.ConnectingMessage = 'running_dhcp'
|
||||||
self.lock.release()
|
self.lock.release()
|
||||||
|
|
||||||
@@ -619,4 +690,3 @@ class Wired:
|
|||||||
print 'executing post connection script'
|
print 'executing post connection script'
|
||||||
misc.Run(after_script)
|
misc.Run(after_script)
|
||||||
#end function run
|
#end function run
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user