1
0
mirror of https://github.com/fumiama/WireGold.git synced 2026-06-13 05:31:08 +08:00

feat(tcp): add config option dialtimeout

This commit is contained in:
源文雨
2024-07-16 22:16:01 +09:00
parent 739cf863f1
commit 5d04567ec9
3 changed files with 29 additions and 5 deletions

View File

@@ -19,6 +19,9 @@ func (l *Link) keepAlive(dur int64) {
logrus.Infoln("[nat] start to keep alive")
t := time.NewTicker(time.Second * time.Duration(dur))
for range t.C {
if l.status == LINK_STATUS_DOWN || l.me.loop == nil {
return
}
n, err := l.WriteAndPut(head.NewPacket(head.ProtoHello, l.me.srcport, l.peerip, l.me.dstport, nil), false)
if err == nil {
logrus.Infoln("[nat] send", n, "bytes keep alive packet")
@@ -78,6 +81,11 @@ func (l *Link) onQuery(packet []byte) {
return
}
if l == nil || l.me == nil {
logrus.Errorln("[nat] nil link/me")
return
}
// 2. notify分发
// ---- 封装 Notify 到 新的 packet
// ---- 调用 l.Send 发送到对方