Pull request 2302: upd-all

Squashed commit of the following:

commit f920006277f39b74c803139af2a9039aa45effae
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Fri Nov 8 16:14:41 2024 +0300

    all: fix pre-commit; upd dnsproxy

commit 391f79b244348c6075f5ba0fccfb8882791bf3f1
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Thu Nov 7 18:53:28 2024 +0300

    scripts: imp install

commit 35324db80b591831c32b7ea45930eefee82a6320
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Thu Nov 7 18:20:23 2024 +0300

    all: imp docs, scripts

commit d2724cfaefdb8659efbdb5bf181a28721a909f07
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Thu Nov 7 17:26:23 2024 +0300

    all: upd go, deps, tools, scripts
This commit is contained in:
Ainar Garipov
2024-11-08 17:18:16 +03:00
parent 6673bb175a
commit ac5a96fada
40 changed files with 834 additions and 916 deletions

View File

@@ -13,6 +13,7 @@ import (
"os"
"time"
"github.com/AdguardTeam/golibs/errors"
"github.com/AdguardTeam/golibs/logutil/slogutil"
"github.com/google/renameio/v2/maybe"
)
@@ -22,20 +23,19 @@ func main() {
l := slogutil.New(nil)
urlStr := "https://adguardteam.github.io/HostlistsRegistry/assets/filters.json"
if v, ok := os.LookupEnv("URL"); ok {
urlStr = v
if s := os.Getenv("URL"); s != "" {
urlStr = s
}
// Validate the URL.
_, err := url.Parse(urlStr)
check(err)
errors.Check(err)
c := &http.Client{
Timeout: 10 * time.Second,
}
resp, err := c.Get(urlStr)
check(err)
resp := errors.Must(c.Get(urlStr))
defer slogutil.CloseAndLog(ctx, l, resp.Body, slog.LevelError)
if resp.StatusCode != http.StatusOK {
@@ -44,7 +44,7 @@ func main() {
hlFlt := &hlFilters{}
err = json.NewDecoder(resp.Body).Decode(hlFlt)
check(err)
errors.Check(err)
aghFlt := &aghFilters{
Categories: map[string]*aghFiltersCategory{
@@ -93,11 +93,10 @@ func main() {
enc := json.NewEncoder(buf)
enc.SetIndent("", " ")
err = enc.Encode(aghFlt)
check(err)
errors.Check(enc.Encode(aghFlt))
err = maybe.WriteFile("client/src/helpers/filters/filters.ts", buf.Bytes(), 0o644)
check(err)
errors.Check(err)
}
// jsHeader is the header for the generated JavaScript file. It informs the
@@ -109,13 +108,6 @@ const jsHeader = `// Code generated by go run ./scripts/vetted-filters/main.go;
export default `
// check is a simple error-checking helper for scripts.
func check(err error) {
if err != nil {
panic(err)
}
}
// hlFilters is the JSON structure for the Hostlists Registry rule list index.
type hlFilters struct {
Filters []*hlFiltersFilter `json:"filters"`