use log.Warn instead of Warning

This commit is contained in:
vyzo 2020-05-05 20:38:53 +03:00
parent ed0d01f92b
commit ce9a0b7edf
7 changed files with 27 additions and 27 deletions

View File

@ -71,7 +71,7 @@ func (p *PubSub) handleNewStream(s network.Stream) {
func (p *PubSub) handleNewPeer(ctx context.Context, pid peer.ID, outgoing <-chan *RPC) { func (p *PubSub) handleNewPeer(ctx context.Context, pid peer.ID, outgoing <-chan *RPC) {
s, err := p.host.NewStream(p.ctx, pid, p.rt.Protocols()...) s, err := p.host.NewStream(p.ctx, pid, p.rt.Protocols()...)
if err != nil { if err != nil {
log.Warning("opening new stream to peer: ", err, pid) log.Warn("opening new stream to peer: ", err, pid)
var ch chan peer.ID var ch chan peer.ID
if err == ms.ErrNotSupported { if err == ms.ErrNotSupported {
@ -107,7 +107,7 @@ func (p *PubSub) handlePeerEOF(ctx context.Context, s network.Stream) {
} }
return return
} }
log.Warning("unexpected message from ", s.Conn().RemotePeer()) log.Warn("unexpected message from ", s.Conn().RemotePeer())
} }
} }

View File

