2020-04-12 08:55:13 -04:00
|
|
|
package routing
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"net"
|
|
|
|
|
|
|
|
|
|
"github.com/qdm12/golibs/logging"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type Routing interface {
|
2020-10-22 18:55:28 -04:00
|
|
|
AddRouteVia(destination net.IPNet, gateway net.IP, iface string) error
|
|
|
|
|
DeleteRouteVia(destination net.IPNet) (err error)
|
2020-07-12 19:05:48 +00:00
|
|
|
DefaultRoute() (defaultInterface string, defaultGateway net.IP, err error)
|
|
|
|
|
LocalSubnet() (defaultSubnet net.IPNet, err error)
|
2020-10-22 18:55:28 -04:00
|
|
|
VPNDestinationIP() (ip net.IP, err error)
|
2020-10-12 10:55:08 -04:00
|
|
|
VPNLocalGatewayIP() (ip net.IP, err error)
|
2020-07-13 02:14:56 +00:00
|
|
|
SetDebug()
|
2020-04-12 08:55:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type routing struct {
|
2020-10-22 18:55:28 -04:00
|
|
|
logger logging.Logger
|
|
|
|
|
debug bool
|
2020-04-12 08:55:13 -04:00
|
|
|
}
|
|
|
|
|
|
2020-10-20 02:45:28 +00:00
|
|
|
// NewConfigurator creates a new Configurator instance.
|
2020-10-22 18:55:28 -04:00
|
|
|
func NewRouting(logger logging.Logger) Routing {
|
2020-04-12 08:55:13 -04:00
|
|
|
return &routing{
|
2020-10-22 18:55:28 -04:00
|
|
|
logger: logger.WithPrefix("routing: "),
|
2020-04-12 08:55:13 -04:00
|
|
|
}
|
|
|
|
|
}
|
2020-07-13 02:14:56 +00:00
|
|
|
|
|
|
|
|
func (c *routing) SetDebug() {
|
|
|
|
|
c.debug = true
|
|
|
|
|
}
|