mirror of
https://github.com/fumiama/WireGold.git
synced 2026-06-11 04:06:14 +08:00
chore: make lint happy
This commit is contained in:
@@ -157,8 +157,12 @@ func (m *Me) listenthread(packet *head.Packet, addr *net.UDPAddr, index int, fin
|
||||
p.pipe <- packet
|
||||
logrus.Debugln("[listen] @", index, "deliver to pipe of", p.peerip)
|
||||
} else {
|
||||
m.nic.Write(packet.Data)
|
||||
logrus.Debugln("[listen] @", index, "deliver", len(packet.Data), "bytes data to nic")
|
||||
_, err := m.nic.Write(packet.Data)
|
||||
if err != nil {
|
||||
logrus.Errorln("[listen] @", index, "deliver", len(packet.Data), "bytes data to nic err:", err)
|
||||
} else {
|
||||
logrus.Debugln("[listen] @", index, "deliver", len(packet.Data), "bytes data to nic")
|
||||
}
|
||||
packet.Put()
|
||||
}
|
||||
default:
|
||||
|
||||
@@ -121,7 +121,7 @@ func (m *Me) MTU() uint16 {
|
||||
return m.mtu
|
||||
}
|
||||
|
||||
func (m *Me) Close() error {
|
||||
func (m *Me) CloseNIC() error {
|
||||
m.nic.Down()
|
||||
return m.nic.Close()
|
||||
}
|
||||
@@ -132,7 +132,7 @@ func (m *Me) Write(packet []byte) (n int, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (m *Me) ListenFromNIC() (written int64, err error) {
|
||||
func (m *Me) ListenNIC() (written int64, err error) {
|
||||
m.nic.Up()
|
||||
return io.Copy(m, m.nic)
|
||||
}
|
||||
|
||||
@@ -86,8 +86,12 @@ func (l *Link) onQuery(packet []byte) {
|
||||
if len(notify) > 0 {
|
||||
logrus.Infoln("[nat] query wrap", len(notify), "notify")
|
||||
w := helper.SelectWriter()
|
||||
json.NewEncoder(w).Encode(¬ify)
|
||||
l.WriteAndPut(head.NewPacket(head.ProtoNotify, l.me.srcport, l.peerip, l.me.dstport, w.Bytes()), false)
|
||||
_ = json.NewEncoder(w).Encode(¬ify)
|
||||
_, err = l.WriteAndPut(head.NewPacket(head.ProtoNotify, l.me.srcport, l.peerip, l.me.dstport, w.Bytes()), false)
|
||||
if err != nil {
|
||||
logrus.Errorln("[nat] notify peer", l, "err:", err)
|
||||
return
|
||||
}
|
||||
helper.PutWriter(w)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user