@@ -198,7 +198,7 @@ func (h *associationHandler) HandleAssociation(ctx context.Context, clientConn n
198
198
if err != nil {
199
199
return onet .NewConnectionError ("ERR_CREATE_SOCKET" , "Failed to create a `PacketConn`" , err )
200
200
}
201
- l = l .With (slog .Any ("ltarget " , targetConn .LocalAddr ()))
201
+ l = l .With (slog .Any ("tgtListener " , targetConn .LocalAddr ()))
202
202
go relayTargetToClient (targetConn , clientConn , cryptoKey , assocMetrics , l )
203
203
} else {
204
204
unpackStart := time .Now ()
@@ -277,7 +277,7 @@ func PacketServe(clientConn net.PacketConn, assocHandle AssociationHandleFunc, m
277
277
lazySlice .Release ()
278
278
}
279
279
}()
280
- n , addr , err := clientConn .ReadFrom (buffer )
280
+ n , clientAddr , err := clientConn .ReadFrom (buffer )
281
281
if err != nil {
282
282
lazySlice .Release ()
283
283
if errors .Is (err , net .ErrClosed ) {
@@ -290,21 +290,21 @@ func PacketServe(clientConn net.PacketConn, assocHandle AssociationHandleFunc, m
290
290
pkt := & packet {payload : buffer [:n ], done : lazySlice .Release }
291
291
292
292
// TODO(#19): Include server address in the NAT key as well.
293
- assoc := nm .Get (addr .String ())
293
+ assoc := nm .Get (clientAddr .String ())
294
294
if assoc == nil {
295
295
assoc = & association {
296
- pc : clientConn ,
297
- raddr : addr ,
298
- readCh : make (chan * packet , 5 ),
299
- doneCh : make (chan struct {}),
296
+ pc : clientConn ,
297
+ clientAddr : clientAddr ,
298
+ readCh : make (chan * packet , 5 ),
299
+ doneCh : make (chan struct {}),
300
300
}
301
301
if err != nil {
302
302
slog .Error ("Failed to handle association" , slog .Any ("err" , err ))
303
303
return
304
304
}
305
305
306
306
var existing bool
307
- assoc , existing = nm .Add (addr .String (), assoc )
307
+ assoc , existing = nm .Add (clientAddr .String (), assoc )
308
308
if ! existing {
309
309
metrics .AddNATEntry ()
310
310
go func () {
@@ -316,7 +316,7 @@ func PacketServe(clientConn net.PacketConn, assocHandle AssociationHandleFunc, m
316
316
}
317
317
select {
318
318
case <- assoc .doneCh :
319
- nm .Del (addr .String ())
319
+ nm .Del (clientAddr .String ())
320
320
case assoc .readCh <- pkt :
321
321
default :
322
322
slog .Debug ("Dropping packet due to full read queue" )
@@ -340,10 +340,10 @@ type packet struct {
340
340
341
341
// association wraps a [net.PacketConn] with an address into a [net.Conn].
342
342
type association struct {
343
- pc net.PacketConn
344
- raddr net.Addr
345
- readCh chan * packet
346
- doneCh chan struct {}
343
+ pc net.PacketConn
344
+ clientAddr net.Addr
345
+ readCh chan * packet
346
+ doneCh chan struct {}
347
347
}
348
348
349
349
var _ net.Conn = (* association )(nil )
@@ -362,7 +362,7 @@ func (c *association) Read(p []byte) (int, error) {
362
362
}
363
363
364
364
func (c * association ) Write (b []byte ) (n int , err error ) {
365
- return c .pc .WriteTo (b , c .raddr )
365
+ return c .pc .WriteTo (b , c .clientAddr )
366
366
}
367
367
368
368
func (c * association ) Close () error {
@@ -375,19 +375,19 @@ func (c *association) LocalAddr() net.Addr {
375
375
}
376
376
377
377
func (c * association ) RemoteAddr () net.Addr {
378
- return c .raddr
378
+ return c .clientAddr
379
379
}
380
380
381
381
func (c * association ) SetDeadline (t time.Time ) error {
382
- return c . pc . SetDeadline ( t )
382
+ return errors . ErrUnsupported
383
383
}
384
384
385
385
func (c * association ) SetReadDeadline (t time.Time ) error {
386
- return c . pc . SetReadDeadline ( t )
386
+ return errors . ErrUnsupported
387
387
}
388
388
389
389
func (c * association ) SetWriteDeadline (t time.Time ) error {
390
- return c . pc . SetWriteDeadline ( t )
390
+ return errors . ErrUnsupported
391
391
}
392
392
393
393
func isDNS (addr net.Addr ) bool {
0 commit comments