Changeset 691 in code for trunk/downstream.go


Ignore:
Timestamp:
Nov 15, 2021, 11:38:04 PM (4 years ago)
Author:
contact
Message:

Allow most config options to be reloaded

Closes: https://todo.sr.ht/~emersion/soju/42

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/downstream.go

    r690 r691  
    291291                dc.supportedCaps[k] = v
    292292        }
    293         if srv.LogPath != "" {
     293        // TODO: this is racy, we should only enable chathistory after
     294        // authentication and then check that user.msgStore implements
     295        // chatHistoryMessageStore
     296        if srv.Config().LogPath != "" {
    294297                dc.supportedCaps["draft/chathistory"] = ""
    295298        }
     
    9971000        }
    9981001
    999         if dc.srv.LogPath != "" && dc.network != nil {
     1002        if _, ok := dc.user.msgStore.(chatHistoryMessageStore); ok && dc.network != nil {
    10001003                dc.setSupportedCap("draft/event-playback", "")
    10011004        } else {
     
    11761179                isupport = append(isupport, fmt.Sprintf("BOUNCER_NETID=%v", dc.network.ID))
    11771180        }
    1178         if dc.network == nil && dc.srv.Title != "" {
    1179                 isupport = append(isupport, "NETWORK="+encodeISUPPORT(dc.srv.Title))
     1181        if title := dc.srv.Config().Title; dc.network == nil && title != "" {
     1182                isupport = append(isupport, "NETWORK="+encodeISUPPORT(title))
    11801183        }
    11811184        if dc.network == nil && dc.caps["soju.im/bouncer-networks"] {
     
    12051208                Prefix:  dc.srv.prefix(),
    12061209                Command: irc.RPL_YOURHOST,
    1207                 Params:  []string{dc.nick, "Your host is " + dc.srv.Hostname},
     1210                Params:  []string{dc.nick, "Your host is " + dc.srv.Config().Hostname},
    12081211        })
    12091212        dc.SendMessage(&irc.Message{
    12101213                Prefix:  dc.srv.prefix(),
    12111214                Command: irc.RPL_MYINFO,
    1212                 Params:  []string{dc.nick, dc.srv.Hostname, "soju", "aiwroO", "OovaimnqpsrtklbeI"},
     1215                Params:  []string{dc.nick, dc.srv.Config().Hostname, "soju", "aiwroO", "OovaimnqpsrtklbeI"},
    12131216        })
    12141217        for _, msg := range generateIsupport(dc.srv.prefix(), dc.nick, isupport) {
     
    12301233        }
    12311234
    1232         if motd := dc.user.srv.MOTD(); motd != "" && dc.network == nil {
     1235        if motd := dc.user.srv.Config().MOTD; motd != "" && dc.network == nil {
    12331236                for _, msg := range generateMOTD(dc.srv.prefix(), dc.nick, motd) {
    12341237                        dc.SendMessage(msg)
     
    14211424                        destination = msg.Params[1]
    14221425                }
    1423                 if destination != "" && destination != dc.srv.Hostname {
     1426                hostname := dc.srv.Config().Hostname
     1427                if destination != "" && destination != hostname {
    14241428                        return ircError{&irc.Message{
    14251429                                Command: irc.ERR_NOSUCHSERVER,
     
    14301434                        Prefix:  dc.srv.prefix(),
    14311435                        Command: "PONG",
    1432                         Params:  []string{dc.srv.Hostname, source},
     1436                        Params:  []string{hostname, source},
    14331437                })
    14341438                return nil
     
    19471951                                Username: dc.user.Username,
    19481952                                Hostname: dc.hostname,
    1949                                 Server:   dc.srv.Hostname,
     1953                                Server:   dc.srv.Config().Hostname,
    19501954                                Nickname: dc.nick,
    19511955                                Flags:    flags,
     
    19661970                                Username: servicePrefix.User,
    19671971                                Hostname: servicePrefix.Host,
    1968                                 Server:   dc.srv.Hostname,
     1972                                Server:   dc.srv.Config().Hostname,
    19691973                                Nickname: serviceNick,
    19701974                                Flags:    "H*",
     
    20262030                                Prefix:  dc.srv.prefix(),
    20272031                                Command: irc.RPL_WHOISSERVER,
    2028                                 Params:  []string{dc.nick, dc.nick, dc.srv.Hostname, "soju"},
     2032                                Params:  []string{dc.nick, dc.nick, dc.srv.Config().Hostname, "soju"},
    20292033                        })
    20302034                        if dc.user.Admin {
     
    20562060                                Prefix:  dc.srv.prefix(),
    20572061                                Command: irc.RPL_WHOISSERVER,
    2058                                 Params:  []string{dc.nick, serviceNick, dc.srv.Hostname, "soju"},
     2062                                Params:  []string{dc.nick, serviceNick, dc.srv.Config().Hostname, "soju"},
    20592063                        })
    20602064                        dc.SendMessage(&irc.Message{
     
    21052109
    21062110                for _, name := range strings.Split(targetsStr, ",") {
    2107                         if name == "$"+dc.srv.Hostname || (name == "$*" && dc.network == nil) {
     2111                        if name == "$"+dc.srv.Config().Hostname || (name == "$*" && dc.network == nil) {
    21082112                                // "$" means a server mask follows. If it's the bouncer's
    21092113                                // hostname, broadcast the message to all bouncer users.
Note: See TracChangeset for help on using the changeset viewer.