chore: 暴露数据给前端
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
package route
|
||||
|
||||
import (
|
||||
"github.com/Dreamacro/clash/constant"
|
||||
"net/http"
|
||||
|
||||
"github.com/Dreamacro/clash/tunnel"
|
||||
@ -19,17 +20,23 @@ type Rule struct {
|
||||
Type string `json:"type"`
|
||||
Payload string `json:"payload"`
|
||||
Proxy string `json:"proxy"`
|
||||
Size int `json:"Size"`
|
||||
}
|
||||
|
||||
func getRules(w http.ResponseWriter, r *http.Request) {
|
||||
rawRules := tunnel.Rules()
|
||||
rules := []Rule{}
|
||||
for _, rule := range rawRules {
|
||||
rules = append(rules, Rule{
|
||||
r := Rule{
|
||||
Type: rule.RuleType().String(),
|
||||
Payload: rule.Payload(),
|
||||
Proxy: rule.Adapter(),
|
||||
})
|
||||
Size: -1,
|
||||
}
|
||||
if rule.RuleType() == constant.GEOIP || rule.RuleType() == constant.GEOSITE {
|
||||
r.Size = rule.(constant.RuleGroup).GetRecodeSize()
|
||||
}
|
||||
rules = append(rules, r)
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user