mirror of https://gogs.blitter.com/RLabs/xs
Random jitter to tun keepalive timing
Signed-off-by: Russ Magee <rmagee@gmail.com>
This commit is contained in:
parent
b8d32ed882
commit
f5480553df
|
@ -16,6 +16,7 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
|
"math/rand"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
@ -888,13 +889,21 @@ func main() {
|
||||||
// Keepalive for any tunnels that may exist
|
// Keepalive for any tunnels that may exist
|
||||||
// #gv:s/label=\"main\$1\"/label=\"tunKeepAlive\"/
|
// #gv:s/label=\"main\$1\"/label=\"tunKeepAlive\"/
|
||||||
// TODO:.gv:main:1:tunKeepAlive
|
// TODO:.gv:main:1:tunKeepAlive
|
||||||
|
//[1]: better to always send tunnel keepAlives even if client didn't specify
|
||||||
|
// any, to prevent listeners from knowing this.
|
||||||
|
//[1] if tunSpecStr != "" {
|
||||||
keepAliveWorker := func() {
|
keepAliveWorker := func() {
|
||||||
for {
|
for {
|
||||||
time.Sleep(time.Duration(2) * time.Second)
|
// Add a bit of jitter to keepAlive so it doesn't stand out quite as much
|
||||||
|
time.Sleep(time.Duration(2000-rand.Intn(200)) * time.Millisecond)
|
||||||
|
// FIXME: keepAlives should probably have small random packet len/data as well
|
||||||
|
// to further obscure them vs. interactive or tunnel data
|
||||||
|
// ** Min pkt len is 2 due to hkex.Conn.WritePacket() padding logic? I forget.
|
||||||
conn.WritePacket([]byte{0, 0}, hkexnet.CSOTunKeepAlive) // nolint: errcheck,gosec
|
conn.WritePacket([]byte{0, 0}, hkexnet.CSOTunKeepAlive) // nolint: errcheck,gosec
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
go keepAliveWorker()
|
go keepAliveWorker()
|
||||||
|
//[1]}
|
||||||
|
|
||||||
if shellMode {
|
if shellMode {
|
||||||
launchTuns(&conn, remoteHost, tunSpecStr)
|
launchTuns(&conn, remoteHost, tunSpecStr)
|
||||||
|
|
Loading…
Reference in New Issue