2019-10-24 12:14:36 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/rs/zerolog/log"
|
2019-10-24 12:41:05 +00:00
|
|
|
"io/ioutil"
|
2019-10-24 12:14:36 +00:00
|
|
|
"net/http"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
const mastodonIndexUrl = "https://instances.social/list.json?q%5Busers%5D=&q%5Bsearch%5D=&strict=false"
|
|
|
|
|
|
|
|
const pleromaIndexUrl = "https://distsn.org/cgi-bin/distsn-pleroma-instances-api.cgi"
|
|
|
|
|
|
|
|
type InstanceLocator struct {
|
|
|
|
pleromaIndexLastRefresh *time.Time
|
|
|
|
mastodonIndexLastRefresh *time.Time
|
|
|
|
instances map[string]Instance
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewInstanceLocator() *InstanceLocator {
|
|
|
|
i := new(InstanceLocator)
|
|
|
|
return i
|
|
|
|
}
|
2019-10-24 12:41:05 +00:00
|
|
|
|
|
|
|
func (i *InstanceLocator) Locate() {
|
|
|
|
//var hostnames []string
|
|
|
|
|
|
|
|
var netClient = &http.Client{
|
|
|
|
Timeout: time.Second * 10,
|
|
|
|
}
|
|
|
|
resp, _ := netClient.Get(mastodonIndexUrl)
|
|
|
|
defer resp.Body.Close()
|
|
|
|
body, _ := ioutil.ReadAll(resp.Body)
|
|
|
|
|
|
|
|
log.Debug().Msgf("%#v", body)
|
|
|
|
}
|