aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2024-12-08 09:20:23 +0800
committerRunxi Yu <me@runxiyu.org>2024-12-08 09:20:23 +0800
commit43e7a5479e120d13fd6c4bc76d1da00ba9ff2668 (patch)
tree7453074d6091728e26c4410503381a5ecbe52306
parentOmit msg.Tags nil check (diff)
downloadmeseircd-43e7a5479e120d13fd6c4bc76d1da00ba9ff2668.tar.gz
meseircd-43e7a5479e120d13fd6c4bc76d1da00ba9ff2668.tar.zst
meseircd-43e7a5479e120d13fd6c4bc76d1da00ba9ff2668.zip
Reformat
-rw-r--r--clients.go14
-rw-r--r--cmd_cap.go2
-rw-r--r--cmd_user.go2
-rw-r--r--numerics.go8
4 files changed, 14 insertions, 12 deletions
diff --git a/clients.go b/clients.go
index a1e0641..0588184 100644
--- a/clients.go
+++ b/clients.go
@@ -67,14 +67,14 @@ func NewLocalClient(conn *net.Conn) (*Client, error) {
State: ClientStatePreRegistration,
Nick: "*",
}
- for _ = range 10 {
- var uid_ = []byte(self.SID)
- for _ = range 6 {
+ for range 10 {
+ uid_ := []byte(self.SID)
+ for range 6 {
randint, err := rand.Int(rand.Reader, big.NewInt(26))
if err != nil {
return nil, err
}
- uid_ = append(uid_, byte(65 + randint.Uint64()))
+ uid_ = append(uid_, byte(65+randint.Uint64()))
}
uid := string(uid_)
_, exists := uidToClient.LoadOrStore(uid, client)
@@ -104,5 +104,7 @@ const (
ClientStateRegistered
)
-var uidToClient = sync.Map{}
-var nickToClient = sync.Map{}
+var (
+ uidToClient = sync.Map{}
+ nickToClient = sync.Map{}
+)
diff --git a/cmd_cap.go b/cmd_cap.go
index 45aaacc..a984c07 100644
--- a/cmd_cap.go
+++ b/cmd_cap.go
@@ -13,7 +13,7 @@ func handleClientCap(msg RMsg, client *Client) bool {
client.Send(MakeMsg(self, ERR_NEEDMOREPARAMS, "CAP", "Not enough parameters"))
return true
}
- switch (strings.ToUpper(msg.Params[0])) {
+ switch strings.ToUpper(msg.Params[0]) {
case "LS":
client.Send(MakeMsg(self, "CAP", client.Nick, "LS", "sasl=PLAIN,EXTERNAL"))
case "REQ":
diff --git a/cmd_user.go b/cmd_user.go
index 3db56c7..06fd7a3 100644
--- a/cmd_user.go
+++ b/cmd_user.go
@@ -13,7 +13,7 @@ func handleClientUser(msg RMsg, client *Client) bool {
client.Send(MakeMsg(self, ERR_NEEDMOREPARAMS, "USER", "Not enough parameters"))
return true
}
- switch (client.State) {
+ switch client.State {
case ClientStatePreRegistration:
client.Ident = "~" + msg.Params[0]
client.Gecos = msg.Params[3]
diff --git a/numerics.go b/numerics.go
index 8877306..fceae22 100644
--- a/numerics.go
+++ b/numerics.go
@@ -5,9 +5,9 @@ const (
)
const (
- ERR_UNKNOWNCOMMAND = "421"
- ERR_INPUTTOOLONG = "417"
- ERR_NEEDMOREPARAMS = "461"
- ERR_NICKNAMEINUSE = "433"
+ ERR_UNKNOWNCOMMAND = "421"
+ ERR_INPUTTOOLONG = "417"
+ ERR_NEEDMOREPARAMS = "461"
+ ERR_NICKNAMEINUSE = "433"
ERR_ALREADYREGISTERED = "462"
)