Commit b3461ea5 authored by rui.zheng's avatar rui.zheng

update

parent a5e06c66
......@@ -375,7 +375,7 @@ func (r *reqReader) Read(p []byte) (n int, err error) {
return
}
func connect(addr string, prot string, chain []Args) (conn net.Conn, err error) {
func connect(addr string, prot string, chain ...Args) (conn net.Conn, err error) {
if !strings.Contains(addr, ":") {
addr += ":80"
}
......@@ -421,9 +421,9 @@ func connectHttp2(client *http.Client, host, target string, prot string) (net.Co
Host: host,
ContentLength: -1,
}
req.Header.Set("gost-target-addr", target)
req.Header.Set("gost-target", target)
if prot != "" {
req.Header.Set("gost-prot", prot)
req.Header.Set("gost-protocol", prot)
}
if glog.V(LDEBUG) {
......
......@@ -13,7 +13,7 @@ func handleTcpForward(conn net.Conn, raddr net.Addr) {
defer conn.Close()
glog.V(LINFO).Infof("[tcp] %s - %s", conn.RemoteAddr(), raddr)
c, err := connect(raddr.String(), "")
c, err := connect(raddr.String(), "", forwardArgs...)
if err != nil {
glog.V(LWARNING).Infof("[tcp] %s -> %s : %s", conn.RemoteAddr(), raddr, err)
return
......
......@@ -56,7 +56,7 @@ func handleHttpRequest(req *http.Request, conn net.Conn, arg Args) {
}
}
c, err := connect(req.Host, "http")
c, err := connect(req.Host, "http", forwardArgs...)
if err != nil {
glog.V(LWARNING).Infof("[http] %s -> %s : %s", conn.RemoteAddr(), req.Host, err)
......@@ -167,7 +167,7 @@ func initHttp2Client(host string, chain ...Args) {
},
DialTLS: func(network, addr string, cfg *tls.Config) (net.Conn, error) {
// replace the default dialer with our forward chain.
conn, err := connectWithChain(host, chain...)
conn, err := connect(host, "http2", chain...)
if err != nil {
return conn, err
}
......@@ -178,7 +178,7 @@ func initHttp2Client(host string, chain ...Args) {
}
func handlerHttp2Request(w http.ResponseWriter, req *http.Request) {
target := req.Header.Get("gost-target-addr")
target := req.Header.Get("gost-target")
if target == "" {
target = req.Host
}
......@@ -189,7 +189,7 @@ func handlerHttp2Request(w http.ResponseWriter, req *http.Request) {
glog.Infoln(string(dump))
}
c, err := connect(target, req.Header.Get("gost-prot"))
c, err := connect(target, req.Header.Get("gost-protocol"), forwardArgs...)
if err != nil {
glog.V(LWARNING).Infof("[http2] %s -> %s : %s", req.RemoteAddr, target, err)
w.Header().Set("Proxy-Agent", "gost/"+Version)
......
......@@ -170,7 +170,7 @@ func handleSocks5Request(req *gosocks5.Request, conn net.Conn) {
case gosocks5.CmdConnect:
glog.V(LINFO).Infof("[socks5-connect] %s - %s", conn.RemoteAddr(), req.Addr)
tconn, err := connect(req.Addr.String(), "socks5")
tconn, err := connect(req.Addr.String(), "socks5", forwardArgs...)
if err != nil {
glog.V(LWARNING).Infof("[socks5-connect] %s -> %s : %s", conn.RemoteAddr(), req.Addr, err)
rep := gosocks5.NewReply(gosocks5.HostUnreachable, nil)
......
......@@ -31,7 +31,7 @@ func handleShadow(conn net.Conn, arg Args) {
}
glog.V(LINFO).Infof("[ss] %s -> %s", conn.RemoteAddr(), addr.String())
sconn, err := connect(addr.String(), "ss")
sconn, err := connect(addr.String(), "ss", forwardArgs...)
if err != nil {
glog.V(LWARNING).Infof("[ss] %s -> %s : %s", conn.RemoteAddr(), addr.String(), err)
return
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment