update config
This commit is contained in:
@ -15,6 +15,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/asaskevich/govalidator"
|
||||
"github.com/go-gost/gost/pkg/auth"
|
||||
"github.com/go-gost/gost/pkg/bypass"
|
||||
"github.com/go-gost/gost/pkg/chain"
|
||||
"github.com/go-gost/gost/pkg/handler"
|
||||
@ -29,10 +30,11 @@ func init() {
|
||||
}
|
||||
|
||||
type http2Handler struct {
|
||||
bypass bypass.Bypass
|
||||
router *chain.Router
|
||||
logger logger.Logger
|
||||
md metadata
|
||||
bypass bypass.Bypass
|
||||
router *chain.Router
|
||||
authenticator auth.Authenticator
|
||||
logger logger.Logger
|
||||
md metadata
|
||||
}
|
||||
|
||||
func NewHandler(opts ...handler.Option) handler.Handler {
|
||||
@ -392,7 +394,7 @@ func (h *http2Handler) basicProxyAuth(proxyAuth string) (username, password stri
|
||||
|
||||
func (h *http2Handler) authenticate(conn net.Conn, req *http.Request, resp *http.Response) (ok bool) {
|
||||
u, p, _ := h.basicProxyAuth(req.Header.Get("Proxy-Authorization"))
|
||||
if h.md.authenticator == nil || h.md.authenticator.Authenticate(u, p) {
|
||||
if h.authenticator == nil || h.authenticator.Authenticate(u, p) {
|
||||
return true
|
||||
}
|
||||
|
||||
|
@ -3,22 +3,19 @@ package http2
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/go-gost/gost/pkg/auth"
|
||||
mdata "github.com/go-gost/gost/pkg/metadata"
|
||||
)
|
||||
|
||||
type metadata struct {
|
||||
authenticator auth.Authenticator
|
||||
proxyAgent string
|
||||
probeResist *probeResist
|
||||
sni bool
|
||||
enableUDP bool
|
||||
proxyAgent string
|
||||
probeResist *probeResist
|
||||
sni bool
|
||||
enableUDP bool
|
||||
}
|
||||
|
||||
func (h *http2Handler) parseMetadata(md mdata.Metadata) error {
|
||||
const (
|
||||
proxyAgent = "proxyAgent"
|
||||
users = "users"
|
||||
probeResistKey = "probeResist"
|
||||
knock = "knock"
|
||||
sni = "sni"
|
||||
@ -27,19 +24,6 @@ func (h *http2Handler) parseMetadata(md mdata.Metadata) error {
|
||||
|
||||
h.md.proxyAgent = mdata.GetString(md, proxyAgent)
|
||||
|
||||
if auths := mdata.GetStrings(md, users); len(auths) > 0 {
|
||||
authenticator := auth.NewLocalAuthenticator(nil)
|
||||
for _, auth := range auths {
|
||||
ss := strings.SplitN(auth, ":", 2)
|
||||
if len(ss) == 1 {
|
||||
authenticator.Add(ss[0], "")
|
||||
} else {
|
||||
authenticator.Add(ss[0], ss[1])
|
||||
}
|
||||
}
|
||||
h.md.authenticator = authenticator
|
||||
}
|
||||
|
||||
if v := mdata.GetString(md, probeResistKey); v != "" {
|
||||
if ss := strings.SplitN(v, ":", 2); len(ss) == 2 {
|
||||
h.md.probeResist = &probeResist{
|
||||
|
Reference in New Issue
Block a user