mirror of
https://github.com/jlu5/PyLink.git
synced 2025-01-23 10:44:09 +01:00
protocols: make "uidgen" a protocol instance attribute
This commit is contained in:
parent
95b70f3ebf
commit
3a8d3d146c
@ -57,9 +57,6 @@ class Irc():
|
|||||||
self.uplink = None
|
self.uplink = None
|
||||||
self.start_ts = int(time.time())
|
self.start_ts = int(time.time())
|
||||||
|
|
||||||
# UID generators, for servers that need it
|
|
||||||
self.uidgen = {}
|
|
||||||
|
|
||||||
def __init__(self, netname, proto):
|
def __init__(self, netname, proto):
|
||||||
# Initialize some variables
|
# Initialize some variables
|
||||||
self.name = netname.lower()
|
self.name = netname.lower()
|
||||||
|
@ -25,6 +25,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
|
|||||||
'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"])
|
self.sidgen = utils.TS6SIDGenerator(self.irc.serverdata["sidrange"])
|
||||||
|
self.uidgen = {}
|
||||||
|
|
||||||
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):
|
||||||
@ -35,11 +36,9 @@ class InspIRCdProtocol(TS6BaseProtocol):
|
|||||||
server = server or self.irc.sid
|
server = server or self.irc.sid
|
||||||
if not utils.isInternalServer(self.irc, server):
|
if not utils.isInternalServer(self.irc, server):
|
||||||
raise ValueError('Server %r is not a PyLink internal PseudoServer!' % server)
|
raise ValueError('Server %r is not a PyLink internal PseudoServer!' % server)
|
||||||
# We need a separate UID generator instance for every PseudoServer
|
# Create an UIDGenerator instance for every SID, so that each gets
|
||||||
# we spawn. Otherwise, things won't wrap around properly.
|
# distinct values.
|
||||||
if server not in self.irc.uidgen:
|
uid = self.uidgen.setdefault(server, utils.TS6UIDGenerator(server)).next_uid()
|
||||||
self.irc.uidgen[server] = utils.TS6UIDGenerator(server)
|
|
||||||
uid = self.irc.uidgen[server].next_uid()
|
|
||||||
ts = ts or int(time.time())
|
ts = ts or int(time.time())
|
||||||
realname = realname or self.irc.botdata['realname']
|
realname = realname or self.irc.botdata['realname']
|
||||||
realhost = realhost or host
|
realhost = realhost or host
|
||||||
|
@ -18,6 +18,7 @@ class TS6Protocol(TS6BaseProtocol):
|
|||||||
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"])
|
self.sidgen = utils.TS6SIDGenerator(self.irc.serverdata["sidrange"])
|
||||||
|
self.uidgen = {}
|
||||||
|
|
||||||
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):
|
||||||
@ -28,11 +29,9 @@ class TS6Protocol(TS6BaseProtocol):
|
|||||||
server = server or self.irc.sid
|
server = server or self.irc.sid
|
||||||
if not utils.isInternalServer(self.irc, server):
|
if not utils.isInternalServer(self.irc, server):
|
||||||
raise ValueError('Server %r is not a PyLink internal PseudoServer!' % server)
|
raise ValueError('Server %r is not a PyLink internal PseudoServer!' % server)
|
||||||
# We need a separate UID generator instance for every PseudoServer
|
# Create an UIDGenerator instance for every SID, so that each gets
|
||||||
# we spawn. Otherwise, things won't wrap around properly.
|
# distinct values.
|
||||||
if server not in self.irc.uidgen:
|
uid = self.uidgen.setdefault(server, utils.TS6UIDGenerator(server)).next_uid()
|
||||||
self.irc.uidgen[server] = utils.TS6UIDGenerator(server)
|
|
||||||
uid = self.irc.uidgen[server].next_uid()
|
|
||||||
# EUID:
|
# EUID:
|
||||||
# parameters: nickname, hopcount, nickTS, umodes, username,
|
# parameters: nickname, hopcount, nickTS, umodes, username,
|
||||||
# visible hostname, IP address, UID, real hostname, account name, gecos
|
# visible hostname, IP address, UID, real hostname, account name, gecos
|
||||||
|
Loading…
Reference in New Issue
Block a user