Move network.clients to user

No need to have this list per-network.
This commit is contained in:
Simon Ser 2021-03-29 16:58:56 +02:00
parent 5a899abaab
commit 55274d7213
2 changed files with 5 additions and 4 deletions

View File

@ -1755,7 +1755,7 @@ func (uc *upstreamConn) appendLog(entity string, msg *irc.Message) (msgID string
delivered = make(deliveredClientMap) delivered = make(deliveredClientMap)
uc.network.delivered.SetValue(entity, delivered) uc.network.delivered.SetValue(entity, delivered)
for clientName, _ := range uc.network.clients { for clientName, _ := range uc.user.clients {
delivered[clientName] = lastID delivered[clientName] = lastID
} }
} }

View File

@ -65,7 +65,6 @@ type network struct {
conn *upstreamConn conn *upstreamConn
channels channelCasemapMap channels channelCasemapMap
delivered deliveredCasemapMap delivered deliveredCasemapMap
clients map[string]struct{} // indexed by client name
lastError error lastError error
casemap casemapping casemap casemapping
} }
@ -83,7 +82,6 @@ func newNetwork(user *user, record *Network, channels []Channel) *network {
stopped: make(chan struct{}), stopped: make(chan struct{}),
channels: m, channels: m,
delivered: deliveredCasemapMap{newCasemapMap(0)}, delivered: deliveredCasemapMap{newCasemapMap(0)},
clients: make(map[string]struct{}),
casemap: casemapRFC1459, casemap: casemapRFC1459,
} }
} }
@ -275,6 +273,7 @@ type user struct {
networks []*network networks []*network
downstreamConns []*downstreamConn downstreamConns []*downstreamConn
msgStore messageStore msgStore messageStore
clients map[string]struct{} // indexed by client name
// LIST commands in progress // LIST commands in progress
pendingLISTs []pendingLIST pendingLISTs []pendingLIST
@ -300,6 +299,7 @@ func newUser(srv *Server, record *User) *user {
events: make(chan event, 64), events: make(chan event, 64),
done: make(chan struct{}), done: make(chan struct{}),
msgStore: msgStore, msgStore: msgStore,
clients: make(map[string]struct{}),
} }
} }
@ -446,7 +446,6 @@ func (u *user) run() {
u.downstreamConns = append(u.downstreamConns, dc) u.downstreamConns = append(u.downstreamConns, dc)
dc.forEachNetwork(func(network *network) { dc.forEachNetwork(func(network *network) {
network.clients[dc.clientName] = struct{}{}
if network.lastError != nil { if network.lastError != nil {
sendServiceNOTICE(dc, fmt.Sprintf("disconnected from %s: %v", network.GetName(), network.lastError)) sendServiceNOTICE(dc, fmt.Sprintf("disconnected from %s: %v", network.GetName(), network.lastError))
} }
@ -455,6 +454,8 @@ func (u *user) run() {
u.forEachUpstream(func(uc *upstreamConn) { u.forEachUpstream(func(uc *upstreamConn) {
uc.updateAway() uc.updateAway()
}) })
u.clients[dc.clientName] = struct{}{}
case eventDownstreamDisconnected: case eventDownstreamDisconnected:
dc := e.dc dc := e.dc