support auth

This commit is contained in:
hdt3213
2021-05-09 18:37:29 +08:00
parent bf90941b76
commit 65fc1c3e62
10 changed files with 111 additions and 13 deletions

View File

@@ -20,6 +20,9 @@ type Connection struct {
// subscribing channels
subs map[string]bool
// password may be changed by CONFIG command during runtime, so store the password
password string
}
// RemoteAddr returns the remote network address
@@ -97,6 +100,14 @@ func (c *Connection) GetChannels() []string {
return channels
}
func (c *Connection) SetPassword(password string) {
c.password = password
}
func (c *Connection) GetPassword() string {
return c.password
}
type FakeConn struct {
Connection
buf bytes.Buffer
@@ -113,4 +124,4 @@ func (c *FakeConn) Clean() {
func (c *FakeConn) Bytes() []byte {
return c.buf.Bytes()
}
}