pass class InvalidSignature(DefectiveMessage): pass class WrongMAC(DefectiveMessage): pass class PacketExpired(DefectiveMessage): pass enc_port = lambda p: utils.ienc4(p)[-2:] dec_port = utils.idec class Address(object): """ Extend later, but make sure we deal with objects Multiaddress https://github.com/haypo/python-ipy """ def __init__(self, ip, udp_port, tcp_port=0, from_binary=False): tcp_port = tcp_port or udp_port if from_binary: assert len(ip) in (4, 16), repr(ip) self.udp_port = dec_port(udp_port) self.tcp_port = dec_port(tcp_port)
class DefectiveMessage(Exception): pass class InvalidSignature(DefectiveMessage): pass class WrongMAC(DefectiveMessage): pass class PacketExpired(DefectiveMessage): pass enc_port = lambda p: utils.ienc4(p)[-2:] dec_port = utils.idec class Address(object): """ Extend later, but make sure we deal with objects Multiaddress https://github.com/haypo/python-ipy """ def __init__(self, ip, udp_port, tcp_port=0, from_binary=False): tcp_port = tcp_port or udp_port if from_binary: assert len(ip) in (4, 16), repr(ip)