From b63d7619dab95d30a7779cc35472874f55d3a035 Mon Sep 17 00:00:00 2001 From: James Lu Date: Sat, 5 Sep 2015 11:52:46 -0700 Subject: [PATCH] unreal: validate uplink protocol version (needs >=2351) --- protocols/unreal.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/protocols/unreal.py b/protocols/unreal.py index a0d8867..47a2285 100644 --- a/protocols/unreal.py +++ b/protocols/unreal.py @@ -125,7 +125,6 @@ def handle_pong(irc, source, command, args): def handle_server(irc, numeric, command, args): # <- SERVER unreal.midnight.vpn 1 :U2351-Fhin6OoEM UnrealIRCd test server - # <- SERVER unreal.midnight.vpn 1 :UnrealIRCd test server sname = args[0] # TODO: handle introductions for other servers if numeric == irc.uplink: @@ -136,6 +135,19 @@ def handle_server(irc, numeric, command, args): "is probably too old! (Got: %s, needed: %s)" % (sorted(irc.protodata.keys()), sorted(_neededCaps))) + sdesc = args[-1].split(" ") + # Get our protocol version :) + vline = sdesc[0].split('-', 1) + try: + protover = int(vline[0].strip('U')) + except ValueError: + raise ProtocolError("Protocol version too old! (needs at least 2351 " + "(Unreal 3.4-beta1/2), got something invalid; " + "is VL being sent?)") + sdesc = args[-1][1:] + if protover < 2351: + raise ProtocolError("Protocol version too old! (needs at least 2351 " + "(Unreal 3.4-beta1/2), got %s)" % protover) irc.servers[numeric] = IrcServer(None, sname) else: raise NotImplementedError