add router interface

This commit is contained in:
ginuerzh
2023-11-19 14:20:35 +08:00
parent 486f2cee61
commit 6b01698ea9
2 changed files with 36 additions and 7 deletions

24
router/router.go Normal file
View File

@ -0,0 +1,24 @@
package router
import (
"context"
"net"
)
type Options struct{}
type Option func(opts *Options)
type Route struct {
// Net is the destination network, e.g. 192.168.0.0/16, 172.10.10.0/24.
Net *net.IPNet
// Gateway is the gateway for the destination network.
Gateway net.IP
}
type Router interface {
// SetRoute adds or updates a route for the router.
SetRoute(ctx context.Context, route *Route, opts ...Option) bool
// GetRoute queries a route by destination IP address.
GetRoute(ctx context.Context, dst net.IP, opts ...Option) *Route
}