Compare commits
2
Commits
master
..
41e1c33e0e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
41e1c33e0e | ||
|
|
aa2bf08255 |
No files matched your search
@@ -1,5 +1,3 @@
|
||||
node_modules/
|
||||
web-ext-artifacts/
|
||||
*.swp
|
||||
package.json
|
||||
package-lock.json
|
||||
@@ -274,23 +274,6 @@ Removes the proxy from a container, reverting to direct connection.
|
||||
|
||||
**Returns:** `boolean` - `true` if detached successfully, `false` otherwise.
|
||||
|
||||
### `fplay.get_cookies(ws, filters = {})`
|
||||
|
||||
Get cookies.
|
||||
|
||||
- `ws` (`WebSocket`) - Active browser connection.
|
||||
- `filters` (`filters`) - Filters to use to get cookies back. Passing `{}` returns all headers for all containers.
|
||||
- `storeId` (`string`) - Match a specific container ID
|
||||
- `domain` (`string`) - Match a specific domain
|
||||
- `secure` (`boolean`) - Match cookies that are secure
|
||||
- `session` (`boolean`) - Match session-only cookies
|
||||
- `name` (`string`) - Match a cookie name
|
||||
- `path` (`string`) - Match cookies issued for a certain path
|
||||
- `url` (`string`) - Match cookies issued for a certain URL
|
||||
- `firstPartyDomain` (`string`) - Match first party domain, where supported
|
||||
|
||||
**Returns:** `Array<object>` (each object contains `name`, `value`, `domain`, `hostOnly`, `path`, `secure`, `httpOnly`, `sameSite`, `session`, `expirationDate`, `storeId`).
|
||||
|
||||
---
|
||||
|
||||
## Events
|
||||
|
||||
@@ -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){
|
||||
@@ -512,13 +496,6 @@ function attach_ws_events(ws){
|
||||
send(ws, seqid, {status: false});
|
||||
break;
|
||||
|
||||
case "get_cookies":
|
||||
|
||||
var cookies = await browser.cookies.getAll(msg.filters);
|
||||
|
||||
send(ws, seqid, {"cookies": cookies});
|
||||
break;
|
||||
|
||||
default:
|
||||
console.log(`ws: unhandled message "${msg.action}"`, msg);
|
||||
break;
|
||||
@@ -528,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);
|
||||
});
|
||||
}
|
||||
@@ -626,7 +604,6 @@ browser.webRequest.onBeforeRequest.addListener(
|
||||
|
||||
resolve_func({success: false});
|
||||
webreq_completed.delete(details.requestId);
|
||||
proxy_map_http_attempts.delete(details.requestId);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -666,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>"] },
|
||||
@@ -714,7 +690,6 @@ browser.webRequest.onCompleted.addListener(
|
||||
|
||||
// clean up
|
||||
webreq_completed.delete(details.requestId);
|
||||
proxy_map_http_attempts.delete(details.requestId);
|
||||
},
|
||||
{ urls: ["<all_urls>"] }
|
||||
);
|
||||
@@ -728,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,
|
||||
{
|
||||
@@ -747,7 +719,6 @@ browser.webRequest.onErrorOccurred.addListener(
|
||||
);
|
||||
|
||||
webreq_completed.delete(page.requestId);
|
||||
proxy_map_http_attempts.delete(page.requestId);
|
||||
},
|
||||
{ urls: ["<all_urls>"] }
|
||||
);
|
||||
@@ -755,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;
|
||||
@@ -807,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(){
|
||||
|
||||
|
||||
+9
-20
@@ -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();
|
||||
@@ -442,23 +444,6 @@ fplay.container_detach_proxy = async function(ws, id){
|
||||
return false;
|
||||
}
|
||||
|
||||
fplay.get_cookies = async function(ws, filters = {}){
|
||||
|
||||
if(typeof filters != "object"){
|
||||
|
||||
filters = {};
|
||||
}
|
||||
|
||||
var cookies = await fplay.send(ws, "get_cookies", {filters: filters});
|
||||
|
||||
if(typeof cookies.cookies == "object"){
|
||||
|
||||
return cookies.cookies;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Unsolicited event handlers
|
||||
@@ -575,4 +560,8 @@ fplay.init = function(port = 3030, password = "cnc", command_timeout = 5000){
|
||||
});
|
||||
}
|
||||
|
||||
process.on('SIGINT', function() {
|
||||
process.exit();
|
||||
});
|
||||
|
||||
module.exports = fplay;
|
||||
Generated
+37
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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