Skip to content

Commit

Permalink
Merge PR #25: fix: rename Murmur to MumbleServer
Browse files Browse the repository at this point in the history
Mumble 1.5 renames the slice definitions from the old server name `Murmur` to *Mumble Server*. The generated python bindings get adjusted to the new module name.
  • Loading branch information
Kissaki authored Jul 13, 2023
2 parents 43563cc + 21164e1 commit cad539b
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions mumo.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,11 @@ def do_main_program():
fsload_slice(cfg.ice.slice)

# noinspection PyUnresolvedReferences
import Murmur
try:
import MumbleServer
except ModuleNotFoundError:
# Try to import Mumble <1.5 name `Murmur` instead
import Murmur as MumbleServer

class mumoIceApp(Ice.Application):
def __init__(self, manager):
Expand Down Expand Up @@ -200,7 +204,7 @@ def initializeIceConnection(self):

info('Connecting to Ice server (%s:%d)', cfg.ice.host, cfg.ice.port)
base = ice.stringToProxy(prxstr)
self.meta = Murmur.MetaPrx.uncheckedCast(base)
self.meta = MumbleServer.MetaPrx.uncheckedCast(base)

if cfg.ice.callback_port > 0:
cbp = ' -p %d' % cfg.ice.callback_port
Expand All @@ -214,7 +218,7 @@ def initializeIceConnection(self):
self.manager.setClientAdapter(adapter)

metacbprx = adapter.addWithUUID(metaCallback(self))
self.metacb = Murmur.MetaCallbackPrx.uncheckedCast(metacbprx)
self.metacb = MumbleServer.MetaCallbackPrx.uncheckedCast(metacbprx)

return self.attachCallbacks()

Expand All @@ -234,15 +238,15 @@ def attachCallbacks(self):
if not cfg.murmur.servers or sid in cfg.murmur.servers:
info('Setting callbacks for virtual server %d', sid)
servercbprx = self.adapter.addWithUUID(serverCallback(self.manager, server, sid))
servercb = Murmur.ServerCallbackPrx.uncheckedCast(servercbprx)
servercb = MumbleServer.ServerCallbackPrx.uncheckedCast(servercbprx)
server.addCallback(servercb)

except (Murmur.InvalidSecretException, Ice.UnknownUserException, Ice.ConnectionRefusedException) as e:
except (MumbleServer.InvalidSecretException, Ice.UnknownUserException, Ice.ConnectionRefusedException) as e:
if isinstance(e, Ice.ConnectionRefusedException):
error('Server refused connection')
elif isinstance(e, Murmur.InvalidSecretException) or \
elif isinstance(e, MumbleServer.InvalidSecretException) or \
isinstance(e, Ice.UnknownUserException) and (
e.unknown == 'Murmur::InvalidSecretException'):
e.unknown == 'MumbleServer::InvalidSecretException'):
error('Invalid ice secret')
else:
# We do not actually want to handle this one, re-raise it
Expand Down Expand Up @@ -300,7 +304,7 @@ def newfunc(*args, **kws):

if not current or 'secret' not in current.ctx or current.ctx['secret'] != cfg.ice.secret:
error('Server transmitted invalid secret. Possible injection attempt.')
raise Murmur.InvalidSecretException()
raise MumbleServer.InvalidSecretException()

return func(*args, **kws)

Expand Down Expand Up @@ -337,9 +341,9 @@ def newfunc(*args, **kws):

return newdec

class metaCallback(Murmur.MetaCallback):
class metaCallback(MumbleServer.MetaCallback):
def __init__(self, app):
Murmur.MetaCallback.__init__(self)
MumbleServer.MetaCallback.__init__(self)
self.app = app

@fortifyIceFu()
Expand All @@ -354,12 +358,12 @@ def started(self, server, current=None):
info('Setting callbacks for virtual server %d', server.id())
try:
servercbprx = self.app.adapter.addWithUUID(serverCallback(self.app.manager, server, sid))
servercb = Murmur.ServerCallbackPrx.uncheckedCast(servercbprx)
servercb = MumbleServer.ServerCallbackPrx.uncheckedCast(servercbprx)
server.addCallback(servercb)

# Apparently this server was restarted without us noticing
except (Murmur.InvalidSecretException, Ice.UnknownUserException) as e:
if hasattr(e, "unknown") and e.unknown != "Murmur::InvalidSecretException":
except (MumbleServer.InvalidSecretException, Ice.UnknownUserException) as e:
if hasattr(e, "unknown") and e.unknown != "MumbleServer::InvalidSecretException":
# Special handling for Murmur 1.2.2 servers with invalid slice files
raise e

Expand Down Expand Up @@ -399,9 +403,9 @@ def new_fu(self, *args, **kwargs):

return new_fu

class serverCallback(Murmur.ServerCallback):
class serverCallback(MumbleServer.ServerCallback):
def __init__(self, manager, server, sid):
Murmur.ServerCallback.__init__(self)
MumbleServer.ServerCallback.__init__(self)
self.manager = manager
self.sid = sid
self.server = server
Expand Down Expand Up @@ -441,9 +445,9 @@ def channelStateChanged(self, c, current=None): pass
@forwardServer
def userTextMessage(self, u, m, current=None): pass

class customContextCallback(Murmur.ServerContextCallback):
class customContextCallback(MumbleServer.ServerContextCallback):
def __init__(self, contextActionCallback, *ctx):
Murmur.ServerContextCallback.__init__(self)
MumbleServer.ServerContextCallback.__init__(self)
self.cb = contextActionCallback
self.ctx = ctx

Expand All @@ -457,7 +461,7 @@ def contextAction(self, *args, **argv):
#
info('Starting mumble moderator')
debug('Initializing manager')
manager = MumoManager(Murmur, customContextCallback)
manager = MumoManager(MumbleServer, customContextCallback)
manager.start()
manager.loadModules()
manager.startModules()
Expand Down

0 comments on commit cad539b

Please sign in to comment.