-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmumble.py
executable file
·69 lines (54 loc) · 1.86 KB
/
mumble.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env python3
import operator
import random
import Ice
Ice.loadSlice('-I/usr/share/Ice/slice', ['/usr/share/slice/Murmur.ice'])
import Murmur
from sqlalchemy.orm.exc import NoResultFound
import db
class Authenticator(Murmur.ServerAuthenticator):
def authenticate(self, name, pw, certificates, certhash, certstrong, current=None):
try:
new_name = ''
if name == 'raylu-bot' and pw == 'bot':
return 999999999, new_name, ['grim sleepers']
try:
db.session.query(db.User).filter(db.User.username==name).one()
except NoResultFound:
new_name = '[G] ' + name
return random.randint(1000000000, 2147483647), new_name, [] # guest
user = db.User.login(name, pw)
if not user:
return -1, new_name, [] # bad password for registered user
entities = user.entities()
groups = user.groups(entities)
group_names = list(map(operator.attrgetter('name'), groups))
if user.flags == 1:
group_names.append('admin')
return user.id, new_name, group_names # regular login
finally:
db.session.remove()
def getInfo(self, id, current=None):
return False, {}
def nameToId(self, name, current=None):
return -2
def idToName(self, id, corrent=None):
return ''
def idToTexture(self, id, corrent=None):
return []
def ice_auth(obj):
return obj.ice_context({'secret': 'ice'})
ice = Ice.initialize()
meta = Murmur.MetaPrx.checkedCast(ice.stringToProxy('Meta:tcp -h 127.0.0.1 -p 6502'))
meta = ice_auth(meta)
adapter = ice.createObjectAdapterWithEndpoints('Callback.Client', 'tcp -h 127.0.0.1')
adapter.activate()
server = ice_auth(meta.getBootedServers()[0])
authenticator = Authenticator()
server_authenticator = Murmur.ServerAuthenticatorPrx.uncheckedCast(adapter.addWithUUID(authenticator))
server_authenticator = ice_auth(server_authenticator)
server.setAuthenticator(server_authenticator)
try:
ice.waitForShutdown()
finally:
ice.shutdown()