Skip to content

Commit

Permalink
Use random sign for akanno.
Browse files Browse the repository at this point in the history
  • Loading branch information
hguandl committed Mar 1, 2021
1 parent 94d9975 commit 92ed54a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion dr-feeder.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
)

// Version is current `git describe --tags` infomation.
var Version string = "v2.1.0"
var Version string = "v2.1.1"

func consume(ch chan common.NotifyPayload, notifiers []notifier.Notifier) {
for {
Expand Down
22 changes: 14 additions & 8 deletions watcher/akanno.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package watcher

import (
"encoding/json"
"fmt"
"log"
"math/rand"
"strings"

"github.com/gocolly/colly/v2"
Expand Down Expand Up @@ -30,17 +32,21 @@ func NewAkAnnounceWatcher(debugURL string) (Watcher, error) {
return watcher, err
}

func (watcher akAnnounceWatcher) apiURL() string {
if watcher.debugURL != "" {
return watcher.debugURL
}
clientID := rand.Intn(114514191) + 11451419
return fmt.Sprintf("%s?sign=%d",
"https://ak-fs.hypergryph.com/announce/IOS/announcement.meta.json",
clientID,
)
}

func (watcher akAnnounceWatcher) fetchAPI() (announceMeta, error) {
var apiURL string
var err error = nil
var data announceMeta

if watcher.debugURL != "" {
apiURL = watcher.debugURL
} else {
apiURL = "https://ak-fs.hypergryph.com/announce/IOS/announcement.meta.json?sign=1145141919"
}

c := colly.NewCollector(
colly.UserAgent(iOSClientUA),
)
Expand All @@ -53,7 +59,7 @@ func (watcher akAnnounceWatcher) fetchAPI() (announceMeta, error) {
err = json.Unmarshal(r.Body, &data)
})

c.Visit(apiURL)
c.Visit(watcher.apiURL())
c.Wait()

return data, err
Expand Down

0 comments on commit 92ed54a

Please sign in to comment.