add backup filter
This commit is contained in:
@ -2,7 +2,7 @@ package grpc
|
||||
|
||||
import (
|
||||
mdata "github.com/go-gost/core/metadata"
|
||||
mdx "github.com/go-gost/x/metadata"
|
||||
mdutil "github.com/go-gost/core/metadata/util"
|
||||
)
|
||||
|
||||
type metadata struct {
|
||||
@ -18,9 +18,9 @@ func (d *grpcDialer) parseMetadata(md mdata.Metadata) (err error) {
|
||||
path = "path"
|
||||
)
|
||||
|
||||
d.md.insecure = mdx.GetBool(md, insecure)
|
||||
d.md.host = mdx.GetString(md, host)
|
||||
d.md.path = mdx.GetString(md, path)
|
||||
d.md.insecure = mdutil.GetBool(md, insecure)
|
||||
d.md.host = mdutil.GetString(md, host)
|
||||
d.md.path = mdutil.GetString(md, path)
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"net/http"
|
||||
|
||||
mdata "github.com/go-gost/core/metadata"
|
||||
mdx "github.com/go-gost/x/metadata"
|
||||
mdutil "github.com/go-gost/core/metadata/util"
|
||||
)
|
||||
|
||||
type metadata struct {
|
||||
@ -20,9 +20,9 @@ func (d *h2Dialer) parseMetadata(md mdata.Metadata) (err error) {
|
||||
header = "header"
|
||||
)
|
||||
|
||||
d.md.host = mdx.GetString(md, host)
|
||||
d.md.path = mdx.GetString(md, path)
|
||||
if m := mdx.GetStringMapString(md, header); len(m) > 0 {
|
||||
d.md.host = mdutil.GetString(md, host)
|
||||
d.md.path = mdutil.GetString(md, path)
|
||||
if m := mdutil.GetStringMapString(md, header); len(m) > 0 {
|
||||
h := http.Header{}
|
||||
for k, v := range m {
|
||||
h.Add(k, v)
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
"time"
|
||||
|
||||
mdata "github.com/go-gost/core/metadata"
|
||||
mdx "github.com/go-gost/x/metadata"
|
||||
mdutil "github.com/go-gost/core/metadata/util"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -35,19 +35,19 @@ func (d *http3Dialer) parseMetadata(md mdata.Metadata) (err error) {
|
||||
host = "host"
|
||||
)
|
||||
|
||||
d.md.authorizePath = mdx.GetString(md, authorizePath)
|
||||
d.md.authorizePath = mdutil.GetString(md, authorizePath)
|
||||
if !strings.HasPrefix(d.md.authorizePath, "/") {
|
||||
d.md.authorizePath = defaultAuthorizePath
|
||||
}
|
||||
d.md.pushPath = mdx.GetString(md, pushPath)
|
||||
d.md.pushPath = mdutil.GetString(md, pushPath)
|
||||
if !strings.HasPrefix(d.md.pushPath, "/") {
|
||||
d.md.pushPath = defaultPushPath
|
||||
}
|
||||
d.md.pullPath = mdx.GetString(md, pullPath)
|
||||
d.md.pullPath = mdutil.GetString(md, pullPath)
|
||||
if !strings.HasPrefix(d.md.pullPath, "/") {
|
||||
d.md.pullPath = defaultPullPath
|
||||
}
|
||||
|
||||
d.md.host = mdx.GetString(md, host)
|
||||
d.md.host = mdutil.GetString(md, host)
|
||||
return
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"time"
|
||||
|
||||
mdata "github.com/go-gost/core/metadata"
|
||||
mdx "github.com/go-gost/x/metadata"
|
||||
mdutil "github.com/go-gost/core/metadata/util"
|
||||
)
|
||||
|
||||
type metadata struct {
|
||||
@ -21,14 +21,14 @@ func (d *icmpDialer) parseMetadata(md mdata.Metadata) (err error) {
|
||||
maxIdleTimeout = "maxIdleTimeout"
|
||||
)
|
||||
|
||||
if mdx.GetBool(md, keepAlive) {
|
||||
d.md.keepAlivePeriod = mdx.GetDuration(md, keepAlivePeriod)
|
||||
if mdutil.GetBool(md, keepAlive) {
|
||||
d.md.keepAlivePeriod = mdutil.GetDuration(md, keepAlivePeriod)
|
||||
if d.md.keepAlivePeriod <= 0 {
|
||||
d.md.keepAlivePeriod = 10 * time.Second
|
||||
}
|
||||
}
|
||||
d.md.handshakeTimeout = mdx.GetDuration(md, handshakeTimeout)
|
||||
d.md.maxIdleTimeout = mdx.GetDuration(md, maxIdleTimeout)
|
||||
d.md.handshakeTimeout = mdutil.GetDuration(md, handshakeTimeout)
|
||||
d.md.maxIdleTimeout = mdutil.GetDuration(md, maxIdleTimeout)
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -5,8 +5,8 @@ import (
|
||||
"time"
|
||||
|
||||
mdata "github.com/go-gost/core/metadata"
|
||||
mdutil "github.com/go-gost/core/metadata/util"
|
||||
kcp_util "github.com/go-gost/x/internal/util/kcp"
|
||||
mdx "github.com/go-gost/x/metadata"
|
||||
)
|
||||
|
||||
type metadata struct {
|
||||
@ -21,14 +21,14 @@ func (d *kcpDialer) parseMetadata(md mdata.Metadata) (err error) {
|
||||
handshakeTimeout = "handshakeTimeout"
|
||||
)
|
||||
|
||||
if file := mdx.GetString(md, configFile); file != "" {
|
||||
if file := mdutil.GetString(md, configFile); file != "" {
|
||||
d.md.config, err = kcp_util.ParseFromFile(file)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if m := mdx.GetStringMap(md, config); len(m) > 0 {
|
||||
if m := mdutil.GetStringMap(md, config); len(m) > 0 {
|
||||
b, err := json.Marshal(m)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -43,6 +43,6 @@ func (d *kcpDialer) parseMetadata(md mdata.Metadata) (err error) {
|
||||
d.md.config = kcp_util.DefaultConfig
|
||||
}
|
||||
|
||||
d.md.handshakeTimeout = mdx.GetDuration(md, handshakeTimeout)
|
||||
d.md.handshakeTimeout = mdutil.GetDuration(md, handshakeTimeout)
|
||||
return
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"time"
|
||||
|
||||
mdata "github.com/go-gost/core/metadata"
|
||||
mdx "github.com/go-gost/x/metadata"
|
||||
mdutil "github.com/go-gost/core/metadata/util"
|
||||
)
|
||||
|
||||
type metadata struct {
|
||||
@ -30,14 +30,14 @@ func (d *mtlsDialer) parseMetadata(md mdata.Metadata) (err error) {
|
||||
muxMaxStreamBuffer = "muxMaxStreamBuffer"
|
||||
)
|
||||
|
||||
d.md.handshakeTimeout = mdx.GetDuration(md, handshakeTimeout)
|
||||
d.md.handshakeTimeout = mdutil.GetDuration(md, handshakeTimeout)
|
||||
|
||||
d.md.muxKeepAliveDisabled = mdx.GetBool(md, muxKeepAliveDisabled)
|
||||
d.md.muxKeepAliveInterval = mdx.GetDuration(md, muxKeepAliveInterval)
|
||||
d.md.muxKeepAliveTimeout = mdx.GetDuration(md, muxKeepAliveTimeout)
|
||||
d.md.muxMaxFrameSize = mdx.GetInt(md, muxMaxFrameSize)
|
||||
d.md.muxMaxReceiveBuffer = mdx.GetInt(md, muxMaxReceiveBuffer)
|
||||
d.md.muxMaxStreamBuffer = mdx.GetInt(md, muxMaxStreamBuffer)
|
||||
d.md.muxKeepAliveDisabled = mdutil.GetBool(md, muxKeepAliveDisabled)
|
||||
d.md.muxKeepAliveInterval = mdutil.GetDuration(md, muxKeepAliveInterval)
|
||||
d.md.muxKeepAliveTimeout = mdutil.GetDuration(md, muxKeepAliveTimeout)
|
||||
d.md.muxMaxFrameSize = mdutil.GetInt(md, muxMaxFrameSize)
|
||||
d.md.muxMaxReceiveBuffer = mdutil.GetInt(md, muxMaxReceiveBuffer)
|
||||
d.md.muxMaxStreamBuffer = mdutil.GetInt(md, muxMaxStreamBuffer)
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
"time"
|
||||
|
||||
mdata "github.com/go-gost/core/metadata"
|
||||
mdx "github.com/go-gost/x/metadata"
|
||||
mdutil "github.com/go-gost/core/metadata/util"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -55,34 +55,34 @@ func (d *mwsDialer) parseMetadata(md mdata.Metadata) (err error) {
|
||||
muxMaxStreamBuffer = "muxMaxStreamBuffer"
|
||||
)
|
||||
|
||||
d.md.host = mdx.GetString(md, host)
|
||||
d.md.host = mdutil.GetString(md, host)
|
||||
|
||||
d.md.path = mdx.GetString(md, path)
|
||||
d.md.path = mdutil.GetString(md, path)
|
||||
if d.md.path == "" {
|
||||
d.md.path = defaultPath
|
||||
}
|
||||
|
||||
d.md.muxKeepAliveDisabled = mdx.GetBool(md, muxKeepAliveDisabled)
|
||||
d.md.muxKeepAliveInterval = mdx.GetDuration(md, muxKeepAliveInterval)
|
||||
d.md.muxKeepAliveTimeout = mdx.GetDuration(md, muxKeepAliveTimeout)
|
||||
d.md.muxMaxFrameSize = mdx.GetInt(md, muxMaxFrameSize)
|
||||
d.md.muxMaxReceiveBuffer = mdx.GetInt(md, muxMaxReceiveBuffer)
|
||||
d.md.muxMaxStreamBuffer = mdx.GetInt(md, muxMaxStreamBuffer)
|
||||
d.md.muxKeepAliveDisabled = mdutil.GetBool(md, muxKeepAliveDisabled)
|
||||
d.md.muxKeepAliveInterval = mdutil.GetDuration(md, muxKeepAliveInterval)
|
||||
d.md.muxKeepAliveTimeout = mdutil.GetDuration(md, muxKeepAliveTimeout)
|
||||
d.md.muxMaxFrameSize = mdutil.GetInt(md, muxMaxFrameSize)
|
||||
d.md.muxMaxReceiveBuffer = mdutil.GetInt(md, muxMaxReceiveBuffer)
|
||||
d.md.muxMaxStreamBuffer = mdutil.GetInt(md, muxMaxStreamBuffer)
|
||||
|
||||
d.md.handshakeTimeout = mdx.GetDuration(md, handshakeTimeout)
|
||||
d.md.readHeaderTimeout = mdx.GetDuration(md, readHeaderTimeout)
|
||||
d.md.readBufferSize = mdx.GetInt(md, readBufferSize)
|
||||
d.md.writeBufferSize = mdx.GetInt(md, writeBufferSize)
|
||||
d.md.enableCompression = mdx.GetBool(md, enableCompression)
|
||||
d.md.handshakeTimeout = mdutil.GetDuration(md, handshakeTimeout)
|
||||
d.md.readHeaderTimeout = mdutil.GetDuration(md, readHeaderTimeout)
|
||||
d.md.readBufferSize = mdutil.GetInt(md, readBufferSize)
|
||||
d.md.writeBufferSize = mdutil.GetInt(md, writeBufferSize)
|
||||
d.md.enableCompression = mdutil.GetBool(md, enableCompression)
|
||||
|
||||
if m := mdx.GetStringMapString(md, header); len(m) > 0 {
|
||||
if m := mdutil.GetStringMapString(md, header); len(m) > 0 {
|
||||
h := http.Header{}
|
||||
for k, v := range m {
|
||||
h.Add(k, v)
|
||||
}
|
||||
d.md.header = h
|
||||
}
|
||||
d.md.keepAlive = mdx.GetDuration(md, keepAlive)
|
||||
d.md.keepAlive = mdutil.GetDuration(md, keepAlive)
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"net/http"
|
||||
|
||||
mdata "github.com/go-gost/core/metadata"
|
||||
mdx "github.com/go-gost/x/metadata"
|
||||
mdutil "github.com/go-gost/core/metadata/util"
|
||||
)
|
||||
|
||||
type metadata struct {
|
||||
@ -18,13 +18,13 @@ func (d *obfsHTTPDialer) parseMetadata(md mdata.Metadata) (err error) {
|
||||
host = "host"
|
||||
)
|
||||
|
||||
if m := mdx.GetStringMapString(md, header); len(m) > 0 {
|
||||
if m := mdutil.GetStringMapString(md, header); len(m) > 0 {
|
||||
h := http.Header{}
|
||||
for k, v := range m {
|
||||
h.Add(k, v)
|
||||
}
|
||||
d.md.header = h
|
||||
}
|
||||
d.md.host = mdx.GetString(md, host)
|
||||
d.md.host = mdutil.GetString(md, host)
|
||||
return
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package tls
|
||||
|
||||
import (
|
||||
mdata "github.com/go-gost/core/metadata"
|
||||
mdx "github.com/go-gost/x/metadata"
|
||||
mdutil "github.com/go-gost/core/metadata/util"
|
||||
)
|
||||
|
||||
type metadata struct {
|
||||
@ -14,6 +14,6 @@ func (d *obfsTLSDialer) parseMetadata(md mdata.Metadata) (err error) {
|
||||
host = "host"
|
||||
)
|
||||
|
||||
d.md.host = mdx.GetString(md, host)
|
||||
d.md.host = mdutil.GetString(md, host)
|
||||
return
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
"time"
|
||||
|
||||
mdata "github.com/go-gost/core/metadata"
|
||||
mdx "github.com/go-gost/x/metadata"
|
||||
mdutil "github.com/go-gost/core/metadata/util"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -35,19 +35,19 @@ func (d *phtDialer) parseMetadata(md mdata.Metadata) (err error) {
|
||||
host = "host"
|
||||
)
|
||||
|
||||
d.md.authorizePath = mdx.GetString(md, authorizePath)
|
||||
d.md.authorizePath = mdutil.GetString(md, authorizePath)
|
||||
if !strings.HasPrefix(d.md.authorizePath, "/") {
|
||||
d.md.authorizePath = defaultAuthorizePath
|
||||
}
|
||||
d.md.pushPath = mdx.GetString(md, pushPath)
|
||||
d.md.pushPath = mdutil.GetString(md, pushPath)
|
||||
if !strings.HasPrefix(d.md.pushPath, "/") {
|
||||
d.md.pushPath = defaultPushPath
|
||||
}
|
||||
d.md.pullPath = mdx.GetString(md, pullPath)
|
||||
d.md.pullPath = mdutil.GetString(md, pullPath)
|
||||
if !strings.HasPrefix(d.md.pullPath, "/") {
|
||||
d.md.pullPath = defaultPullPath
|
||||
}
|
||||
|
||||
d.md.host = mdx.GetString(md, host)
|
||||
d.md.host = mdutil.GetString(md, host)
|
||||
return
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"time"
|
||||
|
||||
mdata "github.com/go-gost/core/metadata"
|
||||
mdx "github.com/go-gost/x/metadata"
|
||||
mdutil "github.com/go-gost/core/metadata/util"
|
||||
)
|
||||
|
||||
type metadata struct {
|
||||
@ -25,18 +25,18 @@ func (d *quicDialer) parseMetadata(md mdata.Metadata) (err error) {
|
||||
cipherKey = "cipherKey"
|
||||
)
|
||||
|
||||
if key := mdx.GetString(md, cipherKey); key != "" {
|
||||
if key := mdutil.GetString(md, cipherKey); key != "" {
|
||||
d.md.cipherKey = []byte(key)
|
||||
}
|
||||
|
||||
if mdx.GetBool(md, keepAlive) {
|
||||
d.md.keepAlivePeriod = mdx.GetDuration(md, keepAlivePeriod)
|
||||
if mdutil.GetBool(md, keepAlive) {
|
||||
d.md.keepAlivePeriod = mdutil.GetDuration(md, keepAlivePeriod)
|
||||
if d.md.keepAlivePeriod <= 0 {
|
||||
d.md.keepAlivePeriod = 10 * time.Second
|
||||
}
|
||||
}
|
||||
d.md.handshakeTimeout = mdx.GetDuration(md, handshakeTimeout)
|
||||
d.md.maxIdleTimeout = mdx.GetDuration(md, maxIdleTimeout)
|
||||
d.md.handshakeTimeout = mdutil.GetDuration(md, handshakeTimeout)
|
||||
d.md.maxIdleTimeout = mdutil.GetDuration(md, maxIdleTimeout)
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
"time"
|
||||
|
||||
mdata "github.com/go-gost/core/metadata"
|
||||
mdx "github.com/go-gost/x/metadata"
|
||||
mdutil "github.com/go-gost/core/metadata/util"
|
||||
"golang.org/x/crypto/ssh"
|
||||
)
|
||||
|
||||
@ -21,13 +21,13 @@ func (d *sshDialer) parseMetadata(md mdata.Metadata) (err error) {
|
||||
passphrase = "passphrase"
|
||||
)
|
||||
|
||||
if key := mdx.GetString(md, privateKeyFile); key != "" {
|
||||
if key := mdutil.GetString(md, privateKeyFile); key != "" {
|
||||
data, err := ioutil.ReadFile(key)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
pp := mdx.GetString(md, passphrase)
|
||||
pp := mdutil.GetString(md, passphrase)
|
||||
if pp == "" {
|
||||
d.md.signer, err = ssh.ParsePrivateKey(data)
|
||||
} else {
|
||||
@ -38,7 +38,7 @@ func (d *sshDialer) parseMetadata(md mdata.Metadata) (err error) {
|
||||
}
|
||||
}
|
||||
|
||||
d.md.handshakeTimeout = mdx.GetDuration(md, handshakeTimeout)
|
||||
d.md.handshakeTimeout = mdutil.GetDuration(md, handshakeTimeout)
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
"time"
|
||||
|
||||
mdata "github.com/go-gost/core/metadata"
|
||||
mdx "github.com/go-gost/x/metadata"
|
||||
mdutil "github.com/go-gost/core/metadata/util"
|
||||
"golang.org/x/crypto/ssh"
|
||||
)
|
||||
|
||||
@ -21,13 +21,13 @@ func (d *sshdDialer) parseMetadata(md mdata.Metadata) (err error) {
|
||||
passphrase = "passphrase"
|
||||
)
|
||||
|
||||
if key := mdx.GetString(md, privateKeyFile); key != "" {
|
||||
if key := mdutil.GetString(md, privateKeyFile); key != "" {
|
||||
data, err := ioutil.ReadFile(key)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
pp := mdx.GetString(md, passphrase)
|
||||
pp := mdutil.GetString(md, passphrase)
|
||||
if pp == "" {
|
||||
d.md.signer, err = ssh.ParsePrivateKey(data)
|
||||
} else {
|
||||
@ -38,7 +38,7 @@ func (d *sshdDialer) parseMetadata(md mdata.Metadata) (err error) {
|
||||
}
|
||||
}
|
||||
|
||||
d.md.handshakeTimeout = mdx.GetDuration(md, handshakeTimeout)
|
||||
d.md.handshakeTimeout = mdutil.GetDuration(md, handshakeTimeout)
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"time"
|
||||
|
||||
mdata "github.com/go-gost/core/metadata"
|
||||
mdx "github.com/go-gost/x/metadata"
|
||||
mdutil "github.com/go-gost/core/metadata/util"
|
||||
)
|
||||
|
||||
type metadata struct {
|
||||
@ -16,7 +16,7 @@ func (d *tlsDialer) parseMetadata(md mdata.Metadata) (err error) {
|
||||
handshakeTimeout = "handshakeTimeout"
|
||||
)
|
||||
|
||||
d.md.handshakeTimeout = mdx.GetDuration(md, handshakeTimeout)
|
||||
d.md.handshakeTimeout = mdutil.GetDuration(md, handshakeTimeout)
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
"time"
|
||||
|
||||
mdata "github.com/go-gost/core/metadata"
|
||||
mdx "github.com/go-gost/x/metadata"
|
||||
mdutil "github.com/go-gost/core/metadata/util"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -43,20 +43,20 @@ func (d *wsDialer) parseMetadata(md mdata.Metadata) (err error) {
|
||||
keepAlivePeriod = "ttl"
|
||||
)
|
||||
|
||||
d.md.host = mdx.GetString(md, host)
|
||||
d.md.host = mdutil.GetString(md, host)
|
||||
|
||||
d.md.path = mdx.GetString(md, path)
|
||||
d.md.path = mdutil.GetString(md, path)
|
||||
if d.md.path == "" {
|
||||
d.md.path = defaultPath
|
||||
}
|
||||
|
||||
d.md.handshakeTimeout = mdx.GetDuration(md, handshakeTimeout)
|
||||
d.md.readHeaderTimeout = mdx.GetDuration(md, readHeaderTimeout)
|
||||
d.md.readBufferSize = mdx.GetInt(md, readBufferSize)
|
||||
d.md.writeBufferSize = mdx.GetInt(md, writeBufferSize)
|
||||
d.md.enableCompression = mdx.GetBool(md, enableCompression)
|
||||
d.md.handshakeTimeout = mdutil.GetDuration(md, handshakeTimeout)
|
||||
d.md.readHeaderTimeout = mdutil.GetDuration(md, readHeaderTimeout)
|
||||
d.md.readBufferSize = mdutil.GetInt(md, readBufferSize)
|
||||
d.md.writeBufferSize = mdutil.GetInt(md, writeBufferSize)
|
||||
d.md.enableCompression = mdutil.GetBool(md, enableCompression)
|
||||
|
||||
if m := mdx.GetStringMapString(md, header); len(m) > 0 {
|
||||
if m := mdutil.GetStringMapString(md, header); len(m) > 0 {
|
||||
h := http.Header{}
|
||||
for k, v := range m {
|
||||
h.Add(k, v)
|
||||
@ -64,8 +64,8 @@ func (d *wsDialer) parseMetadata(md mdata.Metadata) (err error) {
|
||||
d.md.header = h
|
||||
}
|
||||
|
||||
if mdx.GetBool(md, keepAlive) {
|
||||
d.md.keepAlive = mdx.GetDuration(md, keepAlivePeriod)
|
||||
if mdutil.GetBool(md, keepAlive) {
|
||||
d.md.keepAlive = mdutil.GetDuration(md, keepAlivePeriod)
|
||||
if d.md.keepAlive <= 0 {
|
||||
d.md.keepAlive = defaultKeepAlivePeriod
|
||||
}
|
||||
|
Reference in New Issue
Block a user