Skip to content

Commit 203c4b9

Browse files
committed
LookupDomain method to uilib
1 parent 9f48868 commit 203c4b9

File tree

4 files changed

+31
-3
lines changed

4 files changed

+31
-3
lines changed

ethereal/assets/qml/webapp.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ ApplicationWindow {
103103
uri.replace(reg, function(match, pre, domain, path) {
104104
uri = pre;
105105

106-
var lookup = eth.lookupDomain(domain.substring(0, domain.length - 4));
106+
var lookup = ui.lookupDomain(domain.substring(0, domain.length - 4));
107107
var ip = [];
108108
for(var i = 0, l = lookup.length; i < l; i++) {
109109
ip.push(lookup.charCodeAt(i))

ethereal/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212

1313
const (
1414
ClientIdentifier = "Ethereal"
15-
Version = "0.6.1"
15+
Version = "0.6.2"
1616
)
1717

1818
var ethereum *eth.Ethereum

ethereal/ui_lib.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
package main
22

33
import (
4+
"bytes"
45
"fmt"
56
"path"
7+
"strconv"
8+
"strings"
69

710
"github.com/ethereum/eth-go"
811
"github.com/ethereum/eth-go/ethchain"
12+
"github.com/ethereum/eth-go/ethcrypto"
913
"github.com/ethereum/eth-go/ethpipe"
1014
"github.com/ethereum/eth-go/ethutil"
1115
"github.com/ethereum/go-ethereum/javascript"
@@ -36,6 +40,30 @@ func NewUiLib(engine *qml.Engine, eth *eth.Ethereum, assetPath string) *UiLib {
3640
return &UiLib{JSPipe: ethpipe.NewJSPipe(eth), engine: engine, eth: eth, assetPath: assetPath, jsEngine: javascript.NewJSRE(eth)}
3741
}
3842

43+
func (self *UiLib) LookupDomain(domain string) string {
44+
world := self.World()
45+
46+
if len(domain) > 32 {
47+
domain = string(ethcrypto.Sha3Bin([]byte(domain)))
48+
}
49+
data := world.Config().Get("DnsReg").StorageString(domain).Bytes()
50+
51+
// Left padded = A record, Right padded = CNAME
52+
if data[0] == 0 {
53+
data = bytes.TrimLeft(data, "\x00")
54+
var ipSlice []string
55+
for _, d := range data {
56+
ipSlice = append(ipSlice, strconv.Itoa(int(d)))
57+
}
58+
59+
return strings.Join(ipSlice, ".")
60+
} else {
61+
data = bytes.TrimRight(data, "\x00")
62+
63+
return string(data)
64+
}
65+
}
66+
3967
func (self *UiLib) ImportTx(rlpTx string) {
4068
tx := ethchain.NewTransactionFromBytes(ethutil.Hex2Bytes(rlpTx))
4169
self.eth.TxPool().QueueTransaction(tx)

ethereum/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313

1414
const (
1515
ClientIdentifier = "Ethereum(G)"
16-
Version = "0.6.1"
16+
Version = "0.6.2"
1717
)
1818

1919
var logger = ethlog.NewLogger("CLI")

0 commit comments

Comments
 (0)