don't forget to rate-limit the new ping feature, once per 24 hours

This commit is contained in:
idk
2023-01-28 01:37:44 +00:00
parent 1f31b5551b
commit 7b5270eb70
3 changed files with 15 additions and 2 deletions

View File

@ -1,5 +1,5 @@
VERSION=0.2.32 VERSION=0.2.33
APP=reseed-tools APP=reseed-tools
USER_GH=eyedeekay USER_GH=eyedeekay
CGO_ENABLED=0 CGO_ENABLED=0

View File

@ -19,7 +19,7 @@ func main() {
app := cli.NewApp() app := cli.NewApp()
app.Name = "reseed-tools" app.Name = "reseed-tools"
app.Version = "0.2.32" app.Version = "0.2.33"
app.Usage = "I2P tools and reseed server" app.Usage = "I2P tools and reseed server"
auth := &cli.Author{ auth := &cli.Author{
Name: "eyedeekay", Name: "eyedeekay",

View File

@ -97,7 +97,20 @@ var AllReseeds = []string{
"https://www2.mk16.de/", "https://www2.mk16.de/",
} }
func yday() time.Time {
today := time.Now()
yesterday := today.Add(-24 * time.Hour)
return yesterday
}
var lastPing = yday()
func PingEverybody() []string { func PingEverybody() []string {
if lastPing.After(yday()) {
log.Println("Your ping was rate-limited")
return nil
}
lastPing = time.Now()
var nonerrs []string var nonerrs []string
for _, urlInput := range AllReseeds { for _, urlInput := range AllReseeds {
err := PingWriteContent(urlInput) err := PingWriteContent(urlInput)