Netlink Go library to interact with IP routes (#267)

This commit is contained in:
Quentin McGaw
2020-10-22 18:55:28 -04:00
committed by GitHub
parent a80cb8f9ba
commit ea3b3bc8a3
12 changed files with 118 additions and 840 deletions

View File

@@ -1,37 +1,30 @@
package routing
import (
"context"
"net"
"github.com/qdm12/golibs/command"
"github.com/qdm12/golibs/files"
"github.com/qdm12/golibs/logging"
)
type Routing interface {
AddRouteVia(ctx context.Context, subnet net.IPNet, defaultGateway net.IP, defaultInterface string) error
DeleteRouteVia(ctx context.Context, subnet net.IPNet) (err error)
AddRouteVia(destination net.IPNet, gateway net.IP, iface string) error
DeleteRouteVia(destination net.IPNet) (err error)
DefaultRoute() (defaultInterface string, defaultGateway net.IP, err error)
LocalSubnet() (defaultSubnet net.IPNet, err error)
VPNDestinationIP(defaultInterface string) (ip net.IP, err error)
VPNDestinationIP() (ip net.IP, err error)
VPNLocalGatewayIP() (ip net.IP, err error)
SetDebug()
}
type routing struct {
commander command.Commander
logger logging.Logger
fileManager files.FileManager
debug bool
logger logging.Logger
debug bool
}
// NewConfigurator creates a new Configurator instance.
func NewRouting(logger logging.Logger, fileManager files.FileManager) Routing {
func NewRouting(logger logging.Logger) Routing {
return &routing{
commander: command.NewCommander(),
logger: logger.WithPrefix("routing: "),
fileManager: fileManager,
logger: logger.WithPrefix("routing: "),
}
}