mirror of
				https://github.com/nadoo/glider.git
				synced 2025-11-04 07:42:38 +08:00 
			
		
		
		
	chore: add comments to export functions
This commit is contained in:
		
							parent
							
								
									417ac556f7
								
							
						
					
					
						commit
						8a2e95b17e
					
				@ -44,7 +44,7 @@ we can set up local listeners as proxy servers, and forward requests to internet
 | 
				
			|||||||
<summary>click to see details</summary>
 | 
					<summary>click to see details</summary>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
|Protocol     | Listen/TCP |  Listen/UDP | Forward/TCP | Forward/UDP | Description
 | 
					|Protocol     | Listen/TCP |  Listen/UDP | Forward/TCP | Forward/UDP | Description
 | 
				
			||||||
|:-           |:-:|:-:|:-:|:-:|:-
 | 
					|:-:          |:-:|:-:|:-:|:-:|:-
 | 
				
			||||||
|Mixed        |√|√| | |http+socks5 server
 | 
					|Mixed        |√|√| | |http+socks5 server
 | 
				
			||||||
|HTTP         |√| |√| |client & server
 | 
					|HTTP         |√| |√| |client & server
 | 
				
			||||||
|SOCKS5       |√|√|√|√|client & server
 | 
					|SOCKS5       |√|√|√|√|client & server
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										5
									
								
								go.mod
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								go.mod
									
									
									
									
									
								
							@ -9,14 +9,15 @@ require (
 | 
				
			|||||||
	github.com/dgryski/go-rc2 v0.0.0-20150621095337-8a9021637152
 | 
						github.com/dgryski/go-rc2 v0.0.0-20150621095337-8a9021637152
 | 
				
			||||||
	github.com/ebfe/rc2 v0.0.0-20131011165748-24b9757f5521 // indirect
 | 
						github.com/ebfe/rc2 v0.0.0-20131011165748-24b9757f5521 // indirect
 | 
				
			||||||
	github.com/insomniacslk/dhcp v0.0.0-20200922210017-67c425063dca
 | 
						github.com/insomniacslk/dhcp v0.0.0-20200922210017-67c425063dca
 | 
				
			||||||
 | 
						github.com/mmcloughlin/avo v0.0.0-20201105074841-5d2f697d268f // indirect
 | 
				
			||||||
	github.com/nadoo/conflag v0.2.3
 | 
						github.com/nadoo/conflag v0.2.3
 | 
				
			||||||
	github.com/nadoo/ipset v0.3.0
 | 
						github.com/nadoo/ipset v0.3.0
 | 
				
			||||||
	github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
 | 
						github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
 | 
				
			||||||
	github.com/xtaci/kcp-go/v5 v5.6.1
 | 
						github.com/xtaci/kcp-go/v5 v5.6.1
 | 
				
			||||||
	golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897
 | 
						golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897
 | 
				
			||||||
	golang.org/x/net v0.0.0-20201031054903-ff519b6c9102 // indirect
 | 
						golang.org/x/net v0.0.0-20201031054903-ff519b6c9102 // indirect
 | 
				
			||||||
	golang.org/x/sys v0.0.0-20201101102859-da207088b7d1 // indirect
 | 
						golang.org/x/sys v0.0.0-20201106081118-db71ae66460a // indirect
 | 
				
			||||||
	golang.org/x/tools v0.0.0-20201102212025-f46e4245211d // indirect
 | 
						golang.org/x/tools v0.0.0-20201105220310-78b158585360 // indirect
 | 
				
			||||||
	gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b // indirect
 | 
						gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b // indirect
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										13
									
								
								go.sum
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								go.sum
									
									
									
									
									
								
							@ -43,6 +43,8 @@ github.com/mdlayher/raw v0.0.0-20191009151244-50f2db8cc065 h1:aFkJ6lx4FPip+S+Uw4
 | 
				
			|||||||
github.com/mdlayher/raw v0.0.0-20191009151244-50f2db8cc065/go.mod h1:7EpbotpCmVZcu+KCX4g9WaRNuu11uyhiW7+Le1dKawg=
 | 
					github.com/mdlayher/raw v0.0.0-20191009151244-50f2db8cc065/go.mod h1:7EpbotpCmVZcu+KCX4g9WaRNuu11uyhiW7+Le1dKawg=
 | 
				
			||||||
github.com/mmcloughlin/avo v0.0.0-20200803215136-443f81d77104 h1:ULR/QWMgcgRiZLUjSSJMU+fW+RDMstRdmnDWj9Q+AsA=
 | 
					github.com/mmcloughlin/avo v0.0.0-20200803215136-443f81d77104 h1:ULR/QWMgcgRiZLUjSSJMU+fW+RDMstRdmnDWj9Q+AsA=
 | 
				
			||||||
github.com/mmcloughlin/avo v0.0.0-20200803215136-443f81d77104/go.mod h1:wqKykBG2QzQDJEzvRkcS8x6MiSJkF52hXZsXcjaB3ls=
 | 
					github.com/mmcloughlin/avo v0.0.0-20200803215136-443f81d77104/go.mod h1:wqKykBG2QzQDJEzvRkcS8x6MiSJkF52hXZsXcjaB3ls=
 | 
				
			||||||
 | 
					github.com/mmcloughlin/avo v0.0.0-20201105074841-5d2f697d268f h1:D4I34fbgczGrhrN4DzBCZXT3u/nMWJnGmviIjSzzXSw=
 | 
				
			||||||
 | 
					github.com/mmcloughlin/avo v0.0.0-20201105074841-5d2f697d268f/go.mod h1:6aKT4zZIrpGqB3RpFU14ByCSSyKY6LfJz4J/JJChHfI=
 | 
				
			||||||
github.com/nadoo/conflag v0.2.3 h1:/+rTaN0bHTIiQbPl1WZK78JRoqjlNqJ9Zf05ep0o5jI=
 | 
					github.com/nadoo/conflag v0.2.3 h1:/+rTaN0bHTIiQbPl1WZK78JRoqjlNqJ9Zf05ep0o5jI=
 | 
				
			||||||
github.com/nadoo/conflag v0.2.3/go.mod h1:dzFfDUpXdr2uS2oV+udpy5N2vfNOu/bFzjhX1WI52co=
 | 
					github.com/nadoo/conflag v0.2.3/go.mod h1:dzFfDUpXdr2uS2oV+udpy5N2vfNOu/bFzjhX1WI52co=
 | 
				
			||||||
github.com/nadoo/ipset v0.3.0 h1:TgULgp4s2PI3ItoCykDzMp8R49fRhMUNoUUEahERr5o=
 | 
					github.com/nadoo/ipset v0.3.0 h1:TgULgp4s2PI3ItoCykDzMp8R49fRhMUNoUUEahERr5o=
 | 
				
			||||||
@ -75,6 +77,7 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de
 | 
				
			|||||||
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
 | 
					github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
 | 
				
			||||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
 | 
					github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
 | 
				
			||||||
golang.org/x/arch v0.0.0-20190909030613-46d78d1859ac/go.mod h1:flIaEI6LNU6xOCD5PaJvn9wGP0agmIOqjrtsKGRguv4=
 | 
					golang.org/x/arch v0.0.0-20190909030613-46d78d1859ac/go.mod h1:flIaEI6LNU6xOCD5PaJvn9wGP0agmIOqjrtsKGRguv4=
 | 
				
			||||||
 | 
					golang.org/x/arch v0.0.0-20201008161808-52c3e6f60cff/go.mod h1:flIaEI6LNU6xOCD5PaJvn9wGP0agmIOqjrtsKGRguv4=
 | 
				
			||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
 | 
					golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
 | 
				
			||||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
 | 
					golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
 | 
				
			||||||
golang.org/x/crypto v0.0.0-20191219195013-becbf705a915/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
 | 
					golang.org/x/crypto v0.0.0-20191219195013-becbf705a915/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
 | 
				
			||||||
@ -116,8 +119,8 @@ golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7w
 | 
				
			|||||||
golang.org/x/sys v0.0.0-20200808120158-1030fc2bf1d9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
					golang.org/x/sys v0.0.0-20200808120158-1030fc2bf1d9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
				
			||||||
golang.org/x/sys v0.0.0-20200916030750-2334cc1a136f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
					golang.org/x/sys v0.0.0-20200916030750-2334cc1a136f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
				
			||||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
					golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
				
			||||||
golang.org/x/sys v0.0.0-20201101102859-da207088b7d1 h1:a/mKvvZr9Jcc8oKfcmgzyp7OwF73JPWsQLvH1z2Kxck=
 | 
					golang.org/x/sys v0.0.0-20201106081118-db71ae66460a h1:ALUFBKlIyeY7y5ZgPJmblk/vKz+zBQSnNiPkt41sgeg=
 | 
				
			||||||
golang.org/x/sys v0.0.0-20201101102859-da207088b7d1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
					golang.org/x/sys v0.0.0-20201106081118-db71ae66460a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
				
			||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
 | 
					golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
 | 
				
			||||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
 | 
					golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
 | 
				
			||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
 | 
					golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
 | 
				
			||||||
@ -125,8 +128,10 @@ golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3
 | 
				
			|||||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
 | 
					golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
 | 
				
			||||||
golang.org/x/tools v0.0.0-20200425043458-8463f397d07c/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
 | 
					golang.org/x/tools v0.0.0-20200425043458-8463f397d07c/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
 | 
				
			||||||
golang.org/x/tools v0.0.0-20200808161706-5bf02b21f123/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
 | 
					golang.org/x/tools v0.0.0-20200808161706-5bf02b21f123/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
 | 
				
			||||||
golang.org/x/tools v0.0.0-20201102212025-f46e4245211d h1:qbdJV2Z36oENmeAcKxD4qJx1FRdKoCzNewsdABS63dY=
 | 
					golang.org/x/tools v0.0.0-20201105001634-bc3cf281b174 h1:0rx0F4EjJNbxTuzWe0KjKcIzs+3VEb/Mrs/d1ciNz1c=
 | 
				
			||||||
golang.org/x/tools v0.0.0-20201102212025-f46e4245211d/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
 | 
					golang.org/x/tools v0.0.0-20201105001634-bc3cf281b174/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
 | 
				
			||||||
 | 
					golang.org/x/tools v0.0.0-20201105220310-78b158585360 h1:/9CzsU8hOpnSUCtem1vfWNgsVeCTgkMdx+VE5YIYxnU=
 | 
				
			||||||
 | 
					golang.org/x/tools v0.0.0-20201105220310-78b158585360/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
 | 
				
			||||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 | 
					golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 | 
				
			||||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 | 
					golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 | 
				
			||||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 | 
					golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 | 
				
			||||||
 | 
				
			|||||||
@ -73,6 +73,7 @@ func Relay(left, right net.Conn) error {
 | 
				
			|||||||
	return nil
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Close closes the Conn.
 | 
				
			||||||
func (c *Conn) Close() error {
 | 
					func (c *Conn) Close() error {
 | 
				
			||||||
	pool.PutBufReader(c.r)
 | 
						pool.PutBufReader(c.r)
 | 
				
			||||||
	return c.Conn.Close()
 | 
						return c.Conn.Close()
 | 
				
			||||||
 | 
				
			|||||||
@ -10,15 +10,18 @@ import (
 | 
				
			|||||||
	"github.com/nadoo/glider/proxy/ss/cipher/internal/shadowstream"
 | 
						"github.com/nadoo/glider/proxy/ss/cipher/internal/shadowstream"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Cipher interface.
 | 
				
			||||||
type Cipher interface {
 | 
					type Cipher interface {
 | 
				
			||||||
	StreamConnCipher
 | 
						StreamConnCipher
 | 
				
			||||||
	PacketConnCipher
 | 
						PacketConnCipher
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// StreamConnCipher is the stream connection cipher.
 | 
				
			||||||
type StreamConnCipher interface {
 | 
					type StreamConnCipher interface {
 | 
				
			||||||
	StreamConn(net.Conn) net.Conn
 | 
						StreamConn(net.Conn) net.Conn
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// StreamConnCipher is the packet connection cipher.
 | 
				
			||||||
type PacketConnCipher interface {
 | 
					type PacketConnCipher interface {
 | 
				
			||||||
	PacketConn(net.PacketConn) net.PacketConn
 | 
						PacketConn(net.PacketConn) net.PacketConn
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -11,6 +11,7 @@ import (
 | 
				
			|||||||
	"golang.org/x/crypto/hkdf"
 | 
						"golang.org/x/crypto/hkdf"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Cipher generates a pair of stream ciphers for encryption and decryption.
 | 
				
			||||||
type Cipher interface {
 | 
					type Cipher interface {
 | 
				
			||||||
	KeySize() int
 | 
						KeySize() int
 | 
				
			||||||
	SaltSize() int
 | 
						SaltSize() int
 | 
				
			||||||
@ -18,6 +19,7 @@ type Cipher interface {
 | 
				
			|||||||
	Decrypter(salt []byte) (cipher.AEAD, error)
 | 
						Decrypter(salt []byte) (cipher.AEAD, error)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// KeySizeError is an error about the key size.
 | 
				
			||||||
type KeySizeError int
 | 
					type KeySizeError int
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (e KeySizeError) Error() string {
 | 
					func (e KeySizeError) Error() string {
 | 
				
			||||||
 | 
				
			|||||||
@ -18,6 +18,7 @@ type Cipher interface {
 | 
				
			|||||||
	Decrypter(iv []byte) cipher.Stream
 | 
						Decrypter(iv []byte) cipher.Stream
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// KeySizeError is an error about the key size.
 | 
				
			||||||
type KeySizeError int
 | 
					type KeySizeError int
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (e KeySizeError) Error() string {
 | 
					func (e KeySizeError) Error() string {
 | 
				
			||||||
@ -31,6 +32,7 @@ func (b *ctrStream) IVSize() int                       { return b.BlockSize() }
 | 
				
			|||||||
func (b *ctrStream) Decrypter(iv []byte) cipher.Stream { return b.Encrypter(iv) }
 | 
					func (b *ctrStream) Decrypter(iv []byte) cipher.Stream { return b.Encrypter(iv) }
 | 
				
			||||||
func (b *ctrStream) Encrypter(iv []byte) cipher.Stream { return cipher.NewCTR(b, iv) }
 | 
					func (b *ctrStream) Encrypter(iv []byte) cipher.Stream { return cipher.NewCTR(b, iv) }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// AESCTR returns an aesctr cipher.
 | 
				
			||||||
func AESCTR(key []byte) (Cipher, error) {
 | 
					func AESCTR(key []byte) (Cipher, error) {
 | 
				
			||||||
	blk, err := aes.NewCipher(key)
 | 
						blk, err := aes.NewCipher(key)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
@ -46,6 +48,7 @@ func (b *cfbStream) IVSize() int                       { return b.BlockSize() }
 | 
				
			|||||||
func (b *cfbStream) Decrypter(iv []byte) cipher.Stream { return cipher.NewCFBDecrypter(b, iv) }
 | 
					func (b *cfbStream) Decrypter(iv []byte) cipher.Stream { return cipher.NewCFBDecrypter(b, iv) }
 | 
				
			||||||
func (b *cfbStream) Encrypter(iv []byte) cipher.Stream { return cipher.NewCFBEncrypter(b, iv) }
 | 
					func (b *cfbStream) Encrypter(iv []byte) cipher.Stream { return cipher.NewCFBEncrypter(b, iv) }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// AESCFB returns an aescfb cipher.
 | 
				
			||||||
func AESCFB(key []byte) (Cipher, error) {
 | 
					func AESCFB(key []byte) (Cipher, error) {
 | 
				
			||||||
	blk, err := aes.NewCipher(key)
 | 
						blk, err := aes.NewCipher(key)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
@ -67,6 +70,7 @@ func (k chacha20ietfkey) Encrypter(iv []byte) cipher.Stream {
 | 
				
			|||||||
	return ciph
 | 
						return ciph
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Chacha20IETF returns a Chacha20IETF cipher.
 | 
				
			||||||
func Chacha20IETF(key []byte) (Cipher, error) {
 | 
					func Chacha20IETF(key []byte) (Cipher, error) {
 | 
				
			||||||
	if len(key) != chacha.KeySize {
 | 
						if len(key) != chacha.KeySize {
 | 
				
			||||||
		return nil, KeySizeError(chacha.KeySize)
 | 
							return nil, KeySizeError(chacha.KeySize)
 | 
				
			||||||
@ -74,6 +78,7 @@ func Chacha20IETF(key []byte) (Cipher, error) {
 | 
				
			|||||||
	return chacha20ietfkey(key), nil
 | 
						return chacha20ietfkey(key), nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// xchacha20
 | 
				
			||||||
type xchacha20key []byte
 | 
					type xchacha20key []byte
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (k xchacha20key) IVSize() int                       { return chacha.XNonceSize }
 | 
					func (k xchacha20key) IVSize() int                       { return chacha.XNonceSize }
 | 
				
			||||||
@ -86,6 +91,7 @@ func (k xchacha20key) Encrypter(iv []byte) cipher.Stream {
 | 
				
			|||||||
	return ciph
 | 
						return ciph
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Xchacha20 returns a Xchacha20 cipher.
 | 
				
			||||||
func Xchacha20(key []byte) (Cipher, error) {
 | 
					func Xchacha20(key []byte) (Cipher, error) {
 | 
				
			||||||
	if len(key) != chacha.KeySize {
 | 
						if len(key) != chacha.KeySize {
 | 
				
			||||||
		return nil, KeySizeError(chacha.KeySize)
 | 
							return nil, KeySizeError(chacha.KeySize)
 | 
				
			||||||
@ -93,7 +99,7 @@ func Xchacha20(key []byte) (Cipher, error) {
 | 
				
			|||||||
	return xchacha20key(key), nil
 | 
						return xchacha20key(key), nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// reference: https://github.com/shadowsocks/shadowsocks-go/blob/master/shadowsocks/encrypt.go
 | 
					// chacah20
 | 
				
			||||||
type chacha20key []byte
 | 
					type chacha20key []byte
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (k chacha20key) IVSize() int                       { return chacha.NonceSize }
 | 
					func (k chacha20key) IVSize() int                       { return chacha.NonceSize }
 | 
				
			||||||
@ -106,6 +112,7 @@ func (k chacha20key) Encrypter(iv []byte) cipher.Stream {
 | 
				
			|||||||
	return ciph
 | 
						return ciph
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ChaCha20 returns a ChaCha20 cipher.
 | 
				
			||||||
func ChaCha20(key []byte) (Cipher, error) {
 | 
					func ChaCha20(key []byte) (Cipher, error) {
 | 
				
			||||||
	if len(key) != chacha.KeySize {
 | 
						if len(key) != chacha.KeySize {
 | 
				
			||||||
		return nil, KeySizeError(chacha.KeySize)
 | 
							return nil, KeySizeError(chacha.KeySize)
 | 
				
			||||||
@ -113,6 +120,7 @@ func ChaCha20(key []byte) (Cipher, error) {
 | 
				
			|||||||
	return chacha20key(key), nil
 | 
						return chacha20key(key), nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// rc4md5
 | 
				
			||||||
type rc4Md5Key []byte
 | 
					type rc4Md5Key []byte
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (k rc4Md5Key) IVSize() int                       { return 16 }
 | 
					func (k rc4Md5Key) IVSize() int                       { return 16 }
 | 
				
			||||||
@ -129,6 +137,7 @@ func (k rc4Md5Key) Encrypter(iv []byte) cipher.Stream {
 | 
				
			|||||||
	return ciph
 | 
						return ciph
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// RC4MD5 returns a RC4MD5 cipher.
 | 
				
			||||||
func RC4MD5(key []byte) (Cipher, error) {
 | 
					func RC4MD5(key []byte) (Cipher, error) {
 | 
				
			||||||
	return rc4Md5Key(key), nil
 | 
						return rc4Md5Key(key), nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -1,6 +1,6 @@
 | 
				
			|||||||
package obfs
 | 
					package obfs
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (	
 | 
					import (
 | 
				
			||||||
	"math/rand"
 | 
						"math/rand"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/nadoo/glider/proxy/ssr/internal/ssr"
 | 
						"github.com/nadoo/glider/proxy/ssr/internal/ssr"
 | 
				
			||||||
@ -80,4 +80,4 @@ func (r *randomHead) Decode(data []byte) (decodedData []byte, needSendBack bool,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
func (r *randomHead) GetOverhead() int {
 | 
					func (r *randomHead) GetOverhead() int {
 | 
				
			||||||
	return 0
 | 
						return 0
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -218,8 +218,8 @@ func (t *tls12TicketAuth) Encode(data []byte) (encodedData []byte, err error) {
 | 
				
			|||||||
		pdata -= 2
 | 
							pdata -= 2
 | 
				
			||||||
		l += 2
 | 
							l += 2
 | 
				
			||||||
		encodedData[pdata-1] = 0x16 // tls handshake
 | 
							encodedData[pdata-1] = 0x16 // tls handshake
 | 
				
			||||||
		pdata -= 1
 | 
							// pdata -= 1
 | 
				
			||||||
		l += 1
 | 
							// l += 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		t.sendSaver = packData(t.sendSaver, data)
 | 
							t.sendSaver = packData(t.sendSaver, data)
 | 
				
			||||||
		t.handshakeStatus = 1
 | 
							t.handshakeStatus = 1
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user