aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2024-12-08 15:54:44 +0800
committerRunxi Yu <me@runxiyu.org>2024-12-08 15:54:44 +0800
commit70d581432bcfca0550f5cfe028c2be20864459e9 (patch)
treefa34b6b8aaa532fbcd06a15f6c9d094feb9ecdb9
parentAUTHENTICATE: Send ERR_SASLFAIL if sasl not requested (diff)
downloadmeseircd-70d581432bcfca0550f5cfe028c2be20864459e9.tar.gz
meseircd-70d581432bcfca0550f5cfe028c2be20864459e9.tar.zst
meseircd-70d581432bcfca0550f5cfe028c2be20864459e9.zip
Send 002 to 005 stubs on registration
-rw-r--r--cap_sasl.go2
-rw-r--r--clients.go37
-rw-r--r--main.go2
-rw-r--r--numerics.go6
4 files changed, 34 insertions, 13 deletions
diff --git a/cap_sasl.go b/cap_sasl.go
index 36a353d..feb1ab4 100644
--- a/cap_sasl.go
+++ b/cap_sasl.go
@@ -1,8 +1,8 @@
package main
import (
- "encoding/base64"
"bytes"
+ "encoding/base64"
)
type ExtraSasl struct {
diff --git a/clients.go b/clients.go
index b141cf8..0ef95c6 100644
--- a/clients.go
+++ b/clients.go
@@ -56,7 +56,7 @@ func (client *Client) Teardown() {
if !uidToClient.CompareAndDelete(client.UID, client) {
slog.Error("uid inconsistent", "uid", client.UID, "client", client)
}
- if (client.State >= ClientStateRegistered || client.Nick != "*") {
+ if client.State >= ClientStateRegistered || client.Nick != "*" {
if !nickToClient.CompareAndDelete(client.Nick, client) {
slog.Error("nick inconsistent", "nick", client.Nick, "client", client)
}
@@ -94,20 +94,35 @@ func NewLocalClient(conn *net.Conn) (*Client, error) {
func (client *Client) checkRegistration() error {
switch client.State {
case ClientStatePreRegistration:
- if client.Nick != "*" && client.Ident != "" {
- client.State = ClientStateRegistered
- return client.Send(MakeMsg(self, RPL_WELCOME, client.Nick, "Welcome"))
- }
- return nil // Incomplete for registration
case ClientStateCapabilitiesFinished:
- if client.Nick != "*" && client.Ident != "" {
- client.State = ClientStateRegistered
- return client.Send(MakeMsg(self, RPL_WELCOME, client.Nick, "Welcome"))
- }
- return nil
default:
return nil
}
+ if client.Nick == "*" || client.Ident == "" {
+ return nil
+ }
+ client.State = ClientStateRegistered
+ err := client.Send(MakeMsg(self, RPL_WELCOME, client.Nick, "Welcome to the rxIRC network, "+client.Nick))
+ if err != nil {
+ return err
+ }
+ err = client.Send(MakeMsg(self, RPL_YOURHOST, client.Nick, "Your host is "+self.Name+", running version "+VERSION))
+ if err != nil {
+ return err
+ }
+ err = client.Send(MakeMsg(self, RPL_CREATED, client.Nick, "This server was created 1970-01-01 00:00:00 UTC"))
+ if err != nil {
+ return err
+ }
+ err = client.Send(MakeMsg(self, RPL_MYINFO, client.Nick, self.Name, VERSION, "", "", ""))
+ if err != nil {
+ return err
+ }
+ err = client.Send(MakeMsg(self, RPL_ISUPPORT, "YAY=", "are supported by this server"))
+ if err != nil {
+ return err
+ }
+ return nil
}
type ClientState uint8
diff --git a/main.go b/main.go
index 28b05b0..3f6025a 100644
--- a/main.go
+++ b/main.go
@@ -8,6 +8,8 @@ import (
"os"
)
+const VERSION = "MeseIRCd-0.0.0"
+
func main() {
logger := slog.New(slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{Level: slog.LevelDebug}))
slog.SetDefault(logger)
diff --git a/numerics.go b/numerics.go
index fceae22..dcf7812 100644
--- a/numerics.go
+++ b/numerics.go
@@ -1,7 +1,11 @@
package main
const (
- RPL_WELCOME = "001"
+ RPL_WELCOME = "001"
+ RPL_YOURHOST = "002"
+ RPL_CREATED = "003"
+ RPL_MYINFO = "004"
+ RPL_ISUPPORT = "005"
)
const (