Some time ago, I created NPM package named GIP, which is a simple JavaScript module and CLI tool that checks external IPv4 address of the machine it runs on. Now I want to create a few scripts in different programming languages that will do the same thing.
These scripts will do the following:
- Do a parallel HTTP request to the multiple services that return the IP address.
- Ensure that the IP address is real by waiting for specific number of the same responses.
You can grab the scripts from the dist directory.
You can pass --ensure N
argument to specify the number of the same responses (default is 3) that you want to wait for. In this way, you will have verification that the IP address is real.
Keep in mind that currently there is 28 services, so do not pass the number greater than 28.
Also, keep in mind that some services may be down or not available in your region. Try to stick with low numbers.
./gip.sh
./gip.sh --ensure 7
python gip.py
python gip.py --ensure 7
bun gip.ts
bun gip.ts --ensure 7
deno --allow-net gip.ts
deno --allow-net gip.ts --ensure 7
go run gip.go
go run gip.go --ensure 7
java gip.java
java gip.java --ensure 7