mirror of
https://github.com/SagerNet/sing-shadowsocks.git
synced 2025-04-03 20:07:40 +03:00
Cleanup code
This commit is contained in:
parent
1273973c66
commit
52a7f9f469
6 changed files with 3 additions and 46 deletions
4
none.go
4
none.go
|
@ -27,10 +27,6 @@ func (m *NoneMethod) Name() string {
|
|||
return MethodNone
|
||||
}
|
||||
|
||||
func (m *NoneMethod) KeyLength() int {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *NoneMethod) DialConn(conn net.Conn, destination M.Socksaddr) (net.Conn, error) {
|
||||
shadowsocksConn := &noneConn{
|
||||
Conn: conn,
|
||||
|
|
|
@ -97,36 +97,6 @@ func (m *Method) Name() string {
|
|||
return m.name
|
||||
}
|
||||
|
||||
func (m *Method) KeyLength() int {
|
||||
return m.keySaltLength
|
||||
}
|
||||
|
||||
func (m *Method) ReadRequest(upstream io.Reader) (io.Reader, error) {
|
||||
_salt := buf.Make(m.keySaltLength)
|
||||
defer common.KeepAlive(_salt)
|
||||
salt := common.Dup(_salt)
|
||||
_, err := io.ReadFull(upstream, salt)
|
||||
if err != nil {
|
||||
return nil, E.Cause(err, "read salt")
|
||||
}
|
||||
key := Kdf(m.key, salt, m.keySaltLength)
|
||||
defer common.KeepAlive(key)
|
||||
return NewReader(upstream, m.constructor(common.Dup(key)), MaxPacketSize), nil
|
||||
}
|
||||
|
||||
func (m *Method) WriteResponse(upstream io.Writer) (io.Writer, error) {
|
||||
_salt := buf.Make(m.keySaltLength)
|
||||
defer common.KeepAlive(_salt)
|
||||
salt := common.Dup(_salt)
|
||||
common.Must1(io.ReadFull(rand.Reader, salt))
|
||||
_, err := upstream.Write(salt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
key := Kdf(m.key, salt, m.keySaltLength)
|
||||
return NewWriter(upstream, m.constructor(common.Dup(key)), MaxPacketSize), nil
|
||||
}
|
||||
|
||||
func (m *Method) DialConn(conn net.Conn, destination M.Socksaddr) (net.Conn, error) {
|
||||
shadowsocksConn := &clientConn{
|
||||
Conn: conn,
|
||||
|
|
|
@ -46,6 +46,7 @@ var (
|
|||
ErrBadHeaderType = E.New("bad header type")
|
||||
ErrBadTimestamp = E.New("bad timestamp")
|
||||
ErrBadRequestSalt = E.New("bad request salt")
|
||||
ErrSaltNotUnique = E.New("salt not unique")
|
||||
ErrBadClientSessionId = E.New("bad client session id")
|
||||
ErrPacketIdNotUnique = E.New("packet id not unique")
|
||||
ErrTooManyServerSessions = E.New("server session changed more than once during the last minute")
|
||||
|
@ -176,10 +177,6 @@ func (m *Method) Name() string {
|
|||
return m.name
|
||||
}
|
||||
|
||||
func (m *Method) KeyLength() int {
|
||||
return m.keySaltLength
|
||||
}
|
||||
|
||||
func (m *Method) DialConn(conn net.Conn, destination M.Socksaddr) (net.Conn, error) {
|
||||
shadowsocksConn := &clientConn{
|
||||
Method: m,
|
||||
|
|
|
@ -31,9 +31,8 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
ErrSaltNotUnique = E.New("bad request: salt not unique")
|
||||
ErrNoPadding = E.New("bad request: missing payload or padding")
|
||||
ErrBadPadding = E.New("bad request: damaged padding")
|
||||
ErrNoPadding = E.New("bad request: missing payload or padding")
|
||||
ErrBadPadding = E.New("bad request: damaged padding")
|
||||
)
|
||||
|
||||
type Service struct {
|
||||
|
|
|
@ -19,7 +19,6 @@ var (
|
|||
|
||||
type Method interface {
|
||||
Name() string
|
||||
KeyLength() int
|
||||
DialConn(conn net.Conn, destination M.Socksaddr) (net.Conn, error)
|
||||
DialEarlyConn(conn net.Conn, destination M.Socksaddr) net.Conn
|
||||
DialPacketConn(conn net.Conn) N.NetPacketConn
|
||||
|
|
|
@ -136,10 +136,6 @@ func (m *Method) Name() string {
|
|||
return m.name
|
||||
}
|
||||
|
||||
func (m *Method) KeyLength() int {
|
||||
return m.keyLength
|
||||
}
|
||||
|
||||
func (m *Method) DialConn(conn net.Conn, destination M.Socksaddr) (net.Conn, error) {
|
||||
shadowsocksConn := &clientConn{
|
||||
Method: m,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue