1
0
mirror of https://github.com/fumiama/WireGold.git synced 2026-06-04 23:40:26 +08:00

feat: impl. trans & ttl

This commit is contained in:
源文雨
2025-03-13 01:52:35 +09:00
parent 658916268a
commit 6fc45333d8
20 changed files with 335 additions and 271 deletions

View File

@@ -12,7 +12,9 @@ import (
_ "github.com/fumiama/WireGold/gold/p2p/tcp" // support tcp connection
_ "github.com/fumiama/WireGold/gold/p2p/udp" // support udp connection
_ "github.com/fumiama/WireGold/gold/p2p/udplite" // support udplite connection
_ "github.com/fumiama/WireGold/gold/proto" // support basic protos
_ "github.com/fumiama/WireGold/gold/proto/data" // support data proto
_ "github.com/fumiama/WireGold/gold/proto/hello" // support hello proto
_ "github.com/fumiama/WireGold/gold/proto/nat" // support nat proto
"github.com/fumiama/WireGold/config"
"github.com/fumiama/WireGold/gold/head"
@@ -125,7 +127,7 @@ func (s *Tunnel) handleWrite() {
binary.LittleEndian.PutUint32(buf[:4], seq)
seq++
copy(buf[4:], b[:s.mtu-4])
s.l.WritePacket(head.ProtoData, buf)
s.l.WritePacket(head.ProtoData, buf, s.l.Me().TTL())
if config.ShowDebugLog {
logrus.Debugln("[tunnel] seq", seq-1, "written")
}
@@ -134,7 +136,7 @@ func (s *Tunnel) handleWrite() {
binary.LittleEndian.PutUint32(buf[:4], seq)
seq++
copy(buf[4:], b)
s.l.WritePacket(head.ProtoData, buf[:len(b)+4])
s.l.WritePacket(head.ProtoData, buf[:len(b)+4], s.l.Me().TTL())
if config.ShowDebugLog {
logrus.Debugln("[tunnel] seq", seq-1, "written")
}

View File

@@ -13,7 +13,9 @@ import (
_ "github.com/fumiama/WireGold/gold/p2p/tcp" // support tcp connection
_ "github.com/fumiama/WireGold/gold/p2p/udp" // support udp connection
_ "github.com/fumiama/WireGold/gold/p2p/udplite" // support udplite connection
_ "github.com/fumiama/WireGold/gold/proto" // support basic protos
_ "github.com/fumiama/WireGold/gold/proto/data" // support data proto
_ "github.com/fumiama/WireGold/gold/proto/hello" // support hello proto
_ "github.com/fumiama/WireGold/gold/proto/nat" // support nat proto
"github.com/fumiama/WireGold/config"
"github.com/fumiama/WireGold/gold/link"
@@ -115,6 +117,7 @@ func (wg *WG) init(srcport, dstport uint16) {
SpeedLoop: wg.c.SpeedLoop,
Mask: wg.c.Mask,
Base14: wg.c.Base14,
MaxTTL: wg.c.MaxTTL,
})
for _, peer := range wg.c.Peers {