mirror of
https://github.com/p1neappleXpress/OpenFlux.git
synced 2026-10-02 05:04:39 +08:00
SocketWatcher.addRoute() installs a /32 bypass route through the physical gateway for every remote IP the process talks to directly, so the transport's own sockets stay off the tunnel. Stop() never removed them, so after the client exited the routes stayed in the table pinned to whatever gateway was current at that moment. Once the network changed (different Wi-Fi, another VPN, a hotspot), traffic to that specific IP kept following the stale route instead of the new default route - breaking reachability to that one host while everything else worked fine. Stop() now removes every route it added. Also notify on SIGHUP, since that's what a closed terminal window sends the foreground process (not SIGINT/SIGTERM) - previously that path skipped cleanup entirely.
17 lines
414 B
Go
17 lines
414 B
Go
//go:build !windows
|
|
|
|
package main
|
|
|
|
import (
|
|
"os"
|
|
"os/signal"
|
|
"syscall"
|
|
)
|
|
|
|
func notifySignals(ch chan os.Signal) {
|
|
// SIGHUP is what a closed terminal window sends the foreground process
|
|
// (not SIGINT/SIGTERM) - without catching it, closing the window instead
|
|
// of Ctrl+C skips the bypass-route cleanup in SocketWatcher.Stop() entirely.
|
|
signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP)
|
|
}
|