bittensor.utils.networking#
Utils for handling local network with ip and ports.
Exceptions#
Raised if we cannot attain your external ip from CURL/URLLIB/IPIFY/AWS |
Functions#
Checks CURL/URLLIB/IPIFY/AWS for your external ip. |
|
|
Returns a formatted websocket endpoint url. |
|
Maps an integer to a unique ip-string |
|
Return a formatted ip string |
|
Maps an ip-string to a unique integer. |
|
Returns the ip version (IPV4 or IPV6). |
Module Contents#
- exception bittensor.utils.networking.ExternalIPNotFound[source]#
Bases:
ExceptionRaised if we cannot attain your external ip from CURL/URLLIB/IPIFY/AWS
Initialize self. See help(type(self)) for accurate signature.
- bittensor.utils.networking.get_external_ip()[source]#
Checks CURL/URLLIB/IPIFY/AWS for your external ip.
- Returns:
Your routers external facing ip as a string.
- Return type:
external_ip (str)
- Raises:
ExternalIPNotFound(Exception) – Raised if all external ip attempts fail.
- bittensor.utils.networking.get_formatted_ws_endpoint_url(endpoint_url)[source]#
Returns a formatted websocket endpoint url.
- Parameters:
endpoint_url (Optional[str]) – The endpoint url to format.
- Returns:
The formatted endpoint url. In the form of ws://<endpoint_url> or wss://<endpoint_url>
- Return type:
formatted_endpoint_url
Note: The port (or lack thereof) is left unchanged.
- bittensor.utils.networking.int_to_ip(int_val)[source]#
Maps an integer to a unique ip-string
- Parameters:
int_val (int) – The integer representation of an ip. Must be in the range (0, 3.4028237e+38).
- Returns:
The string representation of an ip. Of form ..*.* for ipv4 or :::::* for ipv6
- Return type:
str_val
- bittensor.utils.networking.ip_to_int(str_val)[source]#
Maps an ip-string to a unique integer.
- Parameters:
str_val (str) – The string representation of an ip. Of form ..*.* for ipv4 or :::::* for ipv6
- Returns:
The integer representation of an ip. Must be in the range (0, 3.4028237e+38).
- Return type:
int_val