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
b244ce00
"...Irrlicht/svn:/svn.code.sf.net/p/irrlicht/code/trunk@1760" did not exist on "1761aa4b96ce5f1f8ca1b412c37392ef51184057"
Commit
b244ce00
authored
Jan 13, 2017
by
rui.zheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add ping-pong support for HTTP2
parent
e476a9f7
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
3 deletions
+44
-3
chain.go
chain.go
+43
-2
gost.go
gost.go
+1
-1
No files found.
chain.go
View file @
b244ce00
package
gost
import
(
"crypto/rand"
"crypto/tls"
"encoding/base64"
"errors"
"github.com/golang/glog"
"golang.org/x/net/http2"
"io"
//"io/ioutil"
"net"
"net/http"
"net/http/httputil"
"net/url"
"strconv"
"strings"
"sync"
"time"
)
// Proxy chain holds a list of proxy nodes
...
...
@@ -134,7 +136,15 @@ func (c *ProxyChain) initHttp2Client(config *tls.Config, nodes ...ProxyNode) {
if
err
!=
nil
{
return
conn
,
err
}
return
tls
.
Client
(
conn
,
cfg
),
nil
conn
=
tls
.
Client
(
conn
,
cfg
)
// enable HTTP2 ping-pong
pingIntvl
,
_
:=
strconv
.
Atoi
(
http2Node
.
Get
(
"ping"
))
if
pingIntvl
>
0
{
enablePing
(
conn
,
time
.
Duration
(
pingIntvl
)
*
time
.
Second
)
}
return
conn
,
nil
},
}
c
.
http2Client
=
&
http
.
Client
{
Transport
:
&
tr
}
...
...
@@ -142,6 +152,37 @@ func (c *ProxyChain) initHttp2Client(config *tls.Config, nodes ...ProxyNode) {
}
func
enablePing
(
conn
net
.
Conn
,
interval
time
.
Duration
)
{
if
conn
==
nil
||
interval
==
0
{
return
}
glog
.
V
(
LINFO
)
.
Infoln
(
"[http2] ping enabled, interval:"
,
interval
)
go
func
()
{
t
:=
time
.
NewTicker
(
interval
)
var
framer
*
http2
.
Framer
for
{
select
{
case
<-
t
.
C
:
if
framer
==
nil
{
framer
=
http2
.
NewFramer
(
conn
,
conn
)
}
var
p
[
8
]
byte
rand
.
Read
(
p
[
:
])
err
:=
framer
.
WritePing
(
false
,
p
)
if
err
!=
nil
{
t
.
Stop
()
framer
=
nil
glog
.
V
(
LWARNING
)
.
Infoln
(
"[http2] ping:"
,
err
)
return
}
glog
.
V
(
LINFO
)
.
Infoln
(
"[http2] ping OK"
)
}
}
}()
}
// Connect to addr through proxy chain
func
(
c
*
ProxyChain
)
Dial
(
addr
string
)
(
net
.
Conn
,
error
)
{
if
!
strings
.
Contains
(
addr
,
":"
)
{
...
...
gost.go
View file @
b244ce00
...
...
@@ -11,7 +11,7 @@ import (
)
const
(
Version
=
"2.3-rc
1
"
Version
=
"2.3-rc
2
"
)
// Log level for glog
...
...
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