aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-03-07 18:26:46 +0800
committerobscuren <geffobscura@gmail.com>2014-03-07 18:26:46 +0800
commit54bcee512d6be40691a579dba8de29193cf09ddd (patch)
tree068f85660befe8d218897a3ad7bb91c5c31bd256
parent685ea3e9a944cc982bf5afc5b3e29c935a6e4c0b (diff)
parent694ef4704176c4c2329b56e4cd5320f558513efb (diff)
downloadgo-tangerine-54bcee512d6be40691a579dba8de29193cf09ddd.tar
go-tangerine-54bcee512d6be40691a579dba8de29193cf09ddd.tar.gz
go-tangerine-54bcee512d6be40691a579dba8de29193cf09ddd.tar.bz2
go-tangerine-54bcee512d6be40691a579dba8de29193cf09ddd.tar.lz
go-tangerine-54bcee512d6be40691a579dba8de29193cf09ddd.tar.xz
go-tangerine-54bcee512d6be40691a579dba8de29193cf09ddd.tar.zst
go-tangerine-54bcee512d6be40691a579dba8de29193cf09ddd.zip
Merge branch 'develop' of https://github.com/jarradh/eth-go into jarradh-develop
-rw-r--r--ethereum.go51
1 files changed, 38 insertions, 13 deletions
diff --git a/ethereum.go b/ethereum.go
index 342f4f573..fb97c34b1 100644
--- a/ethereum.go
+++ b/ethereum.go
@@ -263,20 +263,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))
+ }
}
}