mirror of https://github.com/cbeuw/Cloak
Switch back to juju/ratelimit
This commit is contained in:
parent
0c00094a8b
commit
c8184fc1d2
2
go.mod
2
go.mod
|
|
@ -4,8 +4,8 @@ go 1.12
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/boltdb/bolt v1.3.1
|
github.com/boltdb/bolt v1.3.1
|
||||||
github.com/cbeuw/ratelimit v1.1.0
|
|
||||||
github.com/gorilla/mux v1.7.3
|
github.com/gorilla/mux v1.7.3
|
||||||
|
github.com/juju/ratelimit v1.0.1
|
||||||
github.com/kr/pretty v0.1.0 // indirect
|
github.com/kr/pretty v0.1.0 // indirect
|
||||||
github.com/sirupsen/logrus v1.4.2
|
github.com/sirupsen/logrus v1.4.2
|
||||||
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4
|
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ package multiplex
|
||||||
import (
|
import (
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
|
||||||
"github.com/cbeuw/ratelimit"
|
"github.com/juju/ratelimit"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Valve needs to be universal, across all sessions that belong to a user
|
// Valve needs to be universal, across all sessions that belong to a user
|
||||||
|
|
@ -14,8 +14,8 @@ type LimitedValve struct {
|
||||||
// rx is from client to server, tx is from server to client
|
// rx is from client to server, tx is from server to client
|
||||||
// DO NOT use terms up or down as this is used in usermanager
|
// DO NOT use terms up or down as this is used in usermanager
|
||||||
// for bandwidth limiting
|
// for bandwidth limiting
|
||||||
rxtb ratelimit.Bucket
|
rxtb *ratelimit.Bucket
|
||||||
txtb ratelimit.Bucket
|
txtb *ratelimit.Bucket
|
||||||
|
|
||||||
rx *int64
|
rx *int64
|
||||||
tx *int64
|
tx *int64
|
||||||
|
|
@ -26,8 +26,8 @@ type UnlimitedValve struct{}
|
||||||
func MakeValve(rxRate, txRate int64) *LimitedValve {
|
func MakeValve(rxRate, txRate int64) *LimitedValve {
|
||||||
var rx, tx int64
|
var rx, tx int64
|
||||||
v := &LimitedValve{
|
v := &LimitedValve{
|
||||||
rxtb: ratelimit.NewLimitedBucketWithRate(float64(rxRate), rxRate),
|
rxtb: ratelimit.NewBucketWithRate(float64(rxRate), rxRate),
|
||||||
txtb: ratelimit.NewLimitedBucketWithRate(float64(txRate), txRate),
|
txtb: ratelimit.NewBucketWithRate(float64(txRate), txRate),
|
||||||
rx: &rx,
|
rx: &rx,
|
||||||
tx: &tx,
|
tx: &tx,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,7 @@ func makeStream(sesh *Session, id uint32, assignedConnId uint32) *Stream {
|
||||||
func (s *Stream) isClosed() bool { return atomic.LoadUint32(&s.closed) == 1 }
|
func (s *Stream) isClosed() bool { return atomic.LoadUint32(&s.closed) == 1 }
|
||||||
|
|
||||||
func (s *Stream) writeFrame(frame *Frame) {
|
func (s *Stream) writeFrame(frame *Frame) {
|
||||||
|
// TODO: refactor this through an interface
|
||||||
if s.session.Unordered {
|
if s.session.Unordered {
|
||||||
s.buf.Write(frame.Payload)
|
s.buf.Write(frame.Payload)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue