new: Big Change, Add support for Extensions 😍

This commit is contained in:
hiddify
2024-09-28 20:31:38 +02:00
parent 1f485e1193
commit 3a508b7929
44 changed files with 8946 additions and 619 deletions

View File

@@ -287,7 +287,7 @@ func setClashAPI(options *option.Options, opt *HiddifyOptions) {
func setLog(options *option.Options, opt *HiddifyOptions) {
options.Log = &option.LogOptions{
Level: opt.LogLevel,
Output: "box.log",
Output: opt.LogFile,
Disabled: false,
Timestamp: true,
DisableColor: true,

View File

@@ -8,6 +8,7 @@ import (
type HiddifyOptions struct {
EnableFullConfig bool `json:"enable-full-config"`
LogLevel string `json:"log-level"`
LogFile string `json:"log-file"`
EnableClashApi bool `json:"enable-clash-api"`
ClashApiPort uint16 `json:"clash-api-port"`
ClashApiSecret string `json:"web-secret"`
@@ -106,8 +107,8 @@ func DefaultHiddifyOptions() *HiddifyOptions {
InboundOptions: InboundOptions{
EnableTun: false,
SetSystemProxy: false,
MixedPort: 2334,
TProxyPort: 2335,
MixedPort: 12334,
TProxyPort: 12335,
LocalDnsPort: 16450,
MTU: 9000,
StrictRoute: true,
@@ -124,10 +125,12 @@ func DefaultHiddifyOptions() *HiddifyOptions {
BypassLAN: false,
AllowConnectionFromLAN: false,
},
LogLevel: "warn",
LogLevel: "warn",
// LogFile: "/dev/null",
LogFile: "box.log",
Region: "other",
EnableClashApi: true,
ClashApiPort: 6756,
ClashApiPort: 16756,
ClashApiSecret: "",
// GeoIPPath: "geoip.db",
// GeoSitePath: "geosite.db",

View File

@@ -31,6 +31,19 @@ func ParseConfig(path string, debug bool) ([]byte, error) {
return ParseConfigContent(string(content), debug, nil, false)
}
func ParseConfigContentToOptions(contentstr string, debug bool, configOpt *HiddifyOptions, fullConfig bool) (*option.Options, error) {
content, err := ParseConfigContent(contentstr, debug, configOpt, fullConfig)
if err != nil {
return nil, err
}
var options option.Options
err = json.Unmarshal(content, &options)
if err != nil {
return nil, err
}
return &options, nil
}
func ParseConfigContent(contentstr string, debug bool, configOpt *HiddifyOptions, fullConfig bool) ([]byte, error) {
if configOpt == nil {
configOpt = DefaultHiddifyOptions()

View File

@@ -9,6 +9,7 @@ import (
"strings"
"github.com/bepass-org/warp-plus/warp"
"github.com/hiddify/hiddify-core/common"
C "github.com/sagernet/sing-box/constant"
// "github.com/bepass-org/wireguard-go/warp"
@@ -189,8 +190,10 @@ func patchWarp(base *option.Outbound, configOpt *HiddifyOptions, final bool, sta
rndDomain := strings.ToLower(generateRandomString(20))
staticIpsDns[rndDomain] = []string{}
if host != "auto4" {
randomIpPort, _ := warp.RandomWarpEndpoint(false, true)
staticIpsDns[rndDomain] = append(staticIpsDns[rndDomain], randomIpPort.Addr().String())
if host == "auto6" || common.CanConnectIPv6() {
randomIpPort, _ := warp.RandomWarpEndpoint(false, true)
staticIpsDns[rndDomain] = append(staticIpsDns[rndDomain], randomIpPort.Addr().String())
}
}
if host != "auto6" {
randomIpPort, _ := warp.RandomWarpEndpoint(true, false)