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
cd842de2
Commit
cd842de2
authored
Nov 01, 2017
by
rui.zheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add multiplex support for ws/wss
parent
31f6d0af
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
429 additions
and
22 deletions
+429
-22
README.md
README.md
+5
-1
cmd/gost/main.go
cmd/gost/main.go
+23
-20
node.go
node.go
+1
-1
ws.go
ws.go
+400
-0
No files found.
README.md
View file @
cd842de2
...
...
@@ -26,6 +26,7 @@ gost - GO Simple Tunnel
*
SSH通道 (2.4+)
*
QUIC通道 (2.4+)
*
obfs4通道 (2.4+)
*
SNI (2.5+)
二进制文件下载:https://github.com/ginuerzh/gost/releases
...
...
@@ -53,7 +54,7 @@ $ sudo snap install gost
```
scheme分为两部分: protocol+transport
protocol: 代理协议类型(http, socks4(a), socks5, ss
), transport: 数据传输方式(ws, wss,
tls, quic, kcp, ssh, h2, h2c, obfs4), 二者可以任意组合,或单独使用:
protocol: 代理协议类型(http, socks4(a), socks5, ss
, sni), transport: 数据传输方式(ws, wss, tls, m
tls, quic, kcp, ssh, h2, h2c, obfs4), 二者可以任意组合,或单独使用:
> http - 标准HTTP代理: http://:8080
...
...
@@ -73,6 +74,8 @@ protocol: 代理协议类型(http, socks4(a), socks5, ss), transport: 数据传
> tls - HTTP/SOCKS5代理,使用TLS传输数据: tls://:443
> mtls - HTTP/SOCKS5代理,使用TLS以多路复用方式传输数据: mtls://:443
> ss - Shadowsocks代理: ss://chacha20:123456@:8338
> ssu - Shadowsocks UDP relay: ssu://chacha20:123456@:8338
...
...
@@ -87,6 +90,7 @@ protocol: 代理协议类型(http, socks4(a), socks5, ss), transport: 数据传
> obfs4 - obfs4通道: obfs4://:8080
> sni - SNI代理: sni://:443
#### 端口转发
...
...
cmd/gost/main.go
View file @
cd842de2
...
...
@@ -102,23 +102,26 @@ func initChain() (*gost.Chain, error) {
InsecureSkipVerify
:
!
toBool
(
node
.
Values
.
Get
(
"secure"
)),
RootCAs
:
rootCAs
,
}
wsOpts
:=
&
gost
.
WSOptions
{}
wsOpts
.
EnableCompression
=
toBool
(
node
.
Values
.
Get
(
"compression"
))
wsOpts
.
ReadBufferSize
,
_
=
strconv
.
Atoi
(
node
.
Values
.
Get
(
"rbuf"
))
wsOpts
.
WriteBufferSize
,
_
=
strconv
.
Atoi
(
node
.
Values
.
Get
(
"wbuf"
))
wsOpts
.
UserAgent
=
node
.
Values
.
Get
(
"agent"
)
var
tr
gost
.
Transporter
switch
node
.
Transport
{
case
"tls"
:
tr
=
gost
.
TLSTransporter
()
case
"mtls"
:
tr
=
gost
.
MTLSTransporter
()
case
"ws"
:
wsOpts
:=
&
gost
.
WSOptions
{}
wsOpts
.
EnableCompression
=
toBool
(
node
.
Values
.
Get
(
"compression"
))
wsOpts
.
ReadBufferSize
,
_
=
strconv
.
Atoi
(
node
.
Values
.
Get
(
"rbuf"
))
wsOpts
.
WriteBufferSize
,
_
=
strconv
.
Atoi
(
node
.
Values
.
Get
(
"wbuf"
))
wsOpts
.
UserAgent
=
node
.
Values
.
Get
(
"agent"
)
tr
=
gost
.
WSTransporter
(
wsOpts
)
case
"mws"
:
tr
=
gost
.
MWSTransporter
(
wsOpts
)
case
"wss"
:
wsOpts
:=
&
gost
.
WSOptions
{}
wsOpts
.
EnableCompression
=
toBool
(
node
.
Values
.
Get
(
"compression"
))
wsOpts
.
ReadBufferSize
,
_
=
strconv
.
Atoi
(
node
.
Values
.
Get
(
"rbuf"
))
wsOpts
.
WriteBufferSize
,
_
=
strconv
.
Atoi
(
node
.
Values
.
Get
(
"wbuf"
))
tr
=
gost
.
WSSTransporter
(
wsOpts
)
case
"mwss"
:
tr
=
gost
.
MWSSTransporter
(
wsOpts
)
case
"kcp"
:
if
!
chain
.
IsEmpty
()
{
return
nil
,
errors
.
New
(
"KCP must be the first node in the proxy chain"
)
...
...
@@ -173,8 +176,6 @@ func initChain() (*gost.Chain, error) {
tr
=
gost
.
Obfs4Transporter
()
case
"ohttp"
:
tr
=
gost
.
ObfsHTTPTransporter
()
case
"mtls"
:
tr
=
gost
.
MTLSTransporter
()
default
:
tr
=
gost
.
TCPTransporter
()
}
...
...
@@ -248,22 +249,26 @@ func serve(chain *gost.Chain) error {
return
err
}
wsOpts
:=
&
gost
.
WSOptions
{}
wsOpts
.
EnableCompression
=
toBool
(
node
.
Values
.
Get
(
"compression"
))
wsOpts
.
ReadBufferSize
,
_
=
strconv
.
Atoi
(
node
.
Values
.
Get
(
"rbuf"
))
wsOpts
.
WriteBufferSize
,
_
=
strconv
.
Atoi
(
node
.
Values
.
Get
(
"wbuf"
))
var
ln
gost
.
Listener
switch
node
.
Transport
{
case
"tls"
:
ln
,
err
=
gost
.
TLSListener
(
node
.
Addr
,
tlsCfg
)
case
"mtls"
:
ln
,
err
=
gost
.
MTLSListener
(
node
.
Addr
,
tlsCfg
)
case
"ws"
:
wsOpts
:=
&
gost
.
WSOptions
{}
wsOpts
.
EnableCompression
=
toBool
(
node
.
Values
.
Get
(
"compression"
))
wsOpts
.
ReadBufferSize
,
_
=
strconv
.
Atoi
(
node
.
Values
.
Get
(
"rbuf"
))
wsOpts
.
WriteBufferSize
,
_
=
strconv
.
Atoi
(
node
.
Values
.
Get
(
"wbuf"
))
ln
,
err
=
gost
.
WSListener
(
node
.
Addr
,
wsOpts
)
case
"mws"
:
ln
,
err
=
gost
.
MWSListener
(
node
.
Addr
,
wsOpts
)
case
"wss"
:
wsOpts
:=
&
gost
.
WSOptions
{}
wsOpts
.
EnableCompression
=
toBool
(
node
.
Values
.
Get
(
"compression"
))
wsOpts
.
ReadBufferSize
,
_
=
strconv
.
Atoi
(
node
.
Values
.
Get
(
"rbuf"
))
wsOpts
.
WriteBufferSize
,
_
=
strconv
.
Atoi
(
node
.
Values
.
Get
(
"wbuf"
))
ln
,
err
=
gost
.
WSSListener
(
node
.
Addr
,
tlsCfg
,
wsOpts
)
case
"mwss"
:
ln
,
err
=
gost
.
MWSSListener
(
node
.
Addr
,
tlsCfg
,
wsOpts
)
case
"kcp"
:
config
,
er
:=
parseKCPConfig
(
node
.
Values
.
Get
(
"c"
))
if
er
!=
nil
{
...
...
@@ -319,8 +324,6 @@ func serve(chain *gost.Chain) error {
ln
,
err
=
gost
.
Obfs4Listener
(
node
.
Addr
)
case
"ohttp"
:
ln
,
err
=
gost
.
ObfsHTTPListener
(
node
.
Addr
)
case
"mtls"
:
ln
,
err
=
gost
.
MTLSListener
(
node
.
Addr
,
tlsCfg
)
default
:
ln
,
err
=
gost
.
TCPListener
(
node
.
Addr
)
}
...
...
node.go
View file @
cd842de2
...
...
@@ -52,7 +52,7 @@ func ParseNode(s string) (node Node, err error) {
}
switch
node
.
Transport
{
case
"tls"
,
"
ws"
,
"wss"
,
"kcp"
,
"ssh"
,
"quic"
,
"ssu"
,
"http2"
,
"h2"
,
"h2c"
,
"obfs4"
,
"mtls
"
:
case
"tls"
,
"
mtls"
,
"ws"
,
"mws"
,
"wss"
,
"mwss"
,
"kcp"
,
"ssh"
,
"quic"
,
"ssu"
,
"http2"
,
"h2"
,
"h2c"
,
"obfs4
"
:
case
"https"
:
node
.
Protocol
=
"http"
node
.
Transport
=
"tls"
...
...
ws.go
View file @
cd842de2
This diff is collapsed.
Click to expand it.
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