mirror of
https://github.com/netbirdio/netbird.git
synced 2025-06-26 12:42:32 +02:00
adds NetFlow functionality to track and log network traffic information between peers, with features including: - Flow logging for TCP, UDP, and ICMP traffic - Integration with connection tracking system - Resource ID tracking in NetFlow events - DNS and exit node collection configuration - Flow API and Redis cache in management - Memory-based flow storage implementation - Kernel conntrack counters and userspace counters - TCP state machine improvements for more accurate tracking - Migration from net.IP to netip.Addr in the userspace firewall
33 lines
844 B
Go
33 lines
844 B
Go
package client
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"google.golang.org/grpc"
|
|
"google.golang.org/grpc/credentials"
|
|
)
|
|
|
|
var _ credentials.PerRPCCredentials = (*authToken)(nil)
|
|
|
|
type authToken struct {
|
|
metaMap map[string]string
|
|
}
|
|
|
|
func (t authToken) GetRequestMetadata(context.Context, ...string) (map[string]string, error) {
|
|
return t.metaMap, nil
|
|
}
|
|
|
|
func (authToken) RequireTransportSecurity() bool {
|
|
return false // Set to true if you want to require a secure connection
|
|
}
|
|
|
|
// WithAuthToken returns a DialOption which sets the receiver flow credentials and places auth state on each outbound RPC
|
|
func withAuthToken(payload, signature string) grpc.DialOption {
|
|
value := fmt.Sprintf("%s.%s", signature, payload)
|
|
authMap := map[string]string{
|
|
"authorization": "Bearer " + value,
|
|
}
|
|
return grpc.WithPerRPCCredentials(authToken{metaMap: authMap})
|
|
}
|