From ea7dc669fd533df542422adb40e81fa3bd4419c9 Mon Sep 17 00:00:00 2001 From: Vadym Vikulin Date: Wed, 20 Dec 2023 13:13:12 +0200 Subject: [PATCH] byte array instead of clice in domain struct --- cmd/genkeys/main.go | 2 +- cmd/mesh/main.go | 2 +- go.mod | 2 +- go.sum | 4 ++-- src/core/address.go | 2 +- src/core/version.go | 5 +++-- 6 files changed, 9 insertions(+), 8 deletions(-) diff --git a/cmd/genkeys/main.go b/cmd/genkeys/main.go index bef8a8555..5a3db8625 100644 --- a/cmd/genkeys/main.go +++ b/cmd/genkeys/main.go @@ -45,7 +45,7 @@ func main() { fmt.Println("Pub:", hex.EncodeToString(newKey.pub)) c := &core.Core{} var bytes [ed25519.PublicKeySize]byte - addr := c.AddrForDomain(types.Domain{Key: bytes[:], Name: newKey.pub}) + addr := c.AddrForDomain(types.Domain{Key: bytes[:], Name: [32]byte(newKey.pub)}) fmt.Println("IP:", net.IP(addr[:]).String()) } } diff --git a/cmd/mesh/main.go b/cmd/mesh/main.go index 53fe334e0..03d1840d9 100644 --- a/cmd/mesh/main.go +++ b/cmd/mesh/main.go @@ -164,7 +164,7 @@ func run(sigCh chan os.Signal) { getNodeKey := func() types.Domain { name := cfg.Domain - return types.Domain{Key: publicKey, Name: []byte(name)} + return types.Domain{Key: publicKey, Name: [ed25519.PublicKeySize]byte([]byte(name))} } switch { diff --git a/go.mod b/go.mod index bc31aa4d1..1715e70ef 100644 --- a/go.mod +++ b/go.mod @@ -2,7 +2,7 @@ module github.com/RiV-chain/RiV-mesh go 1.21 -replace github.com/Arceliar/ironwood => github.com/RiV-chain/ironwood v0.0.0-20231220103331-37a8ba431a4e +replace github.com/Arceliar/ironwood => github.com/RiV-chain/ironwood v0.0.0-20231220110601-a30286562e6e replace github.com/mikispag/dns-over-tls-forwarder => github.com/RiV-chain/dns-over-tls-forwarder v0.0.0-20230828114909-c2cd9f8d79d3 diff --git a/go.sum b/go.sum index 208996df4..e8c4b38f6 100644 --- a/go.sum +++ b/go.sum @@ -4,8 +4,8 @@ github.com/Arceliar/phony v0.0.0-20220903101357-530938a4b13d h1:UK9fsWbWqwIQkMCz github.com/Arceliar/phony v0.0.0-20220903101357-530938a4b13d/go.mod h1:BCnxhRf47C/dy/e/D2pmB8NkB3dQVIrkD98b220rx5Q= github.com/RiV-chain/dns-over-tls-forwarder v0.0.0-20230828114909-c2cd9f8d79d3 h1:gz71d+oEAMXYUYw54JKT4A6CxniQx6B9J0G5CYJeLok= github.com/RiV-chain/dns-over-tls-forwarder v0.0.0-20230828114909-c2cd9f8d79d3/go.mod h1:V2Irj3BjF2tLZ3xXp6TMQCu0I+eJWQPEktbLMHQN8XA= -github.com/RiV-chain/ironwood v0.0.0-20231220103331-37a8ba431a4e h1:RLKFjAHKnaCXQUyVdiBWf3VULWLRea6UW849QJbNODY= -github.com/RiV-chain/ironwood v0.0.0-20231220103331-37a8ba431a4e/go.mod h1:O9iIMM9iVSXUIKNcrjossDuuXLwoGNuLSDXqjtTBHJk= +github.com/RiV-chain/ironwood v0.0.0-20231220110601-a30286562e6e h1:JLsGxvmxpuijrprn5U7gdvS97ruA8WE4FkpRS6w+l50= +github.com/RiV-chain/ironwood v0.0.0-20231220110601-a30286562e6e/go.mod h1:O9iIMM9iVSXUIKNcrjossDuuXLwoGNuLSDXqjtTBHJk= github.com/apernet/quic-go v0.40.1-0.20231112225043-e7f3af208dee h1:S3r63crMLzbjjVJjiR+l6oS7Dzli1mYpxXNNlVc/qCc= github.com/apernet/quic-go v0.40.1-0.20231112225043-e7f3af208dee/go.mod h1:9i0/jnY+4NvJA/wdatko2/I8iRf5R0bvZQ6fbk76tRA= github.com/bits-and-blooms/bitset v1.3.1/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA= diff --git a/src/core/address.go b/src/core/address.go index f2a106d79..0e36640fd 100644 --- a/src/core/address.go +++ b/src/core/address.go @@ -73,7 +73,7 @@ func (c *Core) AddrForDomain(domain iwt.Domain) *Address { if len(domain.Key) != ed25519.PublicKeySize { return nil } - addr, err := encodeToIPv6(c.GetPrefix(), domain.Name) + addr, err := encodeToIPv6(c.GetPrefix(), domain.Name[:]) if err != nil { c.log.Errorln(err) return nil diff --git a/src/core/version.go b/src/core/version.go index 9ddb36094..c052e9fd4 100644 --- a/src/core/version.go +++ b/src/core/version.go @@ -132,8 +132,9 @@ func (m *version_metadata) decode(r io.Reader, password []byte) error { copy(m.domain.Key, bs[:ed25519.PublicKeySize]) case metaDomainName: - m.domain.Name = make(ed25519.PublicKey, ed25519.PublicKeySize) - copy(m.domain.Name, bs[:ed25519.PublicKeySize]) + var n [ed25519.PublicKeySize]byte + copy(n[:], bs[:ed25519.PublicKeySize]) + m.domain.Name = n case metaPriority: m.priority = bs[0]