proxystore.p2p.nat¶
Tools for getting the NAT type using STUN.
This module is a wrapper around the tools provided by pystun3.
NatType
¶
Bases: Enum
NAT type.
Learn more about NAT types at https://en.wikipedia.org/wiki/Network_address_translation.
OpenInternet
class-attribute
instance-attribute
¶
Host is not behind a NAT.
FullCone
class-attribute
instance-attribute
¶
Host is behind a full-cone NAT.
SymmetricUDPFirewall
class-attribute
instance-attribute
¶
Host is behind a symmetric UDP firewall.
RestrictedCone
class-attribute
instance-attribute
¶
Host is behind a restricted-cone NAT.
PortRestrictedCone
class-attribute
instance-attribute
¶
Host is behind a port-restricted-cone NAT.
Symmetric
class-attribute
instance-attribute
¶
Host is behind a symmetric NAT.
Result
¶
Bases: NamedTuple
Result of NAT type check.
Attributes:
-
nat_type
(NatType
) –Enum type of the found NAT this host is behind.
-
external_ip
(str
) –External IP of this host.
-
external_port
(int
) –External port of this host.
check_nat
¶
Check the NAT type this host is behind.
This function uses the STUN protocol (RFC 3489) to discover the presence and type of the NAT between this host and the open Internet.
Parameters:
-
source_ip
(str
, default:'0.0.0.0'
) –Address to bind to.
-
source_port
(int
, default:54320
) –Port to listen on.
Returns:
-
Result
–Result containing the NAT type and external IP/port of the host.
Raises:
-
RuntimeError
–if no STUN servers return a response or if the hosts IP or port changed during the STUN process.
Source code in proxystore/p2p/nat.py
check_nat_and_log
¶
Check the NAT type this host is behind and log the results.
Wrapper around check_nat()
that logs
the results rather than return them.
Parameters:
-
source_ip
(str
, default:'0.0.0.0'
) –Address to bind to.
-
source_port
(int
, default:54320
) –Port to listen on.