2023-12-04 18:45:22 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"encoding/json"
|
|
|
|
"net/http"
|
|
|
|
"os"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2024-02-15 10:37:03 +08:00
|
|
|
_, adgNoReg, err := adguard(context.Background(), &http.Client{})
|
2023-12-04 18:45:22 +08:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
os.MkdirAll("output", 0777)
|
2024-02-15 10:37:03 +08:00
|
|
|
write("output/AdGuardSDNSFilter.json", adgNoReg)
|
2023-12-09 22:23:30 +08:00
|
|
|
write("output/AdGuardSDNSFilter-NoRegex.json", adgNoReg)
|
2023-12-04 18:45:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func write(name string, ruleSet *Ruleset) {
|
|
|
|
f, err := os.Create(name)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
defer f.Close()
|
|
|
|
|
|
|
|
e := json.NewEncoder(f)
|
|
|
|
e.SetEscapeHTML(false)
|
|
|
|
e.SetIndent("", " ")
|
|
|
|
err = e.Encode(ruleSet)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|