mirror of
https://github.com/speatzle/nfsense.git
synced 2025-09-13 15:19:08 +00:00
Seperate Definitions by Sub System
This commit is contained in:
parent
14c8da64cc
commit
72bf96295d
31 changed files with 120 additions and 108 deletions
|
@ -4,11 +4,11 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
|
||||
"nfsense.net/nfsense/internal/definitions"
|
||||
"nfsense.net/nfsense/internal/definitions/firewall"
|
||||
)
|
||||
|
||||
type GetDestinationNATRulesResult struct {
|
||||
DestinationNATRules []definitions.DestinationNATRule `json:"destination_nat_rules"`
|
||||
DestinationNATRules []firewall.DestinationNATRule `json:"destination_nat_rules"`
|
||||
}
|
||||
|
||||
func (f *Firewall) GetDestinationNATRules(ctx context.Context, params struct{}) (GetDestinationNATRulesResult, error) {
|
||||
|
@ -18,7 +18,7 @@ func (f *Firewall) GetDestinationNATRules(ctx context.Context, params struct{})
|
|||
}
|
||||
|
||||
type CreateDestinationNATRuleParameters struct {
|
||||
DestinationNATRule definitions.DestinationNATRule `json:"destination_nat_rule"`
|
||||
DestinationNATRule firewall.DestinationNATRule `json:"destination_nat_rule"`
|
||||
}
|
||||
|
||||
func (f *Firewall) CreateDestinationNATRule(ctx context.Context, params CreateDestinationNATRuleParameters) (struct{}, error) {
|
||||
|
@ -30,8 +30,8 @@ func (f *Firewall) CreateDestinationNATRule(ctx context.Context, params CreateDe
|
|||
}
|
||||
|
||||
type UpdateDestinationNATRuleParameters struct {
|
||||
Index uint64 `json:"index"`
|
||||
DestinationNATRule definitions.DestinationNATRule `json:"destination_nat_rule"`
|
||||
Index uint64 `json:"index"`
|
||||
DestinationNATRule firewall.DestinationNATRule `json:"destination_nat_rule"`
|
||||
}
|
||||
|
||||
func (f *Firewall) UpdateDestinationNATRule(ctx context.Context, params UpdateDestinationNATRuleParameters) (struct{}, error) {
|
||||
|
@ -61,7 +61,7 @@ func (f *Firewall) MoveDestinationNATRule(ctx context.Context, params MoveDestin
|
|||
|
||||
rule := conf.Firewall.DestinationNATRules[params.Index]
|
||||
sliceWithoutRule := append(conf.Firewall.DestinationNATRules[:params.Index], conf.Firewall.DestinationNATRules[params.Index+1:]...)
|
||||
newSlice := make([]definitions.DestinationNATRule, params.ToIndex+1)
|
||||
newSlice := make([]firewall.DestinationNATRule, params.ToIndex+1)
|
||||
copy(newSlice, sliceWithoutRule[:params.ToIndex])
|
||||
newSlice[params.ToIndex] = rule
|
||||
conf.Firewall.DestinationNATRules = append(newSlice, sliceWithoutRule[params.ToIndex:]...)
|
||||
|
|
|
@ -4,11 +4,11 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
|
||||
"nfsense.net/nfsense/internal/definitions"
|
||||
"nfsense.net/nfsense/internal/definitions/firewall"
|
||||
)
|
||||
|
||||
type GetForwardRulesResult struct {
|
||||
ForwardRules []definitions.ForwardRule `json:"forward_rules"`
|
||||
ForwardRules []firewall.ForwardRule `json:"forward_rules"`
|
||||
}
|
||||
|
||||
func (f *Firewall) GetForwardRules(ctx context.Context, params struct{}) (GetForwardRulesResult, error) {
|
||||
|
@ -18,7 +18,7 @@ func (f *Firewall) GetForwardRules(ctx context.Context, params struct{}) (GetFor
|
|||
}
|
||||
|
||||
type CreateForwardRuleParameters struct {
|
||||
ForwardRule definitions.ForwardRule `json:"forward_rule"`
|
||||
ForwardRule firewall.ForwardRule `json:"forward_rule"`
|
||||
}
|
||||
|
||||
func (f *Firewall) CreateForwardRule(ctx context.Context, params CreateForwardRuleParameters) (struct{}, error) {
|
||||
|
@ -30,8 +30,8 @@ func (f *Firewall) CreateForwardRule(ctx context.Context, params CreateForwardRu
|
|||
}
|
||||
|
||||
type UpdateForwardRuleParameters struct {
|
||||
Index uint64 `json:"index"`
|
||||
ForwardRule definitions.ForwardRule `json:"forward_rule"`
|
||||
Index uint64 `json:"index"`
|
||||
ForwardRule firewall.ForwardRule `json:"forward_rule"`
|
||||
}
|
||||
|
||||
func (f *Firewall) UpdateForwardRule(ctx context.Context, params UpdateForwardRuleParameters) (struct{}, error) {
|
||||
|
@ -61,7 +61,7 @@ func (f *Firewall) MoveForwardRule(ctx context.Context, params MoveForwardRulePa
|
|||
|
||||
rule := conf.Firewall.ForwardRules[params.Index]
|
||||
sliceWithoutRule := append(conf.Firewall.ForwardRules[:params.Index], conf.Firewall.ForwardRules[params.Index+1:]...)
|
||||
newSlice := make([]definitions.ForwardRule, params.ToIndex+1)
|
||||
newSlice := make([]firewall.ForwardRule, params.ToIndex+1)
|
||||
copy(newSlice, sliceWithoutRule[:params.ToIndex])
|
||||
newSlice[params.ToIndex] = rule
|
||||
conf.Firewall.ForwardRules = append(newSlice, sliceWithoutRule[params.ToIndex:]...)
|
||||
|
|
|
@ -4,11 +4,11 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
|
||||
"nfsense.net/nfsense/internal/definitions"
|
||||
"nfsense.net/nfsense/internal/definitions/firewall"
|
||||
)
|
||||
|
||||
type GetSourceNATRulesResult struct {
|
||||
SourceNATRules []definitions.SourceNATRule `json:"source_nat_rules"`
|
||||
SourceNATRules []firewall.SourceNATRule `json:"source_nat_rules"`
|
||||
}
|
||||
|
||||
func (f *Firewall) GetSourceNATRules(ctx context.Context, params struct{}) (GetSourceNATRulesResult, error) {
|
||||
|
@ -18,7 +18,7 @@ func (f *Firewall) GetSourceNATRules(ctx context.Context, params struct{}) (GetS
|
|||
}
|
||||
|
||||
type CreateSourceNATRuleParameters struct {
|
||||
SourceNATRule definitions.SourceNATRule `json:"source_nat_rule"`
|
||||
SourceNATRule firewall.SourceNATRule `json:"source_nat_rule"`
|
||||
}
|
||||
|
||||
func (f *Firewall) CreateSourceNATRule(ctx context.Context, params CreateSourceNATRuleParameters) (struct{}, error) {
|
||||
|
@ -30,8 +30,8 @@ func (f *Firewall) CreateSourceNATRule(ctx context.Context, params CreateSourceN
|
|||
}
|
||||
|
||||
type UpdateSourceNATRuleParameters struct {
|
||||
Index uint64 `json:"index"`
|
||||
SourceNATRule definitions.SourceNATRule `json:"source_nat_rule"`
|
||||
Index uint64 `json:"index"`
|
||||
SourceNATRule firewall.SourceNATRule `json:"source_nat_rule"`
|
||||
}
|
||||
|
||||
func (f *Firewall) UpdateSourceNATRule(ctx context.Context, params UpdateSourceNATRuleParameters) (struct{}, error) {
|
||||
|
@ -61,7 +61,7 @@ func (f *Firewall) MoveSourceNATRule(ctx context.Context, params MoveSourceNATRu
|
|||
|
||||
rule := conf.Firewall.SourceNATRules[params.Index]
|
||||
sliceWithoutRule := append(conf.Firewall.SourceNATRules[:params.Index], conf.Firewall.SourceNATRules[params.Index+1:]...)
|
||||
newSlice := make([]definitions.SourceNATRule, params.ToIndex+1)
|
||||
newSlice := make([]firewall.SourceNATRule, params.ToIndex+1)
|
||||
copy(newSlice, sliceWithoutRule[:params.ToIndex])
|
||||
newSlice[params.ToIndex] = rule
|
||||
conf.Firewall.SourceNATRules = append(newSlice, sliceWithoutRule[params.ToIndex:]...)
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
|
||||
"nfsense.net/nfsense/internal/definitions"
|
||||
"nfsense.net/nfsense/internal/definitions/network"
|
||||
"nfsense.net/nfsense/internal/networkd/dbus"
|
||||
)
|
||||
|
||||
|
@ -28,7 +28,7 @@ type GetInterfaceParameters struct {
|
|||
|
||||
type GetInterfaceResult struct {
|
||||
Name string `json:"name"`
|
||||
definitions.Interface
|
||||
network.Interface
|
||||
}
|
||||
|
||||
func (f *Network) GetInterface(ctx context.Context, params GetInterfaceParameters) (GetInterfaceResult, error) {
|
||||
|
@ -44,7 +44,7 @@ func (f *Network) GetInterface(ctx context.Context, params GetInterfaceParameter
|
|||
}
|
||||
|
||||
type GetInterfacesResult struct {
|
||||
Interfaces map[string]definitions.Interface
|
||||
Interfaces map[string]network.Interface
|
||||
}
|
||||
|
||||
func (f *Network) GetInterfaces(ctx context.Context, params struct{}) (GetInterfacesResult, error) {
|
||||
|
@ -55,7 +55,7 @@ func (f *Network) GetInterfaces(ctx context.Context, params struct{}) (GetInterf
|
|||
|
||||
type CreateInterfaceParameters struct {
|
||||
Name string `json:"name"`
|
||||
definitions.Interface
|
||||
network.Interface
|
||||
}
|
||||
|
||||
func (f *Network) CreateInterface(ctx context.Context, params CreateInterfaceParameters) (struct{}, error) {
|
||||
|
@ -73,7 +73,7 @@ func (f *Network) CreateInterface(ctx context.Context, params CreateInterfacePar
|
|||
|
||||
type UpdateInterfaceParameters struct {
|
||||
Name string
|
||||
definitions.Interface
|
||||
network.Interface
|
||||
}
|
||||
|
||||
func (f *Network) UpdateInterface(ctx context.Context, params UpdateInterfaceParameters) (struct{}, error) {
|
||||
|
|
|
@ -4,11 +4,11 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
|
||||
"nfsense.net/nfsense/internal/definitions"
|
||||
"nfsense.net/nfsense/internal/definitions/network"
|
||||
)
|
||||
|
||||
type GetStaticRoutesResult struct {
|
||||
StaticRoutes []definitions.StaticRoute
|
||||
StaticRoutes []network.StaticRoute
|
||||
}
|
||||
|
||||
func (f *Network) GetStaticRoutes(ctx context.Context, params struct{}) (GetStaticRoutesResult, error) {
|
||||
|
@ -17,7 +17,7 @@ func (f *Network) GetStaticRoutes(ctx context.Context, params struct{}) (GetStat
|
|||
}, nil
|
||||
}
|
||||
|
||||
func (f *Network) CreateStaticRoute(ctx context.Context, params definitions.StaticRoute) (struct{}, error) {
|
||||
func (f *Network) CreateStaticRoute(ctx context.Context, params network.StaticRoute) (struct{}, error) {
|
||||
t, conf := f.ConfigManager.StartTransaction()
|
||||
defer t.Discard()
|
||||
|
||||
|
@ -27,7 +27,7 @@ func (f *Network) CreateStaticRoute(ctx context.Context, params definitions.Stat
|
|||
|
||||
type UpdateStaticRouteParameters struct {
|
||||
Index uint
|
||||
definitions.StaticRoute
|
||||
network.StaticRoute
|
||||
}
|
||||
|
||||
func (f *Network) UpdateStaticRoute(ctx context.Context, params UpdateStaticRouteParameters) (struct{}, error) {
|
||||
|
|
|
@ -4,11 +4,11 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
|
||||
"nfsense.net/nfsense/internal/definitions"
|
||||
"nfsense.net/nfsense/internal/definitions/object"
|
||||
)
|
||||
|
||||
type GetAddressesResult struct {
|
||||
Addresses map[string]definitions.Address
|
||||
Addresses map[string]object.Address
|
||||
}
|
||||
|
||||
func (f *Object) GetAddresses(ctx context.Context, params struct{}) (GetAddressesResult, error) {
|
||||
|
@ -19,7 +19,7 @@ func (f *Object) GetAddresses(ctx context.Context, params struct{}) (GetAddresse
|
|||
|
||||
type CreateAddressParameters struct {
|
||||
Name string
|
||||
Address definitions.Address
|
||||
Address object.Address
|
||||
}
|
||||
|
||||
func (f *Object) CreateAddress(ctx context.Context, params CreateAddressParameters) (struct{}, error) {
|
||||
|
@ -37,7 +37,7 @@ func (f *Object) CreateAddress(ctx context.Context, params CreateAddressParamete
|
|||
|
||||
type UpdateAddressParameters struct {
|
||||
Name string
|
||||
Address definitions.Address
|
||||
Address object.Address
|
||||
}
|
||||
|
||||
func (f *Object) UpdateAddress(ctx context.Context, params UpdateAddressParameters) (struct{}, error) {
|
||||
|
|
|
@ -4,11 +4,11 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
|
||||
"nfsense.net/nfsense/internal/definitions"
|
||||
"nfsense.net/nfsense/internal/definitions/object"
|
||||
)
|
||||
|
||||
type GetServicesResult struct {
|
||||
Services map[string]definitions.Service
|
||||
Services map[string]object.Service
|
||||
}
|
||||
|
||||
func (f *Object) GetServices(ctx context.Context, params struct{}) (GetServicesResult, error) {
|
||||
|
@ -19,7 +19,7 @@ func (f *Object) GetServices(ctx context.Context, params struct{}) (GetServicesR
|
|||
|
||||
type CreateServiceParameters struct {
|
||||
Name string
|
||||
Service definitions.Service
|
||||
Service object.Service
|
||||
}
|
||||
|
||||
func (f *Object) CreateService(ctx context.Context, params CreateServiceParameters) (struct{}, error) {
|
||||
|
@ -37,7 +37,7 @@ func (f *Object) CreateService(ctx context.Context, params CreateServiceParamete
|
|||
|
||||
type UpdateServiceParameters struct {
|
||||
Name string
|
||||
Service definitions.Service
|
||||
Service object.Service
|
||||
}
|
||||
|
||||
func (f *Object) UpdateService(ctx context.Context, params UpdateServiceParameters) (struct{}, error) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue