diff --git a/ingress/ingress.go b/ingress/ingress.go index 161a164..81db5b8 100644 --- a/ingress/ingress.go +++ b/ingress/ingress.go @@ -2,15 +2,20 @@ package ingress import "context" -type GetOptions struct{} +type Options struct{} -type GetOption func(opts *GetOptions) +type Option func(opts *Options) -type SetOptions struct{} - -type SetOption func(opts *SetOptions) +type Rule struct { + // Hostname is the hostname match pattern, e.g. example.com, *.example.org or .example.com. + Hostname string + // Endpoint is the tunnel ID for the hostname. + Endpoint string +} type Ingress interface { - Get(ctx context.Context, host string, opts ...GetOption) string - Set(ctx context.Context, host, endpoint string, opts ...SetOption) bool + // SetRule adds or updates a rule for the ingress. + SetRule(ctx context.Context, rule *Rule, opts ...Option) bool + // GetRule queries a rule by host. + GetRule(ctx context.Context, host string, opts ...Option) *Rule } diff --git a/router/router.go b/router/router.go new file mode 100644 index 0000000..3fc2ac4 --- /dev/null +++ b/router/router.go @@ -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 +}