Compare commits
4 Commits
8e4fc06cf1
...
abc73f2ca2
Author | SHA1 | Date | |
---|---|---|---|
|
abc73f2ca2 | ||
|
6b01698ea9 | ||
|
486f2cee61 | ||
|
a916f04016 |
@ -8,6 +8,7 @@ import (
|
||||
"github.com/go-gost/core/bypass"
|
||||
"github.com/go-gost/core/chain"
|
||||
"github.com/go-gost/core/limiter/rate"
|
||||
"github.com/go-gost/core/limiter/traffic"
|
||||
"github.com/go-gost/core/logger"
|
||||
"github.com/go-gost/core/metadata"
|
||||
)
|
||||
@ -18,6 +19,7 @@ type Options struct {
|
||||
Auth *url.Userinfo
|
||||
Auther auth.Authenticator
|
||||
RateLimiter rate.RateLimiter
|
||||
Limiter traffic.TrafficLimiter
|
||||
TLSConfig *tls.Config
|
||||
Logger logger.Logger
|
||||
Service string
|
||||
@ -55,6 +57,12 @@ func RateLimiterOption(limiter rate.RateLimiter) Option {
|
||||
}
|
||||
}
|
||||
|
||||
func TrafficLimiterOption(limiter traffic.TrafficLimiter) Option {
|
||||
return func(opts *Options) {
|
||||
opts.Limiter = limiter
|
||||
}
|
||||
}
|
||||
|
||||
func TLSConfigOption(tlsConfig *tls.Config) Option {
|
||||
return func(opts *Options) {
|
||||
opts.TLSConfig = tlsConfig
|
||||
|
@ -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)
|
||||
// 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
|
||||
}
|
||||
|
@ -10,7 +10,40 @@ type Limiter interface {
|
||||
Set(n int)
|
||||
}
|
||||
|
||||
type TrafficLimiter interface {
|
||||
In(key string) Limiter
|
||||
Out(key string) Limiter
|
||||
type Options struct {
|
||||
Network string
|
||||
Addr string
|
||||
Client string
|
||||
Src string
|
||||
}
|
||||
|
||||
type Option func(opts *Options)
|
||||
|
||||
func NetworkOption(network string) Option {
|
||||
return func(opts *Options) {
|
||||
opts.Network = network
|
||||
}
|
||||
}
|
||||
|
||||
func AddrOption(addr string) Option {
|
||||
return func(opts *Options) {
|
||||
opts.Addr = addr
|
||||
}
|
||||
}
|
||||
|
||||
func ClientOption(client string) Option {
|
||||
return func(opts *Options) {
|
||||
opts.Client = client
|
||||
}
|
||||
}
|
||||
|
||||
func SrcOption(src string) Option {
|
||||
return func(opts *Options) {
|
||||
opts.Src = src
|
||||
}
|
||||
}
|
||||
|
||||
type TrafficLimiter interface {
|
||||
In(ctx context.Context, key string, opts ...Option) Limiter
|
||||
Out(ctx context.Context, key string, opts ...Option) Limiter
|
||||
}
|
||||
|
22
router/router.go
Normal file
22
router/router.go
Normal file
@ -0,0 +1,22 @@
|
||||
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 {
|
||||
// GetRoute queries a route by destination IP address.
|
||||
GetRoute(ctx context.Context, dst net.IP, opts ...Option) *Route
|
||||
}
|
Loading…
Reference in New Issue
Block a user