1
0
mirror of https://github.com/nitezs/sub2sing-box.git synced 2024-12-23 15:04:41 -05:00
This commit is contained in:
Nite07 2024-09-19 18:12:24 +08:00
parent 89bb0d03e0
commit a1dcc1867f
19 changed files with 69 additions and 49 deletions

View File

@ -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"
)

View File

@ -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"
)

View File

@ -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
}

View File

@ -1,7 +1,7 @@
package cmd
import (
"sub2sing-box/api"
"github.com/nitezs/sub2sing-box/api"
"github.com/spf13/cobra"
)

View File

@ -2,7 +2,8 @@ package cmd
import (
"fmt"
"sub2sing-box/constant"
"github.com/nitezs/sub2sing-box/constant"
"github.com/spf13/cobra"
)

View File

@ -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(

2
go.mod
View File

@ -1,4 +1,4 @@
module sub2sing-box
module github.com/nitezs/sub2sing-box
go 1.21.5

View File

@ -2,7 +2,8 @@ package main
import (
"fmt"
"sub2sing-box/cmd"
"github.com/nitezs/sub2sing-box/cmd"
)
func main() {

View File

@ -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

View File

@ -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"

View File

@ -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) {

View File

@ -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) {

View File

@ -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){

View File

@ -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) {

View File

@ -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) {

View File

@ -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) {

View File

@ -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) {

View File

@ -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": {

View File

@ -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": {