mirror of
https://github.com/Chia-Network/chia-blockchain.git
synced 2026-09-28 01:56:38 -04:00
+16
-2
@@ -686,14 +686,28 @@ class ChiaServer:
|
||||
ip = None
|
||||
port = self._port
|
||||
|
||||
# Use chia's service first.
|
||||
try:
|
||||
async with ClientSession() as session:
|
||||
async with session.get("https://checkip.amazonaws.com/") as resp:
|
||||
timeout = ClientTimeout(total=15)
|
||||
async with ClientSession(timeout=timeout) as session:
|
||||
async with session.get("https://ip.chia.net/") as resp:
|
||||
if resp.status == 200:
|
||||
ip = str(await resp.text())
|
||||
ip = ip.rstrip()
|
||||
except Exception:
|
||||
ip = None
|
||||
|
||||
# Fallback to `checkip` from amazon.
|
||||
if ip is None:
|
||||
try:
|
||||
timeout = ClientTimeout(total=15)
|
||||
async with ClientSession(timeout=timeout) as session:
|
||||
async with session.get("https://checkip.amazonaws.com/") as resp:
|
||||
if resp.status == 200:
|
||||
ip = str(await resp.text())
|
||||
ip = ip.rstrip()
|
||||
except Exception:
|
||||
ip = None
|
||||
if ip is None:
|
||||
return None
|
||||
peer = PeerInfo(ip, uint16(port))
|
||||
|
||||
Reference in New Issue
Block a user