Preparation for TLS
This commit is contained in:
parent
98c785df43
commit
2b510d3a04
31
server.go
31
server.go
|
@ -77,8 +77,14 @@ func NewServer(configPath, software, version string) *Server {
|
|||
func (sv *Server) Run() {
|
||||
xlog.Info("%s/%s", sv.software, sv.version)
|
||||
go monitoringRun(sv)
|
||||
laddr, _ := sv.config.GetString("net", "listen_ircd")
|
||||
laddr, err := sv.config.GetString("net", "listen")
|
||||
if err == nil {
|
||||
go sv.listen(laddr)
|
||||
}
|
||||
laddr, err = sv.config.GetString("net", "listen_tls")
|
||||
if err == nil {
|
||||
go sv.listenTls(laddr)
|
||||
}
|
||||
sv.dispatch()
|
||||
}
|
||||
|
||||
|
@ -100,6 +106,9 @@ func (sv *Server) listen(laddr string) {
|
|||
}
|
||||
}
|
||||
|
||||
func (sv *Server) listenTls(laddr string) {
|
||||
}
|
||||
|
||||
func (sv *Server) dispatch() {
|
||||
for {
|
||||
time.Sleep(1 * time.Millisecond)
|
||||
|
@ -111,7 +120,7 @@ func (sv *Server) dispatch() {
|
|||
case cl := <-sv.AddClient:
|
||||
name := cl.Name()
|
||||
sv.clients[name] = cl
|
||||
sv.clientLogon(cl)
|
||||
sv.sendLogon(cl.Name())
|
||||
xlog.Info("Client registered: '%s'", name)
|
||||
xlog.Info("Server has %d client(s)", len(sv.clients))
|
||||
xlog.Debug("Goroutines running: %d", runtime.NumGoroutine())
|
||||
|
@ -191,23 +200,23 @@ func (sv *Server) sendReply(tar, cmd, args, trail string) {
|
|||
cl.Receive(irc.M(sv.host, cmd, args, trail))
|
||||
}
|
||||
|
||||
func (sv *Server) clientLogon(cl Client) {
|
||||
sv.sendReply(cl.Name(), RPL_WELCOME, "", "Willkommen!")
|
||||
sv.sendReply(cl.Name(), RPL_YOURHOST, "",
|
||||
func (sv *Server) sendLogon(nick string) {
|
||||
sv.sendReply(nick, RPL_WELCOME, "", "Willkommen!")
|
||||
sv.sendReply(nick, RPL_YOURHOST, "",
|
||||
fmt.Sprintf("Your host is %s, running on %s/%s",
|
||||
sv.host, sv.software, sv.version))
|
||||
sv.sendReply(cl.Name(), RPL_CREATED, "",
|
||||
sv.sendReply(nick, RPL_CREATED, "",
|
||||
fmt.Sprintf("Created: %s", sv.created))
|
||||
sv.sendReply(cl.Name(), RPL_MYINFO, "",
|
||||
sv.sendReply(nick, RPL_MYINFO, "",
|
||||
fmt.Sprintf(myinfo, sv.host, sv.software, sv.version))
|
||||
sv.sendReply(cl.Name(), RPL_ISUPPORT, "",
|
||||
sv.sendReply(nick, RPL_ISUPPORT, "",
|
||||
isupport+" are supported by this server")
|
||||
sv.sendReply(cl.Name(), RPL_MOTDSTART, "",
|
||||
sv.sendReply(nick, RPL_MOTDSTART, "",
|
||||
fmt.Sprintf("- %s Message of the day -", sv.host))
|
||||
for _, line := range strings.Split(sv.motd, "\n") {
|
||||
sv.sendReply(cl.Name(), RPL_MOTD, "", fmt.Sprintf("- %s", line))
|
||||
sv.sendReply(nick, RPL_MOTD, "", fmt.Sprintf("- %s", line))
|
||||
}
|
||||
sv.sendReply(cl.Name(), RPL_ENDOFMOTD, "", "End of MOTD command")
|
||||
sv.sendReply(nick, RPL_ENDOFMOTD, "", "End of MOTD command")
|
||||
}
|
||||
|
||||
func (sv *Server) channelJoin(nick, ch string) {
|
||||
|
|
Loading…
Reference in New Issue