Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
G
gost
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
gost
Commits
a5e06c66
Commit
a5e06c66
authored
Sep 29, 2016
by
rui.zheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix http2
parent
057a17be
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
74 additions
and
63 deletions
+74
-63
conn.go
conn.go
+48
-38
forward.go
forward.go
+1
-1
http.go
http.go
+18
-13
main.go
main.go
+2
-1
socks.go
socks.go
+1
-1
ss.go
ss.go
+1
-1
util.go
util.go
+3
-8
No files found.
conn.go
View file @
a5e06c66
...
@@ -52,13 +52,10 @@ func listenAndServe(arg Args) error {
...
@@ -52,13 +52,10 @@ func listenAndServe(arg Args) error {
case
"wss"
:
// websocket security connection
case
"wss"
:
// websocket security connection
return
NewWs
(
arg
)
.
listenAndServeTLS
()
return
NewWs
(
arg
)
.
listenAndServeTLS
()
case
"tls"
:
// tls connection
case
"tls"
:
// tls connection
if
arg
.
Protocol
==
"http2"
{
// only support http2 over TLS
return
listenAndServeHttp2
(
arg
,
http
.
HandlerFunc
(
handlerHttp2Request
))
}
ln
,
err
=
tls
.
Listen
(
"tcp"
,
arg
.
Addr
,
ln
,
err
=
tls
.
Listen
(
"tcp"
,
arg
.
Addr
,
&
tls
.
Config
{
Certificates
:
[]
tls
.
Certificate
{
arg
.
Cert
}})
&
tls
.
Config
{
Certificates
:
[]
tls
.
Certificate
{
arg
.
Cert
}})
case
"http2"
:
// http2 connetction
case
"http2"
:
// http2 connetction
return
listenAndServeHttp2
(
arg
,
http
.
HandlerFunc
(
handle
Http2Transpor
t
))
return
listenAndServeHttp2
(
arg
,
http
.
HandlerFunc
(
handle
rHttp2Reques
t
))
case
"tcp"
:
// Local TCP port forwarding
case
"tcp"
:
// Local TCP port forwarding
return
listenAndServeTcpForward
(
arg
)
return
listenAndServeTcpForward
(
arg
)
case
"udp"
:
// Local UDP port forwarding
case
"udp"
:
// Local UDP port forwarding
...
@@ -378,58 +375,71 @@ func (r *reqReader) Read(p []byte) (n int, err error) {
...
@@ -378,58 +375,71 @@ func (r *reqReader) Read(p []byte) (n int, err error) {
return
return
}
}
func
Connect
(
addr
string
)
(
conn
net
.
Conn
,
err
error
)
{
func
connect
(
addr
string
,
prot
string
,
chain
[]
Args
)
(
conn
net
.
Conn
,
err
error
)
{
if
len
(
forwardArgs
)
>
0
{
if
!
strings
.
Contains
(
addr
,
":"
)
{
last
:=
forwardArgs
[
len
(
forwardArgs
)
-
1
]
addr
+=
":80"
if
http2Client
!=
nil
&&
last
.
Protocol
==
"http2"
{
return
connectHttp2
(
http2Client
,
addr
)
}
}
}
return
connectWithChain
(
addr
,
forwardArgs
...
)
}
func
connectHttp2
(
client
*
http
.
Client
,
host
string
)
(
net
.
Conn
,
error
)
{
if
enabled
,
h2host
:=
http2Enabled
();
enabled
{
pr
,
pw
:=
io
.
Pipe
()
return
connectHttp2
(
http2Client
,
h2host
,
addr
,
prot
)
u
:=
url
.
URL
{
Scheme
:
"https"
,
Host
:
host
}
req
,
err
:=
http
.
NewRequest
(
http
.
MethodConnect
,
u
.
String
(),
ioutil
.
NopCloser
(
pr
))
if
err
!=
nil
{
return
nil
,
err
}
}
req
.
ContentLength
=
-
1
if
glog
.
V
(
LDEBUG
)
{
if
len
(
chain
)
==
0
{
dump
,
_
:=
httputil
.
DumpRequest
(
req
,
false
)
return
net
.
DialTimeout
(
"tcp"
,
addr
,
time
.
Second
*
90
)
glog
.
Infoln
(
string
(
dump
))
}
}
resp
,
err
:=
http2Client
.
Do
(
req
)
var
end
Args
conn
,
end
,
err
=
forwardChain
(
chain
...
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
resp
.
StatusCode
!=
http
.
StatusOK
{
if
err
:=
establish
(
conn
,
addr
,
end
);
err
!=
nil
{
resp
.
Body
.
Close
()
conn
.
Close
()
return
nil
,
err
ors
.
New
(
resp
.
Status
)
return
nil
,
err
}
}
conn
:=
&
Http2ClientConn
{
r
:
resp
.
Body
,
w
:
pw
}
conn
.
remoteAddr
,
_
=
net
.
ResolveTCPAddr
(
"tcp"
,
host
)
return
conn
,
nil
return
conn
,
nil
}
}
func
connectWithChain
(
addr
string
,
chain
...
Args
)
(
conn
net
.
Conn
,
err
error
)
{
func
http2Enabled
()
(
enabled
bool
,
host
string
)
{
if
!
strings
.
Contains
(
addr
,
":"
)
{
length
:=
len
(
forwardArgs
)
addr
+=
":80"
if
http2Client
==
nil
||
length
==
0
||
forwardArgs
[
length
-
1
]
.
Transport
!=
"http2"
{
return
}
}
if
len
(
chain
)
==
0
{
return
true
,
forwardArgs
[
length
-
1
]
.
Addr
return
net
.
DialTimeout
(
"tcp"
,
addr
,
time
.
Second
*
90
)
}
func
connectHttp2
(
client
*
http
.
Client
,
host
,
target
string
,
prot
string
)
(
net
.
Conn
,
error
)
{
pr
,
pw
:=
io
.
Pipe
()
req
:=
http
.
Request
{
Method
:
http
.
MethodConnect
,
URL
:
&
url
.
URL
{
Scheme
:
"https"
,
Host
:
host
},
Header
:
make
(
http
.
Header
),
Proto
:
"HTTP/2.0"
,
ProtoMajor
:
2
,
ProtoMinor
:
0
,
Body
:
ioutil
.
NopCloser
(
pr
),
Host
:
host
,
ContentLength
:
-
1
,
}
req
.
Header
.
Set
(
"gost-target-addr"
,
target
)
if
prot
!=
""
{
req
.
Header
.
Set
(
"gost-prot"
,
prot
)
}
}
var
end
Args
if
glog
.
V
(
LDEBUG
)
{
conn
,
end
,
err
=
forwardChain
(
chain
...
)
dump
,
_
:=
httputil
.
DumpRequest
(
&
req
,
false
)
glog
.
Infoln
(
string
(
dump
))
}
resp
,
err
:=
client
.
Do
(
&
req
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
err
:=
establish
(
conn
,
addr
,
end
);
err
!=
nil
{
if
resp
.
StatusCode
!=
http
.
StatusOK
{
conn
.
Close
()
resp
.
Body
.
Close
()
return
nil
,
err
return
nil
,
err
ors
.
New
(
resp
.
Status
)
}
}
conn
:=
&
Http2ClientConn
{
r
:
resp
.
Body
,
w
:
pw
}
conn
.
remoteAddr
,
_
=
net
.
ResolveTCPAddr
(
"tcp"
,
target
)
return
conn
,
nil
return
conn
,
nil
}
}
...
...
forward.go
View file @
a5e06c66
...
@@ -13,7 +13,7 @@ func handleTcpForward(conn net.Conn, raddr net.Addr) {
...
@@ -13,7 +13,7 @@ func handleTcpForward(conn net.Conn, raddr net.Addr) {
defer
conn
.
Close
()
defer
conn
.
Close
()
glog
.
V
(
LINFO
)
.
Infof
(
"[tcp] %s - %s"
,
conn
.
RemoteAddr
(),
raddr
)
glog
.
V
(
LINFO
)
.
Infof
(
"[tcp] %s - %s"
,
conn
.
RemoteAddr
(),
raddr
)
c
,
err
:=
Connect
(
raddr
.
String
()
)
c
,
err
:=
connect
(
raddr
.
String
(),
""
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
V
(
LWARNING
)
.
Infof
(
"[tcp] %s -> %s : %s"
,
conn
.
RemoteAddr
(),
raddr
,
err
)
glog
.
V
(
LWARNING
)
.
Infof
(
"[tcp] %s -> %s : %s"
,
conn
.
RemoteAddr
(),
raddr
,
err
)
return
return
...
...
http.go
View file @
a5e06c66
...
@@ -19,7 +19,7 @@ var (
...
@@ -19,7 +19,7 @@ var (
)
)
func
handleHttpRequest
(
req
*
http
.
Request
,
conn
net
.
Conn
,
arg
Args
)
{
func
handleHttpRequest
(
req
*
http
.
Request
,
conn
net
.
Conn
,
arg
Args
)
{
glog
.
V
(
LINFO
)
.
Infof
(
"[http] %s
- %s"
,
conn
.
RemoteAddr
(),
req
.
Host
)
glog
.
V
(
LINFO
)
.
Infof
(
"[http] %s
%s - %s %s"
,
req
.
Method
,
conn
.
RemoteAddr
(),
req
.
Host
,
req
.
Proto
)
if
glog
.
V
(
LDEBUG
)
{
if
glog
.
V
(
LDEBUG
)
{
dump
,
_
:=
httputil
.
DumpRequest
(
req
,
false
)
dump
,
_
:=
httputil
.
DumpRequest
(
req
,
false
)
...
@@ -55,7 +55,8 @@ func handleHttpRequest(req *http.Request, conn net.Conn, arg Args) {
...
@@ -55,7 +55,8 @@ func handleHttpRequest(req *http.Request, conn net.Conn, arg Args) {
return
return
}
}
}
}
c
,
err
:=
Connect
(
req
.
Host
)
c
,
err
:=
connect
(
req
.
Host
,
"http"
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
V
(
LWARNING
)
.
Infof
(
"[http] %s -> %s : %s"
,
conn
.
RemoteAddr
(),
req
.
Host
,
err
)
glog
.
V
(
LWARNING
)
.
Infof
(
"[http] %s -> %s : %s"
,
conn
.
RemoteAddr
(),
req
.
Host
,
err
)
...
@@ -160,7 +161,6 @@ func (c *Http2ClientConn) SetWriteDeadline(t time.Time) error {
...
@@ -160,7 +161,6 @@ func (c *Http2ClientConn) SetWriteDeadline(t time.Time) error {
// init http2 client with target http2 proxy server addr, and forward chain chain
// init http2 client with target http2 proxy server addr, and forward chain chain
func
initHttp2Client
(
host
string
,
chain
...
Args
)
{
func
initHttp2Client
(
host
string
,
chain
...
Args
)
{
glog
.
V
(
LINFO
)
.
Infoln
(
"init http2 client"
)
tr
:=
http2
.
Transport
{
tr
:=
http2
.
Transport
{
TLSClientConfig
:
&
tls
.
Config
{
TLSClientConfig
:
&
tls
.
Config
{
InsecureSkipVerify
:
true
,
InsecureSkipVerify
:
true
,
...
@@ -178,15 +178,20 @@ func initHttp2Client(host string, chain ...Args) {
...
@@ -178,15 +178,20 @@ func initHttp2Client(host string, chain ...Args) {
}
}
func
handlerHttp2Request
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
func
handlerHttp2Request
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
glog
.
V
(
LINFO
)
.
Infof
(
"[http2] %s - %s"
,
req
.
RemoteAddr
,
req
.
Host
)
target
:=
req
.
Header
.
Get
(
"gost-target-addr"
)
if
target
==
""
{
target
=
req
.
Host
}
glog
.
V
(
LINFO
)
.
Infof
(
"[http2] %s %s - %s %s"
,
req
.
Method
,
req
.
RemoteAddr
,
target
,
req
.
Proto
)
if
glog
.
V
(
LDEBUG
)
{
if
glog
.
V
(
LDEBUG
)
{
dump
,
_
:=
httputil
.
DumpRequest
(
req
,
false
)
dump
,
_
:=
httputil
.
DumpRequest
(
req
,
false
)
glog
.
Infoln
(
string
(
dump
))
glog
.
Infoln
(
string
(
dump
))
}
}
c
,
err
:=
Connect
(
req
.
Host
)
c
,
err
:=
connect
(
target
,
req
.
Header
.
Get
(
"gost-prot"
)
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
V
(
LWARNING
)
.
Infof
(
"[http2] %s -> %s : %s"
,
req
.
RemoteAddr
,
req
.
Hos
t
,
err
)
glog
.
V
(
LWARNING
)
.
Infof
(
"[http2] %s -> %s : %s"
,
req
.
RemoteAddr
,
targe
t
,
err
)
w
.
Header
()
.
Set
(
"Proxy-Agent"
,
"gost/"
+
Version
)
w
.
Header
()
.
Set
(
"Proxy-Agent"
,
"gost/"
+
Version
)
w
.
WriteHeader
(
http
.
StatusServiceUnavailable
)
w
.
WriteHeader
(
http
.
StatusServiceUnavailable
)
if
fw
,
ok
:=
w
.
(
http
.
Flusher
);
ok
{
if
fw
,
ok
:=
w
.
(
http
.
Flusher
);
ok
{
...
@@ -196,7 +201,7 @@ func handlerHttp2Request(w http.ResponseWriter, req *http.Request) {
...
@@ -196,7 +201,7 @@ func handlerHttp2Request(w http.ResponseWriter, req *http.Request) {
}
}
defer
c
.
Close
()
defer
c
.
Close
()
glog
.
V
(
LINFO
)
.
Infof
(
"[http2] %s <-> %s"
,
req
.
RemoteAddr
,
req
.
Hos
t
)
glog
.
V
(
LINFO
)
.
Infof
(
"[http2] %s <-> %s"
,
req
.
RemoteAddr
,
targe
t
)
errc
:=
make
(
chan
error
,
2
)
errc
:=
make
(
chan
error
,
2
)
if
req
.
Method
==
http
.
MethodConnect
{
if
req
.
Method
==
http
.
MethodConnect
{
...
@@ -211,7 +216,7 @@ func handlerHttp2Request(w http.ResponseWriter, req *http.Request) {
...
@@ -211,7 +216,7 @@ func handlerHttp2Request(w http.ResponseWriter, req *http.Request) {
// we take over the underly connection
// we take over the underly connection
conn
,
_
,
err
:=
hj
.
Hijack
()
conn
,
_
,
err
:=
hj
.
Hijack
()
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
V
(
LWARNING
)
.
Infof
(
"[http2] %s -> %s : %s"
,
req
.
RemoteAddr
,
req
.
Hos
t
,
err
)
glog
.
V
(
LWARNING
)
.
Infof
(
"[http2] %s -> %s : %s"
,
req
.
RemoteAddr
,
targe
t
,
err
)
return
return
}
}
defer
conn
.
Close
()
defer
conn
.
Close
()
...
@@ -230,7 +235,7 @@ func handlerHttp2Request(w http.ResponseWriter, req *http.Request) {
...
@@ -230,7 +235,7 @@ func handlerHttp2Request(w http.ResponseWriter, req *http.Request) {
}
else
{
}
else
{
req
.
Header
.
Set
(
"Connection"
,
"Keep-Alive"
)
req
.
Header
.
Set
(
"Connection"
,
"Keep-Alive"
)
if
err
=
req
.
Write
(
c
);
err
!=
nil
{
if
err
=
req
.
Write
(
c
);
err
!=
nil
{
glog
.
V
(
LWARNING
)
.
Infof
(
"[http2] %s -> %s : %s"
,
req
.
RemoteAddr
,
req
.
Hos
t
,
err
)
glog
.
V
(
LWARNING
)
.
Infof
(
"[http2] %s -> %s : %s"
,
req
.
RemoteAddr
,
targe
t
,
err
)
return
return
}
}
...
@@ -250,15 +255,16 @@ func handlerHttp2Request(w http.ResponseWriter, req *http.Request) {
...
@@ -250,15 +255,16 @@ func handlerHttp2Request(w http.ResponseWriter, req *http.Request) {
if
fw
,
ok
:=
w
.
(
http
.
Flusher
);
ok
{
if
fw
,
ok
:=
w
.
(
http
.
Flusher
);
ok
{
fw
.
Flush
()
fw
.
Flush
()
}
}
if
_
,
err
:=
io
.
Copy
(
flushWriter
{
w
},
resp
.
Body
);
err
!=
nil
{
if
_
,
err
:=
io
.
Copy
(
flushWriter
{
w
},
resp
.
Body
);
err
!=
nil
{
glog
.
V
(
LWARNING
)
.
Infof
(
"[http2] %s <- %s : %s"
,
req
.
RemoteAddr
,
req
.
Hos
t
,
err
)
glog
.
V
(
LWARNING
)
.
Infof
(
"[http2] %s <- %s : %s"
,
req
.
RemoteAddr
,
targe
t
,
err
)
}
}
}
}
glog
.
V
(
LINFO
)
.
Infof
(
"[http2] %s >-< %s"
,
req
.
RemoteAddr
,
req
.
Hos
t
)
glog
.
V
(
LINFO
)
.
Infof
(
"[http2] %s >-< %s"
,
req
.
RemoteAddr
,
targe
t
)
}
}
//func processSocks5OverHttp2()
func
handleHttp2Transport
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
func
handleHttp2Transport
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
glog
.
V
(
LINFO
)
.
Infof
(
"[http2] %s - %s"
,
req
.
RemoteAddr
,
req
.
Host
)
glog
.
V
(
LINFO
)
.
Infof
(
"[http2] %s - %s"
,
req
.
RemoteAddr
,
req
.
Host
)
if
glog
.
V
(
LDEBUG
)
{
if
glog
.
V
(
LDEBUG
)
{
...
@@ -296,7 +302,6 @@ func (fw flushWriter) Write(p []byte) (n int, err error) {
...
@@ -296,7 +302,6 @@ func (fw flushWriter) Write(p []byte) (n int, err error) {
n
,
err
=
fw
.
w
.
Write
(
p
)
n
,
err
=
fw
.
w
.
Write
(
p
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
V
(
LWARNING
)
.
Infoln
(
"flush writer:"
,
err
)
glog
.
V
(
LWARNING
)
.
Infoln
(
"flush writer:"
,
err
)
return
}
}
if
f
,
ok
:=
fw
.
w
.
(
http
.
Flusher
);
ok
{
if
f
,
ok
:=
fw
.
w
.
(
http
.
Flusher
);
ok
{
f
.
Flush
()
f
.
Flush
()
...
...
main.go
View file @
a5e06c66
...
@@ -17,6 +17,7 @@ const (
...
@@ -17,6 +17,7 @@ const (
LWARNING
LWARNING
LINFO
LINFO
LDEBUG
LDEBUG
LVDEBUG
// verbose debug
)
)
const
(
const
(
...
@@ -37,7 +38,7 @@ func init() {
...
@@ -37,7 +38,7 @@ func init() {
flag
.
BoolVar
(
&
pv
,
"V"
,
false
,
"print version"
)
flag
.
BoolVar
(
&
pv
,
"V"
,
false
,
"print version"
)
flag
.
Parse
()
flag
.
Parse
()
if
glog
.
V
(
LDEBUG
)
{
if
glog
.
V
(
L
V
DEBUG
)
{
http2
.
VerboseLogs
=
true
http2
.
VerboseLogs
=
true
}
}
}
}
...
...
socks.go
View file @
a5e06c66
...
@@ -170,7 +170,7 @@ func handleSocks5Request(req *gosocks5.Request, conn net.Conn) {
...
@@ -170,7 +170,7 @@ func handleSocks5Request(req *gosocks5.Request, conn net.Conn) {
case
gosocks5
.
CmdConnect
:
case
gosocks5
.
CmdConnect
:
glog
.
V
(
LINFO
)
.
Infof
(
"[socks5-connect] %s - %s"
,
conn
.
RemoteAddr
(),
req
.
Addr
)
glog
.
V
(
LINFO
)
.
Infof
(
"[socks5-connect] %s - %s"
,
conn
.
RemoteAddr
(),
req
.
Addr
)
tconn
,
err
:=
Connect
(
req
.
Addr
.
String
()
)
tconn
,
err
:=
connect
(
req
.
Addr
.
String
(),
"socks5"
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
V
(
LWARNING
)
.
Infof
(
"[socks5-connect] %s -> %s : %s"
,
conn
.
RemoteAddr
(),
req
.
Addr
,
err
)
glog
.
V
(
LWARNING
)
.
Infof
(
"[socks5-connect] %s -> %s : %s"
,
conn
.
RemoteAddr
(),
req
.
Addr
,
err
)
rep
:=
gosocks5
.
NewReply
(
gosocks5
.
HostUnreachable
,
nil
)
rep
:=
gosocks5
.
NewReply
(
gosocks5
.
HostUnreachable
,
nil
)
...
...
ss.go
View file @
a5e06c66
...
@@ -31,7 +31,7 @@ func handleShadow(conn net.Conn, arg Args) {
...
@@ -31,7 +31,7 @@ func handleShadow(conn net.Conn, arg Args) {
}
}
glog
.
V
(
LINFO
)
.
Infof
(
"[ss] %s -> %s"
,
conn
.
RemoteAddr
(),
addr
.
String
())
glog
.
V
(
LINFO
)
.
Infof
(
"[ss] %s -> %s"
,
conn
.
RemoteAddr
(),
addr
.
String
())
sconn
,
err
:=
Connect
(
addr
.
String
()
)
sconn
,
err
:=
connect
(
addr
.
String
(),
"ss"
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
V
(
LWARNING
)
.
Infof
(
"[ss] %s -> %s : %s"
,
conn
.
RemoteAddr
(),
addr
.
String
(),
err
)
glog
.
V
(
LWARNING
)
.
Infof
(
"[ss] %s -> %s : %s"
,
conn
.
RemoteAddr
(),
addr
.
String
(),
err
)
return
return
...
...
util.go
View file @
a5e06c66
...
@@ -79,7 +79,7 @@ func parseArgs(ss []string) (args []Args) {
...
@@ -79,7 +79,7 @@ func parseArgs(ss []string) (args []Args) {
arg
.
Protocol
=
"http"
arg
.
Protocol
=
"http"
arg
.
Transport
=
"tls"
arg
.
Transport
=
"tls"
case
"http2"
:
case
"http2"
:
arg
.
Protocol
=
""
arg
.
Protocol
=
"
http2
"
case
"tcp"
,
"udp"
:
// started from v2.1, tcp and udp are for local port forwarding
case
"tcp"
,
"udp"
:
// started from v2.1, tcp and udp are for local port forwarding
arg
.
Remote
=
strings
.
Trim
(
u
.
EscapedPath
(),
"/"
)
arg
.
Remote
=
strings
.
Trim
(
u
.
EscapedPath
(),
"/"
)
case
"rtcp"
,
"rudp"
:
// started from v2.1, rtcp and rudp are for remote port forwarding
case
"rtcp"
,
"rudp"
:
// started from v2.1, rtcp and rudp are for remote port forwarding
...
@@ -89,9 +89,7 @@ func parseArgs(ss []string) (args []Args) {
...
@@ -89,9 +89,7 @@ func parseArgs(ss []string) (args []Args) {
}
}
switch
arg
.
Protocol
{
switch
arg
.
Protocol
{
case
"http"
,
"socks"
,
"socks5"
,
"ss"
:
case
"http"
,
"http2"
,
"socks"
,
"socks5"
,
"ss"
:
case
"http2"
:
arg
.
Transport
=
"tls"
// standard http2 proxy, only support http2 over tls
default
:
default
:
arg
.
Protocol
=
""
arg
.
Protocol
=
""
}
}
...
@@ -112,14 +110,11 @@ func processForwardChain(chain ...Args) {
...
@@ -112,14 +110,11 @@ func processForwardChain(chain ...Args) {
// http2 restrict: only last proxy can enable http2
// http2 restrict: only last proxy can enable http2
for
i
,
_
:=
range
c
{
for
i
,
_
:=
range
c
{
if
c
[
i
]
.
Protocol
==
"http2"
{
c
[
i
]
.
Protocol
=
"http"
}
if
c
[
i
]
.
Transport
==
"http2"
{
if
c
[
i
]
.
Transport
==
"http2"
{
c
[
i
]
.
Transport
=
""
c
[
i
]
.
Transport
=
""
}
}
}
}
if
last
.
Protocol
==
"http2"
||
last
.
Transport
==
"http2"
{
if
last
.
Transport
==
"http2"
{
initHttp2Client
(
last
.
Addr
,
c
...
)
initHttp2Client
(
last
.
Addr
,
c
...
)
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment