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:
@@ -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 发送到对方
|
||||
|
||||
Reference in New Issue
Block a user