Skip to content

Conversation

@chise0713
Copy link

I found that brotli is already an indirect dependency, so this PR adds a support for Content-Encoding: br.

Tested by this example:

package main

import (
        "net/http"

        "github.com/andybalholm/brotli"
)

func main() {
        http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
                data := `{"version":1,"rules":[{"domain_suffix":["alphabet.com"],"domain_keyword":["fitbit","google"]}]}`
                w.Header().Set("Content-Encoding", "br")
                w.Header().Set("Content-Type", "application/json")
                bw := brotli.NewWriter(w)
                defer bw.Close()
                bw.Write([]byte(data))
        })
        panic(http.ListenAndServe("127.0.0.1:1408", nil))
}

sing-box logs and config file:

./sing-box run -c test.json; cat test.json 
INFO[0000] network: updated default interface enp7s0, index 2
DEBUG[0000] router: updating rule-set test from URL: http://127.0.0.1:1408
INFO[0000] outbound/direct: outbound connection to 127.0.0.1:1408
INFO[0000] router: updated rule-set test
INFO[0000] sing-box started (0.00s)
^C{
  "route": {
    "rule_set": [
      {
        "type": "remote",
        "tag": "test",
        "format": "source",
        "url": "http://127.0.0.1:1408"
      }
    ]
  }
}

But it's only in rule_set_remote.go and router.go, and wrote by some random AI that's not me.

If this PR doesn't meet the standards, feel free to just close it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant