Native Libraries
GoTotus provides native libraries for a more fluid syntax and simpler use:
Python
Location: https://github.com/GoTotus/pytotus
pip install totus
import json
from totus import Totus
t = Totus()
reference = t.Reference()
print("Your Public IP ...")
result = reference.IP()
print(json.dumps(result, indent=4))
print("Cloudflare 1.1.1.1 ...")
result = reference.IP(ip4='1.1.1.1')
print(json.dumps(result, indent=4))
print("Cloudflare ip6 for previous 1.1.1.1: 2606:4700:4700::1111 ...")
result = reference.IP(ip6='2606:4700:4700::1111')
print(json.dumps(result, indent=4))
will Output:
Your Public IP ...
{
"as": "212238",
"asn": "212238",
"cc": "US",
"city": "Miami",
"country": "United States of America",
"elevation": 0,
"gh": "dhwfxhhf1850",
"ip4": "45.134.142.198",
"is_proxy": false,
"lat": 25.77427,
"lon": -80.1936,
"postcode": "33010",
"region": "Florida",
"timezone": "-05:00"
}
Cloudflare 1.1.1.1 ...
{
"as": "13335",
"asn": "13335",
"cc": "AU",
"city": "Brisbane",
"country": "Australia",
"elevation": 0,
"gh": "r7hgdpxtuzr3",
"ip4": "1.1.1.1",
"is_proxy": false,
"lat": -27.46754,
"lon": 153.02809,
"postcode": "4000",
"region": "Queensland",
"timezone": "+10:00"
}
Cloudflare ip6 for previous 1.1.1.1: 2606:4700:4700::1111 ...
{
"as": "13335",
"asn": "13335",
"cc": "US",
"city": "San Francisco",
"country": "United States of America",
"elevation": 0,
"gh": "9q8yyk8yuv1s",
"ip6": "2606:4700:4700::1111",
"is_proxy": false,
"lat": 37.77493,
"lon": -122.41942,
"postcode": "94153",
"region": "California",
"timezone": "-08:00"
}
Node / Javascript
npm i totus
let Totus = require('totus');
(async () => {
try {
const t = new Totus();
const reference = t.Reference();
console.log("Your Public IP ...");
console.log(await reference.IP());
console.log("Cloudflare 1.1.1.1 ...");
console.log(await reference.IP({ip4: '1.1.1.1'}));
console.log("Cloudflare ip6 for previous 1.1.1.1: 2606:4700:4700::1111 ...");
console.log(await reference.IP({ip6: '2606:4700:4700::1111'}));
} catch (error) {
console.error('Error:', error.message);
}
})();
Golang
go get github.com/GoTotus/gototus
func main() {
t, err := totus.NewTotus("", "", "")
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
ref := t.Reference()
fmt.Println("Your Public IP ...")
result, err := ref.IP()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Println(result)
fmt.Println("Cloudflare 1.1.1.1 ...")
result, err = ref.IP4("1.1.1.1")
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Println(result)
fmt.Println("Cloudflare ip6 for previous 1.1.1.1: 2606:4700:4700::1111 ...")
result, err = ref.IP6("2606:4700:4700::1111")
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Println(result)
}