Skip to content

Commit

Permalink
Fix clash template
Browse files Browse the repository at this point in the history
  • Loading branch information
problematicconsumer committed Aug 20, 2023
1 parent 9d63ae0 commit 85efdbb
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 166 deletions.
2 changes: 0 additions & 2 deletions custom/custom.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import (

var box *BoxService

var templateOptions = shared.ConfigTemplateOptions{IncludeTunInbound: false, IncludeMixedInbound: true, IncludeLogOutput: true}

//export setup
func setup(baseDir *C.char, workingDir *C.char, tempDir *C.char) {
Setup(C.GoString(baseDir), C.GoString(workingDir), C.GoString(tempDir))
Expand Down
127 changes: 127 additions & 0 deletions shared/config.json.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
{
"log": {},
"dns": {
"servers": [
{
"tag": "remote",
"address_resolver": "local",
"address": "tcp://1.1.1.1",
"strategy": "prefer_ipv4",
"detour": "select"
},
{
"tag": "local",
"address": "local",
"detour": "direct"
}
],
"rules": [
{
"clash_mode": "global",
"server": "remote"
},
{
"clash_mode": "direct",
"server": "local"
},
{
"outbound": [
"any"
],
"server": "local"
},
{
"geosite": "ir",
"server": "local"
}
],
"strategy": "ipv4_only"
},
"inbounds": [
{
"type": "tun",
"inet4_address": "172.19.0.1/30",
"sniff": true,
"sniff_override_destination": true,
"domain_strategy": "ipv4_only",
"strict_route": true,
"mtu": 9000,
"endpoint_independent_nat": true,
"auto_route": true
},
{
"type": "socks",
"tag": "socks-in",
"listen": "127.0.0.1",
"sniff": true,
"sniff_override_destination": true,
"domain_strategy": "ipv4_only",
"listen_port": 2333,
"users": []
},
{
"type": "mixed",
"tag": "mixed-in",
"sniff": true,
"sniff_override_destination": true,
"domain_strategy": "ipv4_only",
"listen": "127.0.0.1",
"listen_port": 2334,
"set_system_proxy": true,
"users": []
}
],
"outbounds": [
{
"type": "direct",
"tag": "direct"
},
{
"type": "block",
"tag": "block"
},
{
"type": "dns",
"tag": "dns-out"
}
],
"route": {
"rules": [
{
"geosite": "category-ads-all",
"outbound": "block"
},
{
"protocol": "dns",
"outbound": "dns-out"
},
{
"clash_mode": "direct",
"outbound": "direct"
},
{
"clash_mode": "global",
"outbound": "select"
},
{
"geoip": [
"ir",
"private"
],
"outbound": "direct"
},
{
"geosite": "ir",
"outbound": "direct"
}
],
"auto_detect_interface": true
},
"experimental": {
"clash_api": {
"external_controller": "127.0.0.1:9090",
"store_selected": true,
"secret": ""
}
}
}
6 changes: 5 additions & 1 deletion shared/parser.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package shared

import (
_ "embed"
"fmt"
"os"

Expand All @@ -10,6 +11,9 @@ import (
"gopkg.in/yaml.v3"
)

//go:embed config.json.template
var configByte []byte

func ParseConfig(path string) error {
content, err := os.ReadFile(path)
if err != nil {
Expand Down Expand Up @@ -43,7 +47,7 @@ func parseClash(content []byte) ([]byte, error) {
return nil, err
}

output := defaultTemplate(ConfigTemplateOptions{})
output := configByte
output, err = convert.Patch(output, sbConfig, "", "", nil)
if err != nil {
fmt.Printf("patch error %s", err)
Expand Down
163 changes: 0 additions & 163 deletions shared/template.go

This file was deleted.

0 comments on commit 85efdbb

Please sign in to comment.