Some tweaking
This commit is contained in:
parent
a2f8d79c75
commit
e4261d73b8
10
client.go
10
client.go
@ -4,7 +4,6 @@ import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
@ -159,8 +158,6 @@ func (c *Client) reply(code int, args ...string) {
|
||||
}
|
||||
|
||||
func (c *Client) clientThread() {
|
||||
defer c.connection.Close()
|
||||
|
||||
readSignalChan := make(chan int, 3)
|
||||
writeSignalChan := make(chan int, 3)
|
||||
writeChan := make(chan string, 100)
|
||||
@ -175,6 +172,8 @@ func (c *Client) clientThread() {
|
||||
}
|
||||
|
||||
delete(c.server.clientMap, c.nick)
|
||||
|
||||
c.connection.Close()
|
||||
}()
|
||||
|
||||
for {
|
||||
@ -188,10 +187,9 @@ func (c *Client) clientThread() {
|
||||
case line := <-c.outputChan:
|
||||
select {
|
||||
case writeChan <- line:
|
||||
//It worked
|
||||
continue
|
||||
default:
|
||||
log.Printf("Dropped a line for client: %q", c.nick)
|
||||
//Do nothing, dropping the line
|
||||
c.disconnect()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
20
main.go
20
main.go
@ -8,17 +8,16 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
var (
|
||||
tlsKeyFile = flag.String("tls-key", "tls.key", "The private key file used for TLS")
|
||||
tlsCertFile = flag.String("tls-cert", "tls.crt", "The certificate file used for TLS")
|
||||
ircAddress = flag.String("irc-address", ":6697", "The address:port to bind to and listen for clients on")
|
||||
serverName = flag.String("irc-servername", "rosella", "Server name displayed to clients")
|
||||
authFile = flag.String("irc-authfile", "", "File containing usernames and passwords of operators.")
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
tlsKeyFile := flag.String("tls-key", "tls.key", "The private key file used for TLS")
|
||||
tlsCertFile := flag.String("tls-cert", "tls.crt", "The certificate file used for TLS")
|
||||
|
||||
ircAddress := flag.String("irc-address", ":6697", "The address:port to bind to and listen for clients on")
|
||||
|
||||
serverName := flag.String("irc-servername", "rosella", "Server name displayed to clients")
|
||||
|
||||
authFile := flag.String("irc-authfile", "", "File containing usernames and passwords of operators.")
|
||||
|
||||
flag.Parse()
|
||||
|
||||
log.Printf("Rosella Initialising.")
|
||||
@ -52,7 +51,8 @@ func main() {
|
||||
}
|
||||
}
|
||||
}
|
||||
server.Run()
|
||||
|
||||
go server.Run()
|
||||
|
||||
tlsConfig := new(tls.Config)
|
||||
|
||||
|
11
server.go
11
server.go
@ -4,7 +4,6 @@ import (
|
||||
"crypto/sha1"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"net"
|
||||
"regexp"
|
||||
"strings"
|
||||
@ -24,19 +23,9 @@ func NewServer() *Server {
|
||||
}
|
||||
|
||||
func (s *Server) Run() {
|
||||
go func() {
|
||||
for event := range s.eventChan {
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
log.Printf("Recovered from panic()")
|
||||
log.Printf("%s sent %q", event.client.nick, event.input)
|
||||
log.Println(err)
|
||||
}
|
||||
}()
|
||||
|
||||
s.handleEvent(<-s.eventChan)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
func (s *Server) HandleConnection(conn net.Conn) {
|
||||
|
Loading…
Reference in New Issue
Block a user