X-Git-Url: http://www.git.cypherpunks.ru/?p=goircd.git;a=blobdiff_plain;f=goircd.go;h=240f0e6eaf49431bde8d00cfb587dca1a48ae0ae;hp=95b463aef0c00fb0ee439cc1cfbc6e46adbae5b3;hb=964a1bf9dbe211e21cc093001caa8962d513d513;hpb=62b4ca67a0fb6f3da4e1268c6d3ecefc84e24d61 diff --git a/goircd.go b/goircd.go index 95b463a..240f0e6 100644 --- a/goircd.go +++ b/goircd.go @@ -1,11 +1,10 @@ /* goircd -- minimalistic simple Internet Relay Chat (IRC) server -Copyright (C) 2014-2015 Sergey Matveev +Copyright (C) 2014-2018 | wn Sergey Matveev This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. +the Free Software Foundation, version 3 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -37,21 +36,19 @@ var ( logdir = flag.String("logdir", "", "Absolute path to directory for logs") statedir = flag.String("statedir", "", "Absolute path to directory for states") passwords = flag.String("passwords", "", "Optional path to passwords file") - - tlsBind = flag.String("tlsbind", "", "TLS address to bind to") - tlsPEM = flag.String("tlspem", "", "Path to TLS certificat+key PEM file") - - verbose = flag.Bool("v", false, "Enable verbose logging.") + tlsBind = flag.String("tlsbind", "", "TLS address to bind to") + tlsPEM = flag.String("tlspem", "", "Path to TLS certificat+key PEM file") + verbose = flag.Bool("v", false, "Enable verbose logging.") ) -func listenerLoop(sock net.Listener, events chan<- ClientEvent) { +func listenerLoop(sock net.Listener, events chan ClientEvent) { for { conn, err := sock.Accept() if err != nil { log.Println("Error during accepting connection", err) continue } - client := NewClient(hostname, conn) + client := NewClient(conn) go client.Processor(events) } } @@ -60,7 +57,6 @@ func Run() { events := make(chan ClientEvent) log.SetFlags(log.Ldate | log.Lmicroseconds | log.Lshortfile) - logSink := make(chan LogEvent) if *logdir == "" { // Dummy logger go func() { @@ -75,10 +71,7 @@ func Run() { log.Println(*logdir, "logger initialized") } - stateSink := make(chan StateEvent) - daemon := NewDaemon(version, hostname, motd, passwords, logSink, stateSink) - daemon.Verbose = *verbose - log.Println("goircd " + daemon.version + " is starting") + log.Println("goircd " + version + " is starting") if *statedir == "" { // Dummy statekeeper go func() { @@ -98,14 +91,14 @@ func Run() { if err != nil { log.Fatalf("Can not read state %s: %v", state, err) } - room, _ := daemon.RoomRegister(path.Base(state)) + room, _ := RoomRegister(path.Base(state)) contents := strings.Split(string(buf), "\n") if len(contents) < 2 { - log.Printf("State corrupted for %s: %q", room.name, contents) + log.Printf("State corrupted for %s: %q", *room.name, contents) } else { - room.topic = contents[0] - room.key = contents[1] - log.Println("Loaded state for room", room.name) + room.topic = &contents[0] + room.key = &contents[1] + log.Println("Loaded state for room", *room.name) } } go StateKeeper(*statedir, stateSink) @@ -133,8 +126,7 @@ func Run() { log.Println("TLS listening on", *tlsBind) go listenerLoop(listenerTLS, events) } - - daemon.Processor(events) + Processor(events, make(chan struct{})) } func main() {