Skip to content
This repository was archived by the owner on May 5, 2023. It is now read-only.

Commit

Permalink
5.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
TooTallNate committed Jun 21, 2021
1 parent 96292f7 commit d1cb60f
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 1 deletion.
72 changes: 72 additions & 0 deletions nordvpn.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import https from 'https';
import fetch from 'node-fetch';
import create, { SocksProxyAgent, SocksProxyAgentOptions } from './src';

const API = 'https://nordvpn.com/api/server'

interface Proxy {
name: string;
domain: string;
ip_address: string;
features: {
socks: boolean;
};
}

async function main() {
const res = await fetch(API);
const data: Proxy[] = await res.json();

for (const proxy of data) {
await test(proxy);
}
}

async function test(proxy: Proxy) {
if (!proxy.features.socks) {
//console.log('`socks` is not supported');
return;
}

console.log('Testing %j - %s (%s)', proxy.name, proxy.domain, proxy.ip_address);
//console.log(proxy);
const info: SocksProxyAgentOptions = {
host: proxy.domain,
username: 'nrajlich@gmail.com',
password: 'Zez]7KW8ZTEy3NaD;8&K'
};

const agent = new SocksProxyAgent(info);

try {
const { ip } = await new Promise((resolve, reject) => {
https
.get(
'https://jsonip.org',
{
agent
},
res => {
//console.log(res.headers);
let data = ''
res.setEncoding('utf8');
res.on('data', d => { data += d });
res.on('end', () => {
resolve(JSON.parse(data));
});
}
)
.once('error', reject);
});
console.log('✅ %j works! IP: %s', proxy.domain, ip);
} catch (err) {
console.log('🛑 %j does not work :( - %s', proxy.domain, err.toString().split('\n')[0]);
}

console.log();
}

main().catch(err => {
console.error(err);
process.exit(1);
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "socks-proxy-agent",
"version": "5.0.0",
"version": "5.0.1",
"description": "A SOCKS proxy `http.Agent` implementation for HTTP and HTTPS",
"main": "dist/index",
"typings": "dist/index",
Expand Down

0 comments on commit d1cb60f

Please # to comment.