diff --git a/cmd/gost/route.go b/cmd/gost/route.go index cdbc0ed..38721da 100644 --- a/cmd/gost/route.go +++ b/cmd/gost/route.go @@ -51,11 +51,20 @@ func (r *route) parseChain() (*gost.Chain, error) { } ngroup.AddNode(nodes...) + maxFails := nodes[0].GetInt("max_fails") + if maxFails == 0 { + maxFails = defaultMaxFails + } + failTimeout := nodes[0].GetDuration("fail_timeout") + if failTimeout == 0 { + failTimeout = defaultFailTimeout + } + ngroup.SetSelector(nil, gost.WithFilter( &gost.FailFilter{ - MaxFails: defaultMaxFails, - FailTimeout: defaultFailTimeout, + MaxFails: maxFails, + FailTimeout: failTimeout, }, &gost.InvalidFilter{}, ), diff --git a/node.go b/node.go index 9acb2a0..7d063f3 100644 --- a/node.go +++ b/node.go @@ -7,6 +7,7 @@ import ( "strconv" "strings" "sync" + "time" ) var ( @@ -140,12 +141,21 @@ func (node *Node) GetInt(key string) int { return n } +func (node *Node) GetDuration(key string) time.Duration { + d, _ := time.ParseDuration(node.Values.Get(key)) + return d +} + func (node Node) String() string { - if node.url == nil { - return fmt.Sprintf("%s+%s://%s", - node.Protocol, node.Transport, node.Addr) + var scheme string + if node.url != nil { + scheme = node.url.Scheme } - return node.url.String() + if scheme == "" { + scheme = fmt.Sprintf("%s+%s", node.Protocol, node.Transport) + } + return fmt.Sprintf("%s://%s", + scheme, node.Addr) } // NodeGroup is a group of nodes. diff --git a/socks.go b/socks.go index 429194c..d9a94ba 100644 --- a/socks.go +++ b/socks.go @@ -19,9 +19,9 @@ import ( ) const ( - // MethodTLS is an extended SOCKS5 method for TLS. + // MethodTLS is an extended SOCKS5 method with tls encryption support. MethodTLS uint8 = 0x80 - // MethodTLSAuth is an extended SOCKS5 method for TLS+AUTH. + // MethodTLSAuth is an extended SOCKS5 method with tls encryption and authentication support. MethodTLSAuth uint8 = 0x82 // MethodMux is an extended SOCKS5 method for stream multiplexing. MethodMux = 0x88