mirror of https://github.com/nucypher/nucypher.git
adopt the 'global' language convention pertaining to public IPv4 addresses
parent
527640170c
commit
a712706e7b
|
@ -27,7 +27,7 @@ from nucypher.policy.conditions.utils import (
|
|||
evaluate_condition_lingo,
|
||||
)
|
||||
from nucypher.utilities.logging import Logger
|
||||
from nucypher.utilities.networking import get_request_public_ipv4
|
||||
from nucypher.utilities.networking import get_request_global_ipv4
|
||||
|
||||
DECRYPTION_REQUESTS_SUCCESSES = Counter(
|
||||
"threshold_decryption_num_successes",
|
||||
|
@ -299,7 +299,7 @@ def _make_rest_app(this_node, log: Logger) -> Flask:
|
|||
@rest_app.route("/ping", methods=['GET'])
|
||||
def ping():
|
||||
"""Asks this node: What is my public IPv4 address?"""
|
||||
ipv4 = get_request_public_ipv4(request=request)
|
||||
ipv4 = get_request_global_ipv4(request=request)
|
||||
if not ipv4:
|
||||
return Response(
|
||||
response="No public IPv4 address detected.",
|
||||
|
|
|
@ -179,6 +179,9 @@ def determine_external_ip_address(
|
|||
3. A centralized IP address service
|
||||
|
||||
If the IP address cannot be determined for any reason UnknownIPAddress is raised.
|
||||
|
||||
This function is intended to be used by nodes operators running `nucypher ursula init`
|
||||
to assist determine their global IPv4 address for configuration purposes only.
|
||||
"""
|
||||
rest_host = None
|
||||
|
||||
|
@ -205,7 +208,7 @@ def determine_external_ip_address(
|
|||
return rest_host
|
||||
|
||||
|
||||
def _is_valid_ipv4(ip: str) -> bool:
|
||||
def _is_global_ipv4(ip: str) -> bool:
|
||||
try:
|
||||
ip = ip_address(ip.strip())
|
||||
return isinstance(ip, IPv4Address) and ip.is_global
|
||||
|
@ -235,7 +238,7 @@ def _ip_sources(request: Request, trusted_proxies: Optional[List[str]] = None) -
|
|||
yield request.remote_addr
|
||||
|
||||
|
||||
def get_request_public_ipv4(
|
||||
def get_request_global_ipv4(
|
||||
request: Request, trusted_proxies: Optional[List[str]] = None
|
||||
) -> Optional[str]:
|
||||
"""
|
||||
|
@ -256,5 +259,5 @@ def get_request_public_ipv4(
|
|||
"""
|
||||
for ip_str in _ip_sources(request=request, trusted_proxies=trusted_proxies):
|
||||
ipv4_address = _ipv6_to_ipv4(ip_str)
|
||||
if ipv4_address and _is_valid_ipv4(ipv4_address):
|
||||
if ipv4_address and _is_global_ipv4(ipv4_address):
|
||||
return ipv4_address
|
||||
|
|
Loading…
Reference in New Issue