mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-21 17:56:39 +00:00
[management, proxy] Add CrowdSec IP reputation integration for reverse proxy (#5722)
This commit is contained in:
@@ -2,6 +2,7 @@ package proxy
|
||||
|
||||
import (
|
||||
"context"
|
||||
"maps"
|
||||
"net/netip"
|
||||
"sync"
|
||||
|
||||
@@ -52,6 +53,7 @@ type CapturedData struct {
|
||||
clientIP netip.Addr
|
||||
userID string
|
||||
authMethod string
|
||||
metadata map[string]string
|
||||
}
|
||||
|
||||
// NewCapturedData creates a CapturedData with the given request ID.
|
||||
@@ -150,6 +152,23 @@ func (c *CapturedData) GetAuthMethod() string {
|
||||
return c.authMethod
|
||||
}
|
||||
|
||||
// SetMetadata sets a key-value pair in the metadata map.
|
||||
func (c *CapturedData) SetMetadata(key, value string) {
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
if c.metadata == nil {
|
||||
c.metadata = make(map[string]string)
|
||||
}
|
||||
c.metadata[key] = value
|
||||
}
|
||||
|
||||
// GetMetadata returns a copy of the metadata map.
|
||||
func (c *CapturedData) GetMetadata() map[string]string {
|
||||
c.mu.RLock()
|
||||
defer c.mu.RUnlock()
|
||||
return maps.Clone(c.metadata)
|
||||
}
|
||||
|
||||
// WithCapturedData adds a CapturedData struct to the context.
|
||||
func WithCapturedData(ctx context.Context, data *CapturedData) context.Context {
|
||||
return context.WithValue(ctx, capturedDataKey, data)
|
||||
|
||||
Reference in New Issue
Block a user