latest.ipv8.messaging.interfaces.dispatcher.endpoint
Module Contents
Classes
An Endpoint implementation to dispatch to other Endpoint implementations. |
Functions
|
Attempt to guess the interface for the given address. |
Attributes
The INTERFACES dictionary describes the mapping of interface names to interface classes. |
|
The PREFERENCE_ORDER list describes the order of preference for the available interfaces. |
|
The FAST_ADDR_TO_INTERFACE is an internal DispatcherEndpoint mapping, to quickly route information. |
- latest.ipv8.messaging.interfaces.dispatcher.endpoint.INTERFACES
The INTERFACES dictionary describes the mapping of interface names to interface classes.
- latest.ipv8.messaging.interfaces.dispatcher.endpoint.PREFERENCE_ORDER = ['UDPIPv4', 'UDPIPv6']
The PREFERENCE_ORDER list describes the order of preference for the available interfaces. For example,
["UDPIPv4", "UDPIPv6"]
means: use IPv4 over IPv6, if it is available.
- latest.ipv8.messaging.interfaces.dispatcher.endpoint.FAST_ADDR_TO_INTERFACE: dict[type, str]
The FAST_ADDR_TO_INTERFACE is an internal DispatcherEndpoint mapping, to quickly route information. For addresses which do not use these classes the slower
guess_interface
will be used.
- latest.ipv8.messaging.interfaces.dispatcher.endpoint.guess_interface(socket_address: Any) str | None
Attempt to guess the interface for the given address.
If the given address is a tuple of a valid IPv4 address string and a port this returns “UDPIPv4”. If the given address is a tuple of a valid IPv6 address string and a port this returns “UDPIPv6”. Otherwise, this returns None.
- class latest.ipv8.messaging.interfaces.dispatcher.endpoint.DispatcherEndpoint(interfaces: list[str], **kwargs)
Bases:
latest.ipv8.messaging.interfaces.endpoint.Endpoint
An Endpoint implementation to dispatch to other Endpoint implementations.
The added complexity is as follows:
Receiving of packets is hooked directly into the sub-Endpoints, no speed is lost.
Sending packets will be directed to the appropriate interface. If an address object class is not defined in FAST_ADDR_TO_INTERFACE, this will have to use
guess_interface
.Adding and removing listeners will have to be forwarded to all sub-Endpoints.
- add_listener(listener: latest.ipv8.messaging.interfaces.endpoint.EndpointListener) None
Reroute a listener to all the interfaces we dispatch to.
- add_prefix_listener(listener: latest.ipv8.messaging.interfaces.endpoint.EndpointListener, prefix: bytes) None
Reroute a prefix listener to all the interfaces we dispatch to.
- remove_listener(listener: latest.ipv8.messaging.interfaces.endpoint.EndpointListener) None
Remove a listener from all the interfaces we dispatch to.
- notify_listeners(packet: tuple[ipv8.types.Address, bytes]) None
Dispatch a new packet to all interfaces.
- get_address(interface: str | None = None) ipv8.types.Address
Get the most likely interface for our interfaces.