aboutsummaryrefslogtreecommitdiff
path: root/hid/main.go
diff options
context:
space:
mode:
authorPřemysl Janouch <p@janouch.name>2018-08-03 21:12:45 +0200
committerPřemysl Janouch <p@janouch.name>2018-08-03 21:45:52 +0200
commit01c3933a073a54d709e647c0a8d3407ae408d7ea (patch)
tree9b81ddf4fa747f9f7004c81afd8d7e9226d0b1b3 /hid/main.go
parent4fa84cc877937834fea84b1977c68c9f8cd9642e (diff)
downloadhaven-01c3933a073a54d709e647c0a8d3407ae408d7ea.tar.gz
haven-01c3933a073a54d709e647c0a8d3407ae408d7ea.tar.xz
haven-01c3933a073a54d709e647c0a8d3407ae408d7ea.zip
hid: cleanups
Diffstat (limited to 'hid/main.go')
-rw-r--r--hid/main.go53
1 files changed, 31 insertions, 22 deletions
diff --git a/hid/main.go b/hid/main.go
index 5d498aa..c8b007e 100644
--- a/hid/main.go
+++ b/hid/main.go
@@ -748,26 +748,29 @@ type writeEvent struct {
err error // write error
}
-// TODO: Port server_context. Maybe we want to keep it in a struct? A better
-// question might be: can we run multiple instances of it?
-// XXX: Beware that maps with identifier keys need to be indexed correctly.
-// We might want to enforce accessor functions for users and channels.
+// TODO: Maybe we want to keep it in a struct?
+// A better question might be: can we run multiple instances of it?
var (
- started time.Time // when has the server been started
+ // network
+ listeners []net.Listener
+ clients = make(map[*client]bool)
+
+ // IRC state
+
+ // XXX: Beware that maps with identifier keys need to be indexed correctly.
+ // We might want to enforce accessor functions for users and channels.
+
+ started time.Time // when the server has been started
users = make(map[string]*client) // maps nicknames to clients
channels = make(map[string]*channel) // maps channel names to data
whowas = make(map[string]*whowasInfo) // WHOWAS registry
- config simpleConfig // server configuration
- serverName string // our server name
- pingInterval time.Duration // ping interval
- maxConnections int // max connections allowed or 0
- motd []string // MOTD (none if empty)
- operators = make(map[string]bool) // TLS cert. fingerprints for IRCops
-)
+ // event loop
+
+ quitting bool
+ quitTimer <-chan time.Time
-var (
sigs = make(chan os.Signal, 1)
conns = make(chan net.Conn)
prepared = make(chan preparedEvent)
@@ -775,11 +778,16 @@ var (
writes = make(chan writeEvent)
timers = make(chan func())
- tlsConf *tls.Config
- clients = make(map[*client]bool)
- listeners []net.Listener
- quitting bool
- quitTimer <-chan time.Time
+ // configuration
+
+ config simpleConfig // server configuration
+ tlsConf *tls.Config // TLS connection configuration
+ serverName string // our server name
+ pingInterval time.Duration // ping interval
+ maxConnections int // max connections allowed or 0
+ motd []string // MOTD (none if empty)
+ catalog map[int]string // message catalog for server msgs
+ operators map[string]bool // TLS certificate fingerprints for IRCops
)
// Forcefully tear down all connections.
@@ -1077,7 +1085,8 @@ func (c *client) makeReply(id int, ap ...interface{}) string {
return s + a
}
-// XXX: This way we cannot typecheck the arguments, so we should be careful.
+// XXX: This way simple static analysis cannot typecheck the arguments, so we
+// need to be careful.
func (c *client) sendReply(id int, args ...interface{}) {
c.send(c.makeReply(id, args...))
}
@@ -3152,12 +3161,12 @@ func ircInitializeMOTD() error {
return nil
}
- pathMOTD := resolveFilename(configMOTD, resolveRelativeConfigFilename)
- if pathMOTD == "" {
+ path := resolveFilename(configMOTD, resolveRelativeConfigFilename)
+ if path == "" {
return fmt.Errorf("cannot find file: %s", configMOTD)
}
- f, err := os.Open(pathMOTD)
+ f, err := os.Open(path)
if err != nil {
return fmt.Errorf("failed reading the MOTD file: %s", err)
}