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
d7ff3efd
Commit
d7ff3efd
authored
Jan 14, 2017
by
rui.zheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update vendor for ss OTA support
parent
148d114c
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
65 additions
and
32 deletions
+65
-32
cmd/gost/vendor/github.com/ginuerzh/gost/conn.go
cmd/gost/vendor/github.com/ginuerzh/gost/conn.go
+21
-24
cmd/gost/vendor/github.com/ginuerzh/gost/server.go
cmd/gost/vendor/github.com/ginuerzh/gost/server.go
+17
-4
cmd/gost/vendor/github.com/shadowsocks/shadowsocks-go/shadowsocks/conn.go
...github.com/shadowsocks/shadowsocks-go/shadowsocks/conn.go
+23
-0
cmd/gost/vendor/vendor.json
cmd/gost/vendor/vendor.json
+4
-4
No files found.
cmd/gost/vendor/github.com/ginuerzh/gost/conn.go
View file @
d7ff3efd
...
@@ -2,18 +2,18 @@ package gost
...
@@ -2,18 +2,18 @@ package gost
import
(
import
(
"bufio"
"bufio"
"bytes"
"crypto/tls"
"crypto/tls"
"encoding/base64"
"encoding/base64"
"errors"
"errors"
"github.com/ginuerzh/gosocks5"
"github.com/ginuerzh/gosocks5"
"github.com/golang/glog"
"github.com/golang/glog"
"github.com/shadowsocks/shadowsocks-go/shadowsocks"
ss
"github.com/shadowsocks/shadowsocks-go/shadowsocks"
"net"
"net"
"net/http"
"net/http"
"net/http/httputil"
"net/http/httputil"
"net/url"
"net/url"
"strconv"
"strconv"
"strings"
"sync"
"sync"
"time"
"time"
)
)
...
@@ -115,15 +115,7 @@ func (c *ProxyConn) handshake() error {
...
@@ -115,15 +115,7 @@ func (c *ProxyConn) handshake() error {
}
}
c
.
conn
=
conn
c
.
conn
=
conn
case
"ss"
:
// shadowsocks
case
"ss"
:
// shadowsocks
if
len
(
c
.
Node
.
Users
)
>
0
{
// nothing to do
method
:=
c
.
Node
.
Users
[
0
]
.
Username
()
password
,
_
:=
c
.
Node
.
Users
[
0
]
.
Password
()
cipher
,
err
:=
shadowsocks
.
NewCipher
(
method
,
password
)
if
err
!=
nil
{
return
err
}
c
.
conn
=
&
shadowConn
{
conn
:
shadowsocks
.
NewConn
(
c
.
conn
,
cipher
)}
}
case
"http"
,
"http2"
:
case
"http"
,
"http2"
:
fallthrough
fallthrough
default
:
default
:
...
@@ -138,26 +130,31 @@ func (c *ProxyConn) handshake() error {
...
@@ -138,26 +130,31 @@ func (c *ProxyConn) handshake() error {
func
(
c
*
ProxyConn
)
Connect
(
addr
string
)
error
{
func
(
c
*
ProxyConn
)
Connect
(
addr
string
)
error
{
switch
c
.
Node
.
Protocol
{
switch
c
.
Node
.
Protocol
{
case
"ss"
:
// shadowsocks
case
"ss"
:
// shadowsocks
host
,
port
,
err
:=
net
.
SplitHostPort
(
addr
)
rawaddr
,
err
:=
ss
.
RawAddr
(
addr
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
p
,
_
:=
strconv
.
Atoi
(
port
)
req
:=
gosocks5
.
NewRequest
(
gosocks5
.
CmdConnect
,
&
gosocks5
.
Addr
{
var
method
,
password
string
Type
:
gosocks5
.
AddrDomain
,
if
len
(
c
.
Node
.
Users
)
>
0
{
Host
:
host
,
method
=
c
.
Node
.
Users
[
0
]
.
Username
()
Port
:
uint16
(
p
),
password
,
_
=
c
.
Node
.
Users
[
0
]
.
Password
()
})
}
buf
:=
bytes
.
Buffer
{}
if
c
.
Node
.
getBool
(
"ota"
)
&&
!
strings
.
HasSuffix
(
method
,
"-auth"
)
{
if
err
:=
req
.
Write
(
&
buf
);
err
!=
nil
{
method
+=
"-auth"
return
err
}
}
b
:=
buf
.
Bytes
()
if
_
,
err
:=
c
.
Write
(
b
[
3
:
]);
err
!=
nil
{
cipher
,
err
:=
ss
.
NewCipher
(
method
,
password
)
if
err
!=
nil
{
return
err
return
err
}
}
glog
.
V
(
LDEBUG
)
.
Infoln
(
"[ss]"
,
req
)
ssc
,
err
:=
ss
.
DialWithRawAddrConn
(
rawaddr
,
c
.
conn
,
cipher
)
if
err
!=
nil
{
return
err
}
c
.
conn
=
&
shadowConn
{
conn
:
ssc
}
return
nil
case
"socks"
,
"socks5"
:
case
"socks"
,
"socks5"
:
host
,
port
,
err
:=
net
.
SplitHostPort
(
addr
)
host
,
port
,
err
:=
net
.
SplitHostPort
(
addr
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
cmd/gost/vendor/github.com/ginuerzh/gost/server.go
View file @
d7ff3efd
...
@@ -10,6 +10,7 @@ import (
...
@@ -10,6 +10,7 @@ import (
"net"
"net"
"net/http"
"net/http"
"strconv"
"strconv"
"strings"
)
)
type
ProxyServer
struct
{
type
ProxyServer
struct
{
...
@@ -18,6 +19,7 @@ type ProxyServer struct {
...
@@ -18,6 +19,7 @@ type ProxyServer struct {
TLSConfig
*
tls
.
Config
TLSConfig
*
tls
.
Config
selector
*
serverSelector
selector
*
serverSelector
cipher
*
ss
.
Cipher
cipher
*
ss
.
Cipher
ota
bool
}
}
func
NewProxyServer
(
node
ProxyNode
,
chain
*
ProxyChain
,
config
*
tls
.
Config
)
*
ProxyServer
{
func
NewProxyServer
(
node
ProxyNode
,
chain
*
ProxyChain
,
config
*
tls
.
Config
)
*
ProxyServer
{
...
@@ -29,10 +31,20 @@ func NewProxyServer(node ProxyNode, chain *ProxyChain, config *tls.Config) *Prox
...
@@ -29,10 +31,20 @@ func NewProxyServer(node ProxyNode, chain *ProxyChain, config *tls.Config) *Prox
}
}
var
cipher
*
ss
.
Cipher
var
cipher
*
ss
.
Cipher
if
node
.
Protocol
==
"ss"
&&
node
.
Users
!=
nil
{
var
ota
bool
if
node
.
Protocol
==
"ss"
{
var
err
error
var
err
error
method
:=
node
.
Users
[
0
]
.
Username
()
var
method
,
password
string
password
,
_
:=
node
.
Users
[
0
]
.
Password
()
if
len
(
node
.
Users
)
>
0
{
method
=
node
.
Users
[
0
]
.
Username
()
password
,
_
=
node
.
Users
[
0
]
.
Password
()
}
ota
=
node
.
getBool
(
"ota"
)
if
strings
.
HasSuffix
(
method
,
"-auth"
)
{
ota
=
true
method
=
strings
.
TrimSuffix
(
method
,
"-auth"
)
}
cipher
,
err
=
ss
.
NewCipher
(
method
,
password
)
cipher
,
err
=
ss
.
NewCipher
(
method
,
password
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Fatal
(
err
)
glog
.
Fatal
(
err
)
...
@@ -54,6 +66,7 @@ func NewProxyServer(node ProxyNode, chain *ProxyChain, config *tls.Config) *Prox
...
@@ -54,6 +66,7 @@ func NewProxyServer(node ProxyNode, chain *ProxyChain, config *tls.Config) *Prox
tlsConfig
:
config
,
tlsConfig
:
config
,
},
},
cipher
:
cipher
,
cipher
:
cipher
,
ota
:
ota
,
}
}
}
}
...
@@ -134,7 +147,7 @@ func (s *ProxyServer) handleConn(conn net.Conn) {
...
@@ -134,7 +147,7 @@ func (s *ProxyServer) handleConn(conn net.Conn) {
switch
s
.
Node
.
Protocol
{
switch
s
.
Node
.
Protocol
{
case
"ss"
:
// shadowsocks
case
"ss"
:
// shadowsocks
server
:=
NewShadowServer
(
ss
.
NewConn
(
conn
,
s
.
cipher
.
Copy
()),
s
)
server
:=
NewShadowServer
(
ss
.
NewConn
(
conn
,
s
.
cipher
.
Copy
()),
s
)
server
.
OTA
=
s
.
Node
.
getBool
(
"ota"
)
server
.
OTA
=
s
.
ota
server
.
Serve
()
server
.
Serve
()
return
return
case
"http"
:
case
"http"
:
...
...
cmd/gost/vendor/github.com/shadowsocks/shadowsocks-go/shadowsocks/conn.go
View file @
d7ff3efd
...
@@ -82,6 +82,29 @@ func DialWithRawAddr(rawaddr []byte, server string, cipher *Cipher) (c *Conn, er
...
@@ -82,6 +82,29 @@ func DialWithRawAddr(rawaddr []byte, server string, cipher *Cipher) (c *Conn, er
return
return
}
}
// add by yang for gost ota
// see https://groups.google.com/forum/#!topic/go-gost/GYBtHmLKR0o
func
DialWithRawAddrConn
(
rawaddr
[]
byte
,
conn
net
.
Conn
,
cipher
*
Cipher
)
(
c
*
Conn
,
err
error
)
{
c
=
NewConn
(
conn
,
cipher
)
if
cipher
.
ota
{
if
c
.
enc
==
nil
{
if
_
,
err
=
c
.
initEncrypt
();
err
!=
nil
{
return
}
}
// since we have initEncrypt, we must send iv manually
conn
.
Write
(
cipher
.
iv
)
rawaddr
[
0
]
|=
OneTimeAuthMask
rawaddr
=
otaConnectAuth
(
cipher
.
iv
,
cipher
.
key
,
rawaddr
)
}
if
_
,
err
=
c
.
write
(
rawaddr
);
err
!=
nil
{
c
.
Close
()
return
nil
,
err
}
return
}
// addr should be in the form of host:port
// addr should be in the form of host:port
func
Dial
(
addr
,
server
string
,
cipher
*
Cipher
)
(
c
*
Conn
,
err
error
)
{
func
Dial
(
addr
,
server
string
,
cipher
*
Cipher
)
(
c
*
Conn
,
err
error
)
{
ra
,
err
:=
RawAddr
(
addr
)
ra
,
err
:=
RawAddr
(
addr
)
...
...
cmd/gost/vendor/vendor.json
View file @
d7ff3efd
...
@@ -15,10 +15,10 @@
...
@@ -15,10 +15,10 @@
"revisionTime"
:
"2016-09-03T01:06:34Z"
"revisionTime"
:
"2016-09-03T01:06:34Z"
},
},
{
{
"checksumSHA1"
:
"
QooLgOqsl0ivXxYygSepzSRAtjQ
="
,
"checksumSHA1"
:
"
t4O2pqbz2JHm0t6OGz7e7L28IRM
="
,
"path"
:
"github.com/ginuerzh/gost"
,
"path"
:
"github.com/ginuerzh/gost"
,
"revision"
:
"1
5a5d74b563e644a471fa42aab0a2876da6b1bb0
"
,
"revision"
:
"1
48d114c7366e1d15e807fe2e472f635fb6ed557
"
,
"revisionTime"
:
"2017-01-
09T03:39:18
Z"
"revisionTime"
:
"2017-01-
14T05:41:49
Z"
},
},
{
{
"checksumSHA1"
:
"URsJa4y/sUUw/STmbeYx9EKqaYE="
,
"checksumSHA1"
:
"URsJa4y/sUUw/STmbeYx9EKqaYE="
,
...
@@ -153,7 +153,7 @@
...
@@ -153,7 +153,7 @@
"revisionTime"
:
"2016-10-02T05:25:12Z"
"revisionTime"
:
"2016-10-02T05:25:12Z"
},
},
{
{
"checksumSHA1"
:
"
VrDrpS/tpn8nfuFCY51U4eH/Jg0
="
,
"checksumSHA1"
:
"
o0WHRL8mNIhfsoWlzhdJ8du6+C8
="
,
"path"
:
"github.com/shadowsocks/shadowsocks-go/shadowsocks"
,
"path"
:
"github.com/shadowsocks/shadowsocks-go/shadowsocks"
,
"revision"
:
"5c9897ecdf623f385ccb8c2c78e32c5256961b41"
,
"revision"
:
"5c9897ecdf623f385ccb8c2c78e32c5256961b41"
,
"revisionTime"
:
"2016-06-15T15:25:08Z"
"revisionTime"
:
"2016-06-15T15:25:08Z"
...
...
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