constgot=require("got");constspawn=require("cross-spawn");const{SocksProxyAgent}=require("socks-proxy-agent");// Launch a TOR proxy via Docker// @see https://github.com/osminogin/docker-tor-simpleconstproxy=spawn("docker",[...["run","--rm","-i","-a","stdout"],...["-p","127.0.0.1:9050:9050/tcp"],...["osminogin/tor-simple:latest"],]);// Wait until the socks5 proxy server is up and runningproxy.stdout.on("data",(data)=>{process.stderr.write(data);if(data.toString().includes("Opened Socks listener")){run().finally(()=>proxy.kill("SIGINT"));}});// Configure an HTTP client using socks5 proxyconstclient=got.extend({agent:{https:newSocksProxyAgent("socks5://localhost:9050"),},});// TODO: Write some code that requires a proxyasyncfunctionrun(){constbody=awaitclient.get("https://jsonip.com/").json();console.log("Client IP:",body.ip);}
Our AI agent was running 10-20 seconds slower than it should, impacting both our own developers and our early adopters. See how I used Sentry Profiling to fix it in record time.
Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.
A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!
On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.
Top comments (0)