Browse Source

add Ice secret and display address fields. (this means mumble-django-nat is now integrated in the main branch.)

Natenom/support-murmur-13-1446181288462
Michael Ziegler 15 years ago
parent
commit
6e95ecd191
  1. 65
      pyweb/mumble/models.py

65
pyweb/mumble/models.py

@ -36,7 +36,7 @@ def mk_config_property( field, doc="" ):
return None
def set_field( self, value ):
self.setConf( field, value )
self.setConf( field, str(value) )
return property( get_field, set_field, doc=doc )
@ -65,7 +65,11 @@ class Mumble( models.Model ):
"global server list.") );
port = models.IntegerField( _('Server Port'), default=settings.MUMBLE_DEFAULT_PORT, help_text=_(
"Port number to bind to. Use -1 to auto assign one.") );
display = models.CharField( _('Server Display Address'), max_length=200, blank=True, help_text=_(
"This field is only relevant if you are located behind a NAT, and names the Hostname or IP address "
"to use in the Channel Viewer and for the global server list registration. If not given, the addr "
"and port fields are used. If display and bind ports are equal, you can omit it here.") );
secret = models.CharField( _('Ice Secret'), max_length=200, blank=True );
supw = property( lambda self: '',
lambda self, value: self.ctl.setSuperUserPassword( self.srvid, value ),
@ -140,23 +144,7 @@ class Mumble( models.Model ):
self.ctl.setConf( self.srvid, 'host', socket.gethostbyname(self.addr) );
self.ctl.setConf( self.srvid, 'port', str(self.port) );
self.ctl.setConf( self.srvid, 'registername', self.name );
self.ctl.setConf( self.srvid, 'registerurl', self.url );
# registerHostname needs to take the port no into account
if self.port and self.port != settings.MUMBLE_DEFAULT_PORT:
self.ctl.setConf( self.srvid, 'registerhostname', "%s:%d" % ( self.addr, self.port ) );
else:
self.ctl.setConf( self.srvid, 'registerhostname', self.addr );
if self.supw:
self.ctl.setSuperUserPassword( self.srvid, self.supw );
self.supw = '';
if self.booted != self.ctl.isBooted( self.srvid ):
if self.booted:
self.ctl.start( self.srvid );
else:
self.ctl.stop( self.srvid );
self.ctl.setConf( self.srvid, 'registerhostname', self.netloc );
# Now allow django to save the record set
return models.Model.save( self );
@ -355,20 +343,37 @@ class Mumble( models.Model ):
channels = property( getChannels, doc="A convenience wrapper for getChannels()." );
rootchan = property( lambda self: self.channels[0], doc="A convenience wrapper for getChannels()[0]." );
def getURL( self, forUser = None ):
""" Create an URL of the form mumble://username@host:port/ for this server. """
userstr = "";
if forUser is not None:
userstr = "%s@" % forUser.name;
def getNetloc( self ):
""" Return the address from the Display field (if any), or the server address.
Users from outside a NAT will need to use the Display address to connect
to this server instance.
"""
if self.display:
if ":" in self.display:
return self.display;
else:
daddr = self.display;
else:
daddr = self.addr;
versionstr = "version=%d.%d.%d" % tuple(self.version[0:3]);
if self.port and self.port != settings.MUMBLE_DEFAULT_PORT:
return "%s:%d" % (daddr, self.port);
else:
return daddr;
if self.port != settings.MUMBLE_DEFAULT_PORT:
return "mumble://%s%s:%d/?%s" % ( userstr, self.addr, self.port, versionstr );
netloc = property( getNetloc, doc=getNetloc.__doc__ );
return "mumble://%s%s/?%s" % ( userstr, self.addr, versionstr );
def getURL( self, forUser = None ):
""" Create an URL of the form mumble://username@host:port/ for this server. """
from urlparse import urlunsplit
versionstr = "version=%d.%d.%d" % tuple(self.version[:3]);
if forUser is not None:
netloc = "%s@%s" % ( forUser.name, self.netloc );
return urlunsplit(( "mumble", netloc, "", versionstr, "" ))
else:
return urlunsplit(( "mumble", self.netloc, "", versionstr, "" ))
connecturl = property( getURL, doc="A convenience wrapper for getURL()." );
connecturl = property( getURL, doc=getURL.__doc__ );
version = property( lambda self: self.ctl.getVersion(), doc="The version of Murmur." );
@ -472,7 +477,7 @@ class MumbleUser( models.Model ):
self.server.rootchan.acl.save();
return value;
aclAdmin = property( getAdmin, setAdmin, doc="Wrapper around getAdmin/setAdmin (not a database field like isAdmin)" );
aclAdmin = property( getAdmin, setAdmin, doc='Admin on root channel' );
# Registration fetching
def getRegistration( self ):

Loading…
Cancel
Save