1
0
mirror of https://github.com/gryf/wicd.git synced 2025-12-28 17:32:36 +01:00

merged dhcp-hostnames

This commit is contained in:
Adam Blackburn
2009-11-21 11:47:02 -06:00
8 changed files with 102 additions and 64 deletions

View File

@@ -307,7 +307,7 @@ class appGui(object):
dialog = gtk.AboutDialog()
dialog.set_name("Wicd")
dialog.set_version(daemon.Hello())
dialog.set_authors([ "Adam Blackburn", "Dan O'Reilly" ])
dialog.set_authors([ "Adam Blackburn", "Dan O'Reilly", "Andrew Psaltis" ])
dialog.set_website("http://wicd.sourceforge.net")
dialog.run()
dialog.destroy()

View File

@@ -8,6 +8,7 @@ contained within them.
#
# Copyright (C) 2008-2009 Adam Blackburn
# Copyright (C) 2008-2009 Dan O'Reilly
# Copyright (C) 2009 Andrew Psaltis
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License Version 2 as
@@ -73,6 +74,7 @@ class AdvancedSettingsDialog(gtk.Dialog):
self.txt_dns_1 = LabelEntry(language['dns'] + ' 1')
self.txt_dns_2 = LabelEntry(language['dns'] + ' 2')
self.txt_dns_3 = LabelEntry(language['dns'] + ' 3')
self.txt_dhcp_hostname = LabelEntry("DHCP Hostname")
self.chkbox_static_ip = gtk.CheckButton(language['use_static_ip'])
self.chkbox_static_dns = gtk.CheckButton(language['use_static_dns'])
self.chkbox_global_dns = gtk.CheckButton(language['use_global_dns'])
@@ -104,6 +106,7 @@ class AdvancedSettingsDialog(gtk.Dialog):
self.vbox.pack_start(self.txt_dns_1, fill=False, expand=False)
self.vbox.pack_start(self.txt_dns_2, fill=False, expand=False)
self.vbox.pack_start(self.txt_dns_3, fill=False, expand=False)
self.vbox.pack_start(self.txt_dhcp_hostname, fill=False, expand=False)
self.vbox.pack_end(self.button_hbox, fill=False, expand=False, padding=5)
@@ -238,6 +241,7 @@ class AdvancedSettingsDialog(gtk.Dialog):
self.set_net_prop("dns1", '')
self.set_net_prop("dns2", '')
self.set_net_prop("dns3", '')
self.set_net_prop("dhcphostname",noneToString(self.txt_dhcp_hostname.get_text()))
class WiredSettingsDialog(AdvancedSettingsDialog):
@@ -279,6 +283,12 @@ class WiredSettingsDialog(AdvancedSettingsDialog):
self.txt_domain.set_text(self.format_entry("dns_domain"))
self.txt_search_dom.set_text(self.format_entry("search_domain"))
self.chkbox_global_dns.set_active(bool(wired.GetWiredProperty("use_global_dns")))
dhcphname = wired.GetWiredProperty("dhcphostname")
if dhcphname is None:
dhcphname = os.uname()[1]
self.txt_dhcp_hostname.set_text(dhcphname)
self.reset_static_checkboxes()
def save_settings(self):
@@ -395,6 +405,11 @@ class WirelessSettingsDialog(AdvancedSettingsDialog):
self.chkbox_global_settings.set_active(bool(wireless.GetWirelessProperty(networkID,
'use_settings_globally')))
dhcphname = wireless.GetWirelessProperty(networkID,"dhcphostname")
if dhcphname is None:
dhcphname = os.uname()[1]
self.txt_dhcp_hostname.set_text(dhcphname)
activeID = -1 # Set the menu to this item when we are done
user_enctype = wireless.GetWirelessProperty(networkID, "enctype")
for x, enc_type in enumerate(self.encrypt_types):

View File

@@ -22,6 +22,7 @@ class WiredConnectThread() -- Connection thread for wired
# Copyright (C) 2007 - 2009 Adam Blackburn
# Copyright (C) 2007 - 2009 Dan O'Reilly
# Copyright (C) 2007 - 2009 Byron Hillis
# Copyright (C) 2009 Andrew Psaltis
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License Version 2 as
@@ -290,7 +291,8 @@ class ConnectThread(threading.Thread):
def __init__(self, network, interface_name, before_script, after_script,
pre_disconnect_script, post_disconnect_script, gdns1,
gdns2, gdns3, gdns_dom, gsearch_dom, iface, debug):
gdns2, gdns3, gdns_dom, gsearch_dom, iface,
debug):
""" Initialise the required object variables and the thread.
Keyword arguments:
@@ -325,7 +327,7 @@ class ConnectThread(threading.Thread):
self.global_dns_3 = gdns3
self.global_dns_dom = gdns_dom
self.global_search_dom = gsearch_dom
self.iface = iface
self.connecting_message = None
@@ -446,8 +448,8 @@ class ConnectThread(threading.Thread):
else:
# Run dhcp...
self.SetStatus('running_dhcp')
print "Running DHCP"
dhcp_status = iface.StartDHCP()
print "Running DHCP with hostname",self.network["dhcphostname"]
dhcp_status = iface.StartDHCP(self.network["dhcphostname"])
if dhcp_status in ['no_dhcp_offers', 'dhcp_failed']:
if self.connect_result != "aborted":
self.abort_connection(dhcp_status)
@@ -1059,7 +1061,8 @@ class WiredConnectThread(ConnectThread):
ConnectThread.__init__(self, network, wired, before_script,
after_script, pre_disconnect_script,
post_disconnect_script, gdns1, gdns2,
gdns3, gdns_dom, gsearch_dom, liface, debug)
gdns3, gdns_dom, gsearch_dom, liface,
debug)
def _connect(self):
""" The main function of the connection thread.

View File

@@ -18,6 +18,7 @@ class WirelessDaemon() -- DBus interface to managed the wireless network.
# Copyright (C) 2007 - 2009 Adam Blackburn
# Copyright (C) 2007 - 2009 Dan O'Reilly
# Copyright (C) 2007 - 2009 Byron Hillis
# Copyright (C) 2009 Andrew Psaltis
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License Version 2 as
@@ -1459,6 +1460,7 @@ class WiredDaemon(dbus.service.Object):
"postdisconnectscript"]:
self.config.set(profilename, option, None)
self.config.set(profilename, "default", default)
self.config.set(profilename,"dhcphostname",os.uname()[1])
self.config.write()
return True

View File

@@ -16,6 +16,7 @@ class BaseWirelessInterface() -- Control a wireless network interface.
# Copyright (C) 2007 - 2009 Adam Blackburn
# Copyright (C) 2007 - 2009 Dan O'Reilly
# Copyright (C) 2007 - 2009 Byron Hillis
# Copyright (C) 2009 Andrew Psaltis
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License Version 2 as
@@ -241,7 +242,7 @@ class BaseInterface(object):
return path
def _get_dhcp_command(self, flavor=None):
def _get_dhcp_command(self, flavor=None, hostname=None):
""" Returns the correct DHCP client command.
Given a type of DHCP request (create or release a lease),
@@ -277,17 +278,17 @@ class BaseInterface(object):
'id' : misc.DHCLIENT,
},
"pump" :
{ 'connect' : r"%(cmd)s -i %(iface)s",
{ 'connect' : r"%(cmd)s -i %(iface)s -h %(hostname)s",
'release' : r"%(cmd)s -r -i %(iface)s",
'id' : misc.PUMP,
},
"dhcpcd" :
{'connect' : r"%(cmd)s %(iface)s",
{'connect' : r"%(cmd)s %(iface)s -h %(hostname)s ",
'release' : r"%(cmd)s -k %(iface)s",
'id' : misc.DHCPCD,
},
"udhcpc":
{'connect' : r"%(cmd)s -n -i %(iface)s",
{'connect' : r"%(cmd)s -n -i %(iface)s -H %(hostname)s ",
'release' : r"killall -SIGUSR2 %(cmd)s",
'id' : misc.UDHCPC,
},
@@ -298,7 +299,7 @@ class BaseInterface(object):
return ""
if flavor == "connect":
return client_dict[client_name]['connect'] % {"cmd":cmd, "iface":self.iface}
return client_dict[client_name]['connect'] % {"cmd":cmd, "iface":self.iface, "hostname":hostname}
elif flavor == "release":
return client_dict[client_name]['release'] % {"cmd":cmd, "iface":self.iface}
else:
@@ -549,7 +550,7 @@ class BaseInterface(object):
return 'dhcp_failed'
@neediface(False)
def StartDHCP(self):
def StartDHCP(self,hostname):
""" Start the DHCP client to obtain an IP address.
Returns:
@@ -557,7 +558,7 @@ class BaseInterface(object):
_check_dhcp_result for the possible values.
"""
cmd = self._get_dhcp_command('connect')
cmd = self._get_dhcp_command('connect',hostname)
if self.verbose: print cmd
self.dhcp_object = misc.Run(cmd, include_stderr=True, return_obj=True)
pipe = self.dhcp_object.stdout