gui-for-singbox: 1.21.0 -> 1.23.2 (#515082)
This commit is contained in:
@@ -29104,6 +29104,13 @@
|
||||
githubId = 5604643;
|
||||
name = "Mikhail Volkhov";
|
||||
};
|
||||
vollate = {
|
||||
name = "Vollate";
|
||||
email = "uint44t@gmail.com";
|
||||
github = "vollate";
|
||||
githubId = 90166078;
|
||||
keys = [ { fingerprint = "A5B9 B2C5 8C04 DCB6 A157 566A 9CDF DE55 0783 E7BB"; } ];
|
||||
};
|
||||
vonfry = {
|
||||
email = "nixos@vonfry.name";
|
||||
github = "Vonfry";
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
diff -ruN a/src/constant/kernel.ts b/src/constant/kernel.ts
|
||||
--- a/src/constant/kernel.ts
|
||||
+++ b/src/constant/kernel.ts
|
||||
@@ -300,9 +300,9 @@
|
||||
'run',
|
||||
'--disable-color',
|
||||
'-c',
|
||||
- '$APP_BASE_PATH/$CORE_BASE_PATH/config.json',
|
||||
+ '$CORE_BASE_PATH/config.json',
|
||||
'-D',
|
||||
- '$APP_BASE_PATH/$CORE_BASE_PATH',
|
||||
+ '$CORE_BASE_PATH',
|
||||
],
|
||||
}
|
||||
}
|
||||
diff -ruN a/src/stores/env.ts b/src/stores/env.ts
|
||||
--- a/src/stores/env.ts
|
||||
+++ b/src/stores/env.ts
|
||||
@@ -15,6 +15,7 @@
|
||||
appName: '',
|
||||
appVersion: '',
|
||||
basePath: '',
|
||||
+ configPath: '',
|
||||
appPath: '',
|
||||
os: '' as OS,
|
||||
arch: '',
|
||||
diff -ruN a/src/stores/kernelApi.ts b/src/stores/kernelApi.ts
|
||||
--- a/src/stores/kernelApi.ts
|
||||
+++ b/src/stores/kernelApi.ts
|
||||
@@ -248,8 +248,12 @@
|
||||
const runCoreProcess = (isAlpha: boolean) => {
|
||||
return new Promise<number | void>((resolve, reject) => {
|
||||
let output: string
|
||||
+ const coreWorkingDirectory =
|
||||
+ envStore.env.os === 'linux' && envStore.env.configPath
|
||||
+ ? `${envStore.env.configPath}/${CoreWorkingDirectory}`
|
||||
+ : CoreWorkingDirectory
|
||||
const pid = ExecBackground(
|
||||
- CoreWorkingDirectory + '/' + getKernelFileName(isAlpha),
|
||||
+ coreWorkingDirectory + '/' + getKernelFileName(isAlpha),
|
||||
getKernelRuntimeArgs(isAlpha),
|
||||
(out) => {
|
||||
output = out
|
||||
@@ -263,8 +267,9 @@
|
||||
reject(output)
|
||||
},
|
||||
{
|
||||
- PidFile: CorePidFilePath,
|
||||
+ PidFile: coreWorkingDirectory + '/pid.txt',
|
||||
StopOutputKeyword: CoreStopOutputKeyword,
|
||||
+ WorkingDirectory: envStore.env.configPath || envStore.env.basePath,
|
||||
Env: getKernelRuntimeEnv(isAlpha),
|
||||
},
|
||||
).catch((e) => reject(e))
|
||||
diff -ruN a/src/types/app.d.ts b/src/types/app.d.ts
|
||||
--- a/src/types/app.d.ts
|
||||
+++ b/src/types/app.d.ts
|
||||
@@ -19,6 +19,7 @@
|
||||
appName: string
|
||||
appVersion: string
|
||||
basePath: string
|
||||
+ configPath: string
|
||||
appPath: string
|
||||
os: OS
|
||||
arch: string
|
||||
diff -ruN a/src/utils/helper.ts b/src/utils/helper.ts
|
||||
--- a/src/utils/helper.ts
|
||||
+++ b/src/utils/helper.ts
|
||||
@@ -822,9 +822,21 @@
|
||||
export const processMagicVariables = (str: string) => {
|
||||
const { env } = useEnvStore()
|
||||
let result = str
|
||||
+ const coreBasePath =
|
||||
+ env.os === 'linux' && env.configPath
|
||||
+ ? `${env.configPath}/${CoreWorkingDirectory}`
|
||||
+ : CoreWorkingDirectory
|
||||
+
|
||||
+ if (env.os === 'linux') {
|
||||
+ result = result.replaceAll('$APP_BASE_PATH/$CORE_BASE_PATH', coreBasePath)
|
||||
+ result = result.replaceAll(
|
||||
+ `${env.basePath}/${CoreWorkingDirectory}`,
|
||||
+ coreBasePath,
|
||||
+ )
|
||||
+ }
|
||||
Object.entries({
|
||||
$APP_BASE_PATH: env.basePath,
|
||||
- $CORE_BASE_PATH: CoreWorkingDirectory,
|
||||
+ $CORE_BASE_PATH: coreBasePath,
|
||||
}).forEach(([source, target]) => {
|
||||
result = result.replaceAll(source, target)
|
||||
})
|
||||
@@ -5,11 +5,13 @@
|
||||
fetchFromGitHub,
|
||||
autoPatchelfHook,
|
||||
copyDesktopItems,
|
||||
glib-networking,
|
||||
nodejs,
|
||||
pkg-config,
|
||||
pnpm_10,
|
||||
fetchPnpmDeps,
|
||||
pnpmConfigHook,
|
||||
wrapGAppsHook3,
|
||||
wails,
|
||||
webkitgtk_4_1,
|
||||
makeDesktopItem,
|
||||
@@ -18,20 +20,20 @@
|
||||
|
||||
let
|
||||
pname = "gui-for-singbox";
|
||||
version = "1.21.0";
|
||||
version = "1.23.2";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "GUI-for-Cores";
|
||||
repo = "GUI.for.SingBox";
|
||||
tag = "v${version}";
|
||||
hash = "sha256-IGsH8QHoj2CvrSEc9eIisxySXQkjPSDBXsCPOXqANVM=";
|
||||
hash = "sha256-CEJ0yzF2smBlLgZ4EH5UWV4Pc4vA2ZH80TjoudUKWZM=";
|
||||
};
|
||||
|
||||
metaCommon = {
|
||||
homepage = "https://github.com/GUI-for-Cores/GUI.for.SingBox";
|
||||
hydraPlatforms = [ ]; # https://gui-for-cores.github.io/guide/#note
|
||||
license = with lib.licenses; [ gpl3Plus ];
|
||||
maintainers = [ ];
|
||||
maintainers = with lib.maintainers; [ vollate ];
|
||||
};
|
||||
|
||||
frontend = stdenv.mkDerivation (finalAttrs: {
|
||||
@@ -39,6 +41,8 @@ let
|
||||
|
||||
sourceRoot = "${finalAttrs.src.name}/frontend";
|
||||
|
||||
patches = [ ./frontend-runtime-path.patch ];
|
||||
|
||||
nativeBuildInputs = [
|
||||
nodejs
|
||||
pnpmConfigHook
|
||||
@@ -53,8 +57,8 @@ let
|
||||
sourceRoot
|
||||
;
|
||||
pnpm = pnpm_10;
|
||||
fetcherVersion = 2;
|
||||
hash = "sha256-dWqwEnXPT+5N+36szm4AF1ChM9M6UJltct+EtQAofGQ=";
|
||||
fetcherVersion = 3;
|
||||
hash = "sha256-m9Rmc9Ww4jb2aQ+RXOwF71daZ6puspdMM/xidnk/YHs=";
|
||||
};
|
||||
|
||||
buildPhase = ''
|
||||
@@ -85,22 +89,20 @@ buildGo126Module {
|
||||
|
||||
patches = [ ./xdg-path-and-restart-patch.patch ];
|
||||
|
||||
# As we need the $out reference, we can't use `replaceVars` here.
|
||||
postPatch = ''
|
||||
substituteInPlace bridge/bridge.go \
|
||||
--subst-var out
|
||||
'';
|
||||
|
||||
vendorHash = "sha256-EeIxt0BzSaZh1F38btUXN9kAvj12nlqEerVgWVGkiuk=";
|
||||
vendorHash = "sha256-9uWrctbQ+vujb1Q8zT7Bv7rVyNY1rCM577c9caOKRNo=";
|
||||
|
||||
nativeBuildInputs = [
|
||||
autoPatchelfHook
|
||||
copyDesktopItems
|
||||
pkg-config
|
||||
wails
|
||||
wrapGAppsHook3
|
||||
];
|
||||
|
||||
buildInputs = [ webkitgtk_4_1 ];
|
||||
buildInputs = [
|
||||
glib-networking
|
||||
webkitgtk_4_1
|
||||
];
|
||||
|
||||
preBuild = ''
|
||||
cp -r ${frontend} frontend/dist
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
diff -ruN a/bridge/bridge.go b/bridge/bridge.go
|
||||
--- a/bridge/bridge.go
|
||||
+++ b/bridge/bridge.go
|
||||
@@ -93,7 +93,10 @@
|
||||
@@ -50,6 +50,7 @@
|
||||
|
||||
Env.BasePath = filepath.ToSlash(filepath.Dir(exePath))
|
||||
Env.AppName = filepath.Base(exePath)
|
||||
+ Env.ConfigPath = filepath.ToSlash(GetConfigPath())
|
||||
|
||||
if slices.Contains(os.Args, "tasksch") {
|
||||
Env.FromTaskSch = true
|
||||
@@ -93,7 +94,10 @@
|
||||
|
||||
func (a *App) RestartApp() FlagResult {
|
||||
log.Printf("RestartApp")
|
||||
@@ -12,3 +21,64 @@
|
||||
|
||||
cmd := exec.Command(exePath)
|
||||
SetCmdWindowHidden(cmd)
|
||||
@@ -116,6 +120,7 @@
|
||||
AppName: Env.AppName,
|
||||
AppVersion: Env.AppVersion,
|
||||
BasePath: Env.BasePath,
|
||||
+ ConfigPath: Env.ConfigPath,
|
||||
OS: Env.OS,
|
||||
ARCH: Env.ARCH,
|
||||
IsPrivileged: Env.IsPrivileged,
|
||||
@@ -258,7 +263,7 @@
|
||||
}
|
||||
|
||||
func loadConfig() {
|
||||
- b, err := os.ReadFile(Env.BasePath + "/data/user.yaml")
|
||||
+ b, err := os.ReadFile(GetPath("data/user.yaml"))
|
||||
if err == nil {
|
||||
yaml.Unmarshal(b, &Config)
|
||||
}
|
||||
diff -ruN a/bridge/types.go b/bridge/types.go
|
||||
--- a/bridge/types.go
|
||||
+++ b/bridge/types.go
|
||||
@@ -21,6 +21,7 @@
|
||||
AppName string `json:"appName"`
|
||||
AppVersion string `json:"appVersion"`
|
||||
BasePath string `json:"basePath"`
|
||||
+ ConfigPath string `json:"configPath"`
|
||||
OS string `json:"os"`
|
||||
ARCH string `json:"arch"`
|
||||
IsPrivileged bool `json:"isPrivileged"`
|
||||
diff -ruN a/bridge/utils.go b/bridge/utils.go
|
||||
--- a/bridge/utils.go
|
||||
+++ b/bridge/utils.go
|
||||
@@ -13,7 +13,29 @@
|
||||
"golang.org/x/text/encoding/simplifiedchinese"
|
||||
)
|
||||
|
||||
+func GetConfigPath() string {
|
||||
+ if Env.OS == "linux" {
|
||||
+ if xdgConfigHome := os.Getenv("XDG_CONFIG_HOME"); xdgConfigHome != "" {
|
||||
+ return filepath.Join(xdgConfigHome, "GUI.for.SingBox")
|
||||
+ }
|
||||
+ if userConfigDir, err := os.UserConfigDir(); err == nil {
|
||||
+ return filepath.Join(userConfigDir, "GUI.for.SingBox")
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return Env.BasePath
|
||||
+}
|
||||
+
|
||||
func GetPath(path string) string {
|
||||
+ if Env.OS == "linux" && !filepath.IsAbs(path) {
|
||||
+ cleanPath := filepath.ToSlash(filepath.Clean(path))
|
||||
+ if cleanPath == "data" {
|
||||
+ path = filepath.Join(GetConfigPath(), "data")
|
||||
+ } else if strings.HasPrefix(cleanPath, "data/") {
|
||||
+ path = filepath.Join(GetConfigPath(), cleanPath)
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
if !filepath.IsAbs(path) {
|
||||
path = filepath.Join(Env.BasePath, path)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user