hardcoded user-agent as tusky + added a DoTries()

This commit is contained in:
farhan 2021-01-25 21:06:47 -05:00
parent 1bebd9064c
commit 4706bce7e3
4 changed files with 8 additions and 2 deletions

View File

@ -66,8 +66,9 @@ func GetNodeInfo(endpoint string, o RunningInstance) RunningInstance {
pleromastodon_nodeinfo_uri := "https://" + endpoint + "/nodeinfo/2.0.json" pleromastodon_nodeinfo_uri := "https://" + endpoint + "/nodeinfo/2.0.json"
req, _ := http.NewRequest("GET", pleromastodon_nodeinfo_uri, nil) req, _ := http.NewRequest("GET", pleromastodon_nodeinfo_uri, nil)
req.Header.Set("User-Agent", "Tusky")
pleromastodon_api_resp, err := o.client.Do(req) pleromastodon_api_resp, err := DoTries(&o, req)
if err != nil { if err != nil {
return o return o
} else { } else {
@ -88,6 +89,7 @@ func GetNodeInfo(endpoint string, o RunningInstance) RunningInstance {
// Check the front page // Check the front page
index_uri := "https://" + endpoint + "/" index_uri := "https://" + endpoint + "/"
req, _ = http.NewRequest("GET", index_uri, nil) req, _ = http.NewRequest("GET", index_uri, nil)
req.Header.Set("User-Agent", "Tusky")
resp_index, err := DoTries(&o, req) resp_index, err := DoTries(&o, req)
o.LastRun = time.Now().Format(time.RFC3339) o.LastRun = time.Now().Format(time.RFC3339)
if err != nil { if err != nil {

View File

@ -87,6 +87,7 @@ func PollMastodonPleroma(endpoint string, o *RunningInstance) {
api_timeline := "https://" + endpoint + "/api/v1/timelines/public?limit=40&since_id=" + min_id api_timeline := "https://" + endpoint + "/api/v1/timelines/public?limit=40&since_id=" + min_id
req, err := http.NewRequest("GET", api_timeline, nil) req, err := http.NewRequest("GET", api_timeline, nil)
req.Header.Set("User-Agent", "Tusky")
if err != nil { if err != nil {
logFatal.Fatal("Unable to create new request for " + endpoint + ": ", err) logFatal.Fatal("Unable to create new request for " + endpoint + ": ", err)
return return

View File

@ -109,9 +109,10 @@ func check_post(uri string) (PostJson, error) {
o := GetHTTPSession(postjson.instance) o := GetHTTPSession(postjson.instance)
req, _ := http.NewRequest("GET", uri, nil) req, _ := http.NewRequest("GET", uri, nil)
req.Header.Set("User-Agent", "Tusky")
req.Header.Add("Accept", "application/ld+json") req.Header.Add("Accept", "application/ld+json")
resp, err := o.client.Do(req) resp, err := DoTries(&o, req)
if err != nil { if err != nil {
return postjson, errors.New("Connection error to " + uri) return postjson, errors.New("Connection error to " + uri)
} }
@ -189,6 +190,7 @@ func check_user(uri string) (UserJson, error) {
o := GetHTTPSession(userjson.instance) o := GetHTTPSession(userjson.instance)
req, _ := http.NewRequest("GET", uri, nil) req, _ := http.NewRequest("GET", uri, nil)
req.Header.Set("User-Agent", "Tusky")
req.Header.Add("Accept", "application/ld+json") req.Header.Add("Accept", "application/ld+json")
var resp *http.Response var resp *http.Response

View File

@ -29,6 +29,7 @@ func StreamMastodon(endpoint string, o *RunningInstance) {
api_timeline := "https://" + endpoint + "/api/v1/streaming/public" api_timeline := "https://" + endpoint + "/api/v1/streaming/public"
req, err := http.NewRequest("GET", api_timeline, nil) req, err := http.NewRequest("GET", api_timeline, nil)
req.Header.Set("User-Agent", "Tusky")
if err != nil { if err != nil {
logFatal.Fatal("Unable to create new request for " + endpoint + ", exiting.") logFatal.Fatal("Unable to create new request for " + endpoint + ", exiting.")
return return