diff options
| author | bt <bt@localhost> | 2026-03-31 09:01:29 +0200 |
|---|---|---|
| committer | bt <bt@localhost> | 2026-03-31 10:38:03 +0200 |
| commit | 75504a81885db55a3f5f9041dcda6b9d2ef421b2 (patch) | |
| tree | b2b254240ec380b875380f5390d30dfa9cb0ad42 /server/user.go | |
| parent | 5e8c7c1c967f01f588655aced32b6b4ca6408850 (diff) | |
| download | solec-75504a81885db55a3f5f9041dcda6b9d2ef421b2.tar.gz solec-75504a81885db55a3f5f9041dcda6b9d2ef421b2.zip | |
[daemon] Better error handling
Diffstat (limited to 'server/user.go')
| -rw-r--r-- | server/user.go | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/server/user.go b/server/user.go new file mode 100644 index 0000000..204fbbe --- /dev/null +++ b/server/user.go @@ -0,0 +1,42 @@ +package server + +import ( + "net" + + "git.rctt.net/solec/core" +) + +type User struct { + Name string + Conns map[net.Conn]struct{} +} + +func NewUser(conn net.Conn, auth core.Auth) User { + u := User{ + Name: auth.Name, + Conns: make(map[net.Conn]struct{}), + } + + u.Conns[conn] = struct{}{} + return u +} + +func (u *User) Send(payload core.Wrapper) error { + for c := range u.Conns { + if err := core.Send(c, payload); err != nil { + return err + } + } + + return nil +} + +func (u *User) Auth(pass string) error { + // TODO: Implement auth + + if pass != "valid" { + return core.ErrAuthInvalidPassword + } + + return nil +} |