@ -189,7 +189,7 @@ func (d *discover) Advertise(topic string) {
go func() { go func() {
next, err := d.discovery.Advertise(advertisingCtx, topic) next, err := d.discovery.Advertise(advertisingCtx, topic)
if err != nil { if err != nil {
log.Warningf("bootstrap: error providing rendezvous for %s: %s", topic, err.Error()) log.Warnf("bootstrap: error providing rendezvous for %s: %s", topic, err.Error())
if next == 0 { if next == 0 {
next = discoveryAdvertiseRetryInterval next = discoveryAdvertiseRetryInterval
} }
@ -203,7 +203,7 @@ func (d *discover) Advertise(topic string) {
case <-t.C: case <-t.C:
next, err = d.discovery.Advertise(advertisingCtx, topic) next, err = d.discovery.Advertise(advertisingCtx, topic)
if err != nil { if err != nil {
log.Warningf("bootstrap: error providing rendezvous for %s: %s", topic, err.Error()) log.Warnf("bootstrap: error providing rendezvous for %s: %s", topic, err.Error())
if next == 0 { if next == 0 {
next = discoveryAdvertiseRetryInterval next = discoveryAdvertiseRetryInterval
} }

View File

@ -526,7 +526,7 @@ func (gs *GossipSubRouter) handleGraft(p peer.ID, ctl *pb.ControlMessage) []*pb.
// we don't GRAFT to/from direct peers; complain loudly if this happens // we don't GRAFT to/from direct peers; complain loudly if this happens
_, direct := gs.direct[p] _, direct := gs.direct[p]
if direct { if direct {
log.Warningf("GRAFT: ignoring request from direct peer %s", p) log.Warnf("GRAFT: ignoring request from direct peer %s", p)
// this is possibly a bug from non-reciprocal configuration; send a PRUNE // this is possibly a bug from non-reciprocal configuration; send a PRUNE
prune = append(prune, topic) prune = append(prune, topic)
// but don't PX // but don't PX
@ -654,16 +654,16 @@ func (gs *GossipSubRouter) pxConnect(peers []*pb.PeerInfo) {
// the peer sent us a signed record; ensure that it is valid // the peer sent us a signed record; ensure that it is valid
envelope, r, err := record.ConsumeEnvelope(pi.SignedPeerRecord, peer.PeerRecordEnvelopeDomain) envelope, r, err := record.ConsumeEnvelope(pi.SignedPeerRecord, peer.PeerRecordEnvelopeDomain)
if err != nil { if err != nil {
log.Warningf("error unmarshalling peer record obtained through px: %s", err) log.Warnf("error unmarshalling peer record obtained through px: %s", err)
continue continue
} }
rec, ok := r.(*peer.PeerRecord) rec, ok := r.(*peer.PeerRecord)
if !ok { if !ok {
log.Warningf("bogus peer record obtained through px: envelope payload is not PeerRecord") log.Warnf("bogus peer record obtained through px: envelope payload is not PeerRecord")
continue continue
} }
if rec.PeerID != p { if rec.PeerID != p {
log.Warningf("bogus peer record obtained through px: peer ID %s doesn't match expected peer %s", rec.PeerID, p) log.Warnf("bogus peer record obtained through px: peer ID %s doesn't match expected peer %s", rec.PeerID, p)
continue continue
} }
spr = envelope spr = envelope
@ -1384,7 +1384,7 @@ func (gs *GossipSubRouter) makePrune(p peer.ID, topic string, doPX bool) *pb.Con
if spr != nil { if spr != nil {
recordBytes, err = spr.Marshal() recordBytes, err = spr.Marshal()
if err != nil { if err != nil {
log.Warningf("error marshaling signed peer record for %s: %s", p, err) log.Warnf("error marshaling signed peer record for %s: %s", p, err)
} }
} }
} }

View File

@ -426,12 +426,12 @@ func (p *PubSub) processLoop(ctx context.Context) {
select { select {
case pid := <-p.newPeers: case pid := <-p.newPeers:
if _, ok := p.peers[pid]; ok { if _, ok := p.peers[pid]; ok {
log.Warning("already have connection to peer: ", pid) log.Warn("already have connection to peer: ", pid)
continue continue
} }
if p.blacklist.Contains(pid) { if p.blacklist.Contains(pid) {
log.Warning("ignoring connection from blacklisted peer: ", pid) log.Warn("ignoring connection from blacklisted peer: ", pid)
continue continue
} }
@ -445,13 +445,13 @@ func (p *PubSub) processLoop(ctx context.Context) {
ch, ok := p.peers[pid] ch, ok := p.peers[pid]
if !ok { if !ok {
log.Warning("new stream for unknown peer: ", pid) log.Warn("new stream for unknown peer: ", pid)
s.Reset() s.Reset()
continue continue
} }
if p.blacklist.Contains(pid) { if p.blacklist.Contains(pid) {
log.Warning("closing stream for blacklisted peer: ", pid) log.Warn("closing stream for blacklisted peer: ", pid)
close(ch) close(ch)
s.Reset() s.Reset()
continue continue
@ -473,7 +473,7 @@ func (p *PubSub) processLoop(ctx context.Context) {
if p.host.Network().Connectedness(pid) == network.Connected { if p.host.Network().Connectedness(pid) == network.Connected {
// still connected, must be a duplicate connection being closed. // still connected, must be a duplicate connection being closed.
// we respawn the writer as we need to ensure there is a stream active // we respawn the writer as we need to ensure there is a stream active
log.Warning("peer declared dead but still connected; respawning writer: ", pid) log.Warn("peer declared dead but still connected; respawning writer: ", pid)
messages := make(chan *RPC, p.peerOutboundQueueSize) messages := make(chan *RPC, p.peerOutboundQueueSize)
messages <- p.getHelloPacket() messages <- p.getHelloPacket()
go p.handleNewPeer(ctx, pid, messages) go p.handleNewPeer(ctx, pid, messages)
@ -886,13 +886,13 @@ func (p *PubSub) handleIncomingRPC(rpc *RPC) {
// ask the router to vet the peer before commiting any processing resources // ask the router to vet the peer before commiting any processing resources
if !p.rt.AcceptFrom(rpc.from) { if !p.rt.AcceptFrom(rpc.from) {
log.Warningf("received message from router graylisted peer %s. Dropping RPC", rpc.from) log.Warnf("received message from router graylisted peer %s. Dropping RPC", rpc.from)
return return
} }
for _, pmsg := range rpc.GetPublish() { for _, pmsg := range rpc.GetPublish() {
if !(p.subscribedToMsg(pmsg) || p.canRelayMsg(pmsg)) { if !(p.subscribedToMsg(pmsg) || p.canRelayMsg(pmsg)) {
log.Warning("received message we didn't subscribe to. Dropping.") log.Warn("received message we didn't subscribe to. Dropping.")
continue continue
} }
@ -913,14 +913,14 @@ func (p *PubSub) pushMsg(msg *Message) {
src := msg.ReceivedFrom src := msg.ReceivedFrom
// reject messages from blacklisted peers // reject messages from blacklisted peers
if p.blacklist.Contains(src) { if p.blacklist.Contains(src) {
log.Warningf("dropping message from blacklisted peer %s", src) log.Warnf("dropping message from blacklisted peer %s", src)
p.tracer.RejectMessage(msg, rejectBlacklstedPeer) p.tracer.RejectMessage(msg, rejectBlacklstedPeer)
return return
} }
// even if they are forwarded by good peers // even if they are forwarded by good peers
if p.blacklist.Contains(msg.GetFrom()) { if p.blacklist.Contains(msg.GetFrom()) {
log.Warningf("dropping message from blacklisted source %s", src) log.Warnf("dropping message from blacklisted source %s", src)
p.tracer.RejectMessage(msg, rejectBlacklistedSource) p.tracer.RejectMessage(msg, rejectBlacklistedSource)
return return
} }

View File

@ -514,7 +514,7 @@ func (ps *peerScore) DeliverMessage(msg *Message) {
// defensive check that this is the first delivery trace -- delivery status should be unknown // defensive check that this is the first delivery trace -- delivery status should be unknown
if drec.status != deliveryUnknown { if drec.status != deliveryUnknown {
log.Warningf("unexpected delivery trace: message from %s was first seen %s ago and has delivery status %d", msg.ReceivedFrom, time.Now().Sub(drec.firstSeen), drec.status) log.Warnf("unexpected delivery trace: message from %s was first seen %s ago and has delivery status %d", msg.ReceivedFrom, time.Now().Sub(drec.firstSeen), drec.status)
return return
} }
@ -561,7 +561,7 @@ func (ps *peerScore) RejectMessage(msg *Message, reason string) {
// defensive check that this is the first rejection trace -- delivery status should be unknown // defensive check that this is the first rejection trace -- delivery status should be unknown
if drec.status != deliveryUnknown { if drec.status != deliveryUnknown {
log.Warningf("unexpected rejection trace: message from %s was first seen %s ago and has delivery status %d", msg.ReceivedFrom, time.Now().Sub(drec.firstSeen), drec.status) log.Warnf("unexpected rejection trace: message from %s was first seen %s ago and has delivery status %d", msg.ReceivedFrom, time.Now().Sub(drec.firstSeen), drec.status)
return return
} }

View File

@ -54,7 +54,7 @@ func (t *basicTracer) Trace(evt *pb.TraceEvent) {
} }
if t.lossy && len(t.buf) > TraceBufferSize { if t.lossy && len(t.buf) > TraceBufferSize {
log.Warningf("trace buffer overflow; dropping trace event") log.Warnf("trace buffer overflow; dropping trace event")
} else { } else {
t.buf = append(t.buf, evt) t.buf = append(t.buf, evt)
} }

View File

@ -200,7 +200,7 @@ func (v *validation) Push(src peer.ID, msg *Message) bool {
select { select {
case v.validateQ <- &validateReq{vals, src, msg}: case v.validateQ <- &validateReq{vals, src, msg}:
default: default:
log.Warningf("message validation throttled: queue full; dropping message from %s", src) log.Warnf("message validation throttled: queue full; dropping message from %s", src)
v.tracer.RejectMessage(msg, rejectValidationQueueFull) v.tracer.RejectMessage(msg, rejectValidationQueueFull)
} }
return false return false
@ -243,7 +243,7 @@ func (v *validation) validateWorker() {
func (v *validation) validate(vals []*topicVal, src peer.ID, msg *Message) { func (v *validation) validate(vals []*topicVal, src peer.ID, msg *Message) {
if msg.Signature != nil { if msg.Signature != nil {
if !v.validateSignature(msg) { if !v.validateSignature(msg) {
log.Warningf("message signature validation failed; dropping message from %s", src) log.Warnf("message signature validation failed; dropping message from %s", src)
v.tracer.RejectMessage(msg, rejectInvalidSignature) v.tracer.RejectMessage(msg, rejectInvalidSignature)
return return
} }
@ -282,7 +282,7 @@ func (v *validation) validate(vals []*topicVal, src peer.ID, msg *Message) {
} }
if result == ValidationReject { if result == ValidationReject {
log.Warningf("message validation failed; dropping message from %s", src) log.Warnf("message validation failed; dropping message from %s", src)
v.tracer.RejectMessage(msg, rejectValidationFailed) v.tracer.RejectMessage(msg, rejectValidationFailed)
return return
} }
@ -296,7 +296,7 @@ func (v *validation) validate(vals []*topicVal, src peer.ID, msg *Message) {
<-v.validateThrottle <-v.validateThrottle
}() }()
default: default:
log.Warningf("message validation throttled; dropping message from %s", src) log.Warnf("message validation throttled; dropping message from %s", src)
v.tracer.RejectMessage(msg, rejectValidationThrottled) v.tracer.RejectMessage(msg, rejectValidationThrottled)
} }
return return
@ -340,7 +340,7 @@ func (v *validation) doValidateTopic(vals []*topicVal, src peer.ID, msg *Message
v.tracer.RejectMessage(msg, rejectValidationIgnored) v.tracer.RejectMessage(msg, rejectValidationIgnored)
return return
case validationThrottled: case validationThrottled:
log.Warningf("message validation throttled; ignoring message from %s", src) log.Warnf("message validation throttled; ignoring message from %s", src)
v.tracer.RejectMessage(msg, rejectValidationThrottled) v.tracer.RejectMessage(msg, rejectValidationThrottled)
default: default:
@ -428,7 +428,7 @@ func (val *topicVal) validateMsg(ctx context.Context, src peer.ID, msg *Message)
return r return r
default: default:
log.Warningf("Unexpected result from validator: %d; ignoring message", r) log.Warnf("Unexpected result from validator: %d; ignoring message", r)
return ValidationIgnore return ValidationIgnore
} }
} }