support multiple network interfaces
This commit is contained in:
@ -180,6 +180,7 @@ type ConnectorConfig struct {
|
||||
type ServiceConfig struct {
|
||||
Name string `json:"name"`
|
||||
Addr string `yaml:",omitempty" json:"addr,omitempty"`
|
||||
Interface string `yaml:",omitempty" json:"interface,omitempty"`
|
||||
Admission string `yaml:",omitempty" json:"admission,omitempty"`
|
||||
Bypass string `yaml:",omitempty" json:"bypass,omitempty"`
|
||||
Resolver string `yaml:",omitempty" json:"resolver,omitempty"`
|
||||
@ -196,17 +197,19 @@ type ChainConfig struct {
|
||||
}
|
||||
|
||||
type HopConfig struct {
|
||||
Name string `json:"name"`
|
||||
Selector *SelectorConfig `yaml:",omitempty" json:"selector,omitempty"`
|
||||
Bypass string `yaml:",omitempty" json:"bypass,omitempty"`
|
||||
Resolver string `yaml:",omitempty" json:"resolver,omitempty"`
|
||||
Hosts string `yaml:",omitempty" json:"hosts,omitempty"`
|
||||
Nodes []*NodeConfig `json:"nodes"`
|
||||
Name string `json:"name"`
|
||||
Interface string `yaml:",omitempty" json:"interface,omitempty"`
|
||||
Selector *SelectorConfig `yaml:",omitempty" json:"selector,omitempty"`
|
||||
Bypass string `yaml:",omitempty" json:"bypass,omitempty"`
|
||||
Resolver string `yaml:",omitempty" json:"resolver,omitempty"`
|
||||
Hosts string `yaml:",omitempty" json:"hosts,omitempty"`
|
||||
Nodes []*NodeConfig `json:"nodes"`
|
||||
}
|
||||
|
||||
type NodeConfig struct {
|
||||
Name string `json:"name"`
|
||||
Addr string `yaml:",omitempty" json:"addr,omitempty"`
|
||||
Interface string `yaml:",omitempty" json:"interface,omitempty"`
|
||||
Bypass string `yaml:",omitempty" json:"bypass,omitempty"`
|
||||
Resolver string `yaml:",omitempty" json:"resolver,omitempty"`
|
||||
Hosts string `yaml:",omitempty" json:"hosts,omitempty"`
|
||||
|
@ -93,11 +93,6 @@ func ParseChain(cfg *config.ChainConfig) (chain.Chainer, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
tr := (&chain.Transport{}).
|
||||
WithConnector(cr).
|
||||
WithDialer(d).
|
||||
WithAddr(v.Addr)
|
||||
|
||||
if v.Bypass == "" {
|
||||
v.Bypass = hop.Bypass
|
||||
}
|
||||
@ -107,15 +102,24 @@ func ParseChain(cfg *config.ChainConfig) (chain.Chainer, error) {
|
||||
if v.Hosts == "" {
|
||||
v.Hosts = hop.Hosts
|
||||
}
|
||||
if v.Interface == "" {
|
||||
v.Interface = hop.Interface
|
||||
}
|
||||
|
||||
tr := (&chain.Transport{}).
|
||||
WithConnector(cr).
|
||||
WithDialer(d).
|
||||
WithAddr(v.Addr).
|
||||
WithInterface(v.Interface)
|
||||
|
||||
node := &chain.Node{
|
||||
Name: v.Name,
|
||||
Addr: v.Addr,
|
||||
Transport: tr,
|
||||
Bypass: registry.BypassRegistry().Get(v.Bypass),
|
||||
Resolver: registry.ResolverRegistry().Get(v.Resolver),
|
||||
Hosts: registry.HostsRegistry().Get(v.Hosts),
|
||||
Marker: &chain.FailMarker{},
|
||||
Transport: tr,
|
||||
}
|
||||
group.AddNode(node)
|
||||
}
|
||||
|
@ -88,14 +88,21 @@ func ParseService(cfg *config.ServiceConfig) (service.Service, error) {
|
||||
if cfg.Handler.Auther != "" {
|
||||
auther = registry.AutherRegistry().Get(cfg.Handler.Auther)
|
||||
}
|
||||
|
||||
router := (&chain.Router{}).
|
||||
WithRetries(cfg.Handler.Retries).
|
||||
// WithTimeout(timeout time.Duration).
|
||||
WithInterface(cfg.Interface).
|
||||
WithChain(registry.ChainRegistry().Get(cfg.Handler.Chain)).
|
||||
WithResolver(registry.ResolverRegistry().Get(cfg.Resolver)).
|
||||
WithHosts(registry.HostsRegistry().Get(cfg.Hosts)).
|
||||
WithLogger(handlerLogger)
|
||||
|
||||
h := registry.HandlerRegistry().Get(cfg.Handler.Type)(
|
||||
handler.RouterOption(router),
|
||||
handler.AutherOption(auther),
|
||||
handler.AuthOption(parseAuth(cfg.Handler.Auth)),
|
||||
handler.RetriesOption(cfg.Handler.Retries),
|
||||
handler.ChainOption(registry.ChainRegistry().Get(cfg.Handler.Chain)),
|
||||
handler.BypassOption(registry.BypassRegistry().Get(cfg.Bypass)),
|
||||
handler.ResolverOption(registry.ResolverRegistry().Get(cfg.Resolver)),
|
||||
handler.HostsOption(registry.HostsRegistry().Get(cfg.Hosts)),
|
||||
handler.TLSConfigOption(tlsConfig),
|
||||
handler.LoggerOption(handlerLogger),
|
||||
)
|
||||
|
Reference in New Issue
Block a user