mirror of https://github.com/cbeuw/Cloak
Use pointer for UserInfo in User struct
This commit is contained in:
parent
7919834dfe
commit
3abef6dbad
|
|
@ -47,7 +47,8 @@ func (c *controller) HandleRequest(req []byte) ([]byte, error) {
|
|||
if err == ErrInvalidMac {
|
||||
log.Printf("!!!CONTROL MESSAGE AND HMAC MISMATCH!!!\n raw request:\n%x\ndecrypted msg:\n%x", req, plain)
|
||||
return nil, err
|
||||
} else {
|
||||
} else if err != nil {
|
||||
log.Println(err)
|
||||
return c.respond([]byte(err.Error())), nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,9 +26,7 @@ type User struct {
|
|||
|
||||
arrUID [32]byte
|
||||
|
||||
// TODO: use pointer here instead because we don't want to accidentally read
|
||||
// UserInfo's Credits?
|
||||
UserInfo
|
||||
*UserInfo
|
||||
|
||||
valve *mux.Valve
|
||||
|
||||
|
|
@ -36,7 +34,7 @@ type User struct {
|
|||
sessions map[uint32]*mux.Session
|
||||
}
|
||||
|
||||
func MakeUser(up *Userpanel, uinfo UserInfo) *User {
|
||||
func MakeUser(up *Userpanel, uinfo *UserInfo) *User {
|
||||
// this instance of valve is shared across ALL sessions of a user
|
||||
valve := mux.MakeValve(uinfo.UpRate, uinfo.DownRate, &uinfo.UpCredit, &uinfo.DownCredit)
|
||||
u := &User{
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ func (up *Userpanel) GetAndActivateUser(UID []byte) (*User, error) {
|
|||
up.activeUsersM.Unlock()
|
||||
return nil, err
|
||||
}
|
||||
u := MakeUser(up, uinfo)
|
||||
u := MakeUser(up, &uinfo)
|
||||
up.activeUsers[arrUID] = u
|
||||
up.activeUsersM.Unlock()
|
||||
return u, nil
|
||||
|
|
|
|||
Loading…
Reference in New Issue