3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-30 14:49:28 +01:00

inspircd: define minimum & target protocol versions instead of hardcoding them

This commit is contained in:
James Lu 2016-03-26 16:23:22 -07:00
parent 70b9bde2c4
commit d5d3c2422b

View File

@ -32,6 +32,9 @@ class InspIRCdProtocol(TS6BaseProtocol):
self.sidgen = utils.TS6SIDGenerator(self.irc) self.sidgen = utils.TS6SIDGenerator(self.irc)
self.uidgen = {} self.uidgen = {}
self.min_proto_ver = 1202
self.proto_ver = 1202
### Outgoing commands ### Outgoing commands
def spawnClient(self, nick, ident='null', host='null', realhost=None, modes=set(), def spawnClient(self, nick, ident='null', host='null', realhost=None, modes=set(),
@ -340,8 +343,8 @@ class InspIRCdProtocol(TS6BaseProtocol):
ts = self.irc.start_ts ts = self.irc.start_ts
f = self.irc.send f = self.irc.send
f('CAPAB START 1202') f('CAPAB START %s' % self.proto_ver)
f('CAPAB CAPABILITIES :PROTOCOL=1202') f('CAPAB CAPABILITIES :PROTOCOL=%s' % self.proto_ver)
f('CAPAB END') f('CAPAB END')
host = self.irc.serverdata["hostname"] host = self.irc.serverdata["hostname"]
@ -417,10 +420,11 @@ class InspIRCdProtocol(TS6BaseProtocol):
# Check the protocol version # Check the protocol version
protocol_version = int(caps['PROTOCOL']) protocol_version = int(caps['PROTOCOL'])
if protocol_version < 1202: if protocol_version < self.min_proto_ver:
raise ProtocolError("Remote protocol version is too old! " raise ProtocolError("Remote protocol version is too old! "
"At least 1202 (InspIRCd 2.0.x) is " "At least %s (InspIRCd 2.0.x) is "
"needed. (got %s)" % protocol_version) "needed. (got %s)" % (self.min_proto_ver,
protocol_version))
# Store the max nick and channel lengths # Store the max nick and channel lengths
self.irc.maxnicklen = int(caps['NICKMAX']) self.irc.maxnicklen = int(caps['NICKMAX'])