From 51bba146afe65fcc183d54d9ddf2e120a67563fe Mon Sep 17 00:00:00 2001 From: Daniel Mangum Date: Tue, 18 Jul 2023 16:27:37 -0400 Subject: [PATCH] to packet server Signed-off-by: Daniel Mangum --- conn.go | 5 ++++- pkg/protocol/recordlayer/inner_plaintext.go | 1 - pkg/protocol/recordlayer/recordlayer.go | 18 +++++++++--------- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/conn.go b/conn.go index a085092ea..a50d977f5 100644 --- a/conn.go +++ b/conn.go @@ -268,7 +268,10 @@ func Server(conn net.Conn, config *Config) (*Conn, error) { return ServerWithContext(ctx, conn, config) } -func UDPServer(ctx context.Context, conn net.PacketConn, rAddr net.Addr, config *Config) (*Conn, error) { +// PacketServer listens for incoming DTLS connections. +// Unlike Server, PacketServer allows for connections to change remote address. +// The provided rAddr will be used as the initial remote address for sending. +func PacketServer(ctx context.Context, conn net.PacketConn, rAddr net.Addr, config *Config) (*Conn, error) { return createConn(ctx, conn, rAddr, config, true, nil) } diff --git a/pkg/protocol/recordlayer/inner_plaintext.go b/pkg/protocol/recordlayer/inner_plaintext.go index cc7b3d6a3..bbc94dd80 100644 --- a/pkg/protocol/recordlayer/inner_plaintext.go +++ b/pkg/protocol/recordlayer/inner_plaintext.go @@ -38,7 +38,6 @@ func (p *InnerPlaintext) Unmarshal(data []byte) error { i-- } if i == 0 { - // TODO: more specific error for missing content type return errBufferTooSmall } p.RealType = protocol.ContentType(data[i]) diff --git a/pkg/protocol/recordlayer/recordlayer.go b/pkg/protocol/recordlayer/recordlayer.go index 9f0411485..dac06345f 100644 --- a/pkg/protocol/recordlayer/recordlayer.go +++ b/pkg/protocol/recordlayer/recordlayer.go @@ -13,15 +13,15 @@ import ( // DTLS fixed size record layer header when Connection IDs are not in-use. -// -------------------------------- -// | Type | Version | Epoch | -// -------------------------------- -// | Epoch | Sequence Number | -// -------------------------------- -// | Sequence Number | Length | -// -------------------------------- -// | Length | Fragment... | -// -------------------------------- +// --------------------------------- +// | Type | Version | Epoch | +// --------------------------------- +// | Epoch | Sequence Number | +// --------------------------------- +// | Sequence Number | Length | +// --------------------------------- +// | Length | Fragment... | +// --------------------------------- // fixedHeaderLenIdx is the index at which the record layer content length is // specified in a fixed length header (i.e. one that does not include a