mirror of
				https://github.com/nadoo/glider.git
				synced 2025-11-04 07:42:38 +08:00 
			
		
		
		
	smux: update to v1.5.16
This commit is contained in:
		
							parent
							
								
									ce85f15c4b
								
							
						
					
					
						commit
						e5031ac8d5
					
				
							
								
								
									
										6
									
								
								go.mod
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								go.mod
									
									
									
									
									
								
							@ -11,8 +11,8 @@ require (
 | 
				
			|||||||
	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/xtaci/kcp-go/v5 v5.6.1
 | 
						github.com/xtaci/kcp-go/v5 v5.6.1
 | 
				
			||||||
	golang.org/x/crypto v0.0.0-20210817164053-32db794688a5
 | 
						golang.org/x/crypto v0.0.0-20210921155107-089bfa567519
 | 
				
			||||||
	golang.org/x/sys v0.0.0-20210910150752-751e447fb3d0
 | 
						golang.org/x/sys v0.0.0-20210921065528-437939a70204
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
require (
 | 
					require (
 | 
				
			||||||
@ -26,7 +26,7 @@ require (
 | 
				
			|||||||
	github.com/templexxx/xorsimd v0.4.1 // indirect
 | 
						github.com/templexxx/xorsimd v0.4.1 // indirect
 | 
				
			||||||
	github.com/tjfoc/gmsm v1.4.1 // indirect
 | 
						github.com/tjfoc/gmsm v1.4.1 // indirect
 | 
				
			||||||
	github.com/u-root/uio v0.0.0-20210528151154-e40b768296a7 // indirect
 | 
						github.com/u-root/uio v0.0.0-20210528151154-e40b768296a7 // indirect
 | 
				
			||||||
	golang.org/x/net v0.0.0-20210908191846-a5e095526f91 // indirect
 | 
						golang.org/x/net v0.0.0-20210917221730-978cfadd31cf // indirect
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Replace dependency modules with local developing copy
 | 
					// Replace dependency modules with local developing copy
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										12
									
								
								go.sum
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								go.sum
									
									
									
									
									
								
							@ -104,8 +104,8 @@ golang.org/x/crypto v0.0.0-20191219195013-becbf705a915/go.mod h1:LzIPMQfyMNhhGPh
 | 
				
			|||||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
 | 
					golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
 | 
				
			||||||
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
 | 
					golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
 | 
				
			||||||
golang.org/x/crypto v0.0.0-20201012173705-84dcc777aaee/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
 | 
					golang.org/x/crypto v0.0.0-20201012173705-84dcc777aaee/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
 | 
				
			||||||
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 h1:HWj/xjIHfjYU5nVXpTM0s39J9CbLn7Cc5a7IC5rwsMQ=
 | 
					golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5UtiO8tQHbUSXxL+pnGRANg=
 | 
				
			||||||
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
 | 
					golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
 | 
				
			||||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
 | 
					golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
 | 
				
			||||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
 | 
					golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
 | 
				
			||||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
 | 
					golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
 | 
				
			||||||
@ -129,8 +129,8 @@ golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81R
 | 
				
			|||||||
golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
 | 
					golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
 | 
				
			||||||
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
 | 
					golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
 | 
				
			||||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
 | 
					golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
 | 
				
			||||||
golang.org/x/net v0.0.0-20210908191846-a5e095526f91 h1:E8wdt+zBjoxD3MA65wEc3pl25BsTi7tbkpwc4ANThjc=
 | 
					golang.org/x/net v0.0.0-20210917221730-978cfadd31cf h1:R150MpwJIv1MpS0N/pc+NhTM8ajzvlmxlY5OYsrevXQ=
 | 
				
			||||||
golang.org/x/net v0.0.0-20210908191846-a5e095526f91/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
 | 
					golang.org/x/net v0.0.0-20210917221730-978cfadd31cf/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
 | 
				
			||||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
 | 
					golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
 | 
				
			||||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 | 
					golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 | 
				
			||||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 | 
					golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 | 
				
			||||||
@ -156,8 +156,8 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w
 | 
				
			|||||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
					golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
				
			||||||
golang.org/x/sys v0.0.0-20210525143221-35b2ab0089ea/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 | 
					golang.org/x/sys v0.0.0-20210525143221-35b2ab0089ea/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 | 
				
			||||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 | 
					golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 | 
				
			||||||
golang.org/x/sys v0.0.0-20210910150752-751e447fb3d0 h1:xrCZDmdtoloIiooiA9q0OQb9r8HejIHYoHGhGCe1pGg=
 | 
					golang.org/x/sys v0.0.0-20210921065528-437939a70204 h1:JJhkWtBuTQKyz2bd5WG9H8iUsJRU3En/KRfN8B2RnDs=
 | 
				
			||||||
golang.org/x/sys v0.0.0-20210910150752-751e447fb3d0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 | 
					golang.org/x/sys v0.0.0-20210921065528-437939a70204/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 | 
				
			||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E=
 | 
					golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E=
 | 
				
			||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
 | 
					golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
 | 
				
			||||||
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=
 | 
				
			||||||
 | 
				
			|||||||
@ -29,7 +29,7 @@ var (
 | 
				
			|||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type writeRequest struct {
 | 
					type writeRequest struct {
 | 
				
			||||||
	prio   uint64
 | 
						prio   uint32
 | 
				
			||||||
	frame  Frame
 | 
						frame  Frame
 | 
				
			||||||
	result chan writeResult
 | 
						result chan writeResult
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -501,7 +501,7 @@ func (s *Session) writeFrame(f Frame) (n int, err error) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// internal writeFrame version to support deadline used in keepalive
 | 
					// internal writeFrame version to support deadline used in keepalive
 | 
				
			||||||
func (s *Session) writeFrameInternal(f Frame, deadline <-chan time.Time, prio uint64) (int, error) {
 | 
					func (s *Session) writeFrameInternal(f Frame, deadline <-chan time.Time, prio uint32) (int, error) {
 | 
				
			||||||
	req := writeRequest{
 | 
						req := writeRequest{
 | 
				
			||||||
		prio:   prio,
 | 
							prio:   prio,
 | 
				
			||||||
		frame:  f,
 | 
							frame:  f,
 | 
				
			||||||
 | 
				
			|||||||
@ -1,9 +1,13 @@
 | 
				
			|||||||
package smux
 | 
					package smux
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func _itimediff(later, earlier uint32) int32 {
 | 
				
			||||||
 | 
						return (int32)(later - earlier)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type shaperHeap []writeRequest
 | 
					type shaperHeap []writeRequest
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (h shaperHeap) Len() int            { return len(h) }
 | 
					func (h shaperHeap) Len() int            { return len(h) }
 | 
				
			||||||
func (h shaperHeap) Less(i, j int) bool  { return h[i].prio < h[j].prio }
 | 
					func (h shaperHeap) Less(i, j int) bool  { return _itimediff(h[j].prio, h[i].prio) > 0 }
 | 
				
			||||||
func (h shaperHeap) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
 | 
					func (h shaperHeap) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
 | 
				
			||||||
func (h *shaperHeap) Push(x interface{}) { *h = append(*h, x.(writeRequest)) }
 | 
					func (h *shaperHeap) Push(x interface{}) { *h = append(*h, x.(writeRequest)) }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -10,17 +10,19 @@ func TestShaper(t *testing.T) {
 | 
				
			|||||||
	w2 := writeRequest{prio: 10}
 | 
						w2 := writeRequest{prio: 10}
 | 
				
			||||||
	w3 := writeRequest{prio: 20}
 | 
						w3 := writeRequest{prio: 20}
 | 
				
			||||||
	w4 := writeRequest{prio: 100}
 | 
						w4 := writeRequest{prio: 100}
 | 
				
			||||||
 | 
						w5 := writeRequest{prio: (1 << 32) - 1}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var reqs shaperHeap
 | 
						var reqs shaperHeap
 | 
				
			||||||
 | 
						heap.Push(&reqs, w5)
 | 
				
			||||||
	heap.Push(&reqs, w4)
 | 
						heap.Push(&reqs, w4)
 | 
				
			||||||
	heap.Push(&reqs, w3)
 | 
						heap.Push(&reqs, w3)
 | 
				
			||||||
	heap.Push(&reqs, w2)
 | 
						heap.Push(&reqs, w2)
 | 
				
			||||||
	heap.Push(&reqs, w1)
 | 
						heap.Push(&reqs, w1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var lastPrio uint64
 | 
						var lastPrio = reqs[0].prio
 | 
				
			||||||
	for len(reqs) > 0 {
 | 
						for len(reqs) > 0 {
 | 
				
			||||||
		w := heap.Pop(&reqs).(writeRequest)
 | 
							w := heap.Pop(&reqs).(writeRequest)
 | 
				
			||||||
		if w.prio < lastPrio {
 | 
							if int32(w.prio-lastPrio) < 0 {
 | 
				
			||||||
			t.Fatal("incorrect shaper priority")
 | 
								t.Fatal("incorrect shaper priority")
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -320,7 +320,7 @@ func (s *Stream) Write(b []byte) (n int, err error) {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
		frame.data = bts[:sz]
 | 
							frame.data = bts[:sz]
 | 
				
			||||||
		bts = bts[sz:]
 | 
							bts = bts[sz:]
 | 
				
			||||||
		n, err := s.sess.writeFrameInternal(frame, deadline, uint64(s.numWritten))
 | 
							n, err := s.sess.writeFrameInternal(frame, deadline, s.numWritten)
 | 
				
			||||||
		s.numWritten++
 | 
							s.numWritten++
 | 
				
			||||||
		sent += n
 | 
							sent += n
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
@ -388,7 +388,7 @@ func (s *Stream) writeV2(b []byte) (n int, err error) {
 | 
				
			|||||||
				}
 | 
									}
 | 
				
			||||||
				frame.data = bts[:sz]
 | 
									frame.data = bts[:sz]
 | 
				
			||||||
				bts = bts[sz:]
 | 
									bts = bts[sz:]
 | 
				
			||||||
				n, err := s.sess.writeFrameInternal(frame, deadline, uint64(atomic.LoadUint32(&s.numWritten)))
 | 
									n, err := s.sess.writeFrameInternal(frame, deadline, atomic.LoadUint32(&s.numWritten))
 | 
				
			||||||
				atomic.AddUint32(&s.numWritten, uint32(sz))
 | 
									atomic.AddUint32(&s.numWritten, uint32(sz))
 | 
				
			||||||
				sent += n
 | 
									sent += n
 | 
				
			||||||
				if err != nil {
 | 
									if err != nil {
 | 
				
			||||||
 | 
				
			|||||||
@ -100,7 +100,7 @@ func authChainAGetRandLen(dataLength int, random *tools.Shift128plusContext, las
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
func getRandStartPos(random *tools.Shift128plusContext, randLength int) int {
 | 
					func getRandStartPos(random *tools.Shift128plusContext, randLength int) int {
 | 
				
			||||||
	if randLength > 0 {
 | 
						if randLength > 0 {
 | 
				
			||||||
		return int(random.Next() % 8589934609 % uint64(randLength))
 | 
							return int(int64(random.Next()%8589934609) % int64(randLength))
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return 0
 | 
						return 0
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user