コード例 #1
0
    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)
コード例 #2
0
ファイル: discovery.py プロジェクト: RepublicMaster/pydevp2p
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)