mirror of
https://gitlab.com/pulsechaincom/go-pulse.git
synced 2024-12-24 12:27:17 +00:00
Updated lookup method to include CNAME's as well as A records
This commit is contained in:
parent
a760ce05b9
commit
fa881220ae
@ -6,7 +6,7 @@ type BloomFilter struct {
|
||||
|
||||
func NewBloomFilter(bin []byte) *BloomFilter {
|
||||
if bin == nil {
|
||||
bin = make([]byte, 255)
|
||||
bin = make([]byte, 256)
|
||||
}
|
||||
|
||||
return &BloomFilter{
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"math/big"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
|
||||
@ -74,8 +75,22 @@ func (self *PEthereum) LookupDomain(domain string) string {
|
||||
if len(domain) > 32 {
|
||||
domain = string(ethcrypto.Sha3Bin([]byte(domain)))
|
||||
}
|
||||
data := world.Config().Get("DnsReg").StorageString(domain).Bytes()
|
||||
|
||||
return strings.Trim(world.Config().Get("DnsReg").StorageString(domain).Str(), "\x00")
|
||||
// Left padded = A record, Right padded = CNAME
|
||||
if data[0] == 0 {
|
||||
data = bytes.TrimLeft(data, "\x00")
|
||||
var ipSlice []string
|
||||
for _, d := range data {
|
||||
ipSlice = append(ipSlice, strconv.Itoa(int(d)))
|
||||
}
|
||||
|
||||
return strings.Join(ipSlice, ".")
|
||||
} else {
|
||||
data = bytes.TrimRight(data, "\x00")
|
||||
|
||||
return string(data)
|
||||
}
|
||||
}
|
||||
|
||||
func (lib *PEthereum) GetBlock(hexHash string) *PBlock {
|
||||
|
Loading…
Reference in New Issue
Block a user