mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-14 06:57:31 +00:00
ipn/store: make StateStore.All optional (#16409)
This method is only needed to migrate between store.FileStore and tpm.tpmStore. We can make a runtime type assertion instead of implementing an unused method for every platform. Updates #15830 Signed-off-by: Andrew Lytvynov <awly@tailscale.com>
This commit is contained in:
@@ -10,7 +10,4 @@ export const sessionStateStorage: IPNStateStorage = {
|
||||
getState(id) {
|
||||
return window.sessionStorage[`ipn-state-${id}`] || ""
|
||||
},
|
||||
all() {
|
||||
return JSON.stringify(window.sessionStorage)
|
||||
},
|
||||
}
|
||||
|
1
cmd/tsconnect/src/types/wasm_js.d.ts
vendored
1
cmd/tsconnect/src/types/wasm_js.d.ts
vendored
@@ -44,7 +44,6 @@ declare global {
|
||||
interface IPNStateStorage {
|
||||
setState(id: string, value: string): void
|
||||
getState(id: string): string
|
||||
all(): string
|
||||
}
|
||||
|
||||
type IPNConfig = {
|
||||
|
@@ -15,7 +15,6 @@ import (
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"iter"
|
||||
"log"
|
||||
"math/rand/v2"
|
||||
"net"
|
||||
@@ -580,29 +579,6 @@ func (s *jsStateStore) WriteState(id ipn.StateKey, bs []byte) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *jsStateStore) All() iter.Seq2[ipn.StateKey, []byte] {
|
||||
return func(yield func(ipn.StateKey, []byte) bool) {
|
||||
jsValue := s.jsStateStorage.Call("all")
|
||||
if jsValue.String() == "" {
|
||||
return
|
||||
}
|
||||
buf, err := hex.DecodeString(jsValue.String())
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
var state map[string][]byte
|
||||
if err := json.Unmarshal(buf, &state); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
for k, v := range state {
|
||||
if !yield(ipn.StateKey(k), v) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func mapSlice[T any, M any](a []T, f func(T) M) []M {
|
||||
n := make([]M, len(a))
|
||||
for i, e := range a {
|
||||
|
Reference in New Issue
Block a user