1
0
mirror of https://github.com/fumiama/WireGold.git synced 2026-07-02 00:20:26 +08:00

feat: drop json in packet

This commit is contained in:
fumiama
2021-12-30 15:19:37 +08:00
parent 4a17d7cf13
commit f91507fe6a
8 changed files with 78 additions and 26 deletions

View File

@@ -75,9 +75,11 @@ func (l *Link) Read() *head.Packet {
func (l *Link) Write(p *head.Packet) (n int, err error) {
p.FillHash()
p.Data = l.Encode(p.Data)
var d []byte
d, err = p.Marshal(l.me.me.String(), l.peerip.String())
logrus.Debugln("[link] write data", string(d))
d := p.Marshal(l.me.me)
if d == nil {
return 0, errors.New("ttl exceeded")
}
logrus.Debugln("[link] write", len(d), "bytes data")
if err == nil {
peerlink := l.me.router.NextHop(l.peerip.String() + "/32")
if peerlink != nil {