Hello Anon World II
Last updated
Last updated
In part II, we will introduce the AnonSocksClient and make our first request over the internet - fetching your (new) IP address! We will continue from the node module and codebase from Hello Anon World I.
The AnonSocksClient is used to tunnel http(s) requests through the network. It provides implementations for get, post, delete
and more that automatically use a running instance of the Anyone client. It can be imported much like the Anon library:
and instantiated immediately after the instantiation of the main anon client, taking it as reference:
For those coming in from part I, you'll notice some new arguments in the anon instantiation - these are optional arguments that become relevant when dealing with SOCKS routing, circuit control and debugging. Seen in this code snippet are the default values for each one.
Here, we will be calling anonSocksClient.get
to fetch our IP through the network. We'll be using the public, free service at https://api.ipify.org, but you can choose any that works as an API! We will simply call 'get' on the API, await its result and print the result:
Let's see the AnonSocksClient setup and this logic in the full function (note that, for now, a short wait time is required after anon.start()
and before making requests through the network).
Running node <programName>.js
from the command line will show the same setup logs as before and then the result of the IP lookup! We're now, as far as external sites are concerned, coming out of Bayern, Germany. Cool!
See the full code on GitHub.
Now, lets look into more fine-tuned circuit control.