@tambam, making sure that you're talking about a need for additional software to return the IP address, correct? otherwise, i don't see the solution in what you offer.
meanwhile:
jack wrote: "You may want to make a http request to an official dns service."
this returns the IP via DNS lookup (@ google) but it's not perfect where it doesn't account for errors:
// Project: DNS Lookup
// Created: 2021-07-16
// By: Virtual Nomad
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "DNS Lookup" )
SetWindowSize( 1280,720, 0 )
SetWindowAllowResize( 1 )
// set display properties
SetVirtualResolution( 1280,720)
SetOrientationAllowed( 1, 1, 1, 1 )
SetSyncRate( 30, 0 )
SetScissor( 0,0,0,0 )
UseNewDefaultFonts( 1 )
URL$ = "google.com"
IP$ = Lookup(URL$)
do
If GetRawKeyState(27) then End
Print( IP$ )
Sync()
loop
Function Lookup(URL$)
http = CreateHTTPConnection()
SetHTTPHost( http, "dns.google", 1 )
SendHTTPRequestASync( http, "/resolve?name="+URL$+"&type=A")
while GetHTTPResponseReady(http) = 0
Print( "Connecting..." )
Sync()
endwhile
response$ = GetHTTPResponse(http)
CloseHTTPConnection(http)
DeleteHTTPConnection(http)
token = CountStringTokens(response$,":")
Response$ = GetStringToken( response$, ":", token )
Response$ = LEFT(Response$, LEN(Response$)-4)
Response$ = RIGHT(Response$, LEN(Response$)-1)
EndFunction Response$
the full response appears to be JSON where the first variable "Status" will be 0 on success or 3 on error.
i could parse that but i imagine someone could take the above & properly handle the JSON response?
see the link at the bottom:
https://dns.google/query?name=google.com
note: while playing with this i noticed google's IP changes much more frequent than "every 5 minutes" at times.
add: apparently some return multiple IP addresses with a comment that my code doesn't account for:
{
"Status": 0,
"TC": false,
"RD": true,
"RA": true,
"AD": false,
"CD": false,
"Question": [
{
"name": "appgamekit.com.",
"type": 1
}
],
"Answer": [
{
"name": "appgamekit.com.",
"type": 1,
"TTL": 299,
"data": "172.67.68.13"
},
{
"name": "appgamekit.com.",
"type": 1,
"TTL": 299,
"data": "104.26.3.123"
},
{
"name": "appgamekit.com.",
"type": 1,
"TTL": 299,
"data": "104.26.2.123"
}
],
"Comment": "Response from 2606:4700:50::adf5:3a6c."
}
so, more parsing required, or, again, proper JSON handling (if possible?).
but, we're getting close.