Add a simple benchmark to e2e tests (#739)

This commit is contained in:
Nate Brown
2022-09-01 09:44:58 -05:00
committed by GitHub
parent c2259f14a7
commit feb3e1317f
7 changed files with 94 additions and 23 deletions

View File

@@ -62,10 +62,12 @@ func (u *Conn) Send(packet *Packet) {
if err := h.Parse(packet.Data); err != nil {
panic(err)
}
u.l.WithField("header", h).
WithField("udpAddr", fmt.Sprintf("%v:%v", packet.FromIp, packet.FromPort)).
WithField("dataLen", len(packet.Data)).
Info("UDP receiving injected packet")
if u.l.Level >= logrus.InfoLevel {
u.l.WithField("header", h).
WithField("udpAddr", fmt.Sprintf("%v:%v", packet.FromIp, packet.FromPort)).
WithField("dataLen", len(packet.Data)).
Info("UDP receiving injected packet")
}
u.RxPackets <- packet
}
@@ -114,7 +116,10 @@ func (u *Conn) ListenOut(r EncReader, lhf LightHouseHandlerFunc, cache *firewall
nb := make([]byte, 12, 12)
for {
p := <-u.RxPackets
p, ok := <-u.RxPackets
if !ok {
return
}
ua.Port = p.FromPort
copy(ua.IP, p.FromIp.To16())
r(ua, nil, plaintext[:0], p.Data, h, fwPacket, lhf, nb, q, cache.Get(u.l))