1
0
mirror of https://github.com/fumiama/WireGold.git synced 2026-06-22 19:40:35 +08:00

feat(p2p): add ICMP backend support

This commit is contained in:
源文雨
2026-04-11 15:02:45 +08:00
parent 9e642f875a
commit 23d9238464
19 changed files with 809 additions and 28 deletions

View File

@@ -208,7 +208,10 @@ func (m *Me) NetworkConfigs() []any {
func (m *Me) Close() error {
for i := 0; i < len(m.jobs); i++ {
close(m.jobs[i])
jb := m.jobs[i]
if jb != nil {
close(jb)
}
}
m.connections = nil
if bin.IsNonNilInterface(m.conn) {

View File

@@ -137,8 +137,8 @@ func (m *Me) extractPeer(srcip, dstip net.IP, addr p2p.EndPoint) *Link {
logrus.Warnln(file.Header(), "packet from", srcip, "to", dstip, "is refused")
return nil
}
if bin.IsNilInterface(p.endpoint) || !p.endpoint.Euqal(addr) {
if m.ep.Network() == "tcp" && !addr.Euqal(p.endpoint) {
if bin.IsNilInterface(p.endpoint) || !p.endpoint.Equal(addr) {
if m.ep.Network() == "tcp" && !addr.Equal(p.endpoint) {
logrus.Infoln(file.Header(), "set endpoint of peer", p.peerip, "to", addr.String())
p.endpoint = addr
} else { // others are all no status link

View File

@@ -75,16 +75,12 @@ func (l *Link) write2peer(b pbuf.Bytes, seq uint32) {
if l.doublepacket {
err := l.write2peer1(b, seq)
if err != nil {
if config.ShowDebugLog {
logrus.Warnln("[send] double wr2peer", l.peerip, "err:", err)
}
logrus.Warnln("[send] double wr2peer", l.peerip, "err:", err)
}
}
err := l.write2peer1(b, seq)
if err != nil {
if config.ShowDebugLog {
logrus.Warnln("[send] wr2peer", l.peerip, "err:", err)
}
logrus.Warnln("[send] wr2peer", l.peerip, "err:", err)
}
}