hid: rename to xS before merge into xK
This commit is contained in:
parent
1238233556
commit
8344b09c4f
@ -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 "}"
|
|
||||||
}'
|
|
19
xS/main.go
19
xS/main.go
@ -13,7 +13,7 @@
|
|||||||
// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
// 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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -43,7 +43,7 @@ import (
|
|||||||
var debugMode = false
|
var debugMode = false
|
||||||
|
|
||||||
const (
|
const (
|
||||||
projectName = "hid"
|
projectName = "xS"
|
||||||
// TODO: Consider using the same version number for all subprojects.
|
// TODO: Consider using the same version number for all subprojects.
|
||||||
projectVersion = "0"
|
projectVersion = "0"
|
||||||
)
|
)
|
||||||
@ -162,15 +162,14 @@ func splitString(s, delims string, ignoreEmpty bool) (result []string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Trivial SSL/TLS autodetection. The first block of data returned by Recvfrom
|
// 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
|
// 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.
|
// not pose a problem in practice. We might try waiting for them.
|
||||||
//
|
//
|
||||||
// SSL2: 1xxx xxxx | xxxx xxxx | <1>
|
// SSL2: 1xxx xxxx | xxxx xxxx | <1>
|
||||||
// (message length) (client hello)
|
// (message length) (client hello)
|
||||||
// SSL3/TLS: <22> | <3> | xxxx xxxx
|
// SSL3/TLS: <22> | <3> | xxxx xxxx
|
||||||
// (handshake)| (protocol version)
|
// (handshake)| (protocol version)
|
||||||
//
|
//
|
||||||
// Note that Go 1.12's crypto/tls offers a slightly more straight-forward
|
// 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,
|
// 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)
|
return writeConfigurationFile(pathHint, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convenience wrapper suitable for most simple applications.
|
// Convenience wrapper suitable for most simple applications.
|
||||||
func callSimpleConfigWriteDefault(pathHint string, table []simpleConfigItem) {
|
func callSimpleConfigWriteDefault(pathHint string, table []simpleConfigItem) {
|
||||||
prologLines := []string{
|
prologLines := []string{
|
||||||
`# ` + projectName + ` ` + projectVersion + ` configuration file`,
|
`# ` + projectName + ` ` + projectVersion + ` configuration file`,
|
||||||
@ -461,7 +460,7 @@ func (fd *floodDetector) check() bool {
|
|||||||
|
|
||||||
// --- IRC protocol ------------------------------------------------------------
|
// --- 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 {
|
func ircToLower(c byte) byte {
|
||||||
switch c {
|
switch c {
|
||||||
@ -1201,7 +1200,7 @@ func (c *client) sendReply(id int, args ...interface{}) {
|
|||||||
c.send(c.makeReply(id, args...))
|
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{}) {
|
func (c *client) sendReplyVector(id int, items []string, args ...interface{}) {
|
||||||
common := c.makeReply(id, args...)
|
common := c.makeReply(id, args...)
|
||||||
|
|
||||||
|
16
xS/xS-gen-replies.awk
Executable file
16
xS/xS-gen-replies.awk
Executable file
@ -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 "}"
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user