Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: no HTTPs in IPv4 diagnostic check #404

Merged
merged 1 commit into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 5 additions & 12 deletions examples/example_fastapi/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,11 @@ async def ip_address():

@app.get("/ip/4")
async def connect_ipv4():
"""Connect to the Quad9 VPN provider using their IPv4 address.
The webserver on that address returns a 404 error, so we accept that response code.
"""
timeout = aiohttp.ClientTimeout(total=5)
async with aiohttp.ClientSession(
connector=aiohttp.TCPConnector(), timeout=timeout
) as session:
async with session.get("https://9.9.9.9") as resp:
# We expect this endpoint to return a 404 error
if resp.status != 404:
resp.raise_for_status()
return {"result": True, "headers": resp.headers}
"""Connect to the Quad9 VPN provider using their IPv4 address."""
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(5)
sock.connect(("9.9.9.9", 53))
return {"result": True}


@app.get("/ip/6")
Expand Down
1 change: 0 additions & 1 deletion vm_supervisor/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ async def check_ipv4(session: ClientSession) -> bool:
try:
result: Dict = await get_json_from_vm(session, "/ip/4")
assert result["result"] is True
assert "headers" in result
return True
except ClientResponseError:
return False
Expand Down