mirror of
https://github.com/soypat/lneto.git
synced 2026-08-23 07:59:05 +00:00
add stringer methods
This commit is contained in:
+8
-3
@@ -11,7 +11,8 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
errMismatchedPort = errors.New("mismatched port")
|
||||
errMismatchedSrcPort = errors.New("source port mismatch")
|
||||
errMismatchedDstPort = errors.New("destination port mismatch")
|
||||
)
|
||||
|
||||
// Handler is a low level TCP handling data structure. It implements logic
|
||||
@@ -120,13 +121,14 @@ func (h *Handler) Recv(b []byte) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
remotePort := tfrm.SourcePort()
|
||||
if h.remotePort != 0 && remotePort != h.remotePort {
|
||||
return errMismatchedPort
|
||||
return errMismatchedSrcPort
|
||||
}
|
||||
dstPort := tfrm.DestinationPort()
|
||||
if h.localPort != dstPort {
|
||||
return errMismatchedPort
|
||||
return errMismatchedDstPort
|
||||
}
|
||||
payload := tfrm.Payload()
|
||||
if len(payload) > h.bufRx.Free() {
|
||||
@@ -160,6 +162,9 @@ func (h *Handler) Recv(b []byte) error {
|
||||
h.debug("tcp.Handler:rx-remoteport-set", slog.Uint64("port", uint64(h.localPort)), slog.Uint64("remoteport", uint64(remotePort)))
|
||||
h.remotePort = remotePort
|
||||
}
|
||||
if h.logenabled(internal.LevelTrace) {
|
||||
h.trace("tcp.Handler:rx-done", slog.Uint64("port", uint64(h.localPort)), slog.Uint64("remoteport", uint64(remotePort)), slog.String("seg", segIncoming.String()))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user