Skip to content

Commit

Permalink
integrated proxy support
Browse files Browse the repository at this point in the history
  • Loading branch information
ccev committed Apr 20, 2024
1 parent f5d3a58 commit 78c5d1f
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 0 deletions.
3 changes: 3 additions & 0 deletions docker-compose-no-traefik.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@ services:
xilriws:
image: ghcr.io/unownhash/xilriws-public:main
restart: unless-stopped
volumes:
- ./proxies.txt:/xilriws/proxies.txt
ports:
- "5090:5090"

2 changes: 2 additions & 0 deletions docker-compose.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ services:
restart: unless-stopped
expose:
- "5090"
volumes:
- ./proxies.txt:/xilriws/proxies.txt
labels:
- traefik.http.routers.xilriws.rule=HostRegexp(`{catchall:.*}`)
- traefik.enable=true
Expand Down
50 changes: 50 additions & 0 deletions xilriws-proxy/background.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
console.log("test")

const ws = new WebSocket('ws://localhost:9091');

let currentProxyCreds = {
"username": null,
"password": null
}

ws.onmessage = (event) => {
console.log('Message from server: ', event.data);
const data = JSON.parse(event.data)

currentProxyCreds = {
username: data.username,
password: data.password
}
startProxy(data.host, data.port)
};

function startProxy(host, port) {
const config = {
mode: "fixed_servers",
rules: {
singleProxy: {
scheme: "http",
host: host,
port: port,
},
bypassList: ["localhost"],
},
};
chrome.proxy.settings.set(
{value: config, scope: "regular"},
function () {
},
);
}

function callbackFn(details) {
return {
authCredentials: currentProxyCreds,
};
}

chrome.webRequest.onAuthRequired.addListener(
callbackFn,
{urls: ["<all_urls>"]},
["blocking"],
);
18 changes: 18 additions & 0 deletions xilriws-proxy/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"manifest_version": 2,
"name": "xilriws-proxy",
"version": "1.0",
"permissions": [
"proxy",
"tabs",
"unlimitedStorage",
"storage",
"<all_urls>",
"webRequest",
"webRequestBlocking",
"devtools"
],
"background": {
"scripts": ["background.js"]
}
}

0 comments on commit 78c5d1f

Please sign in to comment.