add filter node option
This commit is contained in:
parent
5d6c2115fa
commit
8d554ddcf7
@ -11,6 +11,12 @@ import (
|
|||||||
"github.com/go-gost/core/selector"
|
"github.com/go-gost/core/selector"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type NodeFilterSettings struct {
|
||||||
|
Protocol string
|
||||||
|
Host string
|
||||||
|
Path string
|
||||||
|
}
|
||||||
|
|
||||||
type HTTPURLRewriteSetting struct {
|
type HTTPURLRewriteSetting struct {
|
||||||
Pattern *regexp.Regexp
|
Pattern *regexp.Regexp
|
||||||
Replacement string
|
Replacement string
|
||||||
@ -34,17 +40,15 @@ type TLSNodeSettings struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type NodeOptions struct {
|
type NodeOptions struct {
|
||||||
|
Network string
|
||||||
Transport *Transport
|
Transport *Transport
|
||||||
Bypass bypass.Bypass
|
Bypass bypass.Bypass
|
||||||
Resolver resolver.Resolver
|
Resolver resolver.Resolver
|
||||||
HostMapper hosts.HostMapper
|
HostMapper hosts.HostMapper
|
||||||
Metadata metadata.Metadata
|
Filter *NodeFilterSettings
|
||||||
Host string
|
|
||||||
Network string
|
|
||||||
Protocol string
|
|
||||||
Path string
|
|
||||||
HTTP *HTTPNodeSettings
|
HTTP *HTTPNodeSettings
|
||||||
TLS *TLSNodeSettings
|
TLS *TLSNodeSettings
|
||||||
|
Metadata metadata.Metadata
|
||||||
}
|
}
|
||||||
|
|
||||||
type NodeOption func(*NodeOptions)
|
type NodeOption func(*NodeOptions)
|
||||||
@ -73,33 +77,15 @@ func HostMapperNodeOption(m hosts.HostMapper) NodeOption {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func HostNodeOption(host string) NodeOption {
|
|
||||||
return func(o *NodeOptions) {
|
|
||||||
o.Host = host
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func NetworkNodeOption(network string) NodeOption {
|
func NetworkNodeOption(network string) NodeOption {
|
||||||
return func(o *NodeOptions) {
|
return func(o *NodeOptions) {
|
||||||
o.Network = network
|
o.Network = network
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func ProtocolNodeOption(protocol string) NodeOption {
|
func NodeFilterOption(filter *NodeFilterSettings) NodeOption {
|
||||||
return func(o *NodeOptions) {
|
return func(o *NodeOptions) {
|
||||||
o.Protocol = protocol
|
o.Filter = filter
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func PathNodeOption(path string) NodeOption {
|
|
||||||
return func(o *NodeOptions) {
|
|
||||||
o.Path = path
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func MetadataNodeOption(md metadata.Metadata) NodeOption {
|
|
||||||
return func(o *NodeOptions) {
|
|
||||||
o.Metadata = md
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,6 +101,12 @@ func TLSNodeOption(tlsSettings *TLSNodeSettings) NodeOption {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func MetadataNodeOption(md metadata.Metadata) NodeOption {
|
||||||
|
return func(o *NodeOptions) {
|
||||||
|
o.Metadata = md
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
type Node struct {
|
type Node struct {
|
||||||
Name string
|
Name string
|
||||||
Addr string
|
Addr string
|
||||||
|
Loading…
Reference in New Issue
Block a user