-
Notifications
You must be signed in to change notification settings - Fork 559
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'tun' of https://github.com/bepass-org/oblivion-desktop …
…into tun
- Loading branch information
Showing
25 changed files
with
1,028 additions
and
284 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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": { | ||
|
@@ -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", | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/)", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.