mirror of
https://github.com/FlareSolverr/FlareSolverr.git
synced 2026-04-23 08:25:36 +02:00
@@ -60,18 +60,35 @@ function buildExtraPrefsFirefox(proxy: Proxy): object {
|
||||
const port = parseInt(portStr);
|
||||
|
||||
const proxyPrefs = {
|
||||
// Proxy configuration
|
||||
"network.proxy.ftp": host,
|
||||
"network.proxy.ftp_port": port,
|
||||
"network.proxy.http": host,
|
||||
"network.proxy.http_port": port,
|
||||
"network.proxy.share_proxy_settings": true,
|
||||
"network.proxy.socks": host,
|
||||
"network.proxy.socks_port": port,
|
||||
"network.proxy.socks_remote_dns": true,
|
||||
"network.proxy.ssl": host,
|
||||
"network.proxy.ssl_port": port,
|
||||
"network.proxy.type": 1
|
||||
"network.proxy.type": 1,
|
||||
"network.proxy.share_proxy_settings": true
|
||||
}
|
||||
if (proxy.url.indexOf("socks") != -1) {
|
||||
// SOCKSv4 & SOCKSv5
|
||||
Object.assign(proxyPrefs, {
|
||||
"network.proxy.socks": host,
|
||||
"network.proxy.socks_port": port,
|
||||
"network.proxy.socks_remote_dns": true
|
||||
});
|
||||
if (proxy.url.indexOf("socks4") != -1) {
|
||||
Object.assign(proxyPrefs, {
|
||||
"network.proxy.socks_version": 4
|
||||
});
|
||||
} else {
|
||||
Object.assign(proxyPrefs, {
|
||||
"network.proxy.socks_version": 5
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// HTTP
|
||||
Object.assign(proxyPrefs, {
|
||||
"network.proxy.ftp": host,
|
||||
"network.proxy.ftp_port": port,
|
||||
"network.proxy.http": host,
|
||||
"network.proxy.http_port": port,
|
||||
"network.proxy.ssl": host,
|
||||
"network.proxy.ssl_port": port
|
||||
});
|
||||
}
|
||||
|
||||
// merge objects
|
||||
|
||||
@@ -9,6 +9,7 @@ const sessions = require('../services/sessions');
|
||||
const version: string = 'v' + require('../../package.json').version
|
||||
|
||||
const proxyUrl = "http://127.0.0.1:8888"
|
||||
const proxySocksUrl = "socks5://127.0.0.1:1080"
|
||||
const googleUrl = "https://www.google.com";
|
||||
const postUrl = "https://ptsv2.com/t/qv4j3-1634496523";
|
||||
const cfUrl = "https://pirateiro.com/torrents/?search=harry";
|
||||
@@ -221,7 +222,7 @@ describe("Test '/v1' path", () => {
|
||||
expect(solution.userAgent).toBe(null)
|
||||
});
|
||||
|
||||
test("Cmd 'request.get' should return OK with 'proxy' param", async () => {
|
||||
test("Cmd 'request.get' should return OK with HTTP 'proxy' param", async () => {
|
||||
/*
|
||||
To configure TinyProxy in local:
|
||||
* sudo vim /etc/tinyproxy/tinyproxy.conf
|
||||
@@ -249,7 +250,7 @@ describe("Test '/v1' path", () => {
|
||||
});
|
||||
|
||||
// todo: credentials are not working
|
||||
test.skip("Cmd 'request.get' should return OK with 'proxy' param with credentials", async () => {
|
||||
test.skip("Cmd 'request.get' should return OK with HTTP 'proxy' param with credentials", async () => {
|
||||
/*
|
||||
To configure TinyProxy in local:
|
||||
* sudo vim /etc/tinyproxy/tinyproxy.conf
|
||||
@@ -279,6 +280,32 @@ describe("Test '/v1' path", () => {
|
||||
expect(solution.status).toContain(200)
|
||||
});
|
||||
|
||||
test("Cmd 'request.get' should return OK with SOCKSv5 'proxy' param", async () => {
|
||||
/*
|
||||
To configure Dante in local:
|
||||
* https://linuxhint.com/set-up-a-socks5-proxy-on-ubuntu-with-dante/
|
||||
* sudo vim /etc/sockd.conf
|
||||
* sudo systemctl restart sockd.service
|
||||
* curl --socks5 socks5://127.0.0.1:1080 https://www.google.com
|
||||
*/
|
||||
const payload = {
|
||||
"cmd": "request.get",
|
||||
"url": googleUrl,
|
||||
"proxy": {
|
||||
"url": proxySocksUrl
|
||||
}
|
||||
}
|
||||
const response: Response = await request(app).post("/v1").send(payload);
|
||||
expect(response.statusCode).toBe(200);
|
||||
|
||||
const apiResponse: V1ResponseSolution = response.body;
|
||||
expect(apiResponse.status).toBe("ok");
|
||||
|
||||
const solution = apiResponse.solution;
|
||||
expect(solution.url).toContain(googleUrl)
|
||||
expect(solution.status).toBe(200);
|
||||
});
|
||||
|
||||
test("Cmd 'request.get' should fail with wrong 'proxy' param", async () => {
|
||||
const payload = {
|
||||
"cmd": "request.get",
|
||||
|
||||
Reference in New Issue
Block a user