|
@ -15,7 +15,7 @@ |
|
|
* GNU General Public License for more details. |
|
|
* GNU General Public License for more details. |
|
|
""" |
|
|
""" |
|
|
|
|
|
|
|
|
import socket, Ice, re |
|
|
|
|
|
|
|
|
import Ice, re |
|
|
from sys import stderr |
|
|
from sys import stderr |
|
|
from urllib import urlopen |
|
|
from urllib import urlopen |
|
|
from StringIO import StringIO |
|
|
from StringIO import StringIO |
|
@ -31,23 +31,6 @@ from mumble.mmobjects import mmChannel, mmPlayer |
|
|
from mumble.mctl import MumbleCtlBase |
|
|
from mumble.mctl import MumbleCtlBase |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_ipv46_host_by_name( hostname ): |
|
|
|
|
|
""" Resolve the given hostname and return both its IPv4 and IPv6 address, |
|
|
|
|
|
if applicable. Returns: { AF_INET: inet4address, AF_INET6: inet6address }. |
|
|
|
|
|
For addresses that don't exist, the corresponding field will be None. |
|
|
|
|
|
""" |
|
|
|
|
|
addrinfo = socket.getaddrinfo( hostname, settings.MUMBLE_DEFAULT_PORT, 0, socket.SOCK_DGRAM ) |
|
|
|
|
|
ret = {} |
|
|
|
|
|
for (family, socktype, proto, canonname, sockaddr) in addrinfo: |
|
|
|
|
|
if family not in ret: |
|
|
|
|
|
ret[family] = sockaddr[0] |
|
|
|
|
|
return ret |
|
|
|
|
|
|
|
|
|
|
|
def get_ipv46_str_by_name( hostname, sep=" " ): |
|
|
|
|
|
""" Return a space-separated string of all addresses the given hostname resolves to. """ |
|
|
|
|
|
return sep.join( get_ipv46_host_by_name( hostname ).values() ) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def mk_config_property( field, doc="", get_coerce=None, get_none=None, set_coerce=unicode, set_none='' ): |
|
|
def mk_config_property( field, doc="", get_coerce=None, get_none=None, set_coerce=unicode, set_none='' ): |
|
|
""" Create a property for the given config field. """ |
|
|
""" Create a property for the given config field. """ |
|
|
|
|
|
|
|
@ -283,11 +266,7 @@ class Mumble( models.Model ): |
|
|
self.ctl.setConf( self.srvid, 'registername', self.name ) |
|
|
self.ctl.setConf( self.srvid, 'registername', self.name ) |
|
|
|
|
|
|
|
|
if self.addr: |
|
|
if self.addr: |
|
|
if " " in self.addr: |
|
|
|
|
|
# user gave multiple addresses, don't mess with that |
|
|
|
|
|
self.ctl.setConf( self.srvid, 'host', self.addr ) |
|
|
self.ctl.setConf( self.srvid, 'host', self.addr ) |
|
|
else: |
|
|
|
|
|
self.ctl.setConf( self.srvid, 'host', get_ipv46_str_by_name(self.addr) ) |
|
|
|
|
|
else: |
|
|
else: |
|
|
self.ctl.setConf( self.srvid, 'host', '' ) |
|
|
self.ctl.setConf( self.srvid, 'host', '' ) |
|
|
|
|
|
|
|
@ -338,47 +317,22 @@ class Mumble( models.Model ): |
|
|
else: |
|
|
else: |
|
|
self.name = conf["registername"] |
|
|
self.name = conf["registername"] |
|
|
|
|
|
|
|
|
if "registerhostname" in conf and conf["registerhostname"]: |
|
|
|
|
|
if ':' in conf["registerhostname"]: |
|
|
|
|
|
regname, regport = conf["registerhostname"].split(':') |
|
|
|
|
|
regport = int(regport) |
|
|
|
|
|
|
|
|
if "host" in conf: |
|
|
|
|
|
self.addr = conf["host"] |
|
|
else: |
|
|
else: |
|
|
regname = conf["registerhostname"] |
|
|
|
|
|
regport = None |
|
|
|
|
|
else: |
|
|
|
|
|
regname = None |
|
|
|
|
|
regport = None |
|
|
|
|
|
|
|
|
|
|
|
if "host" in conf and conf["host"]: |
|
|
|
|
|
addr = conf["host"] |
|
|
|
|
|
else: |
|
|
|
|
|
addr = None |
|
|
|
|
|
|
|
|
self.addr = "" |
|
|
|
|
|
|
|
|
if "port" in conf and conf["port"]: |
|
|
|
|
|
|
|
|
if "port" in conf: |
|
|
self.port = int(conf["port"]) |
|
|
self.port = int(conf["port"]) |
|
|
else: |
|
|
else: |
|
|
self.port = None |
|
|
self.port = None |
|
|
|
|
|
|
|
|
if regname and addr: |
|
|
|
|
|
if regport == self.port: |
|
|
|
|
|
if get_ipv46_str_by_name(regname) == get_ipv46_str_by_name(addr): |
|
|
|
|
|
self.display = '' |
|
|
|
|
|
self.addr = regname |
|
|
|
|
|
else: |
|
|
|
|
|
self.display = regname |
|
|
|
|
|
self.addr = addr |
|
|
|
|
|
else: |
|
|
|
|
|
|
|
|
if "registerhostname" in conf and conf["registerhostname"] != self.addr: |
|
|
self.display = conf["registerhostname"] |
|
|
self.display = conf["registerhostname"] |
|
|
self.addr = addr |
|
|
|
|
|
elif regname and not addr: |
|
|
|
|
|
self.display = regname |
|
|
|
|
|
self.addr = '' |
|
|
|
|
|
elif addr and not regname: |
|
|
|
|
|
self.display = '' |
|
|
|
|
|
self.addr = addr |
|
|
|
|
|
|
|
|
if ' ' in self.addr and self.display == self.addr.split(' ')[0]: |
|
|
|
|
|
self.display = "" |
|
|
else: |
|
|
else: |
|
|
self.display = '' |
|
|
|
|
|
self.addr = '' |
|
|
|
|
|
|
|
|
self.display = "" |
|
|
|
|
|
|
|
|
self.save( dontConfigureMurmur=True ) |
|
|
self.save( dontConfigureMurmur=True ) |
|
|
|
|
|
|
|
|