diff --git a/cmd/soju/main.go b/cmd/soju/main.go index f092a36..f8626f0 100644 --- a/cmd/soju/main.go +++ b/cmd/soju/main.go @@ -97,8 +97,8 @@ func main() { } srv := soju.NewServer(db) - // TODO: load from config/DB srv.Hostname = cfg.Hostname + srv.Title = cfg.Title srv.LogPath = cfg.LogPath srv.HTTPOrigins = cfg.HTTPOrigins srv.AcceptProxyIPs = cfg.AcceptProxyIPs diff --git a/config/config.go b/config/config.go index b8dc1fa..560b651 100644 --- a/config/config.go +++ b/config/config.go @@ -38,8 +38,9 @@ type TLS struct { type Server struct { Listen []string - Hostname string TLS *TLS + Hostname string + Title string MOTDPath string SQLDriver string @@ -87,6 +88,14 @@ func parse(cfg scfg.Block) (*Server, error) { if err := d.ParseParams(&srv.Hostname); err != nil { return nil, err } + case "title": + if err := d.ParseParams(&srv.Title); err != nil { + return nil, err + } + case "motd": + if err := d.ParseParams(&srv.MOTDPath); err != nil { + return nil, err + } case "tls": tls := &TLS{} if err := d.ParseParams(&tls.CertPath, &tls.KeyPath); err != nil { @@ -129,10 +138,6 @@ func parse(cfg scfg.Block) (*Server, error) { if srv.MaxUserNetworks, err = strconv.Atoi(max); err != nil { return nil, fmt.Errorf("directive %q: %v", d.Name, err) } - case "motd": - if err := d.ParseParams(&srv.MOTDPath); err != nil { - return nil, err - } default: return nil, fmt.Errorf("unknown directive %q", d.Name) } diff --git a/doc/soju.1.scd b/doc/soju.1.scd index 6c4a447..a21979a 100644 --- a/doc/soju.1.scd +++ b/doc/soju.1.scd @@ -104,6 +104,10 @@ The following directives are supported: *hostname* Server hostname (default: system hostname). +*title* + Server title. This will be sent as the _ISUPPORT NETWORK_ value when clients + don't select a specific network. + *tls* <cert> <key> Enable TLS support. The certificate and the key files must be PEM-encoded. diff --git a/downstream.go b/downstream.go index 4b00f43..19da13d 100644 --- a/downstream.go +++ b/downstream.go @@ -1157,7 +1157,9 @@ func (dc *downstreamConn) welcome() error { if dc.network != nil { isupport = append(isupport, fmt.Sprintf("BOUNCER_NETID=%v", dc.network.ID)) } - + if dc.network == nil && dc.srv.Title != "" { + isupport = append(isupport, "NETWORK="+encodeISUPPORT(dc.srv.Title)) + } if dc.network == nil && dc.caps["soju.im/bouncer-networks"] { isupport = append(isupport, "WHOX") } diff --git a/irc.go b/irc.go index bc76efc..83cbdc1 100644 --- a/irc.go +++ b/irc.go @@ -761,3 +761,9 @@ func generateWHOXReply(prefix *irc.Prefix, nick, fields string, info *whoxInfo) Params: append([]string{nick}, params...), } } + +var isupportEncoder = strings.NewReplacer(" ", "\\x20", "\\", "\\x5C") + +func encodeISUPPORT(s string) string { + return isupportEncoder.Replace(s) +} diff --git a/server.go b/server.go index 7f853cd..5d5562c 100644 --- a/server.go +++ b/server.go @@ -50,6 +50,7 @@ func (l *prefixLogger) Printf(format string, v ...interface{}) { type Server struct { Hostname string + Title string Logger Logger HistoryLimit int LogPath string