func GetPeerList(address net.IP) addresslist.IPSlice { resp, err := http.Get("http://" + address.String() + "/peerlist" + GetPort(address)) if err != nil { log.Println(err) } data, err := ioutil.ReadAll(resp.Body) if err != nil { log.Println(err) } return addresslist.FromString(string(data)) }
func InitializeAddressList() { path := ConfPath("peerlist") file, err := os.Open(path) pathErr, ok := err.(*os.PathError) if err != nil && ok && pathErr.Err.Error() == "no such file or directory" { //Yeah, this is pretty bad but the library // did not expose a constant to represent this log.Println(err) BootStrap() //This bootstraps us into the network return } else if err != nil { log.Fatal(err) } data, err := ioutil.ReadAll(file) if err != nil { log.Fatal(err) } iplist := addresslist.FromString(string(data)) AddressList = addresslist.New(iplist) log.Println("Loaded AddressList from file") }