@@ -431,6 +431,7 @@ func runDerpProbeQueuingDelayContinously(ctx context.Context, from, to *tailcfg.
431431 t := time .NewTicker (time .Second / time .Duration (packetsPerSecond ))
432432 defer t .Stop ()
433433
434+ toDERPPubKey := toc .SelfPublicKey ()
434435 seq := uint64 (0 )
435436 for {
436437 select {
@@ -446,7 +447,7 @@ func runDerpProbeQueuingDelayContinously(ctx context.Context, from, to *tailcfg.
446447 txRecordsMu .Unlock ()
447448 binary .BigEndian .PutUint64 (pkt , seq )
448449 seq ++
449- if err := fromc .Send (toc . SelfPublicKey () , pkt ); err != nil {
450+ if err := fromc .Send (toDERPPubKey , pkt ); err != nil {
450451 sendErrC <- fmt .Errorf ("sending packet %w" , err )
451452 return
452453 }
@@ -460,6 +461,7 @@ func runDerpProbeQueuingDelayContinously(ctx context.Context, from, to *tailcfg.
460461 go func () {
461462 defer wg .Done ()
462463 defer close (recvFinishedC ) // to break out of 'select' below.
464+ fromDERPPubKey := fromc .SelfPublicKey ()
463465 for {
464466 m , err := toc .Recv ()
465467 if err != nil {
@@ -469,7 +471,7 @@ func runDerpProbeQueuingDelayContinously(ctx context.Context, from, to *tailcfg.
469471 switch v := m .(type ) {
470472 case derp.ReceivedPacket :
471473 now := time .Now ()
472- if v .Source != fromc . SelfPublicKey () {
474+ if v .Source != fromDERPPubKey {
473475 recvFinishedC <- fmt .Errorf ("got data packet from unexpected source, %v" , v .Source )
474476 return
475477 }
@@ -767,9 +769,10 @@ func runDerpProbeNodePair(ctx context.Context, from, to *tailcfg.DERPNode, fromc
767769 // Send the packets.
768770 sendc := make (chan error , 1 )
769771 go func () {
772+ toDERPPubKey := toc .SelfPublicKey ()
770773 for idx , pkt := range pkts {
771774 inFlight .AcquireContext (ctx )
772- if err := fromc .Send (toc . SelfPublicKey () , pkt ); err != nil {
775+ if err := fromc .Send (toDERPPubKey , pkt ); err != nil {
773776 sendc <- fmt .Errorf ("sending packet %d: %w" , idx , err )
774777 return
775778 }
@@ -781,6 +784,7 @@ func runDerpProbeNodePair(ctx context.Context, from, to *tailcfg.DERPNode, fromc
781784 go func () {
782785 defer close (recvc ) // to break out of 'select' below.
783786 idx := 0
787+ fromDERPPubKey := fromc .SelfPublicKey ()
784788 for {
785789 m , err := toc .Recv ()
786790 if err != nil {
@@ -790,7 +794,7 @@ func runDerpProbeNodePair(ctx context.Context, from, to *tailcfg.DERPNode, fromc
790794 switch v := m .(type ) {
791795 case derp.ReceivedPacket :
792796 inFlight .Release ()
793- if v .Source != fromc . SelfPublicKey () {
797+ if v .Source != fromDERPPubKey {
794798 recvc <- fmt .Errorf ("got data packet %d from unexpected source, %v" , idx , v .Source )
795799 return
796800 }
@@ -925,7 +929,7 @@ func derpProbeBandwidthTUN(ctx context.Context, transferTimeSeconds, totalBytesT
925929
926930 destinationAddrBytes := destinationAddr .AsSlice ()
927931 scratch := make ([]byte , 4 )
928- toPubDERPKey := toc .SelfPublicKey ()
932+ toDERPPubKey := toc .SelfPublicKey ()
929933 for {
930934 n , err := dev .Read (bufs , sizes , tunStartOffset )
931935 if err != nil {
@@ -954,7 +958,7 @@ func derpProbeBandwidthTUN(ctx context.Context, transferTimeSeconds, totalBytesT
954958 copy (pkt [12 :16 ], pkt [16 :20 ])
955959 copy (pkt [16 :20 ], scratch )
956960
957- if err := fromc .Send (toPubDERPKey , pkt ); err != nil {
961+ if err := fromc .Send (toDERPPubKey , pkt ); err != nil {
958962 tunReadErrC <- err
959963 return
960964 }
0 commit comments