add obfs dialer
This commit is contained in:
@ -136,8 +136,8 @@ func (h *httpHandler) handleRequest(ctx context.Context, conn net.Conn, req *htt
|
||||
Header: http.Header{},
|
||||
}
|
||||
|
||||
if h.md.proxyAgent != "" {
|
||||
resp.Header.Add("Proxy-Agent", h.md.proxyAgent)
|
||||
for k, v := range h.md.headers {
|
||||
resp.Header.Set(k, v)
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1,6 +1,7 @@
|
||||
package http
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/go-gost/gost/pkg/auth"
|
||||
@ -8,17 +9,17 @@ import (
|
||||
)
|
||||
|
||||
type metadata struct {
|
||||
authenticator auth.Authenticator
|
||||
proxyAgent string
|
||||
retryCount int
|
||||
authenticator auth.Authenticator
|
||||
probeResist *probeResist
|
||||
sni bool
|
||||
enableUDP bool
|
||||
headers map[string]string
|
||||
}
|
||||
|
||||
func (h *httpHandler) parseMetadata(md md.Metadata) error {
|
||||
const (
|
||||
proxyAgent = "proxyAgent"
|
||||
headers = "headers"
|
||||
users = "users"
|
||||
probeResistKey = "probeResist"
|
||||
knock = "knock"
|
||||
@ -27,8 +28,6 @@ func (h *httpHandler) parseMetadata(md md.Metadata) error {
|
||||
enableUDP = "udp"
|
||||
)
|
||||
|
||||
h.md.proxyAgent = md.GetString(proxyAgent)
|
||||
|
||||
if v, _ := md.Get(users).([]interface{}); len(v) > 0 {
|
||||
authenticator := auth.NewLocalAuthenticator(nil)
|
||||
for _, auth := range v {
|
||||
@ -44,6 +43,14 @@ func (h *httpHandler) parseMetadata(md md.Metadata) error {
|
||||
h.md.authenticator = authenticator
|
||||
}
|
||||
|
||||
if mm, _ := md.Get(headers).(map[interface{}]interface{}); len(mm) > 0 {
|
||||
m := make(map[string]string)
|
||||
for k, v := range mm {
|
||||
m[fmt.Sprintf("%v", k)] = fmt.Sprintf("%v", v)
|
||||
}
|
||||
h.md.headers = m
|
||||
}
|
||||
|
||||
if v := md.GetString(probeResistKey); v != "" {
|
||||
if ss := strings.SplitN(v, ":", 2); len(ss) == 2 {
|
||||
h.md.probeResist = &probeResist{
|
||||
|
@ -23,8 +23,8 @@ func (h *httpHandler) handleUDP(ctx context.Context, conn net.Conn, network, add
|
||||
ProtoMinor: 1,
|
||||
Header: http.Header{},
|
||||
}
|
||||
if h.md.proxyAgent != "" {
|
||||
resp.Header.Add("Proxy-Agent", h.md.proxyAgent)
|
||||
for k, v := range h.md.headers {
|
||||
resp.Header.Set(k, v)
|
||||
}
|
||||
|
||||
if !h.md.enableUDP {
|
||||
|
Reference in New Issue
Block a user