Skip to content

Commit

Permalink
fix: ubuntu network proxy auto config (#23)
Browse files Browse the repository at this point in the history
* fix: network proxy auto config
* chore: run linter
* chore: bump version
  • Loading branch information
keplervital authored Sep 6, 2023
1 parent 7c39884 commit 21fe7f0
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 25 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[![GitHub license](https://img.shields.io/badge/license-Apache%202.0-blue.svg?style=for-the-badge)](LICENSE)
[![Install MacOS](https://img.shields.io/badge/install-MacOSX-blue.svg?style=for-the-badge&logo=apple)](https://github.com/dfinity/http-proxy/releases/download/0.0.5-alpha/ic-http-proxy-mac-universal-0.0.5-alpha.dmg)
[![Install Windows](https://img.shields.io/badge/install-Windows-blue.svg?style=for-the-badge&logo=windows)](https://github.com/dfinity/http-proxy/releases/download/0.0.5-alpha/ic-http-proxy-win-x64-0.0.5-alpha.exe)
[![Install Debian](https://img.shields.io/badge/install-Debian-blue.svg?style=for-the-badge&logo=debian)](https://github.com/dfinity/http-proxy/releases/download/0.0.5-alpha/ic-http-proxy-linux-arm64-0.0.5-alpha.deb)
[![Install MacOS](https://img.shields.io/badge/install-MacOSX-blue.svg?style=for-the-badge&logo=apple)](https://github.com/dfinity/http-proxy/releases/download/0.0.6-alpha/ic-http-proxy-mac-universal-0.0.6-alpha.dmg)
[![Install Windows](https://img.shields.io/badge/install-Windows-blue.svg?style=for-the-badge&logo=windows)](https://github.com/dfinity/http-proxy/releases/download/0.0.6-alpha/ic-http-proxy-win-x64-0.0.6-alpha.exe)
[![Install Debian](https://img.shields.io/badge/install-Debian-blue.svg?style=for-the-badge&logo=debian)](https://github.com/dfinity/http-proxy/releases/download/0.0.6-alpha/ic-http-proxy-linux-arm64-0.0.6-alpha.deb)

# IC HTTP Proxy
> This application is currently only a proof of concept implementation and should be used at your own risk.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dfinity/http-proxy",
"version": "0.0.5-alpha",
"version": "0.0.6-alpha",
"description": "HTTP Proxy to enable trustless access to the Internet Computer.",
"author": "Kepler Vital <[email protected]>",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dfinity/http-proxy-core",
"version": "0.0.5-alpha",
"version": "0.0.6-alpha",
"description": "Gateway server to enable trustless access to the Internet Computer.",
"main": "built/main.js",
"types": "built/main.d.ts",
Expand Down
4 changes: 2 additions & 2 deletions packages/daemon/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dfinity/http-proxy-daemon",
"version": "0.0.5-alpha",
"version": "0.0.6-alpha",
"description": "Daemon process to enable trustless access to the Internet Computer.",
"main": "built/main.js",
"types": "built/main.d.ts",
Expand Down Expand Up @@ -62,7 +62,7 @@
"typescript": "^4.9.5"
},
"dependencies": {
"@dfinity/http-proxy-core": "0.0.5-alpha",
"@dfinity/http-proxy-core": "0.0.6-alpha",
"http-proxy": "^1.18.1",
"node-cache": "^5.1.2",
"node-forge": "^1.3.1",
Expand Down
24 changes: 22 additions & 2 deletions packages/daemon/src/platforms/linux/linux.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
FIREFOX_PROFILES_FOLDER,
MOZILLA_CERTIFICATES_FOLDER,
ROOT_CA_PATH,
findDbusLaunchPath,
findP11KitTrustPath,
} from './utils';

Expand Down Expand Up @@ -81,12 +82,20 @@ export class LinuxPlatform implements Platform {
}

private async tooggleNetworkWebProxy(enable: boolean): Promise<void> {
const dconfCachePath = `/home/${this.username}/.cache/dconf`;
const pacUrl = `http://${this.configs.pac.host}:${this.configs.pac.port}/proxy.pac`;

if (pathExists(dconfCachePath)) {
await execAsync(
`sudo chown -R "${this.username}":"${this.username}" "${dconfCachePath}"`
);
}

if (enable) {
await execAsync(
[
`su -l ${this.username} -c "gsettings set org.gnome.system.proxy mode 'auto' && gsettings set org.gnome.system.proxy autoconfig-url '${pacUrl}'"`,
`sudo -u "${this.username}" dbus-launch gsettings set org.gnome.system.proxy mode 'auto'`,
`sudo -u "${this.username}" dbus-launch gsettings set org.gnome.system.proxy autoconfig-url '${pacUrl}'`,
].join(' && ')
);

Expand All @@ -95,7 +104,7 @@ export class LinuxPlatform implements Platform {

await execAsync(
[
`su -l ${this.username} -c "gsettings set org.gnome.system.proxy mode 'none'"`,
`sudo -u "${this.username}" dbus-launch gsettings set org.gnome.system.proxy mode 'none'`,
].join(' && ')
);
}
Expand Down Expand Up @@ -153,6 +162,17 @@ export class LinuxPlatform implements Platform {
throw new Error('Failed to setup p11-kit dependency');
}
}

const dbusLaunchPath = await findDbusLaunchPath();
if (!dbusLaunchPath) {
await execAsync(`sudo apt install dbus-x11 -y`);

const installed = await findDbusLaunchPath();

if (!installed) {
throw new Error('Failed to setup dbus-x11 dependency');
}
}
}

private async firefoxSetupCertificates(profilesPath: string): Promise<void> {
Expand Down
6 changes: 6 additions & 0 deletions packages/daemon/src/platforms/linux/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@ export const findP11KitTrustPath = async (): Promise<string | null> => {

return path.length ? path : null;
};

export const findDbusLaunchPath = async (): Promise<string | null> => {
const path = await execAsync('which dbus-launch');

return path.length ? path : null;
};
6 changes: 3 additions & 3 deletions packages/server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dfinity/http-proxy-server",
"version": "0.0.5-alpha",
"version": "0.0.6-alpha",
"description": "Gateway server to enable trustless access to the Internet Computer.",
"main": "built/main.js",
"types": "built/main.d.ts",
Expand Down Expand Up @@ -51,8 +51,8 @@
"dependencies": {
"@dfinity/agent": "^0.19.0",
"@dfinity/candid": "^0.19.0",
"@dfinity/http-proxy-core": "0.0.5-alpha",
"@dfinity/http-proxy-daemon": "0.0.5-alpha",
"@dfinity/http-proxy-core": "0.0.6-alpha",
"@dfinity/http-proxy-daemon": "0.0.6-alpha",
"@dfinity/principal": "^0.19.0",
"@dfinity/response-verification": "^1.0.2",
"http-proxy": "^1.18.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/server/src/commons/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { EnvironmentConfiguration } from './typings';

const environment: EnvironmentConfiguration = {
platform: os.platform(),
userAgent: 'ICHttpProxy/0.0.5-alpha',
userAgent: 'ICHttpProxy/0.0.6-alpha',
certificate: {
storage: {
folder: 'certs',
Expand Down
6 changes: 3 additions & 3 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dfinity/http-proxy-ui",
"version": "0.0.5-alpha",
"version": "0.0.6-alpha",
"description": "Desktop interface to facilitate user interaction with the HTTP Proxy server.",
"main": "built/main.js",
"scripts": {
Expand Down Expand Up @@ -37,8 +37,8 @@
},
"homepage": "https://github.com/dfinity/http-proxy/tree/main/packages/ui#readme",
"dependencies": {
"@dfinity/http-proxy-core": "0.0.5-alpha",
"@dfinity/http-proxy-server": "0.0.5-alpha"
"@dfinity/http-proxy-core": "0.0.6-alpha",
"@dfinity/http-proxy-server": "0.0.6-alpha"
},
"devDependencies": {
"@types/node": "^18.14.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/services/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class ProxyService {
return isStarted;
}

fork(entrypoint, undefined, {
fork(entrypoint, [], {
stdio: 'ignore',
env: process.env,
detached: true,
Expand Down
16 changes: 8 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ __metadata:
languageName: node
linkType: hard

"@dfinity/[email protected].5-alpha, @dfinity/http-proxy-core@workspace:packages/core":
"@dfinity/[email protected].6-alpha, @dfinity/http-proxy-core@workspace:packages/core":
version: 0.0.0-use.local
resolution: "@dfinity/http-proxy-core@workspace:packages/core"
dependencies:
Expand All @@ -127,11 +127,11 @@ __metadata:
languageName: unknown
linkType: soft

"@dfinity/[email protected].5-alpha, @dfinity/http-proxy-daemon@workspace:packages/daemon":
"@dfinity/[email protected].6-alpha, @dfinity/http-proxy-daemon@workspace:packages/daemon":
version: 0.0.0-use.local
resolution: "@dfinity/http-proxy-daemon@workspace:packages/daemon"
dependencies:
"@dfinity/http-proxy-core": 0.0.5-alpha
"@dfinity/http-proxy-core": 0.0.6-alpha
"@types/node": ^18.14.0
"@types/node-forge": ^1.3.1
"@types/pako": ^2.0.0
Expand All @@ -155,14 +155,14 @@ __metadata:
languageName: unknown
linkType: soft

"@dfinity/[email protected].5-alpha, @dfinity/http-proxy-server@workspace:packages/server":
"@dfinity/[email protected].6-alpha, @dfinity/http-proxy-server@workspace:packages/server":
version: 0.0.0-use.local
resolution: "@dfinity/http-proxy-server@workspace:packages/server"
dependencies:
"@dfinity/agent": ^0.19.0
"@dfinity/candid": ^0.19.0
"@dfinity/http-proxy-core": 0.0.5-alpha
"@dfinity/http-proxy-daemon": 0.0.5-alpha
"@dfinity/http-proxy-core": 0.0.6-alpha
"@dfinity/http-proxy-daemon": 0.0.6-alpha
"@dfinity/principal": ^0.19.0
"@dfinity/response-verification": ^1.0.2
"@types/isomorphic-fetch": ^0.0.36
Expand Down Expand Up @@ -191,8 +191,8 @@ __metadata:
version: 0.0.0-use.local
resolution: "@dfinity/http-proxy-ui@workspace:packages/ui"
dependencies:
"@dfinity/http-proxy-core": 0.0.5-alpha
"@dfinity/http-proxy-server": 0.0.5-alpha
"@dfinity/http-proxy-core": 0.0.6-alpha
"@dfinity/http-proxy-server": 0.0.6-alpha
"@types/node": ^18.14.0
"@typescript-eslint/eslint-plugin": ^5.54.1
"@typescript-eslint/parser": ^5.54.1
Expand Down

0 comments on commit 21fe7f0

Please sign in to comment.