mirror of
https://github.com/speatzle/nfsense.git
synced 2025-09-13 07:19:07 +00:00
Add Apply Interfaces
This commit is contained in:
parent
80f255fe86
commit
e72c2c4f2e
2 changed files with 33 additions and 1 deletions
|
@ -2,8 +2,10 @@ package network
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"nfsense.net/nfsense/internal/definitions"
|
||||
"nfsense.net/nfsense/internal/interfaces"
|
||||
)
|
||||
|
||||
type GetInterfacesParameters struct {
|
||||
|
@ -18,3 +20,24 @@ func (f *Network) GetInterfaces(ctx context.Context, params GetInterfacesParamet
|
|||
Interfaces: f.Conf.Network.Interfaces,
|
||||
}, nil
|
||||
}
|
||||
|
||||
type ApplyInterfacesParameters struct {
|
||||
}
|
||||
|
||||
type ApplyInterfacesResult struct {
|
||||
Log string
|
||||
}
|
||||
|
||||
func (f *Network) ApplyInterfaces(ctx context.Context, params ApplyInterfacesParameters) (ApplyInterfacesResult, error) {
|
||||
data, err := interfaces.GenerateInterfacesFile(*f.Conf)
|
||||
if err != nil {
|
||||
return ApplyInterfacesResult{}, fmt.Errorf("Generating Interfaces File: %w", err)
|
||||
}
|
||||
log, err := interfaces.ApplyInterfacesFile(data)
|
||||
if err != nil {
|
||||
return ApplyInterfacesResult{}, fmt.Errorf("Applying Interfaces File: %w", err)
|
||||
}
|
||||
return ApplyInterfacesResult{
|
||||
Log: log,
|
||||
}, nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue