From f4fb5b3568a1235f0bc48b8865f44cf033c7e0c7 Mon Sep 17 00:00:00 2001 From: jyyi1 Date: Thu, 12 Sep 2024 13:49:03 -0400 Subject: [PATCH] update according to code review --- client/electron/go_vpn_tunnel.ts | 8 ++++---- client/electron/process.ts | 4 ++-- client/go/outline/electron/main.go | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/client/electron/go_vpn_tunnel.ts b/client/electron/go_vpn_tunnel.ts index 5722e8f259..e41c01f088 100755 --- a/client/electron/go_vpn_tunnel.ts +++ b/client/electron/go_vpn_tunnel.ts @@ -292,7 +292,7 @@ class GoTun2socks { this.monitorStarted().then(() => (restarting = true)); try { lastError = null; - await this.process.launch(args, true); + await this.process.launch(args, false); console.info('[tun2socks] - exited with no errors'); } catch (e) { console.error('[tun2socks] - terminated due to:', e); @@ -340,10 +340,10 @@ async function checkConnectivity(tun2socks: GoTun2socks) { const output = await tun2socks.checkConnectivity(); // Only parse the first line, because sometimes Windows Crypto API adds warnings to stdout. const outObj = JSON.parse(output.split('\n')[0]); - if ('tcpErrorJson' in outObj && outObj.tcpErrorJson) { - throw new Error(outObj.tcpErrorJson); + if ('tcp' in outObj && outObj.tcp) { + throw new Error(outObj.tcp); } - if ('udpErrorJson' in outObj && outObj.udpErrorJson) { + if ('udp' in outObj && outObj.udp) { return false; } return true; diff --git a/client/electron/process.ts b/client/electron/process.ts index 417112cbfc..6e40db6bb1 100755 --- a/client/electron/process.ts +++ b/client/electron/process.ts @@ -70,7 +70,7 @@ export class ChildProcessHelper { * * @param args The args for the process */ - async launch(args: string[], ignoreStdOut: boolean = false): Promise { + async launch(args: string[], returnStdOut: boolean = true): Promise { if (this.childProcess) { throw new Error( `subprocess ${this.processName} has already been launched` @@ -102,7 +102,7 @@ export class ChildProcessHelper { this.childProcess?.stdout?.on('data', data => { this.stdOutListener?.(data); - if (!ignoreStdOut) { + if (returnStdOut) { stdOutStr += data?.toString() ?? ''; } }); diff --git a/client/go/outline/electron/main.go b/client/go/outline/electron/main.go index 4281ee9995..e4df2cdf13 100644 --- a/client/go/outline/electron/main.go +++ b/client/go/outline/electron/main.go @@ -52,8 +52,8 @@ var logger = slog.New(slog.NewTextHandler(os.Stdout, nil)) // The result JSON containing two error strings when "--checkConnectivity". type CheckConnectivityResult struct { - TCPErrorJson string `json:"tcpErrorJson,omitempty"` - UDPErrorJson string `json:"udpErrorJson,omitempty"` + TCPErrorJson string `json:"tcp"` + UDPErrorJson string `json:"udp"` } var args struct {