3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-12-25 04:02:45 +01:00

ts6/inspircd: fix TS6SIDGenerator not actually incrementing...

It was being replaced on every call... It was only supposed to do that if sidgen hadn't been set yet!
This commit is contained in:
James Lu 2015-09-12 12:05:53 -07:00
parent 36b0a08368
commit 0cbdefcab1
2 changed files with 4 additions and 4 deletions

View File

@ -24,6 +24,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
self.hook_map = {'FJOIN': 'JOIN', 'RSQUIT': 'SQUIT', 'FMODE': 'MODE', self.hook_map = {'FJOIN': 'JOIN', 'RSQUIT': 'SQUIT', 'FMODE': 'MODE',
'FTOPIC': 'TOPIC', 'OPERTYPE': 'MODE', 'FHOST': 'CHGHOST', 'FTOPIC': 'TOPIC', 'OPERTYPE': 'MODE', 'FHOST': 'CHGHOST',
'FIDENT': 'CHGIDENT', 'FNAME': 'CHGNAME'} 'FIDENT': 'CHGIDENT', 'FNAME': 'CHGNAME'}
self.sidgen = utils.TS6SIDGenerator(self.irc.serverdata["sidrange"])
def spawnClient(self, nick, ident='null', host='null', realhost=None, modes=set(), def spawnClient(self, nick, ident='null', host='null', realhost=None, modes=set(),
server=None, ip='0.0.0.0', realname=None, ts=None, opertype=None): server=None, ip='0.0.0.0', realname=None, ts=None, opertype=None):
@ -272,8 +273,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
# "desc" defaults to the configured server description. # "desc" defaults to the configured server description.
desc = desc or self.irc.serverdata.get('serverdesc') or self.irc.botdata['serverdesc'] desc = desc or self.irc.serverdata.get('serverdesc') or self.irc.botdata['serverdesc']
if sid is None: # No sid given; generate one! if sid is None: # No sid given; generate one!
self.irc.sidgen = utils.TS6SIDGenerator(self.irc.serverdata["sidrange"]) sid = self.sidgen.next_sid()
sid = self.irc.sidgen.next_sid()
assert len(sid) == 3, "Incorrect SID length" assert len(sid) == 3, "Incorrect SID length"
if sid in self.irc.servers: if sid in self.irc.servers:
raise ValueError('A server with SID %r already exists!' % sid) raise ValueError('A server with SID %r already exists!' % sid)

View File

@ -17,6 +17,7 @@ class TS6Protocol(TS6BaseProtocol):
super(TS6Protocol, self).__init__(irc) super(TS6Protocol, self).__init__(irc)
self.casemapping = 'rfc1459' self.casemapping = 'rfc1459'
self.hook_map = {'SJOIN': 'JOIN', 'TB': 'TOPIC', 'TMODE': 'MODE', 'BMASK': 'MODE'} self.hook_map = {'SJOIN': 'JOIN', 'TB': 'TOPIC', 'TMODE': 'MODE', 'BMASK': 'MODE'}
self.sidgen = utils.TS6SIDGenerator(self.irc.serverdata["sidrange"])
def spawnClient(self, nick, ident='null', host='null', realhost=None, modes=set(), def spawnClient(self, nick, ident='null', host='null', realhost=None, modes=set(),
server=None, ip='0.0.0.0', realname=None, ts=None, opertype=None): server=None, ip='0.0.0.0', realname=None, ts=None, opertype=None):
@ -263,8 +264,7 @@ class TS6Protocol(TS6BaseProtocol):
name = name.lower() name = name.lower()
desc = desc or self.irc.serverdata.get('serverdesc') or self.irc.botdata['serverdesc'] desc = desc or self.irc.serverdata.get('serverdesc') or self.irc.botdata['serverdesc']
if sid is None: # No sid given; generate one! if sid is None: # No sid given; generate one!
self.irc.sidgen = utils.TS6SIDGenerator(self.irc.serverdata["sidrange"]) sid = self.sidgen.next_sid()
sid = self.irc.sidgen.next_sid()
assert len(sid) == 3, "Incorrect SID length" assert len(sid) == 3, "Incorrect SID length"
if sid in self.irc.servers: if sid in self.irc.servers:
raise ValueError('A server with SID %r already exists!' % sid) raise ValueError('A server with SID %r already exists!' % sid)