/api/system/public-ip

GET

Learns this machine’s public IPv4 address as the outside world sees it, plus the country that address is in. The core asks https://cloudcoin.org/myip.php (which answers from the real client address behind Cloudflare and looks the country up server-side) and then api.ipify.org as an independent second opinion. Raidax uses this for self-discovery: it compares the answer with the DNS entry for its own fleet name and, if they differ, publishes the observed address to the DRD.

Parameters

None. The primary URL comes from rest_core.conf (myip_url, default https://cloudcoin.org/myip.php).

Responses

Success Response (200)

{
    "command": "system-public-ip",
    "success": true,
    "ip4": "96.86.143.105",
    "source": "myip.php",
    "second_opinion": "96.86.143.105",
    "agree": true,
    "country": "US",
    "country_name": "United States"
}
FieldTypeDescription
ip4stringThe address to publish. From myip.php when it answered, otherwise from the second opinion.
sourcestringmyip.php or ipify.
second_opinionstringWhat api.ipify.org reported, or empty.
agreebooleanBoth services answered and agreed. Disagreement usually means a split-horizon or multi-homed egress; myip.php wins.
country, country_namestringISO 3166-1 alpha-2 code and name from myip.php; empty when unknown. Raidax uses the code as the default jurisdiction unless its config overrides it.

Error Responses

502 Bad Gateway

Neither service answered within the timeout.

{ "error": true, "message": "No public-IP service answered", "code": 502 }

Examples

cURL Example

curl -X GET "http://localhost:8080/api/system/public-ip"

JavaScript Example

fetch(`http://localhost:8080/api/system/public-ip`)
    .then(r => r.json())
    .then(d => console.log(d.ip4, d.country, d.agree ? '(confirmed)' : '(single source)'));

Python Example

import requests
d = requests.get('http://localhost:8080/api/system/public-ip').json()
print(d['ip4'], d['country'], d['agree'])

Notes

  • Only the connection address counts; no forwarded-for header from the caller can influence the answer.
  • Private or loopback addresses get no country.