diff options
-rw-r--r-- | cap_sasl.go | 2 | ||||
-rw-r--r-- | clients.go | 37 | ||||
-rw-r--r-- | main.go | 2 | ||||
-rw-r--r-- | numerics.go | 6 |
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 { @@ -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 @@ -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 ( |