New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

free-proxy-checker

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

free-proxy-checker - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

6

examples/example3-download-proxies.js
const path = require('path');
const {ProxyChecker, ProxyScrapeDownloader, FoxtoolsDownloader, FreeProxyListDownloader, downloadAllProxies} = require(path.dirname(__filename) + '/..' + '/src/index.js');
const {ProxyChecker, ProxyScrapeDownloader, FoxtoolsDownloader, FreeProxyListDownloader, MyProxyDownloader, downloadAllProxies} = require(path.dirname(__filename) + '/..' + '/src/index.js');

@@ -19,2 +19,6 @@ (async () => {

const myProxyDownloader = new MyProxyDownloader();
const myProxyListProxies = await myProxyDownloader.download();
console.log(myProxyListProxies);
// You can also download all proxies from all proxy providers at once

@@ -21,0 +25,0 @@ const allProxies = await downloadAllProxies();

2

package.json
{
"name": "free-proxy-checker",
"version": "1.0.2",
"version": "1.0.3",
"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",

@@ -35,3 +35,3 @@ # free-proxy_checker

(async () => {
// We can download proxies from a particular proxy provider, e.g. proxyscrape, foxtools or freeproxylist
// We can download proxies from a particular proxy provider, e.g. proxyscrape, foxtools, freeproxylist and my proxy
const proxyScrapeDownloader = new ProxyScrapeDownloader();

@@ -38,0 +38,0 @@ const proxyScrapeProxies = await proxyScrapeDownloader.download();

const {HttpProxy, SocksProxy} = require('./proxies.js');
const {ProxyChecker} = require('./proxyChecker.js');
const {ProxyScrapeDownloader, FreeProxyListDownloader, FoxtoolsDownloader, downloadAllProxies} = require('./proxyDownloader.js');
const {ProxyScrapeDownloader, FreeProxyListDownloader, FoxtoolsDownloader, MyProxyDownloader, downloadAllProxies} = require('./proxyDownloader.js');

@@ -13,2 +13,3 @@

module.exports.FoxtoolsDownloader = FoxtoolsDownloader;
module.exports.MyProxyDownloader = MyProxyDownloader;
module.exports.downloadAllProxies = downloadAllProxies;

@@ -11,5 +11,10 @@ const http = require("http");

constructor(host, port) {
this.host = host;
this.port = port;
this.isUp = null;
if (this._isValidHost(host)) {
this.host = host;
this.port = port;
this.isUp = null;
} else {
throw new Error('Host provided is not a valid IP address');
}

@@ -21,2 +26,6 @@ if (this.constructor === Proxy) {

_isValidHost(ipAddress) {
return net.isIP(ipAddress);
}
async _testConnection(timeout) {

@@ -23,0 +32,0 @@ throw new Error("Method '_testConnection()' must be implemented.");

@@ -126,4 +126,6 @@ const https = require('https');

.forEach(row => {
const [host, port] = row.replace(/\r/g, '').split(':');
proxies.push(new HttpProxy(host, port));
try {
const [host, port] = row.replace(/\r/g, '').split(':');
proxies.push(new HttpProxy(host, port));
} catch(_) {}
})

@@ -183,6 +185,64 @@ }

async function downloadAllProxies () {
class MyProxyDownloader extends ProxyDownloader {
constructor() {
super();
this.name = 'My proxy';
}
async download() {
const urls = [
'https://www.my-proxy.com/free-proxy-list.html',
'https://www.my-proxy.com/free-proxy-list-2.html',
'https://www.my-proxy.com/free-proxy-list-3.html',
'https://www.my-proxy.com/free-proxy-list-4.html',
'https://www.my-proxy.com/free-proxy-list-5.html',
'https://www.my-proxy.com/free-proxy-list-6.html',
'https://www.my-proxy.com/free-proxy-list-7.html',
'https://www.my-proxy.com/free-proxy-list-8.html',
'https://www.my-proxy.com/free-proxy-list-9.html',
'https://www.my-proxy.com/free-proxy-list-10.html',
'https://www.my-proxy.com/free-elite-proxy.html',
'https://www.my-proxy.com/free-anonymous-proxy.html',
'https://www.my-proxy.com/free-socks-4-proxy.html',
'https://www.my-proxy.com/free-socks-5-proxy.html',
];
let proxies = [];
for (let url of urls) {
try {
const proxyPageContent = await this._getURL(url);
const indexStartProxiesDiv = proxyPageContent.indexOf('<div class="list"');
const indexEndProxiesDiv = indexStartProxiesDiv + proxyPageContent.slice(indexStartProxiesDiv, proxyPageContent.length).indexOf('</div>');
proxyPageContent.slice(indexStartProxiesDiv, indexEndProxiesDiv).replace('<div class="list">', '').replace("<div class='to-lock'>", '')
.split('<br>')
.filter(Boolean)
.forEach((row) => {
try {
const rowSplit = row.split(':');
const host = rowSplit[0]
const port = rowSplit[1].split('#')[0];
if (url.indexOf('sock') > -1) {
proxies.push(new SocksProxy(host, port));
} else {
proxies.push(new HttpProxy(host, port));
}
} catch (_) {
console.log(`(${this.name}) Tried to create a proxy from invalid data`)
}
})
} catch (_) {
console.log(`An error occured while downloading proxies from ${this.name}`);
}
}
return proxies;
}
}
async function downloadAllProxies() {
const proxyScrapeDownloader = new ProxyScrapeDownloader();
const foxtoolsDownloader = new FoxtoolsDownloader();
const freeProxyListDownloader = new FreeProxyListDownloader();
const myProxyDownloader = new MyProxyDownloader();

@@ -193,2 +253,3 @@ const proxyPromises = await Promise.allSettled([

freeProxyListDownloader.download(),
myProxyDownloader.download()
]);

@@ -206,2 +267,3 @@

module.exports.FreeProxyListDownloader = FreeProxyListDownloader;
module.exports.MyProxyDownloader = MyProxyDownloader;
module.exports.downloadAllProxies = downloadAllProxies;
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc