-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4e3bee6
commit 20791d3
Showing
6 changed files
with
78 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { getProxiesList as getProxiesListWebshare } from "./webshare.js"; | ||
import { getProxiesList as getProxiesListProxyscrape } from "./proxyscrape.js"; | ||
|
||
let proxyList = []; | ||
|
||
async function getProxiesList() { | ||
if (process.env.WEBSHARE_TOKEN !== undefined) { | ||
proxyList = await getProxiesListWebshare(); | ||
} | ||
else if (process.env.PROXYSCRAPE_TOKEN !== undefined) { | ||
proxyList = await getProxiesListProxyscrape(); | ||
} | ||
} | ||
|
||
getProxiesList(); | ||
|
||
export default function getProxy(index) { | ||
return proxyList[index]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
const PROXYSCRAPE_TOKEN = process.env.PROXYSCRAPE_TOKEN; | ||
import { UploadStatus } from "../../data/upload.js"; | ||
import { CronJob } from "cron"; | ||
import axios from "axios"; | ||
|
||
async function getProxies() { | ||
try { | ||
const url = `https://api.proxyscrape.com/v2/account/datacenter_shared/proxy-list?protocol=http&auth=${PROXYSCRAPE_TOKEN}&type=getproxies&country[]=de&format=normal&status=all`; | ||
const response = await axios.get(url); | ||
const { data } = response; | ||
|
||
const results = data.split("\r\n").filter((proxy) => proxy.length > 0); | ||
const proxyList = results.map((proxy) => { | ||
const [ip, port] = proxy.split(":"); | ||
return { | ||
ip, | ||
port, | ||
}; | ||
}); | ||
return proxyList; | ||
} catch (error) { | ||
return [] | ||
} | ||
} | ||
|
||
export async function getProxiesList() { | ||
return await getProxies(); | ||
} | ||
|
||
export default function getProxy(index) { | ||
return proxyList[index]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters