mirror of
https://github.com/juanfont/headscale.git
synced 2024-11-30 02:43:05 +00:00
Fix nil dereference in nodes list command.
Fixes a nil pointer dereference observed when listing nodes that have not yet connected. ``` panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xb931a4] goroutine 1 [running]: github.com/juanfont/headscale/cmd/headscale/cli.glob..func8(0x13c93e0, 0xc0004c4220, 0x0, 0x2) /go/src/headscale/cmd/headscale/cli/nodes.go:74 +0x364 github.com/spf13/cobra.(*Command).execute(0x13c93e0, 0xc0004c41e0, 0x2, 0x2, 0x13c93e0, 0xc0004c41e0) /go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:856 +0x2c2 github.com/spf13/cobra.(*Command).ExecuteC(0x13ca2e0, 0xc000497110, 0xe76416, 0x6) /go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:960 +0x375 github.com/spf13/cobra.(*Command).Execute(...) /go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:897 main.main() /go/src/headscale/cmd/headscale/headscale.go:89 +0x805 command terminated with exit code 2 ```
This commit is contained in:
parent
a63fb6b007
commit
fdcd3bb574
1 changed files with 6 additions and 1 deletions
|
@ -4,6 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
@ -71,7 +72,11 @@ var ListNodesCmd = &cobra.Command{
|
||||||
if m.AuthKey != nil && m.AuthKey.Ephemeral {
|
if m.AuthKey != nil && m.AuthKey.Ephemeral {
|
||||||
ephemeral = true
|
ephemeral = true
|
||||||
}
|
}
|
||||||
fmt.Printf("%s\t%s\t%t\n", m.Name, m.LastSeen.Format("2006-01-02 15:04:05"), ephemeral)
|
var lastSeen time.Time
|
||||||
|
if m.LastSeen != nil {
|
||||||
|
lastSeen = *m.LastSeen
|
||||||
|
}
|
||||||
|
fmt.Printf("%s\t%s\t%t\n", m.Name, lastSeen.Format("2006-01-02 15:04:05"), ephemeral)
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue