diff options
author | Maran <maran.hidskes@gmail.com> | 2014-03-17 17:37:37 +0800 |
---|---|---|
committer | Maran <maran.hidskes@gmail.com> | 2014-03-17 17:37:37 +0800 |
commit | 8ea7e21f64842380833cce7aafa52b909cb8426b (patch) | |
tree | 08b138c3ef94da8fb1ff0a11c7c47aba5e59e616 /ethereum.go | |
parent | 3274e0a2496e622a847b213bb5ba0272650ef06c (diff) | |
download | dexon-8ea7e21f64842380833cce7aafa52b909cb8426b.tar dexon-8ea7e21f64842380833cce7aafa52b909cb8426b.tar.gz dexon-8ea7e21f64842380833cce7aafa52b909cb8426b.tar.bz2 dexon-8ea7e21f64842380833cce7aafa52b909cb8426b.tar.lz dexon-8ea7e21f64842380833cce7aafa52b909cb8426b.tar.xz dexon-8ea7e21f64842380833cce7aafa52b909cb8426b.tar.zst dexon-8ea7e21f64842380833cce7aafa52b909cb8426b.zip |
Merge
Diffstat (limited to 'ethereum.go')
-rw-r--r-- | ethereum.go | 51 |
1 files changed, 38 insertions, 13 deletions
diff --git a/ethereum.go b/ethereum.go index 302f3c04f..c906a6954 100644 --- a/ethereum.go +++ b/ethereum.go @@ -271,20 +271,45 @@ func (s *Ethereum) Start() { if ethutil.Config.Seed { ethutil.Config.Log.Debugln("Seeding") - // Testnet seed bootstrapping - resp, err := http.Get("https://www.ethereum.org/servers.poc3.txt") - if err != nil { - log.Println("Fetching seed failed:", err) - return - } - defer resp.Body.Close() - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - log.Println("Reading seed failed:", err) - return - } + // DNS Bootstrapping + _, nodes, err := net.LookupSRV("eth", "tcp", "ethereum.org") + if err == nil { + peers := []string{} + // Iterate SRV nodes + for _, n := range nodes { + target := n.Target + port := strconv.Itoa(int(n.Port)) + // Resolve target to ip (Go returns list, so may resolve to multiple ips?) + addr, err := net.LookupHost(target) + if err == nil { + for _, a := range addr { + // Build string out of SRV port and Resolved IP + peer := net.JoinHostPort(a, port) + log.Println("Found DNS Bootstrap Peer:", peer) + peers = append(peers, peer) + } + } else { + log.Println("Couldn't resolve :", target) + } + } + // Connect to Peer list + s.ProcessPeerList(peers) + } else { + // Fallback to servers.poc3.txt + resp, err := http.Get("http://www.ethereum.org/servers.poc3.txt") + if err != nil { + log.Println("Fetching seed failed:", err) + return + } + defer resp.Body.Close() + body, err := ioutil.ReadAll(resp.Body) + if err != nil { + log.Println("Reading seed failed:", err) + return + } - s.ConnectToPeer(string(body)) + s.ConnectToPeer(string(body)) + } } } |