diff --git a/api/handler/convert.go b/api/handler/convert.go index 5fbdaf9..79a2fe7 100644 --- a/api/handler/convert.go +++ b/api/handler/convert.go @@ -2,9 +2,10 @@ package handler import ( "encoding/json" - "sub2sing-box/common" - "sub2sing-box/model" - "sub2sing-box/util" + + "github.com/nitezs/sub2sing-box/common" + "github.com/nitezs/sub2sing-box/model" + "github.com/nitezs/sub2sing-box/util" "github.com/gin-gonic/gin" ) diff --git a/api/server.go b/api/server.go index 73165bf..9580fd7 100644 --- a/api/server.go +++ b/api/server.go @@ -6,7 +6,8 @@ import ( "html/template" "net/http" "strconv" - "sub2sing-box/api/handler" + + "github.com/nitezs/sub2sing-box/api/handler" "github.com/gin-gonic/gin" ) diff --git a/cmd/convert.go b/cmd/convert.go index 35a1ae7..c999d62 100644 --- a/cmd/convert.go +++ b/cmd/convert.go @@ -5,8 +5,9 @@ import ( "fmt" "os" "path/filepath" - "sub2sing-box/common" - "sub2sing-box/model" + + "github.com/nitezs/sub2sing-box/common" + "github.com/nitezs/sub2sing-box/model" "github.com/spf13/cobra" ) @@ -79,7 +80,7 @@ func convertRun(cmd *cobra.Command, args []string) { func loadConfig() { if config == "" { if wd, err := os.Getwd(); err == nil { - config = filepath.Join(wd, "sub2sing-box.json") + config = filepath.Join(wd, "github.com/nitezs/sub2sing-box.json") if _, err := os.Stat(config); os.IsNotExist(err) { return } diff --git a/cmd/server.go b/cmd/server.go index cf65eb1..7c79770 100644 --- a/cmd/server.go +++ b/cmd/server.go @@ -1,7 +1,7 @@ package cmd import ( - "sub2sing-box/api" + "github.com/nitezs/sub2sing-box/api" "github.com/spf13/cobra" ) diff --git a/cmd/version.go b/cmd/version.go index 608c9ce..8f6b76c 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -2,7 +2,8 @@ package cmd import ( "fmt" - "sub2sing-box/constant" + + "github.com/nitezs/sub2sing-box/constant" "github.com/spf13/cobra" ) diff --git a/common/convert.go b/common/convert.go index b820fdb..8efa799 100644 --- a/common/convert.go +++ b/common/convert.go @@ -9,10 +9,11 @@ import ( "regexp" "sort" "strings" - C "sub2sing-box/constant" - "sub2sing-box/model" - "sub2sing-box/parser" - "sub2sing-box/util" + + C "github.com/nitezs/sub2sing-box/constant" + "github.com/nitezs/sub2sing-box/model" + "github.com/nitezs/sub2sing-box/parser" + "github.com/nitezs/sub2sing-box/util" ) func Convert( diff --git a/go.mod b/go.mod index 8e73ba2..5d7e233 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module sub2sing-box +module github.com/nitezs/sub2sing-box go 1.21.5 diff --git a/main.go b/main.go index 408dbce..bb83faf 100644 --- a/main.go +++ b/main.go @@ -2,7 +2,8 @@ package main import ( "fmt" - "sub2sing-box/cmd" + + "github.com/nitezs/sub2sing-box/cmd" ) func main() { diff --git a/model/outbound.go b/model/outbound.go index 15b907c..6a75fc6 100644 --- a/model/outbound.go +++ b/model/outbound.go @@ -5,7 +5,8 @@ import ( "errors" "reflect" "strings" - C "sub2sing-box/constant" + + C "github.com/nitezs/sub2sing-box/constant" ) type _Outbound struct { @@ -83,6 +84,9 @@ func (h *Outbound) MarshalJSON() ([]byte, error) { if err != nil { return nil, err } + if rawOptions == nil { + return json.Marshal((*_Outbound)(h)) + } result := make(map[string]any) result["type"] = h.Type result["tag"] = h.Tag diff --git a/model/sort.go b/model/sort.go index e80e8eb..8e232ba 100644 --- a/model/sort.go +++ b/model/sort.go @@ -1,7 +1,7 @@ package model import ( - C "sub2sing-box/constant" + C "github.com/nitezs/sub2sing-box/constant" "golang.org/x/text/collate" "golang.org/x/text/language" diff --git a/parser/hysteria.go b/parser/hysteria.go index bfc7e6f..bc5e87c 100644 --- a/parser/hysteria.go +++ b/parser/hysteria.go @@ -5,8 +5,9 @@ import ( "net/url" "strconv" "strings" - "sub2sing-box/constant" - "sub2sing-box/model" + + "github.com/nitezs/sub2sing-box/constant" + "github.com/nitezs/sub2sing-box/model" ) func ParseHysteria(proxy string) (model.Outbound, error) { diff --git a/parser/hysteria2.go b/parser/hysteria2.go index 56c7f0f..328b929 100644 --- a/parser/hysteria2.go +++ b/parser/hysteria2.go @@ -4,8 +4,9 @@ import ( "fmt" "net/url" "strings" - "sub2sing-box/constant" - "sub2sing-box/model" + + "github.com/nitezs/sub2sing-box/constant" + "github.com/nitezs/sub2sing-box/model" ) func ParseHysteria2(proxy string) (model.Outbound, error) { diff --git a/parser/parsers_map.go b/parser/parsers_map.go index dd8e9ac..d17c8ac 100644 --- a/parser/parsers_map.go +++ b/parser/parsers_map.go @@ -1,8 +1,8 @@ package parser import ( - "sub2sing-box/constant" - "sub2sing-box/model" + "github.com/nitezs/sub2sing-box/constant" + "github.com/nitezs/sub2sing-box/model" ) var ParserMap map[string]func(string) (model.Outbound, error) = map[string]func(string) (model.Outbound, error){ diff --git a/parser/shadowsocks.go b/parser/shadowsocks.go index ca75561..ef5dc8f 100644 --- a/parser/shadowsocks.go +++ b/parser/shadowsocks.go @@ -4,9 +4,10 @@ import ( "fmt" "net/url" "strings" - "sub2sing-box/constant" - "sub2sing-box/model" - "sub2sing-box/util" + + "github.com/nitezs/sub2sing-box/constant" + "github.com/nitezs/sub2sing-box/model" + "github.com/nitezs/sub2sing-box/util" ) func ParseShadowsocks(proxy string) (model.Outbound, error) { diff --git a/parser/trojan.go b/parser/trojan.go index 20730ca..5d89a58 100644 --- a/parser/trojan.go +++ b/parser/trojan.go @@ -4,8 +4,9 @@ import ( "fmt" "net/url" "strings" - "sub2sing-box/constant" - "sub2sing-box/model" + + "github.com/nitezs/sub2sing-box/constant" + "github.com/nitezs/sub2sing-box/model" ) func ParseTrojan(proxy string) (model.Outbound, error) { diff --git a/parser/vless.go b/parser/vless.go index 6690cb9..d9c9ce9 100644 --- a/parser/vless.go +++ b/parser/vless.go @@ -4,8 +4,9 @@ import ( "fmt" "net/url" "strings" - "sub2sing-box/constant" - "sub2sing-box/model" + + "github.com/nitezs/sub2sing-box/constant" + "github.com/nitezs/sub2sing-box/model" ) func ParseVless(proxy string) (model.Outbound, error) { diff --git a/parser/vmess.go b/parser/vmess.go index 10bf6fc..3fa66bb 100644 --- a/parser/vmess.go +++ b/parser/vmess.go @@ -5,9 +5,10 @@ import ( "net/url" "strconv" "strings" - "sub2sing-box/constant" - "sub2sing-box/model" - "sub2sing-box/util" + + "github.com/nitezs/sub2sing-box/constant" + "github.com/nitezs/sub2sing-box/model" + "github.com/nitezs/sub2sing-box/util" ) func ParseVmess(proxy string) (model.Outbound, error) { diff --git a/templates/tun-fakeip-with-country-group.json b/templates/tun-fakeip-with-country-group.json index c228a81..217225a 100644 --- a/templates/tun-fakeip-with-country-group.json +++ b/templates/tun-fakeip-with-country-group.json @@ -15,18 +15,15 @@ "detour": "direct" }, { - "tag": "remote", + "tag": "fakeip", "address": "fakeip" } ], "rules": [ { "outbound": "any", - "server": "local" - }, - { - "query_type": ["A", "AAAA"], - "server": "remote" + "server": "local", + "disable_cache": true }, { "clash_mode": "Direct", @@ -45,14 +42,19 @@ "mode": "and", "rules": [ { - "rule_set": "geosite-geolocation-!cn" + "rule_set": "geosite-geolocation-!cn", + "invert": true }, { "rule_set": "geoip-cn" } ], "server": "google", - "client_subnet": "114.114.114.114" + "client_subnet": "114.114.114.114/24" + }, + { + "query_type": ["A", "AAAA"], + "server": "fakeip" } ], "fakeip": { diff --git a/templates/tun-fakeip.json b/templates/tun-fakeip.json index a4a4047..50e5812 100644 --- a/templates/tun-fakeip.json +++ b/templates/tun-fakeip.json @@ -15,18 +15,15 @@ "detour": "direct" }, { - "tag": "remote", + "tag": "fakeip", "address": "fakeip" } ], "rules": [ { "outbound": "any", - "server": "local" - }, - { - "query_type": ["A", "AAAA"], - "server": "remote" + "server": "local", + "disable_cache": true }, { "clash_mode": "Direct", @@ -45,14 +42,19 @@ "mode": "and", "rules": [ { - "rule_set": "geosite-geolocation-!cn" + "rule_set": "geosite-geolocation-!cn", + "invert": true }, { "rule_set": "geoip-cn" } ], "server": "google", - "client_subnet": "114.114.114.114" + "client_subnet": "114.114.114.114/24" + }, + { + "query_type": ["A", "AAAA"], + "server": "fakeip" } ], "fakeip": {