cvoip-init
This commit is contained in:
parent
8bf16e2b7a
commit
46e7837346
51
CVoipAuth.ini
Normal file
51
CVoipAuth.ini
Normal file
@ -0,0 +1,51 @@
|
||||
;Database configuration
|
||||
[database]
|
||||
;Only tested with MySQL at the moment
|
||||
lib = MySQLdb
|
||||
name = smf
|
||||
user = smf
|
||||
password = secret
|
||||
prefix = smf_
|
||||
host = 127.0.0.1
|
||||
port = 3306
|
||||
|
||||
;Django configuration
|
||||
[django]
|
||||
;If true, the authenticator will use Django to handle user authentication instead of the database
|
||||
enabled = True
|
||||
;The path to the Django project
|
||||
project = /home/xdreamist/Developer/Zeroc Ice/CVoipPanel
|
||||
;project = /path/to/your/django/project
|
||||
;The Django settings module to use
|
||||
settings = CVoipPanel.settings
|
||||
|
||||
;Player configuration
|
||||
[user]
|
||||
;If you do not already know what it is just leave it as it is
|
||||
id_offset = 1000000000
|
||||
;If enabled avatars are automatically set as user avatars
|
||||
avatar_enable = False
|
||||
;Reject users if the authenticator experiences an internal error during authentication
|
||||
reject_on_error = True
|
||||
|
||||
;Ice configuration
|
||||
[ice]
|
||||
host = 127.0.0.1
|
||||
port = 6502
|
||||
slice = MumbleServer.ice
|
||||
secret = secret
|
||||
watchdog = 30
|
||||
|
||||
;Murmur configuration
|
||||
[murmur]
|
||||
;List of virtual server IDs, empty = all
|
||||
servers =
|
||||
|
||||
;Logging configuration
|
||||
[log]
|
||||
; Available loglevels: 10 = DEBUG (default) | 20 = INFO | 30 = WARNING | 40 = ERROR
|
||||
level =
|
||||
file = CVoipAuth.log
|
||||
|
||||
[iceraw]
|
||||
Ice.ThreadPool.Server.Size = 5
|
||||
892
CVoipAuth.py
Normal file
892
CVoipAuth.py
Normal file
@ -0,0 +1,892 @@
|
||||
import sys
|
||||
import Ice
|
||||
import _thread
|
||||
import urllib.request, urllib.error, urllib.parse
|
||||
import logging
|
||||
import configparser
|
||||
import bcrypt
|
||||
|
||||
from threading import Timer
|
||||
from optparse import OptionParser
|
||||
from logging import (debug,
|
||||
info,
|
||||
warning,
|
||||
error,
|
||||
critical,
|
||||
exception,
|
||||
getLogger)
|
||||
|
||||
from hashlib import sha1
|
||||
|
||||
def x2bool(s):
|
||||
"""Helper function to convert strings from the config to bool"""
|
||||
if isinstance(s, bool):
|
||||
return s
|
||||
elif isinstance(s, str):
|
||||
return s.lower() in ['1', 'true']
|
||||
raise ValueError()
|
||||
|
||||
#
|
||||
#--- Default configuration values
|
||||
#
|
||||
cfgfile = 'CVoipAuth.ini'
|
||||
default = {'database':(('lib', str, 'MySQLdb'),
|
||||
('password', str, 'secret'),
|
||||
('host', str, '127.0.0.1'),
|
||||
('port', int, 3306)),
|
||||
|
||||
'django':(('enabled', x2bool, False),
|
||||
('project', str, 'CVoipPanel'),
|
||||
('settings', str, 'CVoipPanel.settings')),
|
||||
|
||||
'user':(('id_offset', int, 1000000000),
|
||||
('avatar_enable', x2bool, False),
|
||||
('reject_on_error', x2bool, True)),
|
||||
|
||||
'ice':(('host', str, '127.0.0.1'),
|
||||
('port', int, 6502),
|
||||
('slice', str, 'MumbleServer.ice'),
|
||||
('secret', str, ''),
|
||||
('watchdog', int, 30)),
|
||||
|
||||
'iceraw':None,
|
||||
|
||||
'murmur':(('servers', lambda x:list(map(int, x.split(','))), []),),
|
||||
'glacier':(('enabled', x2bool, False),
|
||||
('user', str, 'CVoipAuth'),
|
||||
('password', str, 'secret'),
|
||||
('host', str, 'localhost'),
|
||||
('port', int, '4063')),
|
||||
|
||||
'log':(('level', int, logging.DEBUG),
|
||||
('file', str, 'CVoipAuth.log'))}
|
||||
|
||||
#
|
||||
#--- Helper classes
|
||||
#
|
||||
class config(object):
|
||||
"""
|
||||
Small abstraction for config loading
|
||||
"""
|
||||
|
||||
def __init__(self, filename = None, default = None):
|
||||
if not filename or not default: return
|
||||
cfg = configparser.ConfigParser()
|
||||
cfg.optionxform = str
|
||||
cfg.read(filename)
|
||||
|
||||
for h,v in default.items():
|
||||
if not v:
|
||||
# Output this whole section as a list of raw key/value tuples
|
||||
try:
|
||||
self.__dict__[h] = cfg.items(h)
|
||||
except configparser.NoSectionError:
|
||||
self.__dict__[h] = []
|
||||
else:
|
||||
self.__dict__[h] = config()
|
||||
for name, conv, vdefault in v:
|
||||
try:
|
||||
self.__dict__[h].__dict__[name] = conv(cfg.get(h, name))
|
||||
except (ValueError, configparser.NoSectionError, configparser.NoOptionError):
|
||||
self.__dict__[h].__dict__[name] = vdefault
|
||||
|
||||
def entity_decode(string):
|
||||
"""
|
||||
Python reverse implementation of php htmlspecialchars
|
||||
"""
|
||||
htmlspecialchars = (('"', '"'),
|
||||
("'", '''),
|
||||
('<', '<'),
|
||||
('>', '>'),
|
||||
('&', '&'))
|
||||
ret = string
|
||||
for (s,t) in htmlspecialchars:
|
||||
ret = ret.replace(t, s)
|
||||
return ret
|
||||
|
||||
def entity_encode(string):
|
||||
"""
|
||||
Python implementation of htmlspecialchars
|
||||
"""
|
||||
htmlspecialchars = (('&', '&'),
|
||||
('"', '"'),
|
||||
("'", '''),
|
||||
('<', '<'),
|
||||
('>', '>'))
|
||||
ret = string
|
||||
for (s,t) in htmlspecialchars:
|
||||
ret = ret.replace(s, t)
|
||||
return ret
|
||||
|
||||
class threadDbException(Exception): pass
|
||||
class threadDB(object):
|
||||
"""
|
||||
Small abstraction to handle database connections for multiple
|
||||
threads
|
||||
"""
|
||||
|
||||
db_connections = {}
|
||||
|
||||
def connection(cls):
|
||||
tid = _thread.get_ident()
|
||||
try:
|
||||
con = cls.db_connections[tid]
|
||||
except:
|
||||
info('Connecting to database server (%s %s:%d %s) for thread %d',
|
||||
cfg.database.lib, cfg.database.host, cfg.database.port, cfg.database.name, tid)
|
||||
|
||||
try:
|
||||
con = db.connect(host = cfg.database.host,
|
||||
port = cfg.database.port,
|
||||
user = cfg.database.user,
|
||||
passwd = cfg.database.password,
|
||||
db = cfg.database.name,
|
||||
charset = 'utf8')
|
||||
# Transactional engines like InnoDB initiate a transaction even
|
||||
# on SELECTs-only. Thus, we auto-commit so smfauth gets recent data.
|
||||
con.autocommit(True)
|
||||
except db.Error as e:
|
||||
error('Could not connect to database: %s', str(e))
|
||||
raise threadDbException()
|
||||
cls.db_connections[tid] = con
|
||||
return con
|
||||
connection = classmethod(connection)
|
||||
|
||||
def cursor(cls):
|
||||
return cls.connection().cursor()
|
||||
cursor = classmethod(cursor)
|
||||
|
||||
def execute(cls, *args, **kwargs):
|
||||
if "threadDB__retry_execution__" in kwargs:
|
||||
# Have a magic keyword so we can call ourselves while preventing
|
||||
# an infinite loop
|
||||
del kwargs["threadDB__retry_execution__"]
|
||||
retry = False
|
||||
else:
|
||||
retry = True
|
||||
|
||||
c = cls.cursor()
|
||||
try:
|
||||
c.execute(*args, **kwargs)
|
||||
except db.OperationalError as e:
|
||||
error('Database operational error %d: %s', e.args[0], e.args[1])
|
||||
c.close()
|
||||
cls.invalidate_connection()
|
||||
if retry:
|
||||
# Make sure we only retry once
|
||||
info('Retrying database operation')
|
||||
kwargs["threadDB__retry_execution__"] = True
|
||||
c = cls.execute(*args, **kwargs)
|
||||
else:
|
||||
error('Database operation failed ultimately')
|
||||
raise threadDbException()
|
||||
return c
|
||||
execute = classmethod(execute)
|
||||
|
||||
def invalidate_connection(cls):
|
||||
tid = _thread.get_ident()
|
||||
con = cls.db_connections.pop(tid, None)
|
||||
if con:
|
||||
debug('Invalidate connection to database for thread %d', tid)
|
||||
con.close()
|
||||
|
||||
invalidate_connection = classmethod(invalidate_connection)
|
||||
|
||||
def disconnect(cls):
|
||||
while cls.db_connections:
|
||||
tid, con = cls.db_connections.popitem()
|
||||
debug('Close database connection for thread %d', tid)
|
||||
con.close()
|
||||
disconnect = classmethod(disconnect)
|
||||
|
||||
def do_main_program():
|
||||
#
|
||||
#--- Authenticator implementation
|
||||
# All of this has to go in here so we can correctly daemonize the tool
|
||||
# without loosing the file descriptors opened by the Ice module
|
||||
slicedir = Ice.getSliceDir()
|
||||
if not slicedir:
|
||||
slicedir = ["-I/usr/share/Ice/slice", "-I/usr/share/slice"]
|
||||
else:
|
||||
slicedir = ['-I' + slicedir]
|
||||
Ice.loadSlice('', slicedir + [cfg.ice.slice])
|
||||
import MumbleServer
|
||||
|
||||
class CVoipAuthenticatorApp(Ice.Application):
|
||||
def run(self, args):
|
||||
self.shutdownOnInterrupt()
|
||||
|
||||
if not self.initializeIceConnection():
|
||||
return 1
|
||||
|
||||
if cfg.ice.watchdog > 0:
|
||||
self.failedWatch = True
|
||||
self.checkConnection()
|
||||
|
||||
# Serve till we are stopped
|
||||
self.communicator().waitForShutdown()
|
||||
self.watchdog.cancel()
|
||||
|
||||
if self.interrupted():
|
||||
warning('Caught interrupt, shutting down')
|
||||
|
||||
threadDB.disconnect()
|
||||
return 0
|
||||
|
||||
def initializeIceConnection(self):
|
||||
"""
|
||||
Establishes the two-way Ice connection and adds the authenticator to the
|
||||
configured servers
|
||||
"""
|
||||
ice = self.communicator()
|
||||
|
||||
if cfg.ice.secret:
|
||||
debug('Using shared ice secret')
|
||||
ice.getImplicitContext().put("secret", cfg.ice.secret)
|
||||
elif not cfg.glacier.enabled:
|
||||
warning('Consider using an ice secret to improve security')
|
||||
|
||||
if cfg.glacier.enabled:
|
||||
#info('Connecting to Glacier2 server (%s:%d)', glacier_host, glacier_port)
|
||||
error('Glacier support not implemented yet')
|
||||
#TODO: Implement this
|
||||
|
||||
info('Connecting to Ice server (%s:%d)', cfg.ice.host, cfg.ice.port)
|
||||
base = ice.stringToProxy('Meta:tcp -h %s -p %d' % (cfg.ice.host, cfg.ice.port))
|
||||
self.meta = MumbleServer.MetaPrx.uncheckedCast(base)
|
||||
|
||||
adapter = ice.createObjectAdapterWithEndpoints('Callback.Client', 'tcp -h %s' % cfg.ice.host)
|
||||
adapter.activate()
|
||||
|
||||
metacbprx = adapter.addWithUUID(metaCallback(self))
|
||||
self.metacb = MumbleServer.MetaCallbackPrx.uncheckedCast(metacbprx)
|
||||
|
||||
authprx = adapter.addWithUUID(CVoipAuthenticator())
|
||||
self.auth = MumbleServer.ServerUpdatingAuthenticatorPrx.uncheckedCast(authprx)
|
||||
|
||||
return self.attachCallbacks()
|
||||
|
||||
def attachCallbacks(self, quiet = False):
|
||||
"""
|
||||
Attaches all callbacks for meta and authenticators
|
||||
"""
|
||||
|
||||
# Ice.ConnectionRefusedException
|
||||
#debug('Attaching callbacks')
|
||||
try:
|
||||
if not quiet: info('Attaching meta callback')
|
||||
|
||||
self.meta.addCallback(self.metacb)
|
||||
|
||||
for server in self.meta.getBootedServers():
|
||||
if not cfg.murmur.servers or server.id() in cfg.murmur.servers:
|
||||
if not quiet: info('Setting authenticator for virtual server %d', server.id())
|
||||
server.setAuthenticator(self.auth)
|
||||
|
||||
except (MumbleServer.InvalidSecretException, Ice.UnknownUserException, Ice.ConnectionRefusedException) as e:
|
||||
if isinstance(e, Ice.ConnectionRefusedException):
|
||||
error('Server refused connection')
|
||||
elif isinstance(e, MumbleServer.InvalidSecretException) or \
|
||||
isinstance(e, Ice.UnknownUserException) and (e.unknown == 'MumbleServer::InvalidSecretException'):
|
||||
error('Invalid ice secret')
|
||||
else:
|
||||
# We do not actually want to handle this one, re-raise it
|
||||
raise e
|
||||
|
||||
self.connected = False
|
||||
return False
|
||||
|
||||
self.connected = True
|
||||
return True
|
||||
|
||||
def checkConnection(self):
|
||||
"""
|
||||
Tries reapplies all callbacks to make sure the authenticator
|
||||
survives server restarts and disconnects.
|
||||
"""
|
||||
#debug('Watchdog run')
|
||||
|
||||
try:
|
||||
if not self.attachCallbacks(quiet = not self.failedWatch):
|
||||
self.failedWatch = True
|
||||
else:
|
||||
self.failedWatch = False
|
||||
except Ice.Exception as e:
|
||||
error('Failed connection check, will retry in next watchdog run (%ds)', cfg.ice.watchdog)
|
||||
debug(str(e))
|
||||
self.failedWatch = True
|
||||
|
||||
# Renew the timer
|
||||
self.watchdog = Timer(cfg.ice.watchdog, self.checkConnection)
|
||||
self.watchdog.start()
|
||||
|
||||
def checkSecret(func):
|
||||
"""
|
||||
Decorator that checks whether the server transmitted the right secret
|
||||
if a secret is supposed to be used.
|
||||
"""
|
||||
if not cfg.ice.secret:
|
||||
return func
|
||||
|
||||
def newfunc(*args, **kws):
|
||||
if 'current' in kws:
|
||||
current = kws["current"]
|
||||
else:
|
||||
current = args[-1]
|
||||
|
||||
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 MumbleServer.InvalidSecretException()
|
||||
|
||||
return func(*args, **kws)
|
||||
|
||||
return newfunc
|
||||
|
||||
def fortifyIceFu(retval = None, exceptions = (Ice.Exception,)):
|
||||
"""
|
||||
Decorator that catches exceptions,logs them and returns a safe retval
|
||||
value. This helps preventing the authenticator getting stuck in
|
||||
critical code paths. Only exceptions that are instances of classes
|
||||
given in the exceptions list are not caught.
|
||||
|
||||
The default is to catch all non-Ice exceptions.
|
||||
"""
|
||||
def newdec(func):
|
||||
def newfunc(*args, **kws):
|
||||
try:
|
||||
return func(*args, **kws)
|
||||
except Exception as e:
|
||||
catch = True
|
||||
for ex in exceptions:
|
||||
if isinstance(e, ex):
|
||||
catch = False
|
||||
break
|
||||
|
||||
if catch:
|
||||
critical('Unexpected exception caught')
|
||||
exception(e)
|
||||
return retval
|
||||
raise
|
||||
|
||||
return newfunc
|
||||
return newdec
|
||||
|
||||
class metaCallback(MumbleServer.MetaCallback):
|
||||
def __init__(self, app):
|
||||
MumbleServer.MetaCallback.__init__(self)
|
||||
self.app = app
|
||||
|
||||
@fortifyIceFu()
|
||||
@checkSecret
|
||||
def started(self, server, current = None):
|
||||
"""
|
||||
This function is called when a virtual server is started
|
||||
and makes sure an authenticator gets attached if needed.
|
||||
"""
|
||||
if not cfg.murmur.servers or server.id() in cfg.murmur.servers:
|
||||
info('Setting authenticator for virtual server %d', server.id())
|
||||
try:
|
||||
server.setAuthenticator(app.auth)
|
||||
# Apparently this server was restarted without us noticing
|
||||
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
|
||||
|
||||
error('Invalid ice secret')
|
||||
return
|
||||
else:
|
||||
debug('Virtual server %d got started', server.id())
|
||||
|
||||
@fortifyIceFu()
|
||||
@checkSecret
|
||||
def stopped(self, server, current = None):
|
||||
"""
|
||||
This function is called when a virtual server is stopped
|
||||
"""
|
||||
if self.app.connected:
|
||||
# Only try to output the server id if we think we are still connected to prevent
|
||||
# flooding of our thread pool
|
||||
try:
|
||||
if not cfg.murmur.servers or server.id() in cfg.murmur.servers:
|
||||
info('Authenticated virtual server %d got stopped', server.id())
|
||||
else:
|
||||
debug('Virtual server %d got stopped', server.id())
|
||||
return
|
||||
except Ice.ConnectionRefusedException:
|
||||
self.app.connected = False
|
||||
|
||||
debug('Server shutdown stopped a virtual server')
|
||||
|
||||
if cfg.user.reject_on_error: # Python 2.4 compat
|
||||
authenticateFortifyResult = (-1, None, None)
|
||||
else:
|
||||
authenticateFortifyResult = (-2, None, None)
|
||||
|
||||
class CVoipAuthenticator(MumbleServer.ServerUpdatingAuthenticator):
|
||||
texture_cache = {}
|
||||
def __init__(self):
|
||||
MumbleServer.ServerUpdatingAuthenticator.__init__(self)
|
||||
|
||||
@fortifyIceFu(authenticateFortifyResult)
|
||||
@checkSecret
|
||||
def authenticate(self, name, pw, certlist, certhash, strong, current = None):
|
||||
"""
|
||||
This function is called to authenticate a user
|
||||
"""
|
||||
debug(f'The user\'s password: {pw}')
|
||||
|
||||
# Search for the user in the database
|
||||
FALL_THROUGH = -2
|
||||
AUTH_REFUSED = -1
|
||||
|
||||
# Django authenticator
|
||||
if cfg.django.enabled:
|
||||
import os
|
||||
import django
|
||||
|
||||
BASE_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), cfg.django.project))
|
||||
sys.path.append(BASE_DIR)
|
||||
info('Using Django project from %s', BASE_DIR)
|
||||
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", cfg.django.settings)
|
||||
django.setup()
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
debug('Using Django for authentication')
|
||||
try:
|
||||
user = User.objects.get(username=name)
|
||||
debug('User found: %s', user.username)
|
||||
if user.check_password(pw):
|
||||
# Successful authentication
|
||||
uid = user.id + cfg.user.id_offset
|
||||
groups = [group.name for group in user.groups.all()]
|
||||
info('User authenticated: "%s" (%d)', name, uid)
|
||||
return (uid, entity_decode(user.get_full_name()), groups)
|
||||
else:
|
||||
info('Failed authentication attempt for user: "%s" (%d)', name, user.id + cfg.user.id_offset)
|
||||
return (AUTH_REFUSED, None, None)
|
||||
except User.DoesNotExist:
|
||||
info('Refuse Connection for unknown user "%s"', name)
|
||||
return (AUTH_REFUSED, None, None)
|
||||
|
||||
if name == 'SuperUser':
|
||||
debug('Forced fall through for SuperUser')
|
||||
return (FALL_THROUGH, None, None)
|
||||
|
||||
try:
|
||||
sql = 'SELECT id_member, passwd, id_group, member_name, real_name, additional_groups, is_activated FROM %smembers WHERE LOWER(member_name) = LOWER(%%s)' % cfg.database.prefix
|
||||
cur = threadDB.execute(sql, [name])
|
||||
except threadDbException:
|
||||
return (FALL_THROUGH, None, None)
|
||||
|
||||
res = cur.fetchone()
|
||||
cur.close()
|
||||
if not res:
|
||||
info('Fall through for unknown user "%s"', name)
|
||||
return (FALL_THROUGH, None, None)
|
||||
|
||||
uid, upw, ugroupid, uname, urealname, uadditgroups, activated = res
|
||||
|
||||
if activated == 1 and smf_check_hash(pw, upw, uname):
|
||||
# Authenticated, fetch group memberships
|
||||
try:
|
||||
if uadditgroups:
|
||||
groupids = str(ugroupid) + ',' + uadditgroups
|
||||
else:
|
||||
groupids = str(ugroupid)
|
||||
|
||||
sql = 'SELECT group_name FROM %smembergroups WHERE id_group IN (%s)' % (cfg.database.prefix, groupids)
|
||||
cur = threadDB.execute(sql)
|
||||
except threadDbException:
|
||||
return (FALL_THROUGH, None, None)
|
||||
|
||||
groups = cur.fetchall()
|
||||
cur.close()
|
||||
if groups:
|
||||
groups = [a[0] for a in groups]
|
||||
|
||||
info('User authenticated: "%s" (%d)', name, uid + cfg.user.id_offset)
|
||||
debug('Group memberships: %s', str(groups))
|
||||
return (uid + cfg.user.id_offset, entity_decode(urealname), groups)
|
||||
|
||||
info('Failed authentication attempt for user: "%s" (%d)', name, uid + cfg.user.id_offset)
|
||||
return (AUTH_REFUSED, None, None)
|
||||
|
||||
@fortifyIceFu((False, None))
|
||||
@checkSecret
|
||||
def getInfo(self, id, current = None):
|
||||
"""
|
||||
Gets called to fetch user specific information
|
||||
"""
|
||||
|
||||
# We do not expose any additional information so always fall through
|
||||
debug('getInfo for %d -> denied', id)
|
||||
return (False, None)
|
||||
|
||||
@fortifyIceFu(-2)
|
||||
@checkSecret
|
||||
def nameToId(self, name, current = None):
|
||||
"""
|
||||
Gets called to get the id for a given username
|
||||
"""
|
||||
|
||||
FALL_THROUGH = -2
|
||||
if name == 'SuperUser':
|
||||
debug('nameToId SuperUser -> forced fall through')
|
||||
return FALL_THROUGH
|
||||
|
||||
try:
|
||||
sql = 'SELECT id_member FROM %smembers WHERE LOWER(member_name) = LOWER(%%s)' % cfg.database.prefix
|
||||
cur = threadDB.execute(sql, [name])
|
||||
except threadDbException:
|
||||
return FALL_THROUGH
|
||||
|
||||
res = cur.fetchone()
|
||||
cur.close()
|
||||
if not res:
|
||||
debug('nameToId %s -> ?', name)
|
||||
return FALL_THROUGH
|
||||
|
||||
debug('nameToId %s -> %d', name, (res[0] + cfg.user.id_offset))
|
||||
return res[0] + cfg.user.id_offset
|
||||
|
||||
@fortifyIceFu("")
|
||||
@checkSecret
|
||||
def idToName(self, id, current = None):
|
||||
"""
|
||||
Gets called to get the username for a given id
|
||||
"""
|
||||
|
||||
FALL_THROUGH = ""
|
||||
# Make sure the ID is in our range and transform it to the actual smf user id
|
||||
if id < cfg.user.id_offset:
|
||||
return FALL_THROUGH
|
||||
bbid = id - cfg.user.id_offset
|
||||
|
||||
# Fetch the user from the database
|
||||
try:
|
||||
sql = 'SELECT member_name FROM %smembers WHERE id_member = %%s' % cfg.database.prefix
|
||||
cur = threadDB.execute(sql, [bbid])
|
||||
except threadDbException:
|
||||
return FALL_THROUGH
|
||||
|
||||
res = cur.fetchone()
|
||||
cur.close()
|
||||
if res:
|
||||
if res[0] == 'SuperUser':
|
||||
debug('idToName %d -> "SuperUser" catched')
|
||||
return FALL_THROUGH
|
||||
|
||||
debug('idToName %d -> "%s"', id, res[0])
|
||||
return res[0]
|
||||
|
||||
debug('idToName %d -> ?', id)
|
||||
return FALL_THROUGH
|
||||
|
||||
@fortifyIceFu("")
|
||||
@checkSecret
|
||||
def idToTexture(self, id, current = None):
|
||||
"""
|
||||
Gets called to get the corresponding texture for a user
|
||||
"""
|
||||
|
||||
FALL_THROUGH = ""
|
||||
|
||||
debug('idToTexture for %d', id)
|
||||
if id < cfg.user.id_offset or not cfg.user.avatar_enable:
|
||||
debug('idToTexture %d -> fall through', id)
|
||||
return FALL_THROUGH
|
||||
|
||||
# Otherwise get the users texture from smf
|
||||
bbid = id - cfg.user.id_offset
|
||||
try:
|
||||
sql = 'SELECT avatar FROM %smembers WHERE id_member = %%s' % cfg.database.prefix
|
||||
cur = threadDB.execute(sql, [bbid])
|
||||
except threadDbException:
|
||||
return FALL_THROUGH
|
||||
res = cur.fetchone()
|
||||
cur.close()
|
||||
if not res:
|
||||
debug('idToTexture %d -> user unknown, fall through', id)
|
||||
return FALL_THROUGH
|
||||
avatar = res[0]
|
||||
|
||||
if not avatar:
|
||||
# Either the user has none or it is in the attachments, check there
|
||||
try:
|
||||
sql = '''SELECT id_attach, file_hash, filename, attachment_type FROM %sattachments WHERE approved = true AND
|
||||
(attachment_type = 0 OR attachment_type = 1) AND id_member = %%s''' % cfg.database.prefix
|
||||
cur = threadDB.execute(sql, [bbid])
|
||||
except threadDbException:
|
||||
return FALL_THROUGH
|
||||
|
||||
res = cur.fetchone()
|
||||
cur.close()
|
||||
if not res:
|
||||
# No uploaded avatar found, seems like the user didn't set one
|
||||
debug('idToTexture %d -> no texture available for this user, fall through', id)
|
||||
return FALL_THROUGH
|
||||
|
||||
fid, fhash, filename, fattachtype = res
|
||||
if cfg.forum.path.startswith('file://'):
|
||||
# We are supposed to load this from the local fs
|
||||
avatar_file = cfg.forum.path + 'attachments/%d_%s' % (fid, fhash)
|
||||
elif fattachtype == 0:
|
||||
avatar_file = cfg.forum.path + 'index.php?action=dlattach;attach=%d;type=avatar' % fid
|
||||
elif fattachtype == 1:
|
||||
avatar_file = cfg.forum.path + 'avatars/' + filename
|
||||
elif "://" in avatar:
|
||||
# ...or it is a external link
|
||||
avatar_file = avatar
|
||||
else:
|
||||
warning("avatar with an unexpected value, fall through")
|
||||
return FALL_THROUGH
|
||||
|
||||
if avatar_file in self.texture_cache:
|
||||
return self.texture_cache[avatar_file]
|
||||
|
||||
try:
|
||||
handle = urllib.request.urlopen(avatar_file)
|
||||
filecontent = handle.read()
|
||||
handle.close()
|
||||
except urllib.error.URLError as e:
|
||||
warning('Image download for "%s" (%d) failed: %s', avatar_file, id, str(e))
|
||||
return FALL_THROUGH
|
||||
|
||||
self.texture_cache[avatar_file] = filecontent
|
||||
|
||||
return self.texture_cache[avatar_file]
|
||||
|
||||
@fortifyIceFu(-2)
|
||||
@checkSecret
|
||||
def registerUser(self, name, current = None):
|
||||
"""
|
||||
Gets called when the server is asked to register a user.
|
||||
"""
|
||||
|
||||
FALL_THROUGH = -2
|
||||
debug('registerUser "%s" -> fall through', name)
|
||||
return FALL_THROUGH
|
||||
|
||||
@fortifyIceFu(-1)
|
||||
@checkSecret
|
||||
def unregisterUser(self, id, current = None):
|
||||
"""
|
||||
Gets called when the server is asked to unregister a user.
|
||||
"""
|
||||
|
||||
FALL_THROUGH = -1
|
||||
# Return -1 to fall through to internal server database, we will not modify the smf database
|
||||
# but we can make murmur delete all additional information it got this way.
|
||||
debug('unregisterUser %d -> fall through', id)
|
||||
return FALL_THROUGH
|
||||
|
||||
@fortifyIceFu({})
|
||||
@checkSecret
|
||||
def getRegisteredUsers(self, filter, current = None):
|
||||
"""
|
||||
Returns a list of usernames in the smf database which contain
|
||||
filter as a substring.
|
||||
"""
|
||||
|
||||
if not filter:
|
||||
filter = '%'
|
||||
|
||||
try:
|
||||
sql = 'SELECT id_member, member_name FROM %smembers WHERE is_activated = 1 AND member_name LIKE %%s' % cfg.database.prefix
|
||||
cur = threadDB.execute(sql, [filter])
|
||||
except threadDbException:
|
||||
return {}
|
||||
|
||||
res = cur.fetchall()
|
||||
cur.close()
|
||||
if not res:
|
||||
debug('getRegisteredUsers -> empty list for filter "%s"', filter)
|
||||
return {}
|
||||
debug ('getRegisteredUsers -> %d results for filter "%s"', len(res), filter)
|
||||
return dict([(a + cfg.user.id_offset, b) for a,b in res])
|
||||
|
||||
@fortifyIceFu(-1)
|
||||
@checkSecret
|
||||
def setInfo(self, id, info, current = None):
|
||||
"""
|
||||
Gets called when the server is supposed to save additional information
|
||||
about a user to his database
|
||||
"""
|
||||
|
||||
FALL_THROUGH = -1
|
||||
# Return -1 to fall through to the internal server handler. We must not modify
|
||||
# the smf database so the additional information is stored in murmurs database
|
||||
debug('setInfo %d -> fall through', id)
|
||||
return FALL_THROUGH
|
||||
|
||||
@fortifyIceFu(-1)
|
||||
@checkSecret
|
||||
def setTexture(self, id, texture, current = None):
|
||||
"""
|
||||
Gets called when the server is asked to update the user texture of a user
|
||||
"""
|
||||
|
||||
FAILED = 0
|
||||
FALL_THROUGH = -1
|
||||
|
||||
if id < cfg.user.id_offset:
|
||||
debug('setTexture %d -> fall through', id)
|
||||
return FALL_THROUGH
|
||||
|
||||
if cfg.user.avatar_enable:
|
||||
# Report a fail (0) as we will not update the avatar in the smf database.
|
||||
debug('setTexture %d -> failed', id)
|
||||
return FAILED
|
||||
|
||||
# If we don't use textures from smf we let mumble save it
|
||||
debug('setTexture %d -> fall through', id)
|
||||
return FALL_THROUGH
|
||||
|
||||
class CustomLogger(Ice.Logger):
|
||||
"""
|
||||
Logger implementation to pipe Ice log messages into
|
||||
our own log
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
Ice.Logger.__init__(self)
|
||||
self._log = getLogger('Ice')
|
||||
|
||||
def _print(self, message):
|
||||
self._log.info(message)
|
||||
|
||||
def trace(self, category, message):
|
||||
self._log.debug('Trace %s: %s', category, message)
|
||||
|
||||
def warning(self, message):
|
||||
self._log.warning(message)
|
||||
|
||||
def error(self, message):
|
||||
self._log.error(message)
|
||||
|
||||
#
|
||||
#--- Start of authenticator
|
||||
#
|
||||
info('Starting cvoip authenticator')
|
||||
initdata = Ice.InitializationData()
|
||||
initdata.properties = Ice.createProperties([], initdata.properties)
|
||||
for prop, val in cfg.iceraw:
|
||||
initdata.properties.setProperty(prop, val)
|
||||
|
||||
initdata.properties.setProperty('Ice.ImplicitContext', 'Shared')
|
||||
initdata.properties.setProperty('Ice.Default.EncodingVersion', '1.0')
|
||||
initdata.logger = CustomLogger()
|
||||
|
||||
app = CVoipAuthenticatorApp()
|
||||
state = app.main(sys.argv[:1], initData = initdata)
|
||||
info('Shutdown complete')
|
||||
|
||||
|
||||
|
||||
#
|
||||
#--- Python implementation of the smf check hash function
|
||||
#
|
||||
def smf_check_hash(password, hash, username):
|
||||
"""
|
||||
Python implementation of the smf check hash function
|
||||
"""
|
||||
ret = False
|
||||
|
||||
try:
|
||||
# SMF 2.1 uses a bcrypt hash, try that first
|
||||
ret = bcrypt.hashpw((username.lower() + password).encode('utf-8'), hash.encode('utf-8')) == hash
|
||||
except ValueError:
|
||||
# The sha1 password hash from SMF 2.0 and earlier will cause a salt value error
|
||||
# In that case, try the legacy sha1 hash
|
||||
ret = sha1((username.lower() + password).encode('utf-8')).hexdigest() == hash
|
||||
|
||||
return ret
|
||||
|
||||
#
|
||||
#--- Start of program
|
||||
#
|
||||
if __name__ == '__main__':
|
||||
# Parse commandline options
|
||||
parser = OptionParser()
|
||||
parser.add_option('-i', '--ini',
|
||||
help = 'load configuration from INI', default = cfgfile)
|
||||
parser.add_option('-v', '--verbose', action='store_true', dest = 'verbose',
|
||||
help = 'verbose output [default]', default = True)
|
||||
parser.add_option('-q', '--quiet', action='store_false', dest = 'verbose',
|
||||
help = 'only error output')
|
||||
parser.add_option('-l', '--logfile', action='store_true', dest = 'logfile',
|
||||
help = 'log output to file instead of terminal', default = False)
|
||||
parser.add_option('-d', '--daemon', action='store_true', dest = 'force_daemon',
|
||||
help = 'run as daemon', default = False)
|
||||
parser.add_option('-a', '--app', action='store_true', dest = 'force_app',
|
||||
help = 'do not run as daemon', default = False)
|
||||
(option, args) = parser.parse_args()
|
||||
|
||||
if option.force_daemon and option.force_app:
|
||||
parser.print_help()
|
||||
sys.exit(1)
|
||||
|
||||
# Load configuration
|
||||
try:
|
||||
cfg = config(option.ini, default)
|
||||
except Exception as e:
|
||||
print('Fatal error, could not load config file from "%s"' % cfgfile, file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
try:
|
||||
db = __import__(cfg.database.lib)
|
||||
except ImportError as e:
|
||||
print('Fatal error, could not import database library "%s", '\
|
||||
'please install the missing dependency and restart the authenticator' % cfg.database.lib, file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
# Initialize logger
|
||||
if cfg.log.file:
|
||||
try:
|
||||
logfile = open(cfg.log.file, 'a')
|
||||
except IOError as e:
|
||||
#print>>sys.stderr, str(e)
|
||||
print('Fatal error, could not open logfile "%s"' % cfg.log.file, file=sys.stderr)
|
||||
sys.exit(1)
|
||||
else:
|
||||
logfile = logging.sys.stderr
|
||||
|
||||
|
||||
if option.verbose:
|
||||
level = cfg.log.level
|
||||
else:
|
||||
level = logging.ERROR
|
||||
|
||||
logging.basicConfig(level = level,
|
||||
format='%(asctime)s %(levelname)s %(message)s',
|
||||
stream = logfile if option.logfile else sys.stdout)
|
||||
|
||||
# By default, we'll run it as an app.
|
||||
# Upgrade to run as a daemon if the user explicitly defined the option with the -a / -d parameter.
|
||||
try:
|
||||
if option.force_daemon:
|
||||
import daemon
|
||||
else:
|
||||
raise ImportError # Pretend that we don't have the daemon library
|
||||
except ImportError:
|
||||
if option.force_daemon:
|
||||
print('Fatal error, could not daemonize process due to missing "daemon" library, ' \
|
||||
'please install the missing dependency and restart the authenticator', file=sys.stderr)
|
||||
sys.exit(1)
|
||||
do_main_program()
|
||||
else:
|
||||
context = daemon.DaemonContext(working_directory = sys.path[0],
|
||||
stderr = logfile)
|
||||
context.__enter__()
|
||||
try:
|
||||
do_main_program()
|
||||
finally:
|
||||
context.__exit__(None, None, None)
|
||||
|
||||
|
||||
# Change django dB to postgres - Done
|
||||
# An extra option to display foreground logs - Done
|
||||
10
DjangoAuth.py
Normal file
10
DjangoAuth.py
Normal file
@ -0,0 +1,10 @@
|
||||
import sys
|
||||
import os
|
||||
import django
|
||||
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "MumblePanel.settings")
|
||||
sys.path.append("/")
|
||||
django.setup()
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
941
MumbleServer.ice
Normal file
941
MumbleServer.ice
Normal file
@ -0,0 +1,941 @@
|
||||
// Copyright 2022-2023 The Mumble Developers. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the LICENSE file at the root of the
|
||||
// Mumble source tree or at <https://www.mumble.info/LICENSE>.
|
||||
|
||||
/**
|
||||
*
|
||||
* Information and control of the murmur server. Each server has
|
||||
* one {@link Meta} interface that controls global information, and
|
||||
* each virtual server has a {@link Server} interface.
|
||||
*
|
||||
**/
|
||||
|
||||
#include <Ice/SliceChecksumDict.ice>
|
||||
|
||||
module MumbleServer
|
||||
{
|
||||
|
||||
/** A network address in IPv6 format.
|
||||
**/
|
||||
["python:seq:tuple"] sequence<byte> NetAddress;
|
||||
|
||||
/** A connected user.
|
||||
**/
|
||||
struct User {
|
||||
/** Session ID. This identifies the connection to the server. */
|
||||
int session;
|
||||
/** User ID. -1 if the user is anonymous. */
|
||||
int userid;
|
||||
/** Is user muted by the server? */
|
||||
bool mute;
|
||||
/** Is user deafened by the server? If true, this implies mute. */
|
||||
bool deaf;
|
||||
/** Is the user suppressed by the server? This means the user is not muted, but does not have speech privileges in the current channel. */
|
||||
bool suppress;
|
||||
/** Is the user a priority speaker? */
|
||||
bool prioritySpeaker;
|
||||
/** Is the user self-muted? */
|
||||
bool selfMute;
|
||||
/** Is the user self-deafened? If true, this implies mute. */
|
||||
bool selfDeaf;
|
||||
/** Is the User recording? (This flag is read-only and cannot be changed using setState().) **/
|
||||
bool recording;
|
||||
/** Channel ID the user is in. Matches {@link Channel.id}. */
|
||||
int channel;
|
||||
/** The name of the user. */
|
||||
string name;
|
||||
/** Seconds user has been online. */
|
||||
int onlinesecs;
|
||||
/** Average transmission rate in bytes per second over the last few seconds. */
|
||||
int bytespersec;
|
||||
/** Legacy client version. */
|
||||
int version;
|
||||
/** New client version. (See https://github.com/mumble-voip/mumble/issues/5827) */
|
||||
long version2;
|
||||
/** Client release. For official releases, this equals the version. For snapshots and git compiles, this will be something else. */
|
||||
string release;
|
||||
/** Client OS. */
|
||||
string os;
|
||||
/** Client OS Version. */
|
||||
string osversion;
|
||||
/** Plugin Identity. This will be the user's unique ID inside the current game. */
|
||||
string identity;
|
||||
/**
|
||||
Base64-encoded Plugin context. This is a binary blob identifying the game and team the user is on.
|
||||
|
||||
The used Base64 alphabet is the one specified in RFC 2045.
|
||||
|
||||
Before Mumble 1.3.0, this string was not Base64-encoded. This could cause problems for some Ice
|
||||
implementations, such as the .NET implementation.
|
||||
|
||||
If you need the exact string that is used by Mumble, you can get it by Base64-decoding this string.
|
||||
|
||||
If you simply need to detect whether two users are in the same game world, string comparisons will
|
||||
continue to work as before.
|
||||
*/
|
||||
string context;
|
||||
/** User comment. Shown as tooltip for this user. */
|
||||
string comment;
|
||||
/** Client address. */
|
||||
NetAddress address;
|
||||
/** TCP only. True until UDP connectivity is established. */
|
||||
bool tcponly;
|
||||
/** Idle time. This is how many seconds it is since the user last spoke. Other activity is not counted. */
|
||||
int idlesecs;
|
||||
/** UDP Ping Average. This is the average ping for the user via UDP over the duration of the connection. */
|
||||
float udpPing;
|
||||
/** TCP Ping Average. This is the average ping for the user via TCP over the duration of the connection. */
|
||||
float tcpPing;
|
||||
};
|
||||
|
||||
sequence<int> IntList;
|
||||
|
||||
/** A text message between users.
|
||||
**/
|
||||
struct TextMessage {
|
||||
/** Sessions (connected users) who were sent this message. */
|
||||
IntList sessions;
|
||||
/** Channels who were sent this message. */
|
||||
IntList channels;
|
||||
/** Trees of channels who were sent this message. */
|
||||
IntList trees;
|
||||
/** The contents of the message. */
|
||||
string text;
|
||||
};
|
||||
|
||||
/** A channel.
|
||||
**/
|
||||
struct Channel {
|
||||
/** Channel ID. This is unique per channel, and the root channel is always id 0. */
|
||||
int id;
|
||||
/** Name of the channel. There can not be two channels with the same parent that has the same name. */
|
||||
string name;
|
||||
/** ID of parent channel, or -1 if this is the root channel. */
|
||||
int parent;
|
||||
/** List of id of linked channels. */
|
||||
IntList links;
|
||||
/** Description of channel. Shown as tooltip for this channel. */
|
||||
string description;
|
||||
/** Channel is temporary, and will be removed when the last user leaves it. */
|
||||
bool temporary;
|
||||
/** Position of the channel which is used in Client for sorting. */
|
||||
int position;
|
||||
};
|
||||
|
||||
/** A group. Groups are defined per channel, and can inherit members from parent channels.
|
||||
**/
|
||||
struct Group {
|
||||
/** Group name */
|
||||
string name;
|
||||
/** Is this group inherited from a parent channel? Read-only. */
|
||||
bool inherited;
|
||||
/** Does this group inherit members from parent channels? */
|
||||
bool inherit;
|
||||
/** Can subchannels inherit members from this group? */
|
||||
bool inheritable;
|
||||
/** List of users to add to the group. */
|
||||
IntList add;
|
||||
/** List of inherited users to remove from the group. */
|
||||
IntList remove;
|
||||
/** Current members of the group, including inherited members. Read-only. */
|
||||
IntList members;
|
||||
};
|
||||
|
||||
/** Write access to channel control. Implies all other permissions (except Speak). */
|
||||
const int PermissionWrite = 0x01;
|
||||
/** Traverse channel. Without this, a client cannot reach subchannels, no matter which privileges he has there. */
|
||||
const int PermissionTraverse = 0x02;
|
||||
/** Enter channel. */
|
||||
const int PermissionEnter = 0x04;
|
||||
/** Speak in channel. */
|
||||
const int PermissionSpeak = 0x08;
|
||||
/** Whisper to channel. This is different from Speak, so you can set up different permissions. */
|
||||
const int PermissionWhisper = 0x100;
|
||||
/** Mute and deafen other users in this channel. */
|
||||
const int PermissionMuteDeafen = 0x10;
|
||||
/** Move users from channel. You need this permission in both the source and destination channel to move another user. */
|
||||
const int PermissionMove = 0x20;
|
||||
/** Make new channel as a subchannel of this channel. */
|
||||
const int PermissionMakeChannel = 0x40;
|
||||
/** Make new temporary channel as a subchannel of this channel. */
|
||||
const int PermissionMakeTempChannel = 0x400;
|
||||
/** Link this channel. You need this permission in both the source and destination channel to link channels, or in either channel to unlink them. */
|
||||
const int PermissionLinkChannel = 0x80;
|
||||
/** Send text message to channel. */
|
||||
const int PermissionTextMessage = 0x200;
|
||||
/** Kick user from server. Only valid on root channel. */
|
||||
const int PermissionKick = 0x10000;
|
||||
/** Ban user from server. Only valid on root channel. */
|
||||
const int PermissionBan = 0x20000;
|
||||
/** Register and unregister users. Only valid on root channel. */
|
||||
const int PermissionRegister = 0x40000;
|
||||
/** Register and unregister users. Only valid on root channel. */
|
||||
const int PermissionRegisterSelf = 0x80000;
|
||||
/** Reset the comment or avatar of a user. Only valid on root channel. */
|
||||
const int ResetUserContent = 0x100000;
|
||||
|
||||
|
||||
/** Access Control List for a channel. ACLs are defined per channel, and can be inherited from parent channels.
|
||||
**/
|
||||
struct ACL {
|
||||
/** Does the ACL apply to this channel? */
|
||||
bool applyHere;
|
||||
/** Does the ACL apply to subchannels? */
|
||||
bool applySubs;
|
||||
/** Is this ACL inherited from a parent channel? Read-only. */
|
||||
bool inherited;
|
||||
/** ID of user this ACL applies to. -1 if using a group name. */
|
||||
int userid;
|
||||
/** Group this ACL applies to. Blank if using userid. */
|
||||
string group;
|
||||
/** Binary mask of privileges to allow. */
|
||||
int allow;
|
||||
/** Binary mask of privileges to deny. */
|
||||
int deny;
|
||||
};
|
||||
|
||||
/** A single ip mask for a ban.
|
||||
**/
|
||||
struct Ban {
|
||||
/** Address to ban. */
|
||||
NetAddress address;
|
||||
/** Number of bits in ban to apply. */
|
||||
int bits;
|
||||
/** Username associated with ban. */
|
||||
string name;
|
||||
/** Hash of banned user. */
|
||||
string hash;
|
||||
/** Reason for ban. */
|
||||
string reason;
|
||||
/** Date ban was applied in unix time format. */
|
||||
int start;
|
||||
/** Duration of ban. */
|
||||
int duration;
|
||||
};
|
||||
|
||||
/** A entry in the log.
|
||||
**/
|
||||
struct LogEntry {
|
||||
/** Timestamp in UNIX time_t */
|
||||
int timestamp;
|
||||
/** The log message. */
|
||||
string txt;
|
||||
};
|
||||
|
||||
class Tree;
|
||||
sequence<Tree> TreeList;
|
||||
|
||||
enum ChannelInfo { ChannelDescription, ChannelPosition };
|
||||
enum UserInfo { UserName, UserEmail, UserComment, UserHash, UserPassword, UserLastActive, UserKDFIterations };
|
||||
|
||||
dictionary<int, User> UserMap;
|
||||
dictionary<int, Channel> ChannelMap;
|
||||
sequence<Channel> ChannelList;
|
||||
sequence<User> UserList;
|
||||
sequence<Group> GroupList;
|
||||
sequence<ACL> ACLList;
|
||||
sequence<LogEntry> LogList;
|
||||
sequence<Ban> BanList;
|
||||
sequence<int> IdList;
|
||||
sequence<string> NameList;
|
||||
dictionary<int, string> NameMap;
|
||||
dictionary<string, int> IdMap;
|
||||
sequence<byte> Texture;
|
||||
dictionary<string, string> ConfigMap;
|
||||
sequence<string> GroupNameList;
|
||||
sequence<byte> CertificateDer;
|
||||
sequence<CertificateDer> CertificateList;
|
||||
|
||||
/** User information map.
|
||||
* Older versions of ice-php can't handle enums as keys. If you are using one of these, replace 'UserInfo' with 'byte'.
|
||||
*/
|
||||
|
||||
dictionary<UserInfo, string> UserInfoMap;
|
||||
|
||||
/** User and subchannel state. Read-only.
|
||||
**/
|
||||
class Tree {
|
||||
/** Channel definition of current channel. */
|
||||
Channel c;
|
||||
/** List of subchannels. */
|
||||
TreeList children;
|
||||
/** Users in this channel. */
|
||||
UserList users;
|
||||
};
|
||||
|
||||
exception MurmurException {};
|
||||
/** This is thrown when you specify an invalid session. This may happen if the user has disconnected since your last call to {@link Server.getUsers}. See {@link User.session} */
|
||||
exception InvalidSessionException extends MurmurException {};
|
||||
/** This is thrown when you specify an invalid channel id. This may happen if the channel was removed by another provess. It can also be thrown if you try to add an invalid channel. */
|
||||
exception InvalidChannelException extends MurmurException {};
|
||||
/** This is thrown when you try to do an operation on a server that does not exist. This may happen if someone has removed the server. */
|
||||
exception InvalidServerException extends MurmurException {};
|
||||
/** This happens if you try to fetch user or channel state on a stopped server, if you try to stop an already stopped server or start an already started server. */
|
||||
exception ServerBootedException extends MurmurException {};
|
||||
/** This is thrown if {@link Server.start} fails, and should generally be the cause for some concern. */
|
||||
exception ServerFailureException extends MurmurException {};
|
||||
/** This is thrown when you specify an invalid userid. */
|
||||
exception InvalidUserException extends MurmurException {};
|
||||
/** This is thrown when you try to set an invalid texture. */
|
||||
exception InvalidTextureException extends MurmurException {};
|
||||
/** This is thrown when you supply an invalid callback. */
|
||||
exception InvalidCallbackException extends MurmurException {};
|
||||
/** This is thrown when you supply the wrong secret in the calling context. */
|
||||
exception InvalidSecretException extends MurmurException {};
|
||||
/** This is thrown when the channel operation would exceed the channel nesting limit */
|
||||
exception NestingLimitException extends MurmurException {};
|
||||
/** This is thrown when you ask the server to disclose something that should be secret. */
|
||||
exception WriteOnlyException extends MurmurException {};
|
||||
/** This is thrown when invalid input data was specified. */
|
||||
exception InvalidInputDataException extends MurmurException {};
|
||||
|
||||
/** Callback interface for servers. You can supply an implementation of this to receive notification
|
||||
* messages from the server.
|
||||
* If an added callback ever throws an exception or goes away, it will be automatically removed.
|
||||
* Please note that all callbacks are done asynchronously; murmur does not wait for the callback to
|
||||
* complete before continuing processing.
|
||||
* Note that callbacks are removed when a server is stopped, so you should have a callback for
|
||||
* {@link MetaCallback.started} which calls {@link Server.addCallback}.
|
||||
* @see MetaCallback
|
||||
* @see Server.addCallback
|
||||
*/
|
||||
interface ServerCallback {
|
||||
/** Called when a user connects to the server.
|
||||
* @param state State of connected user.
|
||||
*/
|
||||
idempotent void userConnected(User state);
|
||||
/** Called when a user disconnects from the server. The user has already been removed, so you can no longer use methods like {@link Server.getState}
|
||||
* to retrieve the user's state.
|
||||
* @param state State of disconnected user.
|
||||
*/
|
||||
idempotent void userDisconnected(User state);
|
||||
/** Called when a user state changes. This is called if the user moves, is renamed, is muted, deafened etc.
|
||||
* @param state New state of user.
|
||||
*/
|
||||
idempotent void userStateChanged(User state);
|
||||
/** Called when user writes a text message
|
||||
* @param state the User sending the message
|
||||
* @param message the TextMessage the user has sent
|
||||
*/
|
||||
idempotent void userTextMessage(User state, TextMessage message);
|
||||
/** Called when a new channel is created.
|
||||
* @param state State of new channel.
|
||||
*/
|
||||
idempotent void channelCreated(Channel state);
|
||||
/** Called when a channel is removed. The channel has already been removed, you can no longer use methods like {@link Server.getChannelState}
|
||||
* @param state State of removed channel.
|
||||
*/
|
||||
idempotent void channelRemoved(Channel state);
|
||||
/** Called when a new channel state changes. This is called if the channel is moved, renamed or if new links are added.
|
||||
* @param state New state of channel.
|
||||
*/
|
||||
idempotent void channelStateChanged(Channel state);
|
||||
};
|
||||
|
||||
/** Context for actions in the Server menu. */
|
||||
const int ContextServer = 0x01;
|
||||
/** Context for actions in the Channel menu. */
|
||||
const int ContextChannel = 0x02;
|
||||
/** Context for actions in the User menu. */
|
||||
const int ContextUser = 0x04;
|
||||
|
||||
/** Callback interface for context actions. You need to supply one of these for {@link Server.addContext}.
|
||||
* If an added callback ever throws an exception or goes away, it will be automatically removed.
|
||||
* Please note that all callbacks are done asynchronously; murmur does not wait for the callback to
|
||||
* complete before continuing processing.
|
||||
*/
|
||||
interface ServerContextCallback {
|
||||
/** Called when a context action is performed.
|
||||
* @param action Action to be performed.
|
||||
* @param usr User which initiated the action.
|
||||
* @param session If nonzero, session of target user.
|
||||
* @param channelid If not -1, id of target channel.
|
||||
*/
|
||||
idempotent void contextAction(string action, User usr, int session, int channelid);
|
||||
};
|
||||
|
||||
/** Callback interface for server authentication. You need to supply one of these for {@link Server.setAuthenticator}.
|
||||
* If an added callback ever throws an exception or goes away, it will be automatically removed.
|
||||
* Please note that unlike {@link ServerCallback} and {@link ServerContextCallback}, these methods are called
|
||||
* synchronously. If the response lags, the entire murmur server will lag.
|
||||
* Also note that, as the method calls are synchronous, making a call to {@link Server} or {@link Meta} will
|
||||
* deadlock the server.
|
||||
*/
|
||||
interface ServerAuthenticator {
|
||||
/** Called to authenticate a user. If you do not know the username in question, always return -2 from this
|
||||
* method to fall through to normal database authentication.
|
||||
* Note that if authentication succeeds, murmur will create a record of the user in it's database, reserving
|
||||
* the username and id so it cannot be used for normal database authentication.
|
||||
* The data in the certificate (name, email addresses etc), as well as the list of signing certificates,
|
||||
* should only be trusted if certstrong is true.
|
||||
*
|
||||
* Internally, Murmur treats usernames as case-insensitive. It is recommended
|
||||
* that authenticators do the same. Murmur checks if a username is in use when
|
||||
* a user connects. If the connecting user is registered, the other username is
|
||||
* kicked. If the connecting user is not registered, the connecting user is not
|
||||
* allowed to join the server.
|
||||
*
|
||||
* @param name Username to authenticate.
|
||||
* @param pw Password to authenticate with.
|
||||
* @param certificates List of der encoded certificates the user connected with.
|
||||
* @param certhash Hash of user certificate, as used by murmur internally when matching.
|
||||
* @param certstrong True if certificate was valid and signed by a trusted CA.
|
||||
* @param newname Set this to change the username from the supplied one.
|
||||
* @param groups List of groups on the root channel that the user will be added to for the duration of the connection.
|
||||
* @return UserID of authenticated user, -1 for authentication failures, -2 for unknown user (fallthrough),
|
||||
* -3 for authentication failures where the data could (temporarily) not be verified.
|
||||
*/
|
||||
idempotent int authenticate(string name, string pw, CertificateList certificates, string certhash, bool certstrong, out string newname, out GroupNameList groups);
|
||||
|
||||
/** Fetch information about a user. This is used to retrieve information like email address, keyhash etc. If you
|
||||
* want murmur to take care of this information itself, simply return false to fall through.
|
||||
* @param id User id.
|
||||
* @param info Information about user. This needs to include at least "name".
|
||||
* @return true if information is present, false to fall through.
|
||||
*/
|
||||
idempotent bool getInfo(int id, out UserInfoMap info);
|
||||
|
||||
/** Map a name to a user id.
|
||||
* @param name Username to map.
|
||||
* @return User id or -2 for unknown name.
|
||||
*/
|
||||
idempotent int nameToId(string name);
|
||||
|
||||
/** Map a user id to a username.
|
||||
* @param id User id to map.
|
||||
* @return Name of user or empty string for unknown id.
|
||||
*/
|
||||
idempotent string idToName(int id);
|
||||
|
||||
/** Map a user to a custom Texture.
|
||||
* @param id User id to map.
|
||||
* @return User texture or an empty texture for unknown users or users without textures.
|
||||
*/
|
||||
idempotent Texture idToTexture(int id);
|
||||
};
|
||||
|
||||
/** Callback interface for server authentication and registration. This allows you to support both authentication
|
||||
* and account updating.
|
||||
* You do not need to implement this if all you want is authentication, you only need this if other scripts
|
||||
* connected to the same server calls e.g. {@link Server.setTexture}.
|
||||
* Almost all of these methods support fall through, meaning murmur should continue the operation against its
|
||||
* own database.
|
||||
*/
|
||||
interface ServerUpdatingAuthenticator extends ServerAuthenticator {
|
||||
/** Register a new user.
|
||||
* @param info Information about user to register.
|
||||
* @return User id of new user, -1 for registration failure, or -2 to fall through.
|
||||
*/
|
||||
int registerUser(UserInfoMap info);
|
||||
|
||||
/** Unregister a user.
|
||||
* @param id Userid to unregister.
|
||||
* @return 1 for successful unregistration, 0 for unsuccessful unregistration, -1 to fall through.
|
||||
*/
|
||||
int unregisterUser(int id);
|
||||
|
||||
/** Get a list of registered users matching filter.
|
||||
* @param filter Substring usernames must contain. If empty, return all registered users.
|
||||
* @return List of matching registered users.
|
||||
*/
|
||||
idempotent NameMap getRegisteredUsers(string filter);
|
||||
|
||||
/** Set additional information for user registration.
|
||||
* @param id Userid of registered user.
|
||||
* @param info Information to set about user. This should be merged with existing information.
|
||||
* @return 1 for successful update, 0 for unsuccessful update, -1 to fall through.
|
||||
*/
|
||||
idempotent int setInfo(int id, UserInfoMap info);
|
||||
|
||||
/** Set texture (now called avatar) of user registration.
|
||||
* @param id registrationId of registered user.
|
||||
* @param tex New texture.
|
||||
* @return 1 for successful update, 0 for unsuccessful update, -1 to fall through.
|
||||
*/
|
||||
idempotent int setTexture(int id, Texture tex);
|
||||
};
|
||||
|
||||
/** Per-server interface. This includes all methods for configuring and altering
|
||||
* the state of a single virtual server. You can retrieve a pointer to this interface
|
||||
* from one of the methods in {@link Meta}.
|
||||
**/
|
||||
["amd"] interface Server {
|
||||
/** Shows if the server currently running (accepting users).
|
||||
*
|
||||
* @return Run-state of server.
|
||||
*/
|
||||
idempotent bool isRunning() throws InvalidSecretException;
|
||||
|
||||
/** Start server. */
|
||||
void start() throws ServerBootedException, ServerFailureException, InvalidSecretException;
|
||||
|
||||
/** Stop server.
|
||||
* Note: Server will be restarted on Murmur restart unless explicitly disabled
|
||||
* with setConf("boot", false)
|
||||
*/
|
||||
void stop() throws ServerBootedException, InvalidSecretException;
|
||||
|
||||
/** Delete server and all it's configuration. */
|
||||
void delete() throws ServerBootedException, InvalidSecretException;
|
||||
|
||||
/** Fetch the server id.
|
||||
*
|
||||
* @return Unique server id.
|
||||
*/
|
||||
idempotent int id() throws InvalidSecretException;
|
||||
|
||||
/** Add a callback. The callback will receive notifications about changes to users and channels.
|
||||
*
|
||||
* @param cb Callback interface which will receive notifications.
|
||||
* @see removeCallback
|
||||
*/
|
||||
void addCallback(ServerCallback *cb) throws ServerBootedException, InvalidCallbackException, InvalidSecretException;
|
||||
|
||||
/** Remove a callback.
|
||||
*
|
||||
* @param cb Callback interface to be removed.
|
||||
* @see addCallback
|
||||
*/
|
||||
void removeCallback(ServerCallback *cb) throws ServerBootedException, InvalidCallbackException, InvalidSecretException;
|
||||
|
||||
/** Set external authenticator. If set, all authentications from clients are forwarded to this
|
||||
* proxy.
|
||||
*
|
||||
* @param auth Authenticator object to perform subsequent authentications.
|
||||
*/
|
||||
void setAuthenticator(ServerAuthenticator *auth) throws ServerBootedException, InvalidCallbackException, InvalidSecretException;
|
||||
|
||||
/** Retrieve configuration item.
|
||||
* @param key Configuration key.
|
||||
* @return Configuration value. If this is empty, see {@link Meta.getDefaultConf}
|
||||
*/
|
||||
idempotent string getConf(string key) throws InvalidSecretException, WriteOnlyException;
|
||||
|
||||
/** Retrieve all configuration items.
|
||||
* @return All configured values. If a value isn't set here, the value from {@link Meta.getDefaultConf} is used.
|
||||
*/
|
||||
idempotent ConfigMap getAllConf() throws InvalidSecretException;
|
||||
|
||||
/** Set a configuration item.
|
||||
* @param key Configuration key.
|
||||
* @param value Configuration value.
|
||||
*/
|
||||
idempotent void setConf(string key, string value) throws InvalidSecretException;
|
||||
|
||||
/** Set superuser password. This is just a convenience for using {@link updateRegistration} on user id 0.
|
||||
* @param pw Password.
|
||||
*/
|
||||
idempotent void setSuperuserPassword(string pw) throws InvalidSecretException;
|
||||
|
||||
/** Fetch log entries.
|
||||
* @param first Lowest numbered entry to fetch. 0 is the most recent item.
|
||||
* @param last Last entry to fetch.
|
||||
* @return List of log entries.
|
||||
*/
|
||||
idempotent LogList getLog(int first, int last) throws InvalidSecretException;
|
||||
|
||||
/** Fetch length of log
|
||||
* @return Number of entries in log
|
||||
*/
|
||||
idempotent int getLogLen() throws InvalidSecretException;
|
||||
|
||||
/** Fetch all users. This returns all currently connected users on the server.
|
||||
* @return List of connected users.
|
||||
* @see getState
|
||||
*/
|
||||
idempotent UserMap getUsers() throws ServerBootedException, InvalidSecretException;
|
||||
|
||||
/** Fetch all channels. This returns all defined channels on the server. The root channel is always channel 0.
|
||||
* @return List of defined channels.
|
||||
* @see getChannelState
|
||||
*/
|
||||
idempotent ChannelMap getChannels() throws ServerBootedException, InvalidSecretException;
|
||||
|
||||
/** Fetch certificate of user. This returns the complete certificate chain of a user.
|
||||
* @param session Connection ID of user. See {@link User.session}.
|
||||
* @return Certificate list of user.
|
||||
*/
|
||||
idempotent CertificateList getCertificateList(int session) throws ServerBootedException, InvalidSessionException, InvalidSecretException;
|
||||
|
||||
/** Fetch all channels and connected users as a tree. This retrieves an easy-to-use representation of the server
|
||||
* as a tree. This is primarily used for viewing the state of the server on a webpage.
|
||||
* @return Recursive tree of all channels and connected users.
|
||||
*/
|
||||
idempotent Tree getTree() throws ServerBootedException, InvalidSecretException;
|
||||
|
||||
/** Fetch all current IP bans on the server.
|
||||
* @return List of bans.
|
||||
*/
|
||||
idempotent BanList getBans() throws ServerBootedException, InvalidSecretException;
|
||||
|
||||
/** Set all current IP bans on the server. This will replace any bans already present, so if you want to add a ban, be sure to call {@link getBans} and then
|
||||
* append to the returned list before calling this method.
|
||||
* @param bans List of bans.
|
||||
*/
|
||||
idempotent void setBans(BanList bans) throws ServerBootedException, InvalidSecretException;
|
||||
|
||||
/** Kick a user. The user is not banned, and is free to rejoin the server.
|
||||
* @param session Connection ID of user. See {@link User.session}.
|
||||
* @param reason Text message to show when user is kicked.
|
||||
*/
|
||||
void kickUser(int session, string reason) throws ServerBootedException, InvalidSessionException, InvalidSecretException;
|
||||
|
||||
/** Get state of a single connected user.
|
||||
* @param session Connection ID of user. See {@link User.session}.
|
||||
* @return State of connected user.
|
||||
* @see setState
|
||||
* @see getUsers
|
||||
*/
|
||||
idempotent User getState(int session) throws ServerBootedException, InvalidSessionException, InvalidSecretException;
|
||||
|
||||
/** Set user state. You can use this to move, mute and deafen users.
|
||||
* @param state User state to set.
|
||||
* @see getState
|
||||
*/
|
||||
idempotent void setState(User state) throws ServerBootedException, InvalidSessionException, InvalidChannelException, InvalidSecretException;
|
||||
|
||||
/** Send text message to a single user.
|
||||
* @param session Connection ID of user. See {@link User.session}.
|
||||
* @param text Message to send.
|
||||
* @see sendMessageChannel
|
||||
*/
|
||||
void sendMessage(int session, string text) throws ServerBootedException, InvalidSessionException, InvalidSecretException;
|
||||
|
||||
/** Check if user is permitted to perform action.
|
||||
* @param session Connection ID of user. See {@link User.session}.
|
||||
* @param channelid ID of Channel. See {@link Channel.id}.
|
||||
* @param perm Permission bits to check.
|
||||
* @return true if any of the permissions in perm were set for the user.
|
||||
*/
|
||||
bool hasPermission(int session, int channelid, int perm) throws ServerBootedException, InvalidSessionException, InvalidChannelException, InvalidSecretException;
|
||||
|
||||
/** Return users effective permissions
|
||||
* @param session Connection ID of user. See {@link User.session}.
|
||||
* @param channelid ID of Channel. See {@link Channel.id}.
|
||||
* @return bitfield of allowed actions
|
||||
*/
|
||||
idempotent int effectivePermissions(int session, int channelid) throws ServerBootedException, InvalidSessionException, InvalidChannelException, InvalidSecretException;
|
||||
|
||||
/** Add a context callback. This is done per user, and will add a context menu action for the user.
|
||||
*
|
||||
* @param session Session of user which should receive context entry.
|
||||
* @param action Action string, a unique name to associate with the action.
|
||||
* @param text Name of action shown to user.
|
||||
* @param cb Callback interface which will receive notifications.
|
||||
* @param ctx Context this should be used in. Needs to be one or a combination of {@link ContextServer}, {@link ContextChannel} and {@link ContextUser}.
|
||||
* @see removeContextCallback
|
||||
*/
|
||||
void addContextCallback(int session, string action, string text, ServerContextCallback *cb, int ctx) throws ServerBootedException, InvalidCallbackException, InvalidSecretException;
|
||||
|
||||
/** Remove a callback.
|
||||
*
|
||||
* @param cb Callback interface to be removed. This callback will be removed from all from all users.
|
||||
* @see addContextCallback
|
||||
*/
|
||||
void removeContextCallback(ServerContextCallback *cb) throws ServerBootedException, InvalidCallbackException, InvalidSecretException;
|
||||
|
||||
/** Get state of single channel.
|
||||
* @param channelid ID of Channel. See {@link Channel.id}.
|
||||
* @return State of channel.
|
||||
* @see setChannelState
|
||||
* @see getChannels
|
||||
*/
|
||||
idempotent Channel getChannelState(int channelid) throws ServerBootedException, InvalidChannelException, InvalidSecretException;
|
||||
|
||||
/** Set state of a single channel. You can use this to move or relink channels.
|
||||
* @param state Channel state to set.
|
||||
* @see getChannelState
|
||||
*/
|
||||
idempotent void setChannelState(Channel state) throws ServerBootedException, InvalidChannelException, InvalidSecretException, NestingLimitException;
|
||||
|
||||
/** Remove a channel and all its subchannels.
|
||||
* @param channelid ID of Channel. See {@link Channel.id}.
|
||||
*/
|
||||
void removeChannel(int channelid) throws ServerBootedException, InvalidChannelException, InvalidSecretException;
|
||||
|
||||
/** Add a new channel.
|
||||
* @param name Name of new channel.
|
||||
* @param parent Channel ID of parent channel. See {@link Channel.id}.
|
||||
* @return ID of newly created channel.
|
||||
*/
|
||||
int addChannel(string name, int parent) throws ServerBootedException, InvalidChannelException, InvalidSecretException, NestingLimitException;
|
||||
|
||||
/** Send text message to channel or a tree of channels.
|
||||
* @param channelid Channel ID of channel to send to. See {@link Channel.id}.
|
||||
* @param tree If true, the message will be sent to the channel and all its subchannels.
|
||||
* @param text Message to send.
|
||||
* @see sendMessage
|
||||
*/
|
||||
void sendMessageChannel(int channelid, bool tree, string text) throws ServerBootedException, InvalidChannelException, InvalidSecretException;
|
||||
|
||||
/** Retrieve ACLs and Groups on a channel.
|
||||
* @param channelid Channel ID of channel to fetch from. See {@link Channel.id}.
|
||||
* @param acls List of ACLs on the channel. This will include inherited ACLs.
|
||||
* @param groups List of groups on the channel. This will include inherited groups.
|
||||
* @param inherit Does this channel inherit ACLs from the parent channel?
|
||||
*/
|
||||
idempotent void getACL(int channelid, out ACLList acls, out GroupList groups, out bool inherit) throws ServerBootedException, InvalidChannelException, InvalidSecretException;
|
||||
|
||||
/** Set ACLs and Groups on a channel. Note that this will replace all existing ACLs and groups on the channel.
|
||||
* @param channelid Channel ID of channel to fetch from. See {@link Channel.id}.
|
||||
* @param acls List of ACLs on the channel.
|
||||
* @param groups List of groups on the channel.
|
||||
* @param inherit Should this channel inherit ACLs from the parent channel?
|
||||
*/
|
||||
idempotent void setACL(int channelid, ACLList acls, GroupList groups, bool inherit) throws ServerBootedException, InvalidChannelException, InvalidSecretException;
|
||||
|
||||
/** Temporarily add a user to a group on a channel. This state is not saved, and is intended for temporary memberships.
|
||||
* @param channelid Channel ID of channel to add to. See {@link Channel.id}.
|
||||
* @param session Connection ID of user. See {@link User.session}.
|
||||
* @param group Group name to add to.
|
||||
*/
|
||||
idempotent void addUserToGroup(int channelid, int session, string group) throws ServerBootedException, InvalidChannelException, InvalidSessionException, InvalidSecretException;
|
||||
|
||||
/** Remove a user from a temporary group membership on a channel. This state is not saved, and is intended for temporary memberships.
|
||||
* @param channelid Channel ID of channel to add to. See {@link Channel.id}.
|
||||
* @param session Connection ID of user. See {@link User.session}.
|
||||
* @param group Group name to remove from.
|
||||
*/
|
||||
idempotent void removeUserFromGroup(int channelid, int session, string group) throws ServerBootedException, InvalidChannelException, InvalidSessionException, InvalidSecretException;
|
||||
|
||||
/** Redirect whisper targets for user. If set, whenever a user tries to whisper to group "source", the whisper will be redirected to group "target".
|
||||
* To remove a redirect pass an empty target string. This is intended for context groups.
|
||||
* @param session Connection ID of user. See {@link User.session}.
|
||||
* @param source Group name to redirect from.
|
||||
* @param target Group name to redirect to.
|
||||
*/
|
||||
idempotent void redirectWhisperGroup(int session, string source, string target) throws ServerBootedException, InvalidSessionException, InvalidSecretException;
|
||||
|
||||
/** Map a list of {@link User.userid} to a matching name.
|
||||
* @param List of ids.
|
||||
* @return Matching list of names, with an empty string representing invalid or unknown ids.
|
||||
*/
|
||||
idempotent NameMap getUserNames(IdList ids) throws ServerBootedException, InvalidSecretException;
|
||||
|
||||
/** Map a list of user names to a matching id.
|
||||
* @param List of names.
|
||||
* @reuturn List of matching ids, with -1 representing invalid or unknown user names.
|
||||
*/
|
||||
idempotent IdMap getUserIds(NameList names) throws ServerBootedException, InvalidSecretException;
|
||||
|
||||
/** Register a new user.
|
||||
* @param info Information about new user. Must include at least "name".
|
||||
* @return The ID of the user. See {@link RegisteredUser.userid}.
|
||||
*/
|
||||
int registerUser(UserInfoMap info) throws ServerBootedException, InvalidUserException, InvalidSecretException;
|
||||
|
||||
/** Remove a user registration.
|
||||
* @param userid ID of registered user. See {@link RegisteredUser.userid}.
|
||||
*/
|
||||
void unregisterUser(int userid) throws ServerBootedException, InvalidUserException, InvalidSecretException;
|
||||
|
||||
/** Update the registration for a user. You can use this to set the email or password of a user,
|
||||
* and can also use it to change the user's name.
|
||||
* @param registration Updated registration record.
|
||||
*/
|
||||
idempotent void updateRegistration(int userid, UserInfoMap info) throws ServerBootedException, InvalidUserException, InvalidSecretException;
|
||||
|
||||
/** Fetch registration for a single user.
|
||||
* @param userid ID of registered user. See {@link RegisteredUser.userid}.
|
||||
* @return Registration record.
|
||||
*/
|
||||
idempotent UserInfoMap getRegistration(int userid) throws ServerBootedException, InvalidUserException, InvalidSecretException;
|
||||
|
||||
/** Fetch a group of registered users.
|
||||
* @param filter Substring of user name. If blank, will retrieve all registered users.
|
||||
* @return List of registration records.
|
||||
*/
|
||||
idempotent NameMap getRegisteredUsers(string filter) throws ServerBootedException, InvalidSecretException;
|
||||
|
||||
/** Verify the password of a user. You can use this to verify a user's credentials.
|
||||
* @param name User name. See {@link RegisteredUser.name}.
|
||||
* @param pw User password.
|
||||
* @return User ID of registered user (See {@link RegisteredUser.userid}), -1 for failed authentication or -2 for unknown usernames.
|
||||
*/
|
||||
idempotent int verifyPassword(string name, string pw) throws ServerBootedException, InvalidSecretException;
|
||||
|
||||
/** Fetch user texture. Textures are stored as zlib compress()ed 600x60 32-bit BGRA data.
|
||||
* @param userid ID of registered user. See {@link RegisteredUser.userid}.
|
||||
* @return Custom texture associated with user or an empty texture.
|
||||
*/
|
||||
idempotent Texture getTexture(int userid) throws ServerBootedException, InvalidUserException, InvalidSecretException;
|
||||
|
||||
/** Set a user texture (now called avatar).
|
||||
* @param userid ID of registered user. See {@link RegisteredUser.userid}.
|
||||
* @param tex Texture (as a Byte-Array) to set for the user, or an empty texture to remove the existing texture.
|
||||
*/
|
||||
idempotent void setTexture(int userid, Texture tex) throws ServerBootedException, InvalidUserException, InvalidTextureException, InvalidSecretException;
|
||||
|
||||
/** Get virtual server uptime.
|
||||
* @return Uptime of the virtual server in seconds
|
||||
*/
|
||||
idempotent int getUptime() throws ServerBootedException, InvalidSecretException;
|
||||
|
||||
/**
|
||||
* Update the server's certificate information.
|
||||
*
|
||||
* Reconfigure the running server's TLS socket with the given
|
||||
* certificate and private key.
|
||||
*
|
||||
* The certificate and and private key must be PEM formatted.
|
||||
*
|
||||
* New clients will see the new certificate.
|
||||
* Existing clients will continue to see the certificate the server
|
||||
* was using when they connected to it.
|
||||
*
|
||||
* This method throws InvalidInputDataException if any of the
|
||||
* following errors happen:
|
||||
* - Unable to decode the PEM certificate and/or private key.
|
||||
* - Unable to decrypt the private key with the given passphrase.
|
||||
* - The certificate and/or private key do not contain RSA keys.
|
||||
* - The certificate is not usable with the given private key.
|
||||
*/
|
||||
idempotent void updateCertificate(string certificate, string privateKey, string passphrase) throws ServerBootedException, InvalidSecretException, InvalidInputDataException;
|
||||
|
||||
/**
|
||||
* Makes the given user start listening to the given channel.
|
||||
* @param userid The ID of the user
|
||||
* @param channelid The ID of the channel
|
||||
*/
|
||||
idempotent void startListening(int userid, int channelid);
|
||||
|
||||
/**
|
||||
* Makes the given user stop listening to the given channel.
|
||||
* @param userid The ID of the user
|
||||
* @param channelid The ID of the channel
|
||||
*/
|
||||
idempotent void stopListening(int userid, int channelid);
|
||||
|
||||
/**
|
||||
* @param userid The ID of the user
|
||||
* @param channelid The ID of the channel
|
||||
* @returns Whether the given user is currently listening to the given channel
|
||||
*/
|
||||
idempotent bool isListening(int userid, int channelid);
|
||||
|
||||
/**
|
||||
* @param userid The ID of the user
|
||||
* @returns An ID-list of channels the given user is listening to
|
||||
*/
|
||||
idempotent IntList getListeningChannels(int userid);
|
||||
|
||||
/**
|
||||
* @param channelid The ID of the channel
|
||||
* @returns An ID-list of users listening to the given channel
|
||||
*/
|
||||
idempotent IntList getListeningUsers(int channelid);
|
||||
|
||||
/**
|
||||
* @param channelid The ID of the channel
|
||||
* @param userid The ID of the user
|
||||
* @returns The volume adjustment set for a listener of the given user in the given channel
|
||||
*/
|
||||
idempotent float getListenerVolumeAdjustment(int channelid, int userid);
|
||||
|
||||
/**
|
||||
* Sets the volume adjustment set for a listener of the given user in the given channel
|
||||
* @param channelid The ID of the channel
|
||||
* @param userid The ID of the user
|
||||
*/
|
||||
idempotent void setListenerVolumeAdjustment(int channelid, int userid, float volumeAdjustment);
|
||||
|
||||
/**
|
||||
* @param receiverUserIDs list of IDs of the users the message shall be sent to
|
||||
*/
|
||||
idempotent void sendWelcomeMessage(IdList receiverUserIDs);
|
||||
};
|
||||
|
||||
/** Callback interface for Meta. You can supply an implementation of this to receive notifications
|
||||
* when servers are stopped or started.
|
||||
* If an added callback ever throws an exception or goes away, it will be automatically removed.
|
||||
* Please note that all callbacks are done asynchronously; murmur does not wait for the callback to
|
||||
* complete before continuing processing.
|
||||
* @see ServerCallback
|
||||
* @see Meta.addCallback
|
||||
*/
|
||||
interface MetaCallback {
|
||||
/** Called when a server is started. The server is up and running when this event is sent, so all methods that
|
||||
* need a running server will work.
|
||||
* @param srv Interface for started server.
|
||||
*/
|
||||
void started(Server *srv);
|
||||
|
||||
/** Called when a server is stopped. The server is already stopped when this event is sent, so no methods that
|
||||
* need a running server will work.
|
||||
* @param srv Interface for started server.
|
||||
*/
|
||||
void stopped(Server *srv);
|
||||
};
|
||||
|
||||
sequence<Server *> ServerList;
|
||||
|
||||
/** This is the meta interface. It is primarily used for retrieving the {@link Server} interfaces for each individual server.
|
||||
**/
|
||||
["amd"] interface Meta {
|
||||
/** Fetch interface to specific server.
|
||||
* @param id Server ID. See {@link Server.getId}.
|
||||
* @return Interface for specified server, or a null proxy if id is invalid.
|
||||
*/
|
||||
idempotent Server *getServer(int id) throws InvalidSecretException;
|
||||
|
||||
/** Create a new server. Call {@link Server.getId} on the returned interface to find it's ID.
|
||||
* @return Interface for new server.
|
||||
*/
|
||||
Server *newServer() throws InvalidSecretException;
|
||||
|
||||
/** Fetch list of all currently running servers.
|
||||
* @return List of interfaces for running servers.
|
||||
*/
|
||||
idempotent ServerList getBootedServers() throws InvalidSecretException;
|
||||
|
||||
/** Fetch list of all defined servers.
|
||||
* @return List of interfaces for all servers.
|
||||
*/
|
||||
idempotent ServerList getAllServers() throws InvalidSecretException;
|
||||
|
||||
/** Fetch default configuration. This returns the configuration items that were set in the configuration file, or
|
||||
* the built-in default. The individual servers will use these values unless they have been overridden in the
|
||||
* server specific configuration. The only special case is the port, which defaults to the value defined here +
|
||||
* the servers ID - 1 (so that virtual server #1 uses the defined port, server #2 uses port+1 etc).
|
||||
* @return Default configuration of the servers.
|
||||
*/
|
||||
idempotent ConfigMap getDefaultConf() throws InvalidSecretException;
|
||||
|
||||
/** Fetch version of Murmur.
|
||||
* @param major Major version.
|
||||
* @param minor Minor version.
|
||||
* @param patch Patchlevel.
|
||||
* @param text Textual representation of version. Note that this may not match the {@link major}, {@link minor} and {@link patch} levels, as it
|
||||
* may be simply the compile date or the SVN revision. This is usually the text you want to present to users.
|
||||
*/
|
||||
idempotent void getVersion(out int major, out int minor, out int patch, out string text);
|
||||
|
||||
/** Add a callback. The callback will receive notifications when servers are started or stopped.
|
||||
*
|
||||
* @param cb Callback interface which will receive notifications.
|
||||
*/
|
||||
void addCallback(MetaCallback *cb) throws InvalidCallbackException, InvalidSecretException;
|
||||
|
||||
/** Remove a callback.
|
||||
*
|
||||
* @param cb Callback interface to be removed.
|
||||
*/
|
||||
void removeCallback(MetaCallback *cb) throws InvalidCallbackException, InvalidSecretException;
|
||||
|
||||
/** Get murmur uptime.
|
||||
* @return Uptime of murmur in seconds
|
||||
*/
|
||||
idempotent int getUptime();
|
||||
|
||||
/** Get slice file.
|
||||
* @return Contents of the slice file server compiled with.
|
||||
*/
|
||||
idempotent string getSlice();
|
||||
|
||||
/** Returns a checksum dict for the slice file.
|
||||
* @return Checksum dict
|
||||
*/
|
||||
idempotent Ice::SliceChecksumDict getSliceChecksums();
|
||||
};
|
||||
};
|
||||
19
requirements.txt
Normal file
19
requirements.txt
Normal file
@ -0,0 +1,19 @@
|
||||
annotated-types==0.7.0
|
||||
anyio==4.9.0
|
||||
asgiref==3.8.1
|
||||
bcrypt==4.3.0
|
||||
Django==5.2.2
|
||||
idna==3.10
|
||||
lockfile==0.12.2
|
||||
mysqlclient==2.2.7
|
||||
psycopg==3.2.9
|
||||
psycopg-binary==3.2.9
|
||||
pydantic==2.11.5
|
||||
pydantic_core==2.33.2
|
||||
python-daemon==3.1.2
|
||||
sniffio==1.3.1
|
||||
sqlparse==0.5.3
|
||||
starlette==0.46.2
|
||||
typing-inspection==0.4.1
|
||||
typing_extensions==4.14.0
|
||||
zeroc-ice==3.7.10.1
|
||||
Loading…
Reference in New Issue
Block a user