Refactor - now wireguard based. (#7)
This commit is contained in:
18
peer/network_state.go
Normal file
18
peer/network_state.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package peer
|
||||
|
||||
import "vppn/m"
|
||||
|
||||
// loadNetworkState reads a cached network state from disk. Any error (most
|
||||
// commonly a missing file on first run) is returned to the caller, which
|
||||
// treats it as "no cache available".
|
||||
func loadNetworkState(path string) (m.NetworkState, error) {
|
||||
var state m.NetworkState
|
||||
err := loadJSON(path, &state)
|
||||
return state, err
|
||||
}
|
||||
|
||||
// saveNetworkState writes state to path atomically (see storeJSON), so a crash
|
||||
// mid-write cannot leave a corrupt cache.
|
||||
func saveNetworkState(path string, state m.NetworkState) error {
|
||||
return storeJSON(path, state)
|
||||
}
|
||||
Reference in New Issue
Block a user