Skip to content

Commit

Permalink
byte array instead of clice in domain struct
Browse files Browse the repository at this point in the history
  • Loading branch information
vikulin committed Dec 20, 2023
1 parent 1d6b9c8 commit ea7dc66
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cmd/genkeys/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/mesh/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
2 changes: 1 addition & 1 deletion src/core/address.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions src/core/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit ea7dc66

Please sign in to comment.