Skip to content

Commit

Permalink
update according to code review
Browse files Browse the repository at this point in the history
  • Loading branch information
jyyi1 committed Sep 12, 2024
1 parent 18cac49 commit f4fb5b3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions client/electron/go_vpn_tunnel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions client/electron/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export class ChildProcessHelper {
*
* @param args The args for the process
*/
async launch(args: string[], ignoreStdOut: boolean = false): Promise<string> {
async launch(args: string[], returnStdOut: boolean = true): Promise<string> {
if (this.childProcess) {
throw new Error(
`subprocess ${this.processName} has already been launched`
Expand Down Expand Up @@ -102,7 +102,7 @@ export class ChildProcessHelper {

this.childProcess?.stdout?.on('data', data => {
this.stdOutListener?.(data);
if (!ignoreStdOut) {
if (returnStdOut) {
stdOutStr += data?.toString() ?? '';
}
});
Expand Down
4 changes: 2 additions & 2 deletions client/go/outline/electron/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit f4fb5b3

Please sign in to comment.