mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-27 21:55:07 +03:00
Add summary helpers to mobile wrapper
Some checks failed
Yggdrasil / Lint (push) Has been cancelled
Yggdrasil / Analyse (push) Has been cancelled
Yggdrasil / Build & Test (Linux, Go 1.22) (push) Has been cancelled
Yggdrasil / Build & Test (Linux, Go 1.23) (push) Has been cancelled
Yggdrasil / Build & Test (Linux, Go 1.24) (push) Has been cancelled
Yggdrasil / Build & Test (Windows, Go 1.22) (push) Has been cancelled
Yggdrasil / Build & Test (Windows, Go 1.23) (push) Has been cancelled
Yggdrasil / Build & Test (Windows, Go 1.24) (push) Has been cancelled
Yggdrasil / Build & Test (macOS, Go 1.22) (push) Has been cancelled
Yggdrasil / Build & Test (macOS, Go 1.23) (push) Has been cancelled
Yggdrasil / Build & Test (macOS, Go 1.24) (push) Has been cancelled
Yggdrasil / Build (Cross freebsd, Go 1.22) (push) Has been cancelled
Yggdrasil / Build (Cross freebsd, Go 1.23) (push) Has been cancelled
Yggdrasil / Build (Cross freebsd, Go 1.24) (push) Has been cancelled
Yggdrasil / Build (Cross openbsd, Go 1.22) (push) Has been cancelled
Yggdrasil / Build (Cross openbsd, Go 1.23) (push) Has been cancelled
Yggdrasil / Build (Cross openbsd, Go 1.24) (push) Has been cancelled
Yggdrasil / All tests passed (push) Has been cancelled
Some checks failed
Yggdrasil / Lint (push) Has been cancelled
Yggdrasil / Analyse (push) Has been cancelled
Yggdrasil / Build & Test (Linux, Go 1.22) (push) Has been cancelled
Yggdrasil / Build & Test (Linux, Go 1.23) (push) Has been cancelled
Yggdrasil / Build & Test (Linux, Go 1.24) (push) Has been cancelled
Yggdrasil / Build & Test (Windows, Go 1.22) (push) Has been cancelled
Yggdrasil / Build & Test (Windows, Go 1.23) (push) Has been cancelled
Yggdrasil / Build & Test (Windows, Go 1.24) (push) Has been cancelled
Yggdrasil / Build & Test (macOS, Go 1.22) (push) Has been cancelled
Yggdrasil / Build & Test (macOS, Go 1.23) (push) Has been cancelled
Yggdrasil / Build & Test (macOS, Go 1.24) (push) Has been cancelled
Yggdrasil / Build (Cross freebsd, Go 1.22) (push) Has been cancelled
Yggdrasil / Build (Cross freebsd, Go 1.23) (push) Has been cancelled
Yggdrasil / Build (Cross freebsd, Go 1.24) (push) Has been cancelled
Yggdrasil / Build (Cross openbsd, Go 1.22) (push) Has been cancelled
Yggdrasil / Build (Cross openbsd, Go 1.23) (push) Has been cancelled
Yggdrasil / Build (Cross openbsd, Go 1.24) (push) Has been cancelled
Yggdrasil / All tests passed (push) Has been cancelled
This commit is contained in:
parent
73705ff09d
commit
5b8dbc8b1e
1 changed files with 26 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
||||||
package mobile
|
package mobile
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/ed25519"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"net"
|
"net"
|
||||||
|
@ -273,3 +274,28 @@ func (m *Yggdrasil) GetMTU() int {
|
||||||
func GetVersion() string {
|
func GetVersion() string {
|
||||||
return version.BuildVersion()
|
return version.BuildVersion()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ConfigSummary struct {
|
||||||
|
PublicKey string
|
||||||
|
IPv6Address string
|
||||||
|
IPv6Subnet string
|
||||||
|
}
|
||||||
|
|
||||||
|
func SummaryForConfig(b []byte) *ConfigSummary {
|
||||||
|
cfg := config.GenerateConfig()
|
||||||
|
if err := cfg.UnmarshalHJSON(b); err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
pub := ed25519.PrivateKey(cfg.PrivateKey).Public().(ed25519.PublicKey)
|
||||||
|
hpub := hex.EncodeToString(pub)
|
||||||
|
addr := net.IP(address.AddrForKey(pub)[:])
|
||||||
|
snet := net.IPNet{
|
||||||
|
IP: append(address.SubnetForKey(pub)[:], 0, 0, 0, 0, 0, 0, 0, 0),
|
||||||
|
Mask: net.CIDRMask(64, 128),
|
||||||
|
}
|
||||||
|
return &ConfigSummary{
|
||||||
|
PublicKey: hpub,
|
||||||
|
IPv6Address: addr.String(),
|
||||||
|
IPv6Subnet: snet.String(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue