diff --git a/pyweb/mumble/MumbleCtlIce.py b/pyweb/mumble/MumbleCtlIce.py index 6ef8dcb..920417b 100644 --- a/pyweb/mumble/MumbleCtlIce.py +++ b/pyweb/mumble/MumbleCtlIce.py @@ -433,6 +433,15 @@ class MumbleCtlIce_120(MumbleCtlIce_118): userdata[key] = userdata[key].decode( "UTF-8" ) return userdata + @protectDjangoErrPage + def getState(self, srvid, sessionid): + userdata = self._getIceServerObject(srvid).getState(sessionid); + for key in userdata.__dict__: + attr = getattr( userdata, key ) + if isinstance( attr, str ): + setattr( userdata, key, attr.decode( "UTF-8" ) ) + return userdata + @protectDjangoErrPage def registerPlayer(self, srvid, name, email, password): # To get the real values of these ENUM entries, try @@ -513,6 +522,24 @@ class MumbleCtlIce_120(MumbleCtlIce_118): def setBans(self, srvid, bans): return self._getIceServerObject(srvid).setBans(bans); + @protectDjangoErrPage + def addBanForSession(self, srvid, sessionid, **kwargs): + session = self.getState(srvid, sessionid); + if "bits" not in kwargs: + kwargs["bits"] = 128; + return self.addBan(srvid, address=session.address, **kwargs); + + @protectDjangoErrPage + def addBan(self, srvid, **kwargs): + for key in kwargs: + if isinstance( kwargs[key], unicode ): + kwargs[key] = kwargs[key].encode("UTF-8") + + from Murmur import Ban + srvbans = self.getBans(srvid); + srvbans.append( Ban( **kwargs ) ); + return self.setBans(srvid, srvbans); + @protectDjangoErrPage def kickUser(self, srvid, userid, reason=""): return self._getIceServerObject(srvid).kickUser( userid, reason.encode("UTF-8") ); diff --git a/pyweb/mumble/models.py b/pyweb/mumble/models.py index c8d14aa..52666a5 100644 --- a/pyweb/mumble/models.py +++ b/pyweb/mumble/models.py @@ -474,6 +474,9 @@ class Mumble( models.Model ): def kickUser( self, sessionid, reason="" ): return self.ctl.kickUser( self.srvid, sessionid, reason ); + + def banUser( self, sessionid, reason="" ): + return self.ctl.addBanForSession( self.srvid, sessionid, reason=reason ); diff --git a/pyweb/mumble/views.py b/pyweb/mumble/views.py index fe525af..3122bcc 100644 --- a/pyweb/mumble/views.py +++ b/pyweb/mumble/views.py @@ -170,6 +170,8 @@ def show( request, server ): if request.method == 'POST' and 'mode' in request.POST and request.POST['mode'] == 'kick': kickform = MumbleKickForm( request.POST ); if kickform.is_valid(): + if kickform.cleaned_data["ban"]: + srv.banUser( kickform.cleaned_data['session'], kickform.cleaned_data['reason'] ); srv.kickUser( kickform.cleaned_data['session'], kickform.cleaned_data['reason'] ); # ChannelTable is a somewhat misleading name, as it actually contains channels and players.