Skip to content

Instantly share code, notes, and snippets.

@mygoare
Created June 8, 2019 10:13
Show Gist options
  • Save mygoare/fb074052280eb35778cd8784b55bff21 to your computer and use it in GitHub Desktop.
Save mygoare/fb074052280eb35778cd8784b55bff21 to your computer and use it in GitHub Desktop.
ss 可用性测试
const request = require('request');
const SocksProxyAgent = require('socks-proxy-agent');
const proxy = 'socks5://127.0.0.1:1086';
const agent = new SocksProxyAgent(proxy)
request({
method: 'get',
url: 'https://ipinfo.io',
headers: {
'user-agent': 'curl/7.54.0',
},
agent,
}, (err, res) => {
if (err) {
console.log('request err: ', err)
} else {
const content = res.body;
try {
const j = JSON.parse(content)
const {ip, city, region, country, org} = j;
console.log(`ip: ${ip}, city: ${city}, region: ${region}, country: ${country}, org: ${org}`)
} catch (e) {
console.log('catch err:', e)
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment