Make server timeout configurable at compile time

This commit is contained in:
2025-05-19 20:22:46 -04:00
parent 8907fdc36e
commit 4210673b84
3 changed files with 9 additions and 6 deletions
+3 -3
View File
@@ -47,14 +47,14 @@ func Start(passphrase []byte) {
os.Exit(0)
}()
// accept connections (timeout after 3 minutes of inactivity)
// accept connections until Timeout takes effect
for {
listener.(*net.UnixListener).SetDeadline(time.Now().Add(3 * time.Minute))
listener.(*net.UnixListener).SetDeadline(time.Now().Add(time.Duration(Timeout) * time.Second))
conn, err := listener.Accept()
if err != nil {
if err.(net.Error).Timeout() {
log.Println("Three minutes have passed without any connections. Exiting...")
log.Println(strconv.Itoa(Timeout) + " seconds have passed without any connections. Exiting...")
listener.Close()
os.Exit(0)
}