mirror of
https://github.com/h44z/wg-portal.git
synced 2025-10-07 08:56:18 +00:00
mikrotik: allow to set DNS, wip: handle routes in wg-controller
This commit is contained in:
@@ -308,12 +308,14 @@ func MergeToPhysicalInterface(pi *PhysicalInterface, i *Interface) {
|
||||
}
|
||||
|
||||
type RoutingTableInfo struct {
|
||||
FwMark uint32
|
||||
Table int
|
||||
Interface Interface
|
||||
AllowedIps []Cidr
|
||||
FwMark uint32
|
||||
Table int
|
||||
}
|
||||
|
||||
func (r RoutingTableInfo) String() string {
|
||||
return fmt.Sprintf("%d -> %d", r.FwMark, r.Table)
|
||||
return fmt.Sprintf("%s: %d -> %d", r.Interface.Identifier, r.FwMark, r.Table)
|
||||
}
|
||||
|
||||
func (r RoutingTableInfo) ManagementEnabled() bool {
|
||||
|
27
internal/domain/interface_controller.go
Normal file
27
internal/domain/interface_controller.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package domain
|
||||
|
||||
import "context"
|
||||
|
||||
type InterfaceController interface {
|
||||
GetId() InterfaceBackend
|
||||
GetInterfaces(_ context.Context) ([]PhysicalInterface, error)
|
||||
GetInterface(_ context.Context, id InterfaceIdentifier) (*PhysicalInterface, error)
|
||||
GetPeers(_ context.Context, deviceId InterfaceIdentifier) ([]PhysicalPeer, error)
|
||||
SaveInterface(
|
||||
_ context.Context,
|
||||
id InterfaceIdentifier,
|
||||
updateFunc func(pi *PhysicalInterface) (*PhysicalInterface, error),
|
||||
) error
|
||||
DeleteInterface(_ context.Context, id InterfaceIdentifier) error
|
||||
SavePeer(
|
||||
_ context.Context,
|
||||
deviceId InterfaceIdentifier,
|
||||
id PeerIdentifier,
|
||||
updateFunc func(pp *PhysicalPeer) (*PhysicalPeer, error),
|
||||
) error
|
||||
DeletePeer(_ context.Context, deviceId InterfaceIdentifier, id PeerIdentifier) error
|
||||
PingAddresses(
|
||||
ctx context.Context,
|
||||
addr string,
|
||||
) (*PingerResult, error)
|
||||
}
|
@@ -199,3 +199,22 @@ func (c Cidr) Contains(other Cidr) bool {
|
||||
|
||||
return subnet.Contains(otherIP)
|
||||
}
|
||||
|
||||
// ContainsDefaultRoute returns true if the given CIDRs contain a default route.
|
||||
func ContainsDefaultRoute(cidrs []Cidr) (ipV4, ipV6 bool) {
|
||||
for _, allowedIP := range cidrs {
|
||||
if ipV4 && ipV6 {
|
||||
break // speed up
|
||||
}
|
||||
|
||||
if allowedIP.Prefix().Bits() == 0 {
|
||||
if allowedIP.IsV4() {
|
||||
ipV4 = true
|
||||
} else {
|
||||
ipV6 = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
Reference in New Issue
Block a user