add auther for metrics

This commit is contained in:
ginuerzh
2023-10-09 21:27:35 +08:00
parent 61f1f05339
commit 4be7d60147
8 changed files with 93 additions and 152 deletions

View File

@ -92,8 +92,10 @@ type APIConfig struct {
}
type MetricsConfig struct {
Addr string `json:"addr"`
Path string `yaml:",omitempty" json:"path,omitempty"`
Addr string `json:"addr"`
Path string `yaml:",omitempty" json:"path,omitempty"`
Auth *AuthConfig `yaml:",omitempty" json:"auth,omitempty"`
Auther string `yaml:",omitempty" json:"auther,omitempty"`
}
type TLSConfig struct {
@ -303,14 +305,13 @@ type ForwarderConfig struct {
Name string `yaml:",omitempty" json:"name,omitempty"`
Selector *SelectorConfig `yaml:",omitempty" json:"selector,omitempty"`
Nodes []*ForwardNodeConfig `json:"nodes"`
// DEPRECATED by nodes since beta.4
Targets []string `yaml:",omitempty" json:"targets,omitempty"`
}
type ForwardNodeConfig struct {
Name string `yaml:",omitempty" json:"name,omitempty"`
Addr string `yaml:",omitempty" json:"addr,omitempty"`
Host string `yaml:",omitempty" json:"host,omitempty"`
Network string `yaml:",omitempty" json:"network,omitempty"`
Protocol string `yaml:",omitempty" json:"protocol,omitempty"`
Bypass string `yaml:",omitempty" json:"bypass,omitempty"`
Bypasses []string `yaml:",omitempty" json:"bypasses,omitempty"`
@ -402,6 +403,7 @@ type NodeConfig struct {
Name string `json:"name"`
Addr string `yaml:",omitempty" json:"addr,omitempty"`
Host string `yaml:",omitempty" json:"host,omitempty"`
Network string `yaml:",omitempty" json:"network,omitempty"`
Protocol string `yaml:",omitempty" json:"protocol,omitempty"`
Interface string `yaml:",omitempty" json:"interface,omitempty"`
SockOpts *SockOptsConfig `yaml:"sockopts,omitempty" json:"sockopts,omitempty"`

View File

@ -168,6 +168,7 @@ func ParseNode(hop string, cfg *config.NodeConfig) (*chain.Node, error) {
chain.MetadataNodeOption(nm),
chain.HostNodeOption(host),
chain.ProtocolNodeOption(cfg.Protocol),
chain.NetworkNodeOption(cfg.Network),
}
if cfg.HTTP != nil {
opts = append(opts, chain.HTTPNodeOption(&chain.HTTPNodeSettings{

View File

@ -1,16 +1,14 @@
package service
import (
"fmt"
"strings"
"github.com/go-gost/core/admission"
"github.com/go-gost/core/auth"
"github.com/go-gost/core/bypass"
"github.com/go-gost/core/chain"
"github.com/go-gost/core/hop"
"github.com/go-gost/core/handler"
"github.com/go-gost/core/hop"
"github.com/go-gost/core/listener"
"github.com/go-gost/core/logger"
mdutil "github.com/go-gost/core/metadata/util"
@ -20,11 +18,11 @@ import (
xchain "github.com/go-gost/x/chain"
"github.com/go-gost/x/config"
"github.com/go-gost/x/config/parsing"
auth_parser "github.com/go-gost/x/config/parsing/auth"
hop_parser "github.com/go-gost/x/config/parsing/hop"
bypass_parser "github.com/go-gost/x/config/parsing/bypass"
selector_parser "github.com/go-gost/x/config/parsing/selector"
admission_parser "github.com/go-gost/x/config/parsing/admission"
auth_parser "github.com/go-gost/x/config/parsing/auth"
bypass_parser "github.com/go-gost/x/config/parsing/bypass"
hop_parser "github.com/go-gost/x/config/parsing/hop"
selector_parser "github.com/go-gost/x/config/parsing/selector"
tls_util "github.com/go-gost/x/internal/util/tls"
"github.com/go-gost/x/metadata"
"github.com/go-gost/x/registry"
@ -260,37 +258,24 @@ func parseForwarder(cfg *config.ForwarderConfig) (hop.Hop, error) {
Name: cfg.Name,
Selector: cfg.Selector,
}
if len(cfg.Nodes) > 0 {
for _, node := range cfg.Nodes {
if node != nil {
hc.Nodes = append(hc.Nodes,
&config.NodeConfig{
Name: node.Name,
Addr: node.Addr,
Host: node.Host,
Protocol: node.Protocol,
Bypass: node.Bypass,
Bypasses: node.Bypasses,
HTTP: node.HTTP,
TLS: node.TLS,
Auth: node.Auth,
},
)
}
}
} else {
for _, target := range cfg.Targets {
if v := strings.TrimSpace(target); v != "" {
hc.Nodes = append(hc.Nodes,
&config.NodeConfig{
Name: target,
Addr: target,
},
)
}
for _, node := range cfg.Nodes {
if node != nil {
hc.Nodes = append(hc.Nodes,
&config.NodeConfig{
Name: node.Name,
Addr: node.Addr,
Host: node.Host,
Network: node.Network,
Protocol: node.Protocol,
Bypass: node.Bypass,
Bypasses: node.Bypasses,
HTTP: node.HTTP,
TLS: node.TLS,
Auth: node.Auth,
},
)
}
}
if len(hc.Nodes) > 0 {
return hop_parser.ParseHop(&hc)
}