From 8344b09c4f9989370691c71b1145b09348e0a6d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=99emysl=20Eric=20Janouch?= Date: Mon, 26 Sep 2022 12:23:58 +0200 Subject: hid: rename to xS before merge into xK --- xS/hid-gen-replies.sh | 16 ---------- xS/hid-replies | 87 --------------------------------------------------- xS/main.go | 19 ++++++----- xS/xS-gen-replies.awk | 16 ++++++++++ xS/xS-replies | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 112 insertions(+), 113 deletions(-) delete mode 100755 xS/hid-gen-replies.sh delete mode 100644 xS/hid-replies create mode 100755 xS/xS-gen-replies.awk create mode 100644 xS/xS-replies diff --git a/xS/hid-gen-replies.sh b/xS/hid-gen-replies.sh deleted file mode 100755 index c32b000..0000000 --- a/xS/hid-gen-replies.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh -LC_ALL=C exec awk ' - /^[0-9]+ *(ERR|RPL)_[A-Z]+ *".*"$/ { - match($0, /".*"/); - ids[$1] = $2; - texts[$2] = substr($0, RSTART, RLENGTH); - } - END { - print "package " ENVIRON["GOPACKAGE"] "\n\nconst (" - for (i in ids) - printf("\t%s = %s\n", ids[i], i) - print ")\n\nvar defaultReplies = map[int]string{" - for (i in ids) - print "\t" ids[i] ": " texts[ids[i]] "," - print "}" - }' diff --git a/xS/hid-replies b/xS/hid-replies deleted file mode 100644 index c539520..0000000 --- a/xS/hid-replies +++ /dev/null @@ -1,87 +0,0 @@ -1 RPL_WELCOME ":Welcome to the Internet Relay Network %s!%s@%s" -2 RPL_YOURHOST ":Your host is %s, running version %s" -3 RPL_CREATED ":This server was created %s" -4 RPL_MYINFO "%s %s %s %s" -5 RPL_ISUPPORT "%s :are supported by this server" -211 RPL_STATSLINKINFO "%s %d %d %d %d %d %d" -212 RPL_STATSCOMMANDS "%s %d %d %d" -219 RPL_ENDOFSTATS "%c :End of STATS report" -221 RPL_UMODEIS "+%s" -242 RPL_STATSUPTIME ":Server Up %d days %d:%02d:%02d" -251 RPL_LUSERCLIENT ":There are %d users and %d services on %d servers" -252 RPL_LUSEROP "%d :operator(s) online" -253 RPL_LUSERUNKNOWN "%d :unknown connection(s)" -254 RPL_LUSERCHANNELS "%d :channels formed" -255 RPL_LUSERME ":I have %d clients and %d servers" -301 RPL_AWAY "%s :%s" -302 RPL_USERHOST ":%s" -303 RPL_ISON ":%s" -305 RPL_UNAWAY ":You are no longer marked as being away" -306 RPL_NOWAWAY ":You have been marked as being away" -311 RPL_WHOISUSER "%s %s %s * :%s" -312 RPL_WHOISSERVER "%s %s :%s" -313 RPL_WHOISOPERATOR "%s :is an IRC operator" -314 RPL_WHOWASUSER "%s %s %s * :%s" -315 RPL_ENDOFWHO "%s :End of WHO list" -317 RPL_WHOISIDLE "%s %d :seconds idle" -318 RPL_ENDOFWHOIS "%s :End of WHOIS list" -319 RPL_WHOISCHANNELS "%s :%s" -322 RPL_LIST "%s %d :%s" -323 RPL_LISTEND ":End of LIST" -324 RPL_CHANNELMODEIS "%s +%s" -329 RPL_CREATIONTIME "%s %d" -331 RPL_NOTOPIC "%s :No topic is set" -332 RPL_TOPIC "%s :%s" -333 RPL_TOPICWHOTIME "%s %s %d" -341 RPL_INVITING "%s %s" -346 RPL_INVITELIST "%s %s" -347 RPL_ENDOFINVITELIST "%s :End of channel invite list" -348 RPL_EXCEPTLIST "%s %s" -349 RPL_ENDOFEXCEPTLIST "%s :End of channel exception list" -351 RPL_VERSION "%s.%d %s :%s" -352 RPL_WHOREPLY "%s %s %s %s %s %s :%d %s" -353 RPL_NAMREPLY "%c %s :%s" -364 RPL_LINKS "%s %s :%d %s" -365 RPL_ENDOFLINKS "%s :End of LINKS list" -366 RPL_ENDOFNAMES "%s :End of NAMES list" -367 RPL_BANLIST "%s %s" -368 RPL_ENDOFBANLIST "%s :End of channel ban list" -369 RPL_ENDOFWHOWAS "%s :End of WHOWAS" -372 RPL_MOTD ":- %s" -375 RPL_MOTDSTART ":- %s Message of the day - " -376 RPL_ENDOFMOTD ":End of MOTD command" -391 RPL_TIME "%s :%s" -401 ERR_NOSUCHNICK "%s :No such nick/channel" -402 ERR_NOSUCHSERVER "%s :No such server" -403 ERR_NOSUCHCHANNEL "%s :No such channel" -404 ERR_CANNOTSENDTOCHAN "%s :Cannot send to channel" -406 ERR_WASNOSUCHNICK "%s :There was no such nickname" -409 ERR_NOORIGIN ":No origin specified" -410 ERR_INVALIDCAPCMD "%s :%s" -411 ERR_NORECIPIENT ":No recipient given (%s)" -412 ERR_NOTEXTTOSEND ":No text to send" -421 ERR_UNKNOWNCOMMAND "%s: Unknown command" -422 ERR_NOMOTD ":MOTD File is missing" -423 ERR_NOADMININFO "%s :No administrative info available" -431 ERR_NONICKNAMEGIVEN ":No nickname given" -432 ERR_ERRONEOUSNICKNAME "%s :Erroneous nickname" -433 ERR_NICKNAMEINUSE "%s :Nickname is already in use" -441 ERR_USERNOTINCHANNEL "%s %s :They aren't on that channel" -442 ERR_NOTONCHANNEL "%s :You're not on that channel" -443 ERR_USERONCHANNEL "%s %s :is already on channel" -445 ERR_SUMMONDISABLED ":SUMMON has been disabled" -446 ERR_USERSDISABLED ":USERS has been disabled" -451 ERR_NOTREGISTERED ":You have not registered" -461 ERR_NEEDMOREPARAMS "%s :Not enough parameters" -462 ERR_ALREADYREGISTERED ":Unauthorized command (already registered)" -467 ERR_KEYSET "%s :Channel key already set" -471 ERR_CHANNELISFULL "%s :Cannot join channel (+l)" -472 ERR_UNKNOWNMODE "%c :is unknown mode char to me for %s" -473 ERR_INVITEONLYCHAN "%s :Cannot join channel (+i)" -474 ERR_BANNEDFROMCHAN "%s :Cannot join channel (+b)" -475 ERR_BADCHANNELKEY "%s :Cannot join channel (+k)" -476 ERR_BADCHANMASK "%s :Bad Channel Mask" -481 ERR_NOPRIVILEGES ":Permission Denied- You're not an IRC operator" -482 ERR_CHANOPRIVSNEEDED "%s :You're not channel operator" -501 ERR_UMODEUNKNOWNFLAG ":Unknown MODE flag" -502 ERR_USERSDONTMATCH ":Cannot change mode for other users" diff --git a/xS/main.go b/xS/main.go index 40f47bc..21851f1 100644 --- a/xS/main.go +++ b/xS/main.go @@ -13,7 +13,7 @@ // CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. // -// hid is a straight-forward port of xD IRCd from C. +// xS is a straight-forward port of xD IRCd from C. package main import ( @@ -43,7 +43,7 @@ import ( var debugMode = false const ( - projectName = "hid" + projectName = "xS" // TODO: Consider using the same version number for all subprojects. projectVersion = "0" ) @@ -162,15 +162,14 @@ func splitString(s, delims string, ignoreEmpty bool) (result []string) { return } -// // Trivial SSL/TLS autodetection. The first block of data returned by Recvfrom // must be at least three octets long for this to work reliably, but that should // not pose a problem in practice. We might try waiting for them. // -// SSL2: 1xxx xxxx | xxxx xxxx | <1> -// (message length) (client hello) -// SSL3/TLS: <22> | <3> | xxxx xxxx -// (handshake)| (protocol version) +// SSL2: 1xxx xxxx | xxxx xxxx | <1> +// (message length) (client hello) +// SSL3/TLS: <22> | <3> | xxxx xxxx +// (handshake)| (protocol version) // // Note that Go 1.12's crypto/tls offers a slightly more straight-forward // solution: "If a client sends an initial message that does not look like TLS, @@ -383,7 +382,7 @@ func simpleConfigWriteDefault(pathHint string, prolog string, return writeConfigurationFile(pathHint, data) } -/// Convenience wrapper suitable for most simple applications. +// Convenience wrapper suitable for most simple applications. func callSimpleConfigWriteDefault(pathHint string, table []simpleConfigItem) { prologLines := []string{ `# ` + projectName + ` ` + projectVersion + ` configuration file`, @@ -461,7 +460,7 @@ func (fd *floodDetector) check() bool { // --- IRC protocol ------------------------------------------------------------ -//go:generate sh -c "./hid-gen-replies.sh > hid-replies.go < hid-replies" +//go:generate sh -c "LC_ALL=C awk -f xS-gen-replies.awk > xS-replies.go < xS-replies" func ircToLower(c byte) byte { switch c { @@ -1201,7 +1200,7 @@ func (c *client) sendReply(id int, args ...interface{}) { c.send(c.makeReply(id, args...)) } -/// Send a space-separated list of words across as many replies as needed. +// Send a space-separated list of words across as many replies as needed. func (c *client) sendReplyVector(id int, items []string, args ...interface{}) { common := c.makeReply(id, args...) diff --git a/xS/xS-gen-replies.awk b/xS/xS-gen-replies.awk new file mode 100755 index 0000000..fce7b50 --- /dev/null +++ b/xS/xS-gen-replies.awk @@ -0,0 +1,16 @@ +#!/usr/bin/awk -f +/^[0-9]+ *(ERR|RPL)_[A-Z]+ *".*"$/ { + match($0, /".*"/); + ids[$1] = $2; + texts[$2] = substr($0, RSTART, RLENGTH); +} + +END { + print "package " ENVIRON["GOPACKAGE"] "\n\nconst (" + for (i in ids) + printf("\t%s = %s\n", ids[i], i) + print ")\n\nvar defaultReplies = map[int]string{" + for (i in ids) + print "\t" ids[i] ": " texts[ids[i]] "," + print "}" +} diff --git a/xS/xS-replies b/xS/xS-replies new file mode 100644 index 0000000..c539520 --- /dev/null +++ b/xS/xS-replies @@ -0,0 +1,87 @@ +1 RPL_WELCOME ":Welcome to the Internet Relay Network %s!%s@%s" +2 RPL_YOURHOST ":Your host is %s, running version %s" +3 RPL_CREATED ":This server was created %s" +4 RPL_MYINFO "%s %s %s %s" +5 RPL_ISUPPORT "%s :are supported by this server" +211 RPL_STATSLINKINFO "%s %d %d %d %d %d %d" +212 RPL_STATSCOMMANDS "%s %d %d %d" +219 RPL_ENDOFSTATS "%c :End of STATS report" +221 RPL_UMODEIS "+%s" +242 RPL_STATSUPTIME ":Server Up %d days %d:%02d:%02d" +251 RPL_LUSERCLIENT ":There are %d users and %d services on %d servers" +252 RPL_LUSEROP "%d :operator(s) online" +253 RPL_LUSERUNKNOWN "%d :unknown connection(s)" +254 RPL_LUSERCHANNELS "%d :channels formed" +255 RPL_LUSERME ":I have %d clients and %d servers" +301 RPL_AWAY "%s :%s" +302 RPL_USERHOST ":%s" +303 RPL_ISON ":%s" +305 RPL_UNAWAY ":You are no longer marked as being away" +306 RPL_NOWAWAY ":You have been marked as being away" +311 RPL_WHOISUSER "%s %s %s * :%s" +312 RPL_WHOISSERVER "%s %s :%s" +313 RPL_WHOISOPERATOR "%s :is an IRC operator" +314 RPL_WHOWASUSER "%s %s %s * :%s" +315 RPL_ENDOFWHO "%s :End of WHO list" +317 RPL_WHOISIDLE "%s %d :seconds idle" +318 RPL_ENDOFWHOIS "%s :End of WHOIS list" +319 RPL_WHOISCHANNELS "%s :%s" +322 RPL_LIST "%s %d :%s" +323 RPL_LISTEND ":End of LIST" +324 RPL_CHANNELMODEIS "%s +%s" +329 RPL_CREATIONTIME "%s %d" +331 RPL_NOTOPIC "%s :No topic is set" +332 RPL_TOPIC "%s :%s" +333 RPL_TOPICWHOTIME "%s %s %d" +341 RPL_INVITING "%s %s" +346 RPL_INVITELIST "%s %s" +347 RPL_ENDOFINVITELIST "%s :End of channel invite list" +348 RPL_EXCEPTLIST "%s %s" +349 RPL_ENDOFEXCEPTLIST "%s :End of channel exception list" +351 RPL_VERSION "%s.%d %s :%s" +352 RPL_WHOREPLY "%s %s %s %s %s %s :%d %s" +353 RPL_NAMREPLY "%c %s :%s" +364 RPL_LINKS "%s %s :%d %s" +365 RPL_ENDOFLINKS "%s :End of LINKS list" +366 RPL_ENDOFNAMES "%s :End of NAMES list" +367 RPL_BANLIST "%s %s" +368 RPL_ENDOFBANLIST "%s :End of channel ban list" +369 RPL_ENDOFWHOWAS "%s :End of WHOWAS" +372 RPL_MOTD ":- %s" +375 RPL_MOTDSTART ":- %s Message of the day - " +376 RPL_ENDOFMOTD ":End of MOTD command" +391 RPL_TIME "%s :%s" +401 ERR_NOSUCHNICK "%s :No such nick/channel" +402 ERR_NOSUCHSERVER "%s :No such server" +403 ERR_NOSUCHCHANNEL "%s :No such channel" +404 ERR_CANNOTSENDTOCHAN "%s :Cannot send to channel" +406 ERR_WASNOSUCHNICK "%s :There was no such nickname" +409 ERR_NOORIGIN ":No origin specified" +410 ERR_INVALIDCAPCMD "%s :%s" +411 ERR_NORECIPIENT ":No recipient given (%s)" +412 ERR_NOTEXTTOSEND ":No text to send" +421 ERR_UNKNOWNCOMMAND "%s: Unknown command" +422 ERR_NOMOTD ":MOTD File is missing" +423 ERR_NOADMININFO "%s :No administrative info available" +431 ERR_NONICKNAMEGIVEN ":No nickname given" +432 ERR_ERRONEOUSNICKNAME "%s :Erroneous nickname" +433 ERR_NICKNAMEINUSE "%s :Nickname is already in use" +441 ERR_USERNOTINCHANNEL "%s %s :They aren't on that channel" +442 ERR_NOTONCHANNEL "%s :You're not on that channel" +443 ERR_USERONCHANNEL "%s %s :is already on channel" +445 ERR_SUMMONDISABLED ":SUMMON has been disabled" +446 ERR_USERSDISABLED ":USERS has been disabled" +451 ERR_NOTREGISTERED ":You have not registered" +461 ERR_NEEDMOREPARAMS "%s :Not enough parameters" +462 ERR_ALREADYREGISTERED ":Unauthorized command (already registered)" +467 ERR_KEYSET "%s :Channel key already set" +471 ERR_CHANNELISFULL "%s :Cannot join channel (+l)" +472 ERR_UNKNOWNMODE "%c :is unknown mode char to me for %s" +473 ERR_INVITEONLYCHAN "%s :Cannot join channel (+i)" +474 ERR_BANNEDFROMCHAN "%s :Cannot join channel (+b)" +475 ERR_BADCHANNELKEY "%s :Cannot join channel (+k)" +476 ERR_BADCHANMASK "%s :Bad Channel Mask" +481 ERR_NOPRIVILEGES ":Permission Denied- You're not an IRC operator" +482 ERR_CHANOPRIVSNEEDED "%s :You're not channel operator" +501 ERR_UMODEUNKNOWNFLAG ":Unknown MODE flag" +502 ERR_USERSDONTMATCH ":Cannot change mode for other users" -- cgit v1.2.3