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

fix(link): atomic 64-bits alignment

This commit is contained in:
源文雨
2025-04-03 16:15:26 +09:00
parent 1f7a42fd29
commit 2483e2d3c7

View File

@@ -23,25 +23,25 @@ import (
// Me 是本机的抽象 // Me 是本机的抽象
type Me struct { type Me struct {
// 用于自我重连 // 读写同步锁
cfg *MyConfig connmapmu sync.RWMutex
// 本机总接收字节数
recvtotlcnt uint64
// 上一次触发循环计数时间
recvlooptime int64
// 本机私钥 // 本机私钥
// 利用 Curve25519 生成 // 利用 Curve25519 生成
// https://pkg.go.dev/golang.org/x/crypto/curve25519 // https://pkg.go.dev/golang.org/x/crypto/curve25519
// https://www.zhihu.com/question/266758647 // https://www.zhihu.com/question/266758647
privKey [32]byte privKey [32]byte
// 本机虚拟 ip // 本机上层配置
me net.IP srcport, dstport, mtu, speedloop uint16
// 本机子网 // 报头掩码
subnet net.IPNet mask uint64
// 本机 endpoint // 本机总接收数据包计数
ep p2p.EndPoint recvloopcnt uintptr
// 本机活跃的所有连接 // 用于自我重连
connections map[string]*Link cfg *MyConfig
// 读写同步锁
connmapmu sync.RWMutex
// 本机监听的连接端点, 也用于向对端直接发送报文
conn p2p.Conn
// 本机网卡 // 本机网卡
nic *lower.NICIO nic *lower.NICIO
// 本机路由表 // 本机路由表
@@ -50,16 +50,19 @@ type Me struct {
recving *ttl.Cache[uint16, head.PacketBytes] recving *ttl.Cache[uint16, head.PacketBytes]
// 抗重放攻击记录池 // 抗重放攻击记录池
recved *ttl.Cache[uint64, struct{}] recved *ttl.Cache[uint64, struct{}]
// 本机上层配置
srcport, dstport, mtu, speedloop uint16 // 以上为64位对齐, 修改时注意保持
// 报头掩码
mask uint64 // 本机虚拟 ip
// 本机总接收字节数 me net.IP
recvtotlcnt uint64 // 本机子网
// 上一次触发循环计数时间 subnet net.IPNet
recvlooptime int64 // 本机 endpoint
// 本机总接收数据包计数 ep p2p.EndPoint
recvloopcnt uintptr // 本机活跃的所有连接
connections map[string]*Link
// 本机监听的连接端点, 也用于向对端直接发送报文
conn p2p.Conn
// 是否进行 base16384 编码 // 是否进行 base16384 编码
base14 bool base14 bool
// 本机初始 ttl // 本机初始 ttl