1
0
mirror of https://github.com/fumiama/WireGold.git synced 2026-06-04 23:40:26 +08:00
Files
WireGold/gold/proto/hello/hello.go
2025-05-13 00:59:05 +09:00

24 lines
644 B
Go

package hello
import (
"github.com/sirupsen/logrus"
"github.com/fumiama/WireGold/gold/head"
"github.com/fumiama/WireGold/gold/link"
"github.com/fumiama/WireGold/internal/file"
)
func init() {
link.RegisterDispacher(head.ProtoHello, func(_ *head.Packet, peer *link.Link, data []byte) {
switch {
case len(data) == 0:
logrus.Warnln(file.Header(), "recv old packet, do nothing")
case data[0] == byte(head.HelloPing):
go peer.WritePacket(head.ProtoHello, []byte{byte(head.HelloPong)}, peer.Me().TTL())
logrus.Infoln(file.Header(), "recv, send ack")
default:
logrus.Infoln(file.Header(), "recv ack, do nothing")
}
})
}