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

adjust log level

This commit is contained in:
fumiama
2021-12-31 22:19:26 +08:00
parent a9ed112162
commit e9851947f2
7 changed files with 27 additions and 33 deletions

View File

@@ -91,7 +91,7 @@ func (l *Link) Write(p *head.Packet, istransfer bool) (n int, err error) {
totl := uint32(len(data))
i := 0
for ; int(totl)-i > int(l.me.mtu); i += int(l.me.mtu) {
logrus.Infoln("[link] split frag", i, ":", i+int(l.me.mtu), ", remain:", int(totl)-i-int(l.me.mtu))
logrus.Debugln("[link] split frag", i, ":", i+int(l.me.mtu), ", remain:", int(totl)-i-int(l.me.mtu))
packet := *p
packet.Data = data[:int(l.me.mtu)]
cnt, err := l.write(&packet, totl, uint16(uint(i)>>3), istransfer, true)
@@ -144,7 +144,7 @@ func (l *Link) write(p *head.Packet, datasz uint32, offset uint16, istransfer, h
if peerep == nil {
return 0, errors.New("[link] nil endpoint of " + p.Dst.String())
}
logrus.Infoln("[link] write", len(d), "bytes data from ep", l.me.myconn.LocalAddr(), "to", peerep, "offset:", fmt.Sprintf("%04x", offset))
logrus.Debugln("[link] write", len(d), "bytes data from ep", l.me.myconn.LocalAddr(), "to", peerep, "offset:", fmt.Sprintf("%04x", offset))
n, err = l.me.myconn.WriteToUDP(d, peerep)
} else {
logrus.Warnln("[link] drop packet: nil peerlink")

View File

@@ -30,7 +30,7 @@ func (m *Me) listen() (conn *net.UDPConn, err error) {
}
}
p, ok := m.IsInPeer(packet.Src.String())
logrus.Infoln("[link] recv from endpoint", addr, "src", packet.Src, "dst", packet.Dst)
logrus.Debugln("[link] recv from endpoint", addr, "src", packet.Src, "dst", packet.Dst)
// logrus.Debugln("[link] recv:", hex.EncodeToString(lbf))
if ok {
if p.pep == "" || p.pep != addr.String() {
@@ -47,7 +47,7 @@ func (m *Me) listen() (conn *net.UDPConn, err error) {
case LINK_STATUS_DOWN:
n, err = p.Write(head.NewPacket(head.ProtoHello, 0, p.peerip, 0, nil), false)
if err == nil {
logrus.Infoln("[link] send", n, "bytes hello ack packet")
logrus.Debugln("[link] send", n, "bytes hello ack packet")
p.status = LINK_STATUS_HALFUP
} else {
logrus.Errorln("[link] send hello ack packet error:", err)
@@ -58,31 +58,31 @@ func (m *Me) listen() (conn *net.UDPConn, err error) {
break
}
case head.ProtoNotify:
logrus.Infoln("[link] recv notify")
logrus.Debugln("[link] recv notify")
p.onNotify(packet)
case head.ProtoQuery:
logrus.Infoln("[link] recv query")
logrus.Debugln("[link] recv query")
p.onQuery(packet)
case head.ProtoData:
if p.pipe != nil {
p.pipe <- packet
logrus.Infoln("[link] deliver to pipe of", p.peerip)
logrus.Debugln("[link] deliver to pipe of", p.peerip)
} else {
m.pipe <- packet.Data
logrus.Infoln("[link] deliver", len(packet.Data), "bytes data to pipe of me")
logrus.Debugln("[link] deliver", len(packet.Data), "bytes data to pipe of me")
}
default:
logrus.Warnln("[link] recv unknown proto:", packet.Proto)
}
} else {
logrus.Infoln("[link] drop invalid packet")
logrus.Debugln("[link] drop invalid packet")
}
} else if p.Accept(packet.Dst) {
if p.allowtrans {
// 转发
n, err = p.Write(packet, true)
if err == nil {
logrus.Infoln("[link] trans", n, "bytes packet to", packet.Dst.String()+":"+strconv.Itoa(int(packet.DstPort)))
logrus.Debugln("[link] trans", n, "bytes packet to", packet.Dst.String()+":"+strconv.Itoa(int(packet.DstPort)))
} else {
logrus.Errorln("[link] trans packet to", packet.Dst.String()+":"+strconv.Itoa(int(packet.DstPort)), "err:", err)
}

View File

@@ -39,7 +39,7 @@ func (m *Me) initrecvpool() {
func (m *Me) wait(data []byte) *head.Packet {
flags := binary.LittleEndian.Uint16(data[10:12])
logrus.Infoln("[recv]", len(data), "bytes data with flag", hex.EncodeToString(data[10:12]))
logrus.Debugln("[recv]", len(data), "bytes data with flag", hex.EncodeToString(data[10:12]))
if flags == 0 || flags == 0x4000 {
h := &head.Packet{}
_, err := h.Unmarshal(data)
@@ -56,13 +56,13 @@ func (m *Me) wait(data []byte) *head.Packet {
hsh := *(*[32]byte)(*(*unsafe.Pointer)(unsafe.Pointer(&hashd)))
h, ok := m.recving[hsh]
if ok {
logrus.Infoln("[recv] get another frag part of", hex.EncodeToString(hashd))
logrus.Debugln("[recv] get another frag part of", hex.EncodeToString(hashd))
ok, err := h.Unmarshal(data)
if err == nil {
if ok {
delete(m.clock, h)
delete(m.recving, hsh)
logrus.Infoln("[recv] all parts of", hex.EncodeToString(hashd), "is reached")
logrus.Debugln("[recv] all parts of", hex.EncodeToString(hashd), "is reached")
return h
}
m.clock[h] = 0
@@ -71,7 +71,7 @@ func (m *Me) wait(data []byte) *head.Packet {
}
return nil
}
logrus.Infoln("[recv] get new frag part of", hex.EncodeToString(hashd))
logrus.Debugln("[recv] get new frag part of", hex.EncodeToString(hashd))
h = &head.Packet{}
_, err := h.Unmarshal(data)
if err != nil {

View File

@@ -55,7 +55,7 @@ func (r *Router) NextHop(ip string) (l *Link) {
for _, c := range r.list {
if c.Contains(ipb) {
l = r.table[c.String()]
logrus.Infoln("[router] get nexthop to", ipb, "-->", c, "link", l)
logrus.Debugln("[router] get nexthop to", ipb, "-->", c, "link", l)
return l
}
}