def handle_INF(self, data): if self.state not in ("IDENTIFY", "NORMAL"): self.status(44, "Invalid state", "FCBINF") return sid, data = data.split(" ", 1) self.inf.update(flag_dict(data)) # Verify that tiger(PID) == CID. if "ID" in self.inf and "PD" in self.inf: hashed = b32d(self.inf["ID"]) unhashed = b32d(self.inf["PD"]) if tiger.new(unhashed).digest() != hashed: self.status(27, "PID does not match CID") return # If the IP address was not provided, or if it was blank, write down # their actual connecting IP. if "I4" not in self.inf or self.inf["I4"] == "0.0.0.0": self.inf["I4"] = self.addr.host # If we weren't identified before, transition to VERIFY and ask for a # password. if self.state == "IDENTIFY": if pass_ip_check(self.addr.host): self.enter() return self.state = "VERIFY" self.nonce = rand32(16) gpa = "IGPA %s" % self.nonce self.sendLine(gpa)
def test_flag_dict_escaped(self): i = "DEcurrent\\stopic" o = {"DE": "current topic"} self.assertEqual(flag_dict(i), o)
def test_flag_dict_multiple(self): i = "HU1 HI1" o = {"HU": "1", "HI": "1"} self.assertEqual(flag_dict(i), o)
def test_flag_dict_single(self): i = "FS0" o = {"FS": "0"} self.assertEqual(flag_dict(i), o)