support multiple network interfaces

This commit is contained in:
ginuerzh
2022-03-01 21:48:50 +08:00
parent 07132d8de7
commit ffdf11e89e
44 changed files with 431 additions and 474 deletions

View File

@ -7,17 +7,12 @@ import (
"github.com/go-gost/gost/pkg/auth"
"github.com/go-gost/gost/pkg/bypass"
"github.com/go-gost/gost/pkg/chain"
"github.com/go-gost/gost/pkg/hosts"
"github.com/go-gost/gost/pkg/logger"
"github.com/go-gost/gost/pkg/resolver"
)
type Options struct {
Retries int
Chain chain.Chainer
Resolver resolver.Resolver
Hosts hosts.HostMapper
Bypass bypass.Bypass
Router *chain.Router
Auth *url.Userinfo
Auther auth.Authenticator
TLSConfig *tls.Config
@ -26,41 +21,24 @@ type Options struct {
type Option func(opts *Options)
func RetriesOption(retries int) Option {
return func(opts *Options) {
opts.Retries = retries
}
}
func ChainOption(chain chain.Chainer) Option {
return func(opts *Options) {
opts.Chain = chain
}
}
func ResolverOption(resolver resolver.Resolver) Option {
return func(opts *Options) {
opts.Resolver = resolver
}
}
func HostsOption(hosts hosts.HostMapper) Option {
return func(opts *Options) {
opts.Hosts = hosts
}
}
func BypassOption(bypass bypass.Bypass) Option {
return func(opts *Options) {
opts.Bypass = bypass
}
}
func RouterOption(router *chain.Router) Option {
return func(opts *Options) {
opts.Router = router
}
}
func AuthOption(auth *url.Userinfo) Option {
return func(opts *Options) {
opts.Auth = auth
}
}
func AutherOption(auther auth.Authenticator) Option {
return func(opts *Options) {
opts.Auther = auther