partial implemented host banning
This commit is contained in:
parent
a4fa8a48c8
commit
0342844a52
76
poll/config.go
Normal file
76
poll/config.go
Normal file
@ -0,0 +1,76 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"encoding/json"
|
||||
"muzzammil.xyz/jsonc"
|
||||
"log"
|
||||
)
|
||||
|
||||
type Database struct {
|
||||
Host string `"json:host"`
|
||||
Port int `"json:port"`
|
||||
Username string `"json:username"`
|
||||
Password string `"json:password"`
|
||||
Workers int `"json:workers"`
|
||||
}
|
||||
|
||||
type MassFollower struct {
|
||||
Acct string `"json:acct"`
|
||||
Name string `"json:name"`
|
||||
Summary string `"json:summary"`
|
||||
FollowingCount int `"json:followingcount"`
|
||||
FollowLimit int `"json:followlimit"`
|
||||
}
|
||||
|
||||
type ExtAccount struct {
|
||||
Username string `"json:username"`
|
||||
Password string `"json:password"`
|
||||
Endpoint string `"json:endpoint"`
|
||||
Followlimit int `"json:followlimit"`
|
||||
}
|
||||
|
||||
type Proxy struct {
|
||||
Host string `"json:host"`
|
||||
Port int `"json:port"`
|
||||
Username string `"json:username'`
|
||||
Password string `"json:password"`
|
||||
}
|
||||
|
||||
type Settings struct {
|
||||
Autostart []string `"json:autostart"`
|
||||
Crawl bool `"json:crawl"`
|
||||
Banned []string `"json:banned"`
|
||||
Alwaysbot []string `"json:alwaysbot"`
|
||||
Proxies []Proxy `"json:proxies"`
|
||||
Externalaccounts []ExtAccount `"json:externalaccounts"`
|
||||
MassFollowers []MassFollower `"json:massfollowers"`
|
||||
Database Database `"json:database"`
|
||||
}
|
||||
|
||||
var settings Settings
|
||||
|
||||
func StringExists(needle string, haystack []string) (bool) {
|
||||
for _, check := range haystack {
|
||||
if check == needle {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func getSettings() {
|
||||
c, err := ioutil.ReadFile("config.jsonc")
|
||||
if (err != nil) {
|
||||
log.Fatal("Unable to open config.jsonc, exiting: ", err)
|
||||
}
|
||||
jsoncbin := jsonc.ToJSON(c) // Calling jsonc.ToJSON() to convert JSONC to JSON
|
||||
if jsonc.Valid(jsoncbin) == false {
|
||||
log.Fatal("Invalid jsonc, exiting.")
|
||||
}
|
||||
|
||||
err = json.Unmarshal(jsoncbin, &settings)
|
||||
if err != nil {
|
||||
log.Fatal("Unable to parse config.jsonc, exiting: ", err)
|
||||
}
|
||||
}
|
@ -197,7 +197,7 @@ func PollMastodonPleroma(endpoint string, reportPostChan chan ReportPost) {
|
||||
}
|
||||
|
||||
// Only done if we are crawling
|
||||
if settings.Crawl == true {
|
||||
if settings.Crawl == true || StringExists(endpoint, settings.Banned) == false {
|
||||
newinstance := newpost.Account.Acct[at_sign+1:]
|
||||
ri_mutex.Lock()
|
||||
_, exists := runninginstances[newinstance]
|
||||
|
Loading…
x
Reference in New Issue
Block a user