mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-01 01:09:22 +01:00
core: enumerate our server after calling proto.connect()
This gives protocol modules a chance to manipulate their SID before it's added to the internal server list, replacing hacks previously used by the Nefarious and Clientbot modules. This is the first step to sid-less servers :)
This commit is contained in:
parent
c410de2fad
commit
852bd74c3b
10
classes.py
10
classes.py
@ -116,9 +116,7 @@ class Irc():
|
||||
# Intialize the server, channel, and user indexes to be populated by
|
||||
# our protocol module. For the server index, we can add ourselves right
|
||||
# now.
|
||||
self.servers = {self.sid: IrcServer(None, self.serverdata['hostname'],
|
||||
internal=True, desc=self.serverdata.get('serverdesc')
|
||||
or self.botdata['serverdesc'])}
|
||||
self.servers = {}
|
||||
self.users = {}
|
||||
self.channels = structures.KeyedDefaultdict(IrcChannel)
|
||||
|
||||
@ -277,6 +275,12 @@ class Irc():
|
||||
# All our checks passed, get the protocol module to connect
|
||||
# and run the listen loop.
|
||||
self.proto.connect()
|
||||
|
||||
log.info('(%s) Enumerating our own SID %s', self.name, self.sid)
|
||||
self.servers[self.sid] = IrcServer(None, self.serverdata['hostname'],
|
||||
internal=True, desc=self.serverdata.get('serverdesc')
|
||||
or self.botdata['serverdesc'])
|
||||
|
||||
log.info('(%s) Starting ping schedulers....', self.name)
|
||||
self.schedulePing()
|
||||
log.info('(%s) Server ready; listening for data.', self.name)
|
||||
|
@ -49,11 +49,8 @@ class ClientbotWrapperProtocol(Protocol):
|
||||
# TODO: fetch channel/user/prefix modes from RPL_ISUPPORT.
|
||||
#self.irc.prefixmodes = {'q': '~', 'a': '&', 'o': '@', 'h': '%', 'v': '+'}
|
||||
|
||||
# HACK: Replace the SID from the config options with our own.
|
||||
old_sid = self.irc.sid
|
||||
self.irc.sid = sid = self.sidgen.next_uid()
|
||||
self.irc.servers[sid] = self.irc.servers[old_sid]
|
||||
del self.irc.servers[old_sid]
|
||||
# Enumerate our own server
|
||||
self.irc.sid = self.sidgen.next_sid()
|
||||
|
||||
# Clear states from last connect
|
||||
self.who_received.clear()
|
||||
|
@ -718,11 +718,8 @@ class P10Protocol(IRCS2SProtocol):
|
||||
|
||||
name = self.irc.serverdata["hostname"]
|
||||
|
||||
# HACK: Encode our SID everywhere, and replace it in the IrcServer index.
|
||||
old_sid = self.irc.sid
|
||||
self.irc.sid = sid = p10b64encode(self.irc.serverdata["sid"])
|
||||
self.irc.servers[sid] = self.irc.servers[old_sid]
|
||||
del self.irc.servers[old_sid]
|
||||
# Encode our SID using P10 Base64.
|
||||
self.irc.sid = p10b64encode(self.irc.serverdata["sid"])
|
||||
|
||||
desc = self.irc.serverdata.get('serverdesc') or self.irc.botdata['serverdesc']
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user