Module libp2p_transport

This module defines the libp2p_transport behaviour.
Required callback functions: start_link/1, start_listener/2, connect/5, match_addr/2, sort_addrs/1.

Data Types

connection_handler()


connection_handler() = {atom(), atom()}

Function Index

connect_to/4Connect through a transport service.
find_session/3Find a existing session for one of a given list of multiaddrs.
for_addr/2
sort_addrs/2 Addresses are sorted by priority ranking from 1 to 5 (1 highest and 5 lowest priority) 1 = NON rfc1918 IP (public IPs), 2 = P2P circuit address (relay), 3 = P2P address, 4 = rfc1918 IPs (private/local IPs), 5 = Proxy transport.
start_client_session/3
start_link/2
start_server_session/3

Function Details

connect_to/4


connect_to(Addr::string(), Options::libp2p_swarm:connect_opts(), Timeout::pos_integer(), TID::ets:tab()) -> {ok, pid()} | {error, term()}


Connect through a transport service. This is a convenience function that verifies the given multiaddr, finds the right transport, and checks if a session already exists for the given multiaddr. The existing session is returned if it already exists, or a connect call is made to transport service to perform the actual connect.

find_session/3


find_session(Tail::[string()], Options::libp2p_config:opts(), TID::ets:tab()) -> {ok, string(), pid()} | {error, term()}


Find a existing session for one of a given list of multiaddrs. Returns {error not_found} if no session is found.

for_addr/2


for_addr(TID::ets:tab(), Addr::string()) -> {ok, string(), {atom(), pid()}} | {error, term()}


sort_addrs/2


sort_addrs(TID::ets:tab(), Addrs::[string()]) -> [string()]


Addresses are sorted by priority ranking from 1 to 5 (1 highest and 5 lowest priority) 1 = NON rfc1918 IP (public IPs), 2 = P2P circuit address (relay), 3 = P2P address, 4 = rfc1918 IPs (private/local IPs), 5 = Proxy transport

start_client_session/3


start_client_session(TID::ets:tab(), Addr::string(), Connection::libp2p_connection:connection()) -> {ok, pid()} | {error, term()}


start_link/2

start_link(TransportMod, TID) -> any()

start_server_session/3


start_server_session(Ref::reference(), TID::ets:tab(), Connection::libp2p_connection:connection()) -> {ok, pid()} | {error, term()}