mirror of https://gogs.blitter.com/RLabs/xs
KeepAlive WIP. TODO: check exitStatus logic for shell 'exit' clean exit
This commit is contained in:
parent
d0f8751b2b
commit
9244cc9785
3
xs/xs.go
3
xs/xs.go
|
@ -1005,7 +1005,7 @@ func main() { //nolint: funlen, gocyclo
|
||||||
loginTimeout := time.AfterFunc(30*time.Second, func() { //nolint:gomnd
|
loginTimeout := time.AfterFunc(30*time.Second, func() { //nolint:gomnd
|
||||||
restoreTermState(oldState)
|
restoreTermState(oldState)
|
||||||
fmt.Printf(" .. [login timeout]\n")
|
fmt.Printf(" .. [login timeout]\n")
|
||||||
exitWithStatus(xsnet.CSOLoginTimeout)
|
exitWithStatus(xsnet.CSELoginTimeout)
|
||||||
})
|
})
|
||||||
|
|
||||||
if authCookie == "" {
|
if authCookie == "" {
|
||||||
|
@ -1152,5 +1152,6 @@ func exitWithStatus(status int) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fmt.Printf("[exitStatus:%d]\n", status)
|
||||||
os.Exit(status)
|
os.Exit(status)
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,7 @@ const (
|
||||||
CSECipherAlgDenied // server rejected proposed Cipher alg
|
CSECipherAlgDenied // server rejected proposed Cipher alg
|
||||||
CSEHMACAlgDenied // server rejected proposed HMAC alg
|
CSEHMACAlgDenied // server rejected proposed HMAC alg
|
||||||
CSEConnDead // connection keepalives expired
|
CSEConnDead // connection keepalives expired
|
||||||
|
CSELoginTimeout
|
||||||
)
|
)
|
||||||
|
|
||||||
// Extended (>255 UNIX exit status) codes
|
// Extended (>255 UNIX exit status) codes
|
||||||
|
@ -68,9 +69,6 @@ const (
|
||||||
CSOExitStatus // Remote cmd exit status
|
CSOExitStatus // Remote cmd exit status
|
||||||
CSOChaff // Dummy packet, do not pass beyond decryption
|
CSOChaff // Dummy packet, do not pass beyond decryption
|
||||||
|
|
||||||
// Client side errors
|
|
||||||
CSOLoginTimeout
|
|
||||||
|
|
||||||
// Tunnel setup/control/status
|
// Tunnel setup/control/status
|
||||||
CSOTunSetup // client -> server tunnel setup request (dstport)
|
CSOTunSetup // client -> server tunnel setup request (dstport)
|
||||||
CSOTunSetupAck // server -> client tunnel setup ack
|
CSOTunSetupAck // server -> client tunnel setup ack
|
||||||
|
|
13
xsnet/net.go
13
xsnet/net.go
|
@ -1196,7 +1196,7 @@ func (hl *HKExListener) Accept() (hc Conn, err error) {
|
||||||
// packet processing.
|
// packet processing.
|
||||||
//
|
//
|
||||||
// See go doc io.Reader
|
// See go doc io.Reader
|
||||||
func (hc Conn) Read(b []byte) (n int, err error) {
|
func (hc *Conn) Read(b []byte) (n int, err error) {
|
||||||
for {
|
for {
|
||||||
if hc.dBuf.Len() > 0 {
|
if hc.dBuf.Len() > 0 {
|
||||||
break
|
break
|
||||||
|
@ -1214,7 +1214,8 @@ func (hc Conn) Read(b []byte) (n int, err error) {
|
||||||
return 0, io.EOF
|
return 0, io.EOF
|
||||||
}
|
}
|
||||||
if strings.HasSuffix(err.Error(), "use of closed network connection") {
|
if strings.HasSuffix(err.Error(), "use of closed network connection") {
|
||||||
logger.LogDebug(fmt.Sprintln("[Client hung up]"))
|
logger.LogDebug(fmt.Sprintln("[Client hung up(1)]"))
|
||||||
|
//!rlm hc.SetStatus(CSENone) //FIXME: re-examine this (exit 9 w/o it - 2023-11-05)
|
||||||
return 0, io.EOF
|
return 0, io.EOF
|
||||||
}
|
}
|
||||||
etxt := fmt.Sprintf("** Failed read:%s (%s) **", "ctrlStatOp", err)
|
etxt := fmt.Sprintf("** Failed read:%s (%s) **", "ctrlStatOp", err)
|
||||||
|
@ -1237,7 +1238,7 @@ func (hc Conn) Read(b []byte) (n int, err error) {
|
||||||
return 0, io.EOF
|
return 0, io.EOF
|
||||||
}
|
}
|
||||||
if strings.HasSuffix(err.Error(), "use of closed network connection") {
|
if strings.HasSuffix(err.Error(), "use of closed network connection") {
|
||||||
logger.LogDebug(fmt.Sprintln("[Client hung up]"))
|
logger.LogDebug(fmt.Sprintln("[Client hung up(2)]"))
|
||||||
return 0, io.EOF
|
return 0, io.EOF
|
||||||
}
|
}
|
||||||
etxt := fmt.Sprintf("** Failed read:%s (%s) **", "HMAC", err)
|
etxt := fmt.Sprintf("** Failed read:%s (%s) **", "HMAC", err)
|
||||||
|
@ -1253,7 +1254,7 @@ func (hc Conn) Read(b []byte) (n int, err error) {
|
||||||
return 0, io.EOF
|
return 0, io.EOF
|
||||||
}
|
}
|
||||||
if strings.HasSuffix(err.Error(), "use of closed network connection") {
|
if strings.HasSuffix(err.Error(), "use of closed network connection") {
|
||||||
logger.LogDebug(fmt.Sprintln("[Client hung up]"))
|
logger.LogDebug(fmt.Sprintln("[Client hung up(3)]"))
|
||||||
return 0, io.EOF
|
return 0, io.EOF
|
||||||
}
|
}
|
||||||
etxt := fmt.Sprintf("** Failed read:%s (%s) **", "payloadLen", err)
|
etxt := fmt.Sprintf("** Failed read:%s (%s) **", "payloadLen", err)
|
||||||
|
@ -1276,7 +1277,7 @@ func (hc Conn) Read(b []byte) (n int, err error) {
|
||||||
return 0, io.EOF
|
return 0, io.EOF
|
||||||
}
|
}
|
||||||
if strings.HasSuffix(err.Error(), "use of closed network connection") {
|
if strings.HasSuffix(err.Error(), "use of closed network connection") {
|
||||||
logger.LogDebug(fmt.Sprintln("[Client hung up]"))
|
logger.LogDebug(fmt.Sprintln("[Client hung up(4)]"))
|
||||||
return 0, io.EOF
|
return 0, io.EOF
|
||||||
}
|
}
|
||||||
etxt := fmt.Sprintf("** Failed read:%s (%s) **", "payloadBytes", err)
|
etxt := fmt.Sprintf("** Failed read:%s (%s) **", "payloadBytes", err)
|
||||||
|
@ -1647,7 +1648,7 @@ func (hc *Conn) keepaliveHelper() {
|
||||||
}
|
}
|
||||||
time.Sleep(time.Duration(nextDuration) * time.Millisecond)
|
time.Sleep(time.Duration(nextDuration) * time.Millisecond)
|
||||||
hc.keepalive -= 1
|
hc.keepalive -= 1
|
||||||
|
logger.LogDebug(fmt.Sprintf("[keepAlive is now %d]\n", hc.keepalive))
|
||||||
//if rand.Intn(32) == 0 {
|
//if rand.Intn(32) == 0 {
|
||||||
// hc.keepalive = 0
|
// hc.keepalive = 0
|
||||||
//}
|
//}
|
||||||
|
|
Loading…
Reference in New Issue