Set isMultiUpstream flag in downstreamConn.welcome()
This will make it easier to globally disable multi-upstream mode.
This commit is contained in:
parent
ff44ea314e
commit
61e6b2efa4
@ -248,17 +248,18 @@ type downstreamConn struct {
|
|||||||
|
|
||||||
id uint64
|
id uint64
|
||||||
|
|
||||||
registered bool
|
registered bool
|
||||||
user *user
|
user *user
|
||||||
nick string
|
nick string
|
||||||
nickCM string
|
nickCM string
|
||||||
rawUsername string
|
rawUsername string
|
||||||
networkName string
|
networkName string
|
||||||
clientName string
|
clientName string
|
||||||
realname string
|
realname string
|
||||||
hostname string
|
hostname string
|
||||||
password string // empty after authentication
|
password string // empty after authentication
|
||||||
network *network // can be nil
|
network *network // can be nil
|
||||||
|
isMultiUpstream bool
|
||||||
|
|
||||||
negotiatingCaps bool
|
negotiatingCaps bool
|
||||||
capVersion int
|
capVersion int
|
||||||
@ -307,20 +308,16 @@ func (dc *downstreamConn) prefix() *irc.Prefix {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dc *downstreamConn) isMultiUpstream() bool {
|
|
||||||
return dc.network == nil && !dc.caps["soju.im/bouncer-networks"]
|
|
||||||
}
|
|
||||||
|
|
||||||
func (dc *downstreamConn) forEachNetwork(f func(*network)) {
|
func (dc *downstreamConn) forEachNetwork(f func(*network)) {
|
||||||
if dc.network != nil {
|
if dc.network != nil {
|
||||||
f(dc.network)
|
f(dc.network)
|
||||||
} else if dc.isMultiUpstream() {
|
} else if dc.isMultiUpstream {
|
||||||
dc.user.forEachNetwork(f)
|
dc.user.forEachNetwork(f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dc *downstreamConn) forEachUpstream(f func(*upstreamConn)) {
|
func (dc *downstreamConn) forEachUpstream(f func(*upstreamConn)) {
|
||||||
if dc.network == nil && !dc.isMultiUpstream() {
|
if dc.network == nil && !dc.isMultiUpstream {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
dc.user.forEachUpstream(func(uc *upstreamConn) {
|
dc.user.forEachUpstream(func(uc *upstreamConn) {
|
||||||
@ -1174,6 +1171,10 @@ func (dc *downstreamConn) welcome() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if dc.network == nil && !dc.caps["soju.im/bouncer-networks"] {
|
||||||
|
dc.isMultiUpstream = true
|
||||||
|
}
|
||||||
|
|
||||||
isupport := []string{
|
isupport := []string{
|
||||||
fmt.Sprintf("CHATHISTORY=%v", chatHistoryLimit),
|
fmt.Sprintf("CHATHISTORY=%v", chatHistoryLimit),
|
||||||
"CASEMAPPING=ascii",
|
"CASEMAPPING=ascii",
|
||||||
@ -1185,7 +1186,7 @@ func (dc *downstreamConn) welcome() error {
|
|||||||
if title := dc.srv.Config().Title; dc.network == nil && title != "" {
|
if title := dc.srv.Config().Title; dc.network == nil && title != "" {
|
||||||
isupport = append(isupport, "NETWORK="+encodeISUPPORT(title))
|
isupport = append(isupport, "NETWORK="+encodeISUPPORT(title))
|
||||||
}
|
}
|
||||||
if dc.network == nil && !dc.isMultiUpstream() {
|
if dc.network == nil && !dc.isMultiUpstream {
|
||||||
isupport = append(isupport, "WHOX")
|
isupport = append(isupport, "WHOX")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1228,7 +1229,7 @@ func (dc *downstreamConn) welcome() error {
|
|||||||
Params: []string{dc.nick, "+" + string(uc.modes)},
|
Params: []string{dc.nick, "+" + string(uc.modes)},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if dc.network == nil && !dc.isMultiUpstream() && dc.user.Admin {
|
if dc.network == nil && !dc.isMultiUpstream && dc.user.Admin {
|
||||||
dc.SendMessage(&irc.Message{
|
dc.SendMessage(&irc.Message{
|
||||||
Prefix: dc.srv.prefix(),
|
Prefix: dc.srv.prefix(),
|
||||||
Command: irc.RPL_UMODEIS,
|
Command: irc.RPL_UMODEIS,
|
||||||
|
2
user.go
2
user.go
@ -152,7 +152,7 @@ func newNetwork(user *user, record *Network, channels []Channel) *network {
|
|||||||
|
|
||||||
func (net *network) forEachDownstream(f func(*downstreamConn)) {
|
func (net *network) forEachDownstream(f func(*downstreamConn)) {
|
||||||
net.user.forEachDownstream(func(dc *downstreamConn) {
|
net.user.forEachDownstream(func(dc *downstreamConn) {
|
||||||
if dc.network == nil && !dc.isMultiUpstream() {
|
if dc.network == nil && !dc.isMultiUpstream {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if dc.network != nil && dc.network != net {
|
if dc.network != nil && dc.network != net {
|
||||||
|
Loading…
Reference in New Issue
Block a user