mirror of
https://github.com/MetaCubeX/ClashMetaForAndroid.git
synced 2024-11-16 08:32:18 +08:00
patch more unsupported config
This commit is contained in:
parent
8f1c235af5
commit
a197f8fce1
|
@ -76,8 +76,7 @@ func Load(path string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start the external controller like in hub.Parse(), but we have set its
|
// like hub.Parse()
|
||||||
// default override value to end with ":0" for security.
|
|
||||||
hub.ApplyConfig(cfg)
|
hub.ApplyConfig(cfg)
|
||||||
|
|
||||||
app.ApplySubtitlePattern(rawCfg.ClashForAndroid.UiSubtitlePattern)
|
app.ApplySubtitlePattern(rawCfg.ClashForAndroid.UiSubtitlePattern)
|
||||||
|
|
|
@ -10,10 +10,9 @@ import (
|
||||||
|
|
||||||
"cfa/native/common"
|
"cfa/native/common"
|
||||||
|
|
||||||
|
"github.com/metacubex/mihomo/config"
|
||||||
C "github.com/metacubex/mihomo/constant"
|
C "github.com/metacubex/mihomo/constant"
|
||||||
"github.com/metacubex/mihomo/log"
|
"github.com/metacubex/mihomo/log"
|
||||||
|
|
||||||
"github.com/metacubex/mihomo/config"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var processors = []processor{
|
var processors = []processor{
|
||||||
|
@ -23,6 +22,7 @@ var processors = []processor{
|
||||||
patchProfile,
|
patchProfile,
|
||||||
patchDns,
|
patchDns,
|
||||||
patchTun,
|
patchTun,
|
||||||
|
patchListeners,
|
||||||
patchProviders,
|
patchProviders,
|
||||||
validConfig,
|
validConfig,
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,23 @@ func patchDns(cfg *config.RawConfig, _ string) error {
|
||||||
|
|
||||||
func patchTun(cfg *config.RawConfig, _ string) error {
|
func patchTun(cfg *config.RawConfig, _ string) error {
|
||||||
cfg.Tun.Enable = false
|
cfg.Tun.Enable = false
|
||||||
|
cfg.Tun.AutoRoute = false
|
||||||
|
cfg.Tun.AutoDetectInterface = false
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func patchListeners(cfg *config.RawConfig, _ string) error {
|
||||||
|
newListeners := make([]map[string]any, 0, len(cfg.Listeners))
|
||||||
|
for _, mapping := range cfg.Listeners {
|
||||||
|
if proxyType, existType := mapping["type"].(string); existType {
|
||||||
|
switch proxyType {
|
||||||
|
case "tproxy", "redir", "tun":
|
||||||
|
continue // remove those listeners which is not supported
|
||||||
|
}
|
||||||
|
}
|
||||||
|
newListeners = append(newListeners, mapping)
|
||||||
|
}
|
||||||
|
cfg.Listeners = newListeners
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ func Start(listen string) (listenAt string, err error) {
|
||||||
|
|
||||||
listener, err = http.NewWithAuthenticate(listen, tunnel.Tunnel, false)
|
listener, err = http.NewWithAuthenticate(listen, tunnel.Tunnel, false)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
listenAt = listener.Listener().Addr().String()
|
listenAt = listener.Address()
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
|
@ -52,14 +52,16 @@ func Start(fd int, stack, gateway, portal, dns string) (io.Closer, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
options := LC.Tun{
|
options := LC.Tun{
|
||||||
Enable: true,
|
Enable: true,
|
||||||
Device: sing_tun.InterfaceName,
|
Device: sing_tun.InterfaceName,
|
||||||
Stack: tunStack,
|
Stack: tunStack,
|
||||||
DNSHijack: dnsHijack,
|
DNSHijack: dnsHijack,
|
||||||
Inet4Address: prefix4,
|
AutoRoute: false, // had set route in TunService.kt
|
||||||
Inet6Address: prefix6,
|
AutoDetectInterface: false, // implements by VpnService::protect
|
||||||
MTU: 9000, // private const val TUN_MTU = 9000 in TunService.kt
|
Inet4Address: prefix4,
|
||||||
FileDescriptor: fd,
|
Inet6Address: prefix6,
|
||||||
|
MTU: 9000, // private const val TUN_MTU = 9000 in TunService.kt
|
||||||
|
FileDescriptor: fd,
|
||||||
}
|
}
|
||||||
|
|
||||||
tunOptions, _ := json.Marshal(options)
|
tunOptions, _ := json.Marshal(options)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user