mirror of
https://github.com/slackhq/nebula.git
synced 2026-05-15 20:37:36 +02:00
Switch to slog, remove logrus (#1672)
This commit is contained in:
@@ -4,12 +4,13 @@
|
||||
package udp
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"log/slog"
|
||||
"net/netip"
|
||||
"os"
|
||||
"sync"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/slackhq/nebula/config"
|
||||
"github.com/slackhq/nebula/header"
|
||||
)
|
||||
@@ -46,10 +47,10 @@ type TesterConn struct {
|
||||
done chan struct{}
|
||||
closeOnce sync.Once
|
||||
|
||||
l *logrus.Logger
|
||||
l *slog.Logger
|
||||
}
|
||||
|
||||
func NewListener(l *logrus.Logger, ip netip.Addr, port int, _ bool, _ int) (Conn, error) {
|
||||
func NewListener(l *slog.Logger, ip netip.Addr, port int, _ bool, _ int) (Conn, error) {
|
||||
return &TesterConn{
|
||||
Addr: netip.AddrPortFrom(ip, uint16(port)),
|
||||
RxPackets: make(chan *Packet, 10),
|
||||
@@ -67,11 +68,12 @@ func (u *TesterConn) Send(packet *Packet) {
|
||||
if err := h.Parse(packet.Data); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if u.l.Level >= logrus.DebugLevel {
|
||||
u.l.WithField("header", h).
|
||||
WithField("udpAddr", packet.From).
|
||||
WithField("dataLen", len(packet.Data)).
|
||||
Debug("UDP receiving injected packet")
|
||||
if u.l.Enabled(context.Background(), slog.LevelDebug) {
|
||||
u.l.Debug("UDP receiving injected packet",
|
||||
"header", h,
|
||||
"udpAddr", packet.From,
|
||||
"dataLen", len(packet.Data),
|
||||
)
|
||||
}
|
||||
select {
|
||||
case <-u.done:
|
||||
|
||||
Reference in New Issue
Block a user