mirror of https://github.com/cbeuw/Cloak
Syntax cleanups
This commit is contained in:
parent
24cdf274dd
commit
41da4102ab
|
|
@ -1,7 +1,5 @@
|
||||||
package multiplex
|
package multiplex
|
||||||
|
|
||||||
import ()
|
|
||||||
|
|
||||||
type Frame struct {
|
type Frame struct {
|
||||||
StreamID uint32
|
StreamID uint32
|
||||||
Seq uint32
|
Seq uint32
|
||||||
|
|
|
||||||
|
|
@ -32,19 +32,12 @@ func MakeValve(rxRate, txRate int64, rxCredit, txCredit *int64) *Valve {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *Valve) SetRxRate(rate int64) { v.rxtb.Store(ratelimit.NewBucketWithRate(float64(rate), rate)) }
|
func (v *Valve) SetRxRate(rate int64) { v.rxtb.Store(ratelimit.NewBucketWithRate(float64(rate), rate)) }
|
||||||
|
|
||||||
func (v *Valve) SetTxRate(rate int64) { v.txtb.Store(ratelimit.NewBucketWithRate(float64(rate), rate)) }
|
func (v *Valve) SetTxRate(rate int64) { v.txtb.Store(ratelimit.NewBucketWithRate(float64(rate), rate)) }
|
||||||
|
|
||||||
func (v *Valve) rxWait(n int) { v.rxtb.Load().(*ratelimit.Bucket).Wait(int64(n)) }
|
func (v *Valve) rxWait(n int) { v.rxtb.Load().(*ratelimit.Bucket).Wait(int64(n)) }
|
||||||
|
|
||||||
func (v *Valve) txWait(n int) { v.txtb.Load().(*ratelimit.Bucket).Wait(int64(n)) }
|
func (v *Valve) txWait(n int) { v.txtb.Load().(*ratelimit.Bucket).Wait(int64(n)) }
|
||||||
|
|
||||||
func (v *Valve) SetRxCredit(n int64) { atomic.StoreInt64(v.rxCredit, n) }
|
func (v *Valve) SetRxCredit(n int64) { atomic.StoreInt64(v.rxCredit, n) }
|
||||||
|
|
||||||
func (v *Valve) SetTxCredit(n int64) { atomic.StoreInt64(v.txCredit, n) }
|
func (v *Valve) SetTxCredit(n int64) { atomic.StoreInt64(v.txCredit, n) }
|
||||||
|
|
||||||
func (v *Valve) GetRxCredit() int64 { return atomic.LoadInt64(v.rxCredit) }
|
func (v *Valve) GetRxCredit() int64 { return atomic.LoadInt64(v.rxCredit) }
|
||||||
|
|
||||||
func (v *Valve) GetTxCredit() int64 { return atomic.LoadInt64(v.txCredit) }
|
func (v *Valve) GetTxCredit() int64 { return atomic.LoadInt64(v.txCredit) }
|
||||||
|
|
||||||
// n can be negative
|
// n can be negative
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// Copied from smux
|
|
||||||
acceptBacklog = 1024
|
acceptBacklog = 1024
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -42,7 +41,6 @@ type Session struct {
|
||||||
suicide sync.Once
|
suicide sync.Once
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1 conn is needed to make a session
|
|
||||||
func MakeSession(id uint32, valve *Valve, obfs Obfser, deobfs Deobfser, obfsedRead func(net.Conn, []byte) (int, error)) *Session {
|
func MakeSession(id uint32, valve *Valve, obfs Obfser, deobfs Deobfser, obfsedRead func(net.Conn, []byte) (int, error)) *Session {
|
||||||
sesh := &Session{
|
sesh := &Session{
|
||||||
id: id,
|
id: id,
|
||||||
|
|
|
||||||
|
|
@ -20,11 +20,6 @@ type rawConfig struct {
|
||||||
DatabasePath string
|
DatabasePath string
|
||||||
BackupDirPath string
|
BackupDirPath string
|
||||||
}
|
}
|
||||||
type stateManager interface {
|
|
||||||
ParseConfig(string) error
|
|
||||||
SetAESKey(string)
|
|
||||||
PutUsedRandom([32]byte)
|
|
||||||
}
|
|
||||||
|
|
||||||
// State type stores the global state of the program
|
// State type stores the global state of the program
|
||||||
type State struct {
|
type State struct {
|
||||||
|
|
|
||||||
|
|
@ -125,7 +125,7 @@ func (up *Userpanel) GetAndActivateAdminUser(AdminUID []byte) (*User, error) {
|
||||||
return user, nil
|
return user, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetUser is used to retrieve a user if s/he is active, or to retrieve the user's infor
|
// GetUser is used to retrieve a user if s/he is active, or to retrieve the user's info
|
||||||
// from the db and mark it as an active user
|
// from the db and mark it as an active user
|
||||||
func (up *Userpanel) GetAndActivateUser(UID []byte) (*User, error) {
|
func (up *Userpanel) GetAndActivateUser(UID []byte) (*User, error) {
|
||||||
up.activeUsersM.Lock()
|
up.activeUsersM.Lock()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue