mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-11 06:29:29 +01:00
commit
e44fbc3845
@ -6,6 +6,7 @@
|
|||||||
package irc
|
package irc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
@ -21,6 +22,9 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"code.cloudfoundry.org/bytefmt"
|
"code.cloudfoundry.org/bytefmt"
|
||||||
|
"github.com/goshuirc/irc-go/ircfmt"
|
||||||
|
"gopkg.in/yaml.v2"
|
||||||
|
|
||||||
"github.com/oragono/oragono/irc/caps"
|
"github.com/oragono/oragono/irc/caps"
|
||||||
"github.com/oragono/oragono/irc/cloaks"
|
"github.com/oragono/oragono/irc/cloaks"
|
||||||
"github.com/oragono/oragono/irc/connection_limits"
|
"github.com/oragono/oragono/irc/connection_limits"
|
||||||
@ -34,7 +38,6 @@ import (
|
|||||||
"github.com/oragono/oragono/irc/mysql"
|
"github.com/oragono/oragono/irc/mysql"
|
||||||
"github.com/oragono/oragono/irc/passwd"
|
"github.com/oragono/oragono/irc/passwd"
|
||||||
"github.com/oragono/oragono/irc/utils"
|
"github.com/oragono/oragono/irc/utils"
|
||||||
"gopkg.in/yaml.v2"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// here's how this works: exported (capitalized) members of the config structs
|
// here's how this works: exported (capitalized) members of the config structs
|
||||||
@ -1305,3 +1308,34 @@ func compileGuestRegexp(guestFormat string, casemapping Casemapping) (standard,
|
|||||||
folded, err = utils.CompileGlob(fmt.Sprintf("%s*%s", initialFolded, finalFolded), false)
|
folded, err = utils.CompileGlob(fmt.Sprintf("%s*%s", initialFolded, finalFolded), false)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (config *Config) loadMOTD() error {
|
||||||
|
if config.Server.MOTD != "" {
|
||||||
|
file, err := os.Open(config.Server.MOTD)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer file.Close()
|
||||||
|
contents, err := ioutil.ReadAll(file)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
lines := bytes.Split(contents, []byte{'\n'})
|
||||||
|
for i, line := range lines {
|
||||||
|
lineToSend := string(bytes.TrimRight(line, "\r\n"))
|
||||||
|
if len(lineToSend) == 0 && i == len(lines)-1 {
|
||||||
|
// if the last line of the MOTD was properly terminated with \n,
|
||||||
|
// there's no need to send a blank line to clients
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if config.Server.MOTDFormatting {
|
||||||
|
lineToSend = ircfmt.Unescape(lineToSend)
|
||||||
|
}
|
||||||
|
// "- " is the required prefix for MOTD
|
||||||
|
lineToSend = fmt.Sprintf("- %s", lineToSend)
|
||||||
|
config.Server.motdLines = append(config.Server.motdLines, lineToSend)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
package irc
|
package irc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -21,6 +20,7 @@ import (
|
|||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"github.com/goshuirc/irc-go/ircfmt"
|
"github.com/goshuirc/irc-go/ircfmt"
|
||||||
|
|
||||||
"github.com/oragono/oragono/irc/caps"
|
"github.com/oragono/oragono/irc/caps"
|
||||||
"github.com/oragono/oragono/irc/connection_limits"
|
"github.com/oragono/oragono/irc/connection_limits"
|
||||||
"github.com/oragono/oragono/irc/history"
|
"github.com/oragono/oragono/irc/history"
|
||||||
@ -667,35 +667,6 @@ func (server *Server) setupPprofListener(config *Config) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (config *Config) loadMOTD() (err error) {
|
|
||||||
if config.Server.MOTD != "" {
|
|
||||||
file, err := os.Open(config.Server.MOTD)
|
|
||||||
if err == nil {
|
|
||||||
defer file.Close()
|
|
||||||
|
|
||||||
reader := bufio.NewReader(file)
|
|
||||||
for {
|
|
||||||
line, err := reader.ReadString('\n')
|
|
||||||
if err != nil {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
line = strings.TrimRight(line, "\r\n")
|
|
||||||
|
|
||||||
if config.Server.MOTDFormatting {
|
|
||||||
line = ircfmt.Unescape(line)
|
|
||||||
}
|
|
||||||
|
|
||||||
// "- " is the required prefix for MOTD, we just add it here to make
|
|
||||||
// bursting it out to clients easier
|
|
||||||
line = fmt.Sprintf("- %s", line)
|
|
||||||
|
|
||||||
config.Server.motdLines = append(config.Server.motdLines, line)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (server *Server) loadDatastore(config *Config) error {
|
func (server *Server) loadDatastore(config *Config) error {
|
||||||
// open the datastore and load server state for which it (rather than config)
|
// open the datastore and load server state for which it (rather than config)
|
||||||
// is the source of truth
|
// is the source of truth
|
||||||
|
Loading…
Reference in New Issue
Block a user