Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…into tun
  • Loading branch information
ircfspace committed Sep 12, 2024
2 parents 8bc4f90 + 4f23260 commit fff8dde
Show file tree
Hide file tree
Showing 25 changed files with 1,028 additions and 284 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,6 @@ log.txt
warp-plus*.zip
assets/bin
stuff
ca.psiphon.PsiphonTunnel.tunnel-core
ca.psiphon.PsiphonTunnel.tunnel-core
sing-box*.tar.gz
sing-box*.zip
1 change: 1 addition & 0 deletions DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,6 @@ checkout `src/main/ipc.ts` and `src/renderer/index.tsx` for an in action example
- (after wp updates) to get the latest wp version, that app is using. run: `npm i`.
- `wp` refers to `warp-plus` in source.
- `od` refers to `oblivion desktop` in source.
- `sb` refers to `sing-box` in source.

happy hacking 😉
211 changes: 115 additions & 96 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"url": "https://github.com/bepass-org/oblivion-desktop/issues",
"email": "[email protected]"
},
"version": "1.6.22",
"version": "2.0.0-beta.3",
"license": "Restrictive",
"main": "./src/main/main.ts",
"scripts": {
Expand All @@ -20,7 +20,7 @@
"build:dll": "cross-env NODE_ENV=development TS_NODE_TRANSPILE_ONLY=true webpack --config ./.erb/configs/webpack.config.renderer.dev.dll.ts",
"build:main": "cross-env NODE_ENV=production TS_NODE_TRANSPILE_ONLY=true webpack --config ./.erb/configs/webpack.config.main.prod.ts",
"build:renderer": "cross-env NODE_ENV=production TS_NODE_TRANSPILE_ONLY=true webpack --config ./.erb/configs/webpack.config.renderer.prod.ts",
"prepare": "ts-node script/dlWp.ts && husky",
"prepare": "ts-node script/dlBins.ts && husky",
"postinstall": "ts-node ./script/postinstall.ts",
"postinstall:darwin-linux": "ts-node .erb/scripts/check-native-dep.js && electron-builder install-app-deps && npm run build:dll",
"postinstall:windows": "ts-node script/makeRegeditVBSAvailable.ts && ts-node .erb/scripts/check-native-dep.js && electron-builder install-app-deps && npm run build:dll",
Expand Down
4 changes: 2 additions & 2 deletions release/app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion release/app/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "oblivion-desktop",
"description": "unofficial desktop version of oblivion",
"version": "1.6.22",
"version": "2.0.0-beta.3",
"homepage": "https://github.com/bepass-org/oblivion-desktop#readme",
"license": "Restrictive",
"author": "ircfspace+kiomarzsss <[email protected]> (https://ircf.space/)",
Expand Down
2 changes: 1 addition & 1 deletion script/beforePackHook.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ exports.default = async function (context) {
};
// TODO don't force download when packaging on the local platform
const { stdout, stderr } = await exec(
`npm exec ts-node script/dlWp.ts force ${context.electronPlatformName} ${archDict[context.arch]}`
`npm exec ts-node script/dlBins.ts force ${context.electronPlatformName} ${archDict[context.arch]}`
);

if (stderr) {
Expand Down
147 changes: 147 additions & 0 deletions script/dlBins.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
import fs from 'fs';
import axios from 'axios';
import decompress from 'decompress';
import { doesDirectoryExist, doesFileExist } from '../src/main/lib/utils';
import { sbVersion, wpVersion } from '../src/main/config';

const forceDownload = process.argv[2] === 'force';
const platform = process.argv[3] || process.platform;
const arch = process.argv[4] || process.arch;

console.log('➡️ platform:', platform);
console.log('➡️ arch:', arch);

async function downloadFile(uri: string, destPath: string) {
try {
const response = await axios.get(uri, {
responseType: 'arraybuffer',
onDownloadProgress: (progressEvent) => {
const percentCompleted = Math.round(
(progressEvent.loaded * 100) / (progressEvent.total || 1)
);
try {
process?.stdout?.clearLine(0);
process?.stdout?.cursorTo(0);
process?.stdout?.write(`Downloading ${uri}: ${percentCompleted}%`);
} catch (error) {
if (
!String(error).includes(
'TypeError: process?.stdout?.clearLine is not a function'
)
) {
console.error(error);
}
}
}
});

const buffer = Buffer.from(new Uint8Array(response.data));
fs.writeFileSync(destPath, buffer);
console.log();
} catch (error: any) {
console.error(`Failed to download ${uri}:`, error.message);
}
}

async function dlUnzipMove(url: string, binPath: string, zipFileName: string) {
const isBinDirExist = await doesDirectoryExist(binPath);
if (!isBinDirExist) {
fs.mkdirSync(binPath, { recursive: true });
}

const zipFilePath = `./${zipFileName}`;

const isZipFileExist = await doesFileExist(zipFilePath);
if (!isZipFileExist || forceDownload) {
console.log(`Downloading ${zipFileName} binary based on your platform and architecture...`);
await downloadFile(url, zipFilePath);
} else {
console.log(`➡️ Skipping Download as ${zipFilePath} already exists.`);
}

try {
await decompress(zipFilePath, binPath, { strip: 1 });
console.log(`✅ ${zipFileName} binary is ready to use.`);
} catch (error) {
console.error(error);
}
}

const warpPlusUrlBase = `https://github.com/bepass-org/warp-plus/releases/download/v${wpVersion}/warp-plus_`;
const singBoxUrlBase = `https://github.com/SagerNet/sing-box/releases/download/v${sbVersion}/sing-box-${sbVersion}-`;

const warpPlusUrls: Record<string, Record<string, string>> = {
linux: {
x64: warpPlusUrlBase + 'linux-amd64.zip',
arm64: warpPlusUrlBase + 'linux-arm64.zip'
},
win32: {
x64: warpPlusUrlBase + 'windows-amd64.zip',
arm64: warpPlusUrlBase + 'windows-arm64.zip',
ia32: warpPlusUrlBase + 'windows-386.zip'
},
darwin: {
x64: warpPlusUrlBase + 'darwin-amd64.zip',
arm64: warpPlusUrlBase + 'darwin-arm64.zip'
}
};

const singBoxUrls: Record<string, Record<string, string>> = {
linux: {
x64: singBoxUrlBase + 'linux-amd64.tar.gz',
arm64: singBoxUrlBase + 'linux-arm64.tar.gz'
},
win32: {
x64: singBoxUrlBase + 'windows-amd64.zip',
arm64: singBoxUrlBase + 'windows-arm64.zip',
ia32: singBoxUrlBase + 'windows-386.zip'
},
darwin: {
x64: singBoxUrlBase + 'darwin-amd64.tar.gz',
arm64: singBoxUrlBase + 'darwin-arm64.tar.gz'
}
};

const removeFile = async (filePath: string) => {
const isExist = await doesFileExist(filePath);
if (isExist) {
fs.rm(filePath, (err) => {
if (err) console.error(`Error removing ${filePath}:`, err);
});
}
};

async function handleDownload() {
await dlUnzipMove(warpPlusUrls[platform][arch], './assets/bin', `warp-plus-v${wpVersion}.zip`);
await removeFile('./assets/bin/wintun.dll');

await dlUnzipMove(
singBoxUrls[platform][arch],
'./assets/bin/sing-box',
`sing-box-v${sbVersion}.${platform === 'win32' ? 'zip' : 'tar.gz'}`
);
}

const notSupported = () => console.log('Your platform/architecture is not supported.');

switch (platform) {
case 'linux':
case 'win32':
case 'darwin':
switch (arch) {
case 'x64':
case 'arm64':
case 'ia32':
handleDownload().catch(notSupported);
break;

default:
notSupported();
break;
}
break;

default:
notSupported();
break;
}
150 changes: 0 additions & 150 deletions script/dlWp.ts

This file was deleted.

4 changes: 3 additions & 1 deletion src/localization/cn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ const chinese: Language = {
error_wp_not_found: 'warp-plus 文件不在应用程序包旁边。',
error_wp_stopped: 'warp-plus 文件在运行时遇到了问题!',
error_connection_failed: '无法连接到1.1.1.1。',
error_country_failed: '无法连接到所选国家.'
error_country_failed: '无法连接到所选国家.',
error_singbox_failed_stop: '停止 Sing-Box 失败!',
error_singbox_failed_start: '启动 Sing-Box 失败!'
},
about: {
title: '关于应用',
Expand Down
4 changes: 3 additions & 1 deletion src/localization/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,9 @@ const deutsch: Language = {
error_wp_not_found: 'Die Datei warp-plus befindet sich nicht neben dem Anwendungspaket.',
error_wp_stopped: 'Die Datei warp-plus hat ein Problem beim Ausführen!',
error_connection_failed: 'Verbindung zu 1.1.1.1 war nicht möglich.',
error_country_failed: 'Verbindung zum ausgewählten Land nicht möglich.'
error_country_failed: 'Verbindung zum ausgewählten Land nicht möglich.',
error_singbox_failed_stop: 'Sing-Box konnte nicht gestoppt werden!',
error_singbox_failed_start: 'Sing-Box konnte nicht gestartet werden!'
},
about: {
title: 'Über',
Expand Down
4 changes: 3 additions & 1 deletion src/localization/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ const english: Language = {
error_wp_not_found: 'The warp-plus file is not located alongside the application package!',
error_wp_stopped: 'The warp-plus file has encountered an issue running!',
error_connection_failed: 'Connection to 1.1.1.1 was not possible.',
error_country_failed: 'Cannot connect to the selected country.'
error_country_failed: 'Cannot connect to the selected country.',
error_singbox_failed_stop: 'Failed to stop Sing-Box!',
error_singbox_failed_start: 'Failed to start Sing-Box!'
},
about: {
title: 'About App',
Expand Down
Loading

0 comments on commit fff8dde

Please sign in to comment.