Skip to content

Commit

Permalink
use IP for GetServerKey
Browse files Browse the repository at this point in the history
  • Loading branch information
pascal-fischer committed Feb 7, 2025
1 parent 7e03c85 commit 7a633d6
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions management/server/grpcserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
log "github.com/sirupsen/logrus"
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/peer"
"google.golang.org/grpc/status"

"github.com/netbirdio/netbird/encryption"
Expand Down Expand Up @@ -114,10 +115,16 @@ func NewServer(
}

func (s *GRPCServer) GetServerKey(ctx context.Context, req *proto.Empty) (*proto.ServerKeyResponse, error) {
log.WithContext(ctx).Tracef("GetServerKey request")
ip := ""
p, ok := peer.FromContext(ctx)
if ok {
ip = p.Addr.String()
}

log.WithContext(ctx).Tracef("GetServerKey request from %s", ip)
start := time.Now()
defer func() {
log.WithContext(ctx).Tracef("GetServerKey took %v", time.Since(start))
log.WithContext(ctx).Tracef("GetServerKey from %s took %v", ip, time.Since(start))
}()

// todo introduce something more meaningful with the key expiration/rotation
Expand Down

0 comments on commit 7a633d6

Please sign in to comment.