fix: endless logout (#4563)
This commit is contained in:
parent
73a5189398
commit
69948a7024
|
@ -2204,6 +2204,7 @@ func (b *GethStatusBackend) Logout() error {
|
||||||
b.mu.Lock()
|
b.mu.Lock()
|
||||||
defer b.mu.Unlock()
|
defer b.mu.Unlock()
|
||||||
|
|
||||||
|
b.log.Debug("logging out")
|
||||||
err := b.cleanupServices()
|
err := b.cleanupServices()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -2222,6 +2223,11 @@ func (b *GethStatusBackend) Logout() error {
|
||||||
}
|
}
|
||||||
b.statusNode = nil
|
b.statusNode = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !b.LocalPairingStateManager.IsPairing() {
|
||||||
|
signal.SendNodeStopped()
|
||||||
|
}
|
||||||
|
|
||||||
// re-initialize the node, at some point we should better manage the lifecycle
|
// re-initialize the node, at some point we should better manage the lifecycle
|
||||||
b.initialize()
|
b.initialize()
|
||||||
|
|
||||||
|
|
4
go.mod
4
go.mod
|
@ -89,7 +89,7 @@ require (
|
||||||
github.com/mutecomm/go-sqlcipher/v4 v4.4.2
|
github.com/mutecomm/go-sqlcipher/v4 v4.4.2
|
||||||
github.com/schollz/peerdiscovery v1.7.0
|
github.com/schollz/peerdiscovery v1.7.0
|
||||||
github.com/siphiuel/lc-proxy-wrapper v0.0.0-20230516150924-246507cee8c7
|
github.com/siphiuel/lc-proxy-wrapper v0.0.0-20230516150924-246507cee8c7
|
||||||
github.com/waku-org/go-waku v0.8.1-0.20240104144340-585648c4eefe
|
github.com/waku-org/go-waku v0.8.1-0.20240130093642-77ea359ef873
|
||||||
github.com/wk8/go-ordered-map/v2 v2.1.7
|
github.com/wk8/go-ordered-map/v2 v2.1.7
|
||||||
github.com/yeqown/go-qrcode/v2 v2.2.1
|
github.com/yeqown/go-qrcode/v2 v2.2.1
|
||||||
github.com/yeqown/go-qrcode/writer/standard v1.2.1
|
github.com/yeqown/go-qrcode/writer/standard v1.2.1
|
||||||
|
@ -261,7 +261,7 @@ require (
|
||||||
github.com/tklauser/numcpus v0.2.2 // indirect
|
github.com/tklauser/numcpus v0.2.2 // indirect
|
||||||
github.com/tyler-smith/go-bip39 v1.1.0 // indirect
|
github.com/tyler-smith/go-bip39 v1.1.0 // indirect
|
||||||
github.com/urfave/cli/v2 v2.24.4 // indirect
|
github.com/urfave/cli/v2 v2.24.4 // indirect
|
||||||
github.com/waku-org/go-discover v0.0.0-20221209174356-61c833f34d98 // indirect
|
github.com/waku-org/go-discover v0.0.0-20240129014929-85f2c00b96a3 // indirect
|
||||||
github.com/waku-org/go-libp2p-rendezvous v0.0.0-20230628220917-7b4e5ae4c0e7 // indirect
|
github.com/waku-org/go-libp2p-rendezvous v0.0.0-20230628220917-7b4e5ae4c0e7 // indirect
|
||||||
github.com/waku-org/go-zerokit-rln v0.1.14-0.20240102145250-fa738c0bdf59 // indirect
|
github.com/waku-org/go-zerokit-rln v0.1.14-0.20240102145250-fa738c0bdf59 // indirect
|
||||||
github.com/waku-org/go-zerokit-rln-apple v0.0.0-20230916172309-ee0ee61dde2b // indirect
|
github.com/waku-org/go-zerokit-rln-apple v0.0.0-20230916172309-ee0ee61dde2b // indirect
|
||||||
|
|
8
go.sum
8
go.sum
|
@ -2097,12 +2097,12 @@ github.com/vishvananda/netns v0.0.0-20180720170159-13995c7128cc/go.mod h1:ZjcWmF
|
||||||
github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU=
|
github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU=
|
||||||
github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0=
|
github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0=
|
||||||
github.com/vishvananda/netns v0.0.0-20210104183010-2eb08e3e575f/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0=
|
github.com/vishvananda/netns v0.0.0-20210104183010-2eb08e3e575f/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0=
|
||||||
github.com/waku-org/go-discover v0.0.0-20221209174356-61c833f34d98 h1:xwY0kW5XZFimdqfZb9cZwT1S3VJP9j3AE6bdNd9boXM=
|
github.com/waku-org/go-discover v0.0.0-20240129014929-85f2c00b96a3 h1:Kk0KYXZE/uNnARF2TbCQyvyZ/w4SgF8VhquNdOVVsNU=
|
||||||
github.com/waku-org/go-discover v0.0.0-20221209174356-61c833f34d98/go.mod h1:eBHgM6T4EG0RZzxpxKy+rGz/6Dw2Nd8DWxS0lm9ESDw=
|
github.com/waku-org/go-discover v0.0.0-20240129014929-85f2c00b96a3/go.mod h1:eBHgM6T4EG0RZzxpxKy+rGz/6Dw2Nd8DWxS0lm9ESDw=
|
||||||
github.com/waku-org/go-libp2p-rendezvous v0.0.0-20230628220917-7b4e5ae4c0e7 h1:0e1h+p84yBp0IN7AqgbZlV7lgFBjm214lgSOE7CeJmE=
|
github.com/waku-org/go-libp2p-rendezvous v0.0.0-20230628220917-7b4e5ae4c0e7 h1:0e1h+p84yBp0IN7AqgbZlV7lgFBjm214lgSOE7CeJmE=
|
||||||
github.com/waku-org/go-libp2p-rendezvous v0.0.0-20230628220917-7b4e5ae4c0e7/go.mod h1:pFvOZ9YTFsW0o5zJW7a0B5tr1owAijRWJctXJ2toL04=
|
github.com/waku-org/go-libp2p-rendezvous v0.0.0-20230628220917-7b4e5ae4c0e7/go.mod h1:pFvOZ9YTFsW0o5zJW7a0B5tr1owAijRWJctXJ2toL04=
|
||||||
github.com/waku-org/go-waku v0.8.1-0.20240104144340-585648c4eefe h1:2D97fbaKlIQRjWMz/iTjnYcxi2z6ekKvspTGtcuPHgU=
|
github.com/waku-org/go-waku v0.8.1-0.20240130093642-77ea359ef873 h1:pnUvFENjM/h7HVF8VsNWTmOXx/rYs62P7H2EFjAnwVw=
|
||||||
github.com/waku-org/go-waku v0.8.1-0.20240104144340-585648c4eefe/go.mod h1:+b5fPPJ4YUIAPJtPOtwB7bTrOQ9lF15I2LnQjV6NMIA=
|
github.com/waku-org/go-waku v0.8.1-0.20240130093642-77ea359ef873/go.mod h1:RjTvkTrIwpoT1cM9HeQqwa2Q7t7WOkb3hpuB/zuZ6SM=
|
||||||
github.com/waku-org/go-zerokit-rln v0.1.14-0.20240102145250-fa738c0bdf59 h1:jisj+OCI6QydLtFq3Pyhu49wl9ytPN7oAHjMfepHDrA=
|
github.com/waku-org/go-zerokit-rln v0.1.14-0.20240102145250-fa738c0bdf59 h1:jisj+OCI6QydLtFq3Pyhu49wl9ytPN7oAHjMfepHDrA=
|
||||||
github.com/waku-org/go-zerokit-rln v0.1.14-0.20240102145250-fa738c0bdf59/go.mod h1:1PdBdPzyTaKt3VnpAHk3zj+r9dXPFOr3IHZP9nFle6E=
|
github.com/waku-org/go-zerokit-rln v0.1.14-0.20240102145250-fa738c0bdf59/go.mod h1:1PdBdPzyTaKt3VnpAHk3zj+r9dXPFOr3IHZP9nFle6E=
|
||||||
github.com/waku-org/go-zerokit-rln-apple v0.0.0-20230916172309-ee0ee61dde2b h1:KgZVhsLkxsj5gb/FfndSCQu6VYwALrCOgYI3poR95yE=
|
github.com/waku-org/go-zerokit-rln-apple v0.0.0-20230916172309-ee0ee61dde2b h1:KgZVhsLkxsj5gb/FfndSCQu6VYwALrCOgYI3poR95yE=
|
||||||
|
|
|
@ -472,10 +472,7 @@ func LoginWithKeycard(accountData, password, keyHex string, configJSON string) s
|
||||||
// Logout is equivalent to clearing whisper identities.
|
// Logout is equivalent to clearing whisper identities.
|
||||||
func Logout() string {
|
func Logout() string {
|
||||||
err := statusBackend.Logout()
|
err := statusBackend.Logout()
|
||||||
if err != nil {
|
return makeJSONResponse(err)
|
||||||
makeJSONResponse(err)
|
|
||||||
}
|
|
||||||
return makeJSONResponse(statusBackend.StopNode())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SignMessage unmarshals rpc params {data, address, password} and
|
// SignMessage unmarshals rpc params {data, address, password} and
|
||||||
|
|
|
@ -507,7 +507,7 @@ func (n *StatusNode) stop() error {
|
||||||
n.stickersSrvc = nil
|
n.stickersSrvc = nil
|
||||||
n.publicMethods = make(map[string]bool)
|
n.publicMethods = make(map[string]bool)
|
||||||
n.pendingTracker = nil
|
n.pendingTracker = nil
|
||||||
|
n.log.Debug("status node stopped")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -123,8 +123,8 @@ type callTimeout struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListenV5 listens on the given connection.
|
// ListenV5 listens on the given connection.
|
||||||
func ListenV5(conn UDPConn, ln *enode.LocalNode, cfg Config) (*UDPv5, error) {
|
func ListenV5(ctx context.Context, conn UDPConn, ln *enode.LocalNode, cfg Config) (*UDPv5, error) {
|
||||||
t, err := newUDPv5(conn, ln, cfg)
|
t, err := newUDPv5(ctx, conn, ln, cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -136,8 +136,8 @@ func ListenV5(conn UDPConn, ln *enode.LocalNode, cfg Config) (*UDPv5, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// newUDPv5 creates a UDPv5 transport, but doesn't start any goroutines.
|
// newUDPv5 creates a UDPv5 transport, but doesn't start any goroutines.
|
||||||
func newUDPv5(conn UDPConn, ln *enode.LocalNode, cfg Config) (*UDPv5, error) {
|
func newUDPv5(ctx context.Context, conn UDPConn, ln *enode.LocalNode, cfg Config) (*UDPv5, error) {
|
||||||
closeCtx, cancelCloseCtx := context.WithCancel(context.Background())
|
closeCtx, cancelCloseCtx := context.WithCancel(ctx)
|
||||||
cfg = cfg.withDefaults()
|
cfg = cfg.withDefaults()
|
||||||
t := &UDPv5{
|
t := &UDPv5{
|
||||||
// static fields
|
// static fields
|
||||||
|
|
|
@ -180,7 +180,7 @@ func (d *DiscoveryV5) listen(ctx context.Context) error {
|
||||||
|
|
||||||
d.localnode.SetFallbackUDP(d.udpAddr.Port)
|
d.localnode.SetFallbackUDP(d.udpAddr.Port)
|
||||||
|
|
||||||
listener, err := discover.ListenV5(conn, d.localnode, d.config)
|
listener, err := discover.ListenV5(ctx, conn, d.localnode, d.config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -1010,7 +1010,7 @@ github.com/tyler-smith/go-bip39/wordlists
|
||||||
# github.com/urfave/cli/v2 v2.24.4
|
# github.com/urfave/cli/v2 v2.24.4
|
||||||
## explicit; go 1.18
|
## explicit; go 1.18
|
||||||
github.com/urfave/cli/v2
|
github.com/urfave/cli/v2
|
||||||
# github.com/waku-org/go-discover v0.0.0-20221209174356-61c833f34d98
|
# github.com/waku-org/go-discover v0.0.0-20240129014929-85f2c00b96a3
|
||||||
## explicit; go 1.15
|
## explicit; go 1.15
|
||||||
github.com/waku-org/go-discover/discover
|
github.com/waku-org/go-discover/discover
|
||||||
github.com/waku-org/go-discover/discover/v4wire
|
github.com/waku-org/go-discover/discover/v4wire
|
||||||
|
@ -1020,7 +1020,7 @@ github.com/waku-org/go-discover/discover/v5wire
|
||||||
github.com/waku-org/go-libp2p-rendezvous
|
github.com/waku-org/go-libp2p-rendezvous
|
||||||
github.com/waku-org/go-libp2p-rendezvous/db
|
github.com/waku-org/go-libp2p-rendezvous/db
|
||||||
github.com/waku-org/go-libp2p-rendezvous/pb
|
github.com/waku-org/go-libp2p-rendezvous/pb
|
||||||
# github.com/waku-org/go-waku v0.8.1-0.20240104144340-585648c4eefe
|
# github.com/waku-org/go-waku v0.8.1-0.20240130093642-77ea359ef873
|
||||||
## explicit; go 1.19
|
## explicit; go 1.19
|
||||||
github.com/waku-org/go-waku/logging
|
github.com/waku-org/go-waku/logging
|
||||||
github.com/waku-org/go-waku/waku/persistence
|
github.com/waku-org/go-waku/waku/persistence
|
||||||
|
|
|
@ -93,6 +93,7 @@ func (mgr *FilterManager) runFilterLoop(wg *sync.WaitGroup) {
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-mgr.ctx.Done():
|
case <-mgr.ctx.Done():
|
||||||
|
mgr.logger.Debug("filter loop stopped")
|
||||||
return
|
return
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
mgr.pingPeers()
|
mgr.pingPeers()
|
||||||
|
|
|
@ -544,6 +544,7 @@ func (w *Waku) runPeerExchangeLoop() {
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-w.ctx.Done():
|
case <-w.ctx.Done():
|
||||||
|
w.logger.Debug("Peer exchange loop stopped")
|
||||||
return
|
return
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
w.logger.Info("Running peer exchange loop")
|
w.logger.Info("Running peer exchange loop")
|
||||||
|
@ -1279,6 +1280,9 @@ func (w *Waku) Start() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
go w.broadcast()
|
go w.broadcast()
|
||||||
|
|
||||||
|
// we should wait `seedBootnodesForDiscV5` shutdown smoothly before set w.ctx to nil within `w.Stop()`
|
||||||
|
w.wg.Add(1)
|
||||||
go w.seedBootnodesForDiscV5()
|
go w.seedBootnodesForDiscV5()
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -1588,6 +1592,7 @@ func (w *Waku) ConnectionChanged(state connection.State) {
|
||||||
// It also restarts if there's a connection change signalled from the client
|
// It also restarts if there's a connection change signalled from the client
|
||||||
func (w *Waku) seedBootnodesForDiscV5() {
|
func (w *Waku) seedBootnodesForDiscV5() {
|
||||||
if !w.settings.EnableDiscV5 || w.node.DiscV5() == nil {
|
if !w.settings.EnableDiscV5 || w.node.DiscV5() == nil {
|
||||||
|
w.wg.Done()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1646,6 +1651,8 @@ func (w *Waku) seedBootnodesForDiscV5() {
|
||||||
lastTry = now()
|
lastTry = now()
|
||||||
|
|
||||||
case <-w.ctx.Done():
|
case <-w.ctx.Done():
|
||||||
|
w.wg.Done()
|
||||||
|
w.logger.Debug("bootnode seeding stopped")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue