refactor: move default destination fallback after profile resolution and add nftables input chain filtering for VPN clients

Move default 172.16.10.0/24 destination assignment to after profile resolution and only apply when both selectedDestinations and services are empty. Extract selectedServices calculation before conditional check in applyCurrentPolicy.

Add nftables input chain to gateway with per-peer filtering. Accept established connections and non-WireGuard traffic. Allow DNS queries to configured
This commit is contained in:
2026-03-19 22:26:03 +01:00
parent bee9e63ace
commit 5d5f736e1b
2 changed files with 27 additions and 5 deletions

View File

@@ -61,13 +61,13 @@ func (s *Service) Enroll(ctx context.Context, userID uuid.UUID, input EnrollRequ
if err != nil {
return EnrollmentResponse{}, err
}
if len(destinations) == 0 {
destinations = []string{"172.16.10.0/24"}
}
availableProfiles, selectedProfileID, selectedDestinations, err := s.resolveAccessProfiles(ctx, userID, enrollment.Device.ID)
if err != nil {
return EnrollmentResponse{}, err
}
if len(selectedDestinations) == 0 && len(servicesForSelectedProfile(availableProfiles, selectedProfileID)) == 0 {
selectedDestinations = []string{"172.16.10.0/24"}
}
if len(selectedDestinations) == 0 {
selectedDestinations = destinations
}
@@ -215,11 +215,11 @@ func (s *Service) applyCurrentPolicy(ctx context.Context, enrollment EnrollmentR
if err != nil {
return EnrollmentResponse{}, err
}
if len(selectedDestinations) == 0 {
selectedServices := servicesForSelectedProfile(availableProfiles, selectedProfileID)
if len(selectedDestinations) == 0 && len(selectedServices) == 0 {
selectedDestinations = []string{"172.16.10.0/24"}
}
selectedServices := servicesForSelectedProfile(availableProfiles, selectedProfileID)
enrollment.Resources = resourcesFromProfile(selectedDestinations, selectedServices)
enrollment.AvailableProfiles = availableProfiles
enrollment.SelectedProfileID = selectedProfileID