Compare commits
2 Commits
master
...
feature/re
| Author | SHA1 | Date | |
|---|---|---|---|
| 41e1c33e0e | |||
| aa2bf08255 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,5 +1,3 @@
|
||||
node_modules/
|
||||
web-ext-artifacts/
|
||||
*.swp
|
||||
package.json
|
||||
package-lock.json
|
||||
|
||||
65
ext/bg.js
65
ext/bg.js
@@ -12,7 +12,6 @@ var global_ws = null;
|
||||
var container_count = 0;
|
||||
|
||||
var proxy_map = {};
|
||||
var proxy_map_http_attempts = new Map();
|
||||
|
||||
var web_response_whitelist = ["main_frame", "xmlhttprequest"];
|
||||
|
||||
@@ -202,12 +201,6 @@ function attach_ws_events(ws){
|
||||
|
||||
ws.addEventListener("open", async function(){
|
||||
|
||||
// clean up internal previous garbage
|
||||
webreq_completed = new Map();
|
||||
proxy_map = {};
|
||||
proxy_map_http_attempts = new Map();
|
||||
web_response_whitelist = ["main_frame", "xmlhttprequest"];
|
||||
|
||||
console.log("ws: connected");
|
||||
await set_status(STATUS_CONNECTED);
|
||||
});
|
||||
@@ -428,15 +421,6 @@ function attach_ws_events(ws){
|
||||
break;
|
||||
|
||||
case "container_delete":
|
||||
// clear http proxy cache
|
||||
try{
|
||||
|
||||
await browser.webRequest.handlerBehaviorChanged();
|
||||
}catch(err){
|
||||
|
||||
console.log("warn: http proxy cache flush failed: " + err);
|
||||
}
|
||||
|
||||
var deleted_containers = 0;
|
||||
|
||||
switch(typeof msg.id){
|
||||
@@ -521,6 +505,7 @@ function attach_ws_events(ws){
|
||||
ws.addEventListener("close", async function(e){
|
||||
|
||||
console.log("ws: offline");
|
||||
webreq_completed = new Map();
|
||||
await set_status(STATUS_OFFLINE);
|
||||
});
|
||||
}
|
||||
@@ -619,7 +604,6 @@ browser.webRequest.onBeforeRequest.addListener(
|
||||
|
||||
resolve_func({success: false});
|
||||
webreq_completed.delete(details.requestId);
|
||||
proxy_map_http_attempts.delete(details.requestId);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -659,7 +643,6 @@ browser.webRequest.onBeforeRequest.addListener(
|
||||
|
||||
resolve_func({success: false});
|
||||
webreq_completed.delete(details.requestId);
|
||||
proxy_map_http_attempts.delete(details.requestId);
|
||||
}
|
||||
},
|
||||
{ urls: ["<all_urls>"] },
|
||||
@@ -707,7 +690,6 @@ browser.webRequest.onCompleted.addListener(
|
||||
|
||||
// clean up
|
||||
webreq_completed.delete(details.requestId);
|
||||
proxy_map_http_attempts.delete(details.requestId);
|
||||
},
|
||||
{ urls: ["<all_urls>"] }
|
||||
);
|
||||
@@ -721,12 +703,9 @@ browser.webRequest.onErrorOccurred.addListener(
|
||||
if(!web_response_whitelist.includes(page.type)){
|
||||
|
||||
webreq_completed.delete(page.requestId);
|
||||
proxy_map_http_attempts.delete(page.requestId);
|
||||
return;
|
||||
}
|
||||
|
||||
const proxy_config = proxy_map[page.cookieStoreId];
|
||||
|
||||
send_event(
|
||||
global_ws,
|
||||
{
|
||||
@@ -740,7 +719,6 @@ browser.webRequest.onErrorOccurred.addListener(
|
||||
);
|
||||
|
||||
webreq_completed.delete(page.requestId);
|
||||
proxy_map_http_attempts.delete(page.requestId);
|
||||
},
|
||||
{ urls: ["<all_urls>"] }
|
||||
);
|
||||
@@ -748,22 +726,6 @@ browser.webRequest.onErrorOccurred.addListener(
|
||||
browser.proxy.onRequest.addListener(function(request){
|
||||
|
||||
const proxy_config = proxy_map[request.cookieStoreId];
|
||||
|
||||
if(
|
||||
proxy_config &&
|
||||
(
|
||||
proxy_config.type == "http" ||
|
||||
proxy_config.type == "https"
|
||||
)
|
||||
){
|
||||
|
||||
return {
|
||||
type: proxy_config.type,
|
||||
host: proxy_config.host,
|
||||
port: proxy_config.port
|
||||
};
|
||||
}
|
||||
|
||||
if(proxy_config){
|
||||
|
||||
return proxy_config;
|
||||
@@ -800,31 +762,6 @@ browser.webRequest.onAuthRequired.addListener(
|
||||
proxy_config.password
|
||||
){
|
||||
|
||||
// check if creds have been tried before...
|
||||
var attempts = proxy_map_http_attempts.get(details.requestId);
|
||||
|
||||
if(typeof attempts == "undefined"){
|
||||
|
||||
proxy_map_http_attempts.set(details.requestId, 1);
|
||||
}else{
|
||||
|
||||
send_event(
|
||||
global_ws,
|
||||
{
|
||||
"action": "dom_load_fail",
|
||||
"data": {
|
||||
id: details.tabId,
|
||||
url: details.url,
|
||||
error: "HTTP proxy refused the connection"
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
webreq_completed.delete(details.requestId);
|
||||
proxy_map_http_attempts.delete(details.requestId);
|
||||
return;
|
||||
}
|
||||
|
||||
return {
|
||||
authCredentials: {
|
||||
username: proxy_config.username,
|
||||
|
||||
@@ -2,7 +2,7 @@ const fplay = require("./lib/fplay.js");
|
||||
|
||||
var port = 3030;
|
||||
var timeout = 30000;
|
||||
var password = "cnc";
|
||||
var password = process.env.FOURPLAY_PASSWORD || "cnc";
|
||||
|
||||
fplay.event.on("server_ready", function(){
|
||||
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
const http = require("http");
|
||||
const { WebSocketServer } = require("ws");
|
||||
|
||||
const {FOURPLAY_PORT = 3000, FOURPLAY_COMMAND_TIMEOUT = 5000, FOURPLAY_PASSWORD = "cnc"} = process.env;
|
||||
|
||||
var fplay = {};
|
||||
|
||||
fplay.PORT = 3030;
|
||||
fplay.COMMAND_TIMEOUT = 5000;
|
||||
fplay.PASSWORD = "cnc";
|
||||
fplay.PORT = FOURPLAY_PORT;
|
||||
fplay.COMMAND_TIMEOUT = FOURPLAY_COMMAND_TIMEOUT;
|
||||
fplay.PASSWORD = FOURPLAY_PASSWORD;
|
||||
|
||||
const { EventEmitter } = require("events");
|
||||
fplay.event = new EventEmitter();
|
||||
@@ -558,4 +560,8 @@ fplay.init = function(port = 3030, password = "cnc", command_timeout = 5000){
|
||||
});
|
||||
}
|
||||
|
||||
process.on('SIGINT', function() {
|
||||
process.exit();
|
||||
});
|
||||
|
||||
module.exports = fplay;
|
||||
|
||||
37
server/package-lock.json
generated
Normal file
37
server/package-lock.json
generated
Normal file
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"name": "@lawlers/4play",
|
||||
"version": "1.2.5",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@lawlers/4play",
|
||||
"version": "1.2.5",
|
||||
"license": "AGPL-3.0-only",
|
||||
"dependencies": {
|
||||
"ws": "^8.21.1"
|
||||
}
|
||||
},
|
||||
"node_modules/ws": {
|
||||
"version": "8.21.2",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-8.21.2.tgz",
|
||||
"integrity": "sha512-54dMVAo4WIe6SKy3vBgN+9bJZqqQ8IMRevAkOLQALhi49qkkQDQfWdAZ8KQlXiEabw88ARXXdUrlvtbKQX+aKw==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"bufferutil": "^4.0.1",
|
||||
"utf-8-validate": ">=5.0.2"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"bufferutil": {
|
||||
"optional": true
|
||||
},
|
||||
"utf-8-validate": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
29
server/package.json
Normal file
29
server/package.json
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"name": "@lawlers/4play",
|
||||
"version": "1.2.5",
|
||||
"description": "4play and dominate",
|
||||
"keywords": [
|
||||
"4play",
|
||||
"fplay",
|
||||
"foreplay",
|
||||
"browser-automation",
|
||||
"puppeteer",
|
||||
"selenium",
|
||||
"playwright",
|
||||
"firefox"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://git.lolcat.ca/lolcat/4play"
|
||||
},
|
||||
"license": "AGPL-3.0-only",
|
||||
"author": "lolcat",
|
||||
"type": "commonjs",
|
||||
"main": "fplay.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"dependencies": {
|
||||
"ws": "^8.21.1"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user