free-proxy-checker
Advanced tools
Comparing version 1.0.3 to 1.0.4
{ | ||
"name": "free-proxy-checker", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Library without any external dependencies to check if free HTTP/SOCKS4/SOCKS5 proxies are working/up.", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -91,1 +91,6 @@ # free-proxy_checker | ||
I may add it to the library if I feel like it's relevant. | ||
## Related projects | ||
[https://niek.github.io/free-proxy-list/](https://niek.github.io/free-proxy-list/): A page that leverages the free-proxy-checker library to display a list of available proxies. | ||
Results are updated every hour. |
const {HttpProxy, SocksProxy} = require('./proxies.js'); | ||
const {ProxyChecker} = require('./proxyChecker.js'); | ||
const {ProxyScrapeDownloader, FreeProxyListDownloader, FoxtoolsDownloader, MyProxyDownloader, downloadAllProxies} = require('./proxyDownloader.js'); | ||
const {ProxyScrapeDownloader, FreeProxyListDownloader, FoxtoolsDownloader, MyProxyDownloader, GeonodeDownloader, SpysMeDownloader, downloadAllProxies} = require('./proxyDownloader.js'); | ||
@@ -14,2 +14,4 @@ | ||
module.exports.MyProxyDownloader = MyProxyDownloader; | ||
module.exports.GeonodeDownloader = GeonodeDownloader; | ||
module.exports.SpysMeDownloader = SpysMeDownloader; | ||
module.exports.downloadAllProxies = downloadAllProxies; |
@@ -33,2 +33,6 @@ const http = require("http"); | ||
toString() { | ||
return `${this.host}:${this.port}-${this.constructor.name}`; | ||
} | ||
} | ||
@@ -35,0 +39,0 @@ |
const https = require('https'); | ||
const http = require('http'); | ||
const net = require('net'); | ||
const { HttpProxy, SocksProxy } = require('./proxies.js'); | ||
@@ -82,3 +83,5 @@ | ||
const [host, port] = row.replace(/\r/g, '').split(':'); | ||
proxies.push(new HttpProxy(host, port)); | ||
if (net.isIP(host)) { | ||
proxies.push(new HttpProxy(host, port)); | ||
} | ||
}) | ||
@@ -90,3 +93,5 @@ | ||
const [host, port] = row.replace(/\r/g, '').split(':'); | ||
proxies.push(new SocksProxy(host, port)); | ||
if (net.isIP(host)) { | ||
proxies.push(new SocksProxy(host, port)); | ||
} | ||
}) | ||
@@ -98,4 +103,2 @@ } catch (_) { | ||
} | ||
return proxies; | ||
} | ||
@@ -132,3 +135,3 @@ } | ||
proxies.push(new HttpProxy(host, port)); | ||
} catch(_) {} | ||
} catch (_) { } | ||
}) | ||
@@ -176,4 +179,5 @@ } | ||
const port = rowSplit[2].replace('</td>', ''); | ||
proxies.push(new HttpProxy(host, port)); | ||
if (net.isIP(host)) { | ||
proxies.push(new HttpProxy(host, port)); | ||
} | ||
}) | ||
@@ -223,7 +227,6 @@ } catch (_) { | ||
.forEach((row) => { | ||
try { | ||
const rowSplit = row.split(':'); | ||
const host = rowSplit[0] | ||
const port = rowSplit[1].split('#')[0]; | ||
const rowSplit = row.split(':'); | ||
const host = rowSplit[0] | ||
const port = rowSplit[1].split('#')[0]; | ||
if (net.isIP(host)) { | ||
if (url.indexOf('sock') > -1) { | ||
@@ -234,4 +237,2 @@ proxies.push(new SocksProxy(host, port)); | ||
} | ||
} catch (_) { | ||
console.log(`(${this.name}) Tried to create a proxy from invalid data`) | ||
} | ||
@@ -248,2 +249,63 @@ }) | ||
class GeonodeDownloader extends ProxyDownloader { | ||
constructor() { | ||
super(); | ||
this.name = 'Geonode'; | ||
} | ||
async download() { | ||
const geonodeProxyContent = await this._getURL('https://proxylist.geonode.com/api/proxy-list?limit=150&page=1&sort_by=speed&sort_type=asc'); | ||
const proxies = []; | ||
try { | ||
const proxiesInfo = JSON.parse(geonodeProxyContent); | ||
proxiesInfo.data.forEach(proxyInfo => { | ||
proxyInfo.protocols.forEach(protocol => { | ||
if (protocol.indexOf('socks') > -1) { | ||
proxies.push(new SocksProxy(proxyInfo.ip, proxyInfo.port)) | ||
} else if (protocol.indexOf('http') > -1) { | ||
proxies.push(new HttpProxy(proxyInfo.ip, proxyInfo.port)) | ||
} | ||
}) | ||
}) | ||
} catch (_) { | ||
console.log(`An error occured while downloading proxies from ${this.name}`); | ||
} finally { | ||
return proxies; | ||
} | ||
} | ||
} | ||
class SpysMeDownloader extends ProxyDownloader { | ||
constructor() { | ||
super(); | ||
this.name = 'Spys me'; | ||
} | ||
async download() { | ||
const spysmeProxyContent = await this._getURL('https://spys.me/proxy.txt'); | ||
const proxies = []; | ||
let parseContent = false; | ||
try { | ||
spysmeProxyContent.split('\n') | ||
.forEach((line) => { | ||
if (parseContent && line.indexOf(':') > -1) { | ||
const [host, port] = line.split(' ')[0].split(':'); | ||
if (net.isIP(host)) { | ||
proxies.push(new SocksProxy(host, port)); | ||
} | ||
} | ||
if (line.length < 1) { | ||
parseContent = true; | ||
} | ||
}) | ||
} catch (_) { | ||
console.log(`An error occured while downloading proxies from ${this.name}`); | ||
} finally { | ||
return proxies; | ||
} | ||
} | ||
} | ||
async function downloadAllProxies() { | ||
@@ -254,2 +316,4 @@ const proxyScrapeDownloader = new ProxyScrapeDownloader(); | ||
const myProxyDownloader = new MyProxyDownloader(); | ||
const geonodeDownloader = new GeonodeDownloader(); | ||
const spysMeDownloader = new SpysMeDownloader(); | ||
@@ -260,10 +324,19 @@ const proxyPromises = await Promise.allSettled([ | ||
freeProxyListDownloader.download(), | ||
myProxyDownloader.download() | ||
myProxyDownloader.download(), | ||
geonodeDownloader.download(), | ||
spysMeDownloader.download(), | ||
]); | ||
const proxies = new Set(); | ||
const proxies = []; | ||
const proxiesSeenKeys = new Set(); | ||
proxyPromises.forEach(res => { | ||
res.value.forEach(v => proxies.add(v)); | ||
res.value.forEach(v => { | ||
const proxyKey = v.toString(); | ||
if (!proxiesSeenKeys.has(proxyKey)) { | ||
proxies.push(v); | ||
proxiesSeenKeys.add(proxyKey); | ||
} | ||
}); | ||
}); | ||
return Array.from(proxies); | ||
return proxies; | ||
} | ||
@@ -275,2 +348,4 @@ | ||
module.exports.MyProxyDownloader = MyProxyDownloader; | ||
module.exports.GeonodeDownloader = GeonodeDownloader; | ||
module.exports.SpysMeDownloader = SpysMeDownloader; | ||
module.exports.downloadAllProxies = downloadAllProxies; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
42888
563
95
5