mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 03:32:33 +08:00
chore: remove Script mode residual code.
This commit is contained in:
parent
d4dcbce9cb
commit
5bd5f1bfda
|
@ -543,7 +543,6 @@ func parseRules(cfg *RawConfig, proxies map[string]C.Proxy) ([]C.Rule, map[strin
|
||||||
|
|
||||||
var rules []C.Rule
|
var rules []C.Rule
|
||||||
rulesConfig := cfg.Rule
|
rulesConfig := cfg.Rule
|
||||||
mode := cfg.Mode
|
|
||||||
|
|
||||||
// parse rules
|
// parse rules
|
||||||
for idx, line := range rulesConfig {
|
for idx, line := range rulesConfig {
|
||||||
|
@ -555,10 +554,6 @@ func parseRules(cfg *RawConfig, proxies map[string]C.Proxy) ([]C.Rule, map[strin
|
||||||
ruleName = strings.ToUpper(rule[0])
|
ruleName = strings.ToUpper(rule[0])
|
||||||
)
|
)
|
||||||
|
|
||||||
if mode == T.Script && ruleName != "GEOSITE" {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
l := len(rule)
|
l := len(rule)
|
||||||
|
|
||||||
if ruleName == "NOT" || ruleName == "OR" || ruleName == "AND" {
|
if ruleName == "NOT" || ruleName == "OR" || ruleName == "AND" {
|
||||||
|
|
|
@ -29,7 +29,6 @@ var Path = func() *path {
|
||||||
type path struct {
|
type path struct {
|
||||||
homeDir string
|
homeDir string
|
||||||
configFile string
|
configFile string
|
||||||
scriptDir string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetHomeDir is used to set the configuration path
|
// SetHomeDir is used to set the configuration path
|
||||||
|
@ -123,23 +122,6 @@ func (p *path) GeoSite() string {
|
||||||
return P.Join(p.homeDir, "GeoSite.dat")
|
return P.Join(p.homeDir, "GeoSite.dat")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *path) ScriptDir() string {
|
|
||||||
if len(p.scriptDir) != 0 {
|
|
||||||
return p.scriptDir
|
|
||||||
}
|
|
||||||
if dir, err := os.MkdirTemp("", Name+"-"); err == nil {
|
|
||||||
p.scriptDir = dir
|
|
||||||
} else {
|
|
||||||
p.scriptDir = P.Join(os.TempDir(), Name)
|
|
||||||
_ = os.MkdirAll(p.scriptDir, 0o644)
|
|
||||||
}
|
|
||||||
return p.scriptDir
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *path) Script() string {
|
|
||||||
return P.Join(p.ScriptDir(), "clash_script.py")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *path) GetAssetLocation(file string) string {
|
func (p *path) GetAssetLocation(file string) string {
|
||||||
return P.Join(p.homeDir, file)
|
return P.Join(p.homeDir, file)
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,6 @@ const (
|
||||||
DstPort
|
DstPort
|
||||||
Process
|
Process
|
||||||
ProcessPath
|
ProcessPath
|
||||||
Script
|
|
||||||
RuleSet
|
RuleSet
|
||||||
Network
|
Network
|
||||||
Uid
|
Uid
|
||||||
|
@ -49,8 +48,6 @@ func (rt RuleType) String() string {
|
||||||
return "Process"
|
return "Process"
|
||||||
case ProcessPath:
|
case ProcessPath:
|
||||||
return "ProcessPath"
|
return "ProcessPath"
|
||||||
case Script:
|
|
||||||
return "Script"
|
|
||||||
case MATCH:
|
case MATCH:
|
||||||
return "Match"
|
return "Match"
|
||||||
case RuleSet:
|
case RuleSet:
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
package route
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/go-chi/chi/v5"
|
|
||||||
"net/http"
|
|
||||||
)
|
|
||||||
|
|
||||||
func scriptRouter() http.Handler {
|
|
||||||
r := chi.NewRouter()
|
|
||||||
r.Get("/", getScript)
|
|
||||||
return r
|
|
||||||
}
|
|
||||||
|
|
||||||
func getScript(writer http.ResponseWriter, request *http.Request) {
|
|
||||||
writer.WriteHeader(http.StatusMethodNotAllowed)
|
|
||||||
}
|
|
|
@ -72,7 +72,6 @@ func Start(addr string, secret string) {
|
||||||
r.Mount("/connections", connectionRouter())
|
r.Mount("/connections", connectionRouter())
|
||||||
r.Mount("/providers/proxies", proxyProviderRouter())
|
r.Mount("/providers/proxies", proxyProviderRouter())
|
||||||
r.Mount("/providers/rules", ruleProviderRouter())
|
r.Mount("/providers/rules", ruleProviderRouter())
|
||||||
r.Mount("/script", scriptRouter())
|
|
||||||
r.Mount("/cache", cacheRouter())
|
r.Mount("/cache", cacheRouter())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -12,14 +12,12 @@ type TunnelMode int
|
||||||
var ModeMapping = map[string]TunnelMode{
|
var ModeMapping = map[string]TunnelMode{
|
||||||
Global.String(): Global,
|
Global.String(): Global,
|
||||||
Rule.String(): Rule,
|
Rule.String(): Rule,
|
||||||
Script.String(): Script,
|
|
||||||
Direct.String(): Direct,
|
Direct.String(): Direct,
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Global TunnelMode = iota
|
Global TunnelMode = iota
|
||||||
Rule
|
Rule
|
||||||
Script
|
|
||||||
Direct
|
Direct
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -63,8 +61,6 @@ func (m TunnelMode) String() string {
|
||||||
return "global"
|
return "global"
|
||||||
case Rule:
|
case Rule:
|
||||||
return "rule"
|
return "rule"
|
||||||
case Script:
|
|
||||||
return "script"
|
|
||||||
case Direct:
|
case Direct:
|
||||||
return "direct"
|
return "direct"
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -291,8 +291,6 @@ func handleUDPConn(packet *inbound.PacketAdapter) {
|
||||||
} else {
|
} else {
|
||||||
log.Infoln("[UDP] %s --> %s match %s using %s", metadata.SourceDetail(), metadata.RemoteAddress(), rule.Payload(), rawPc.Chains().String())
|
log.Infoln("[UDP] %s --> %s match %s using %s", metadata.SourceDetail(), metadata.RemoteAddress(), rule.Payload(), rawPc.Chains().String())
|
||||||
}
|
}
|
||||||
case mode == Script:
|
|
||||||
log.Infoln("[UDP] %s --> %s using SCRIPT %s", metadata.SourceDetail(), metadata.RemoteAddress(), rawPc.Chains().String())
|
|
||||||
case mode == Global:
|
case mode == Global:
|
||||||
log.Infoln("[UDP] %s --> %s using GLOBAL", metadata.SourceDetail(), metadata.RemoteAddress())
|
log.Infoln("[UDP] %s --> %s using GLOBAL", metadata.SourceDetail(), metadata.RemoteAddress())
|
||||||
case mode == Direct:
|
case mode == Direct:
|
||||||
|
@ -362,8 +360,6 @@ func handleTCPConn(connCtx C.ConnContext) {
|
||||||
} else {
|
} else {
|
||||||
log.Infoln("[TCP] %s --> %s match %s using %s", metadata.SourceDetail(), metadata.RemoteAddress(), rule.RuleType().String(), remoteConn.Chains().String())
|
log.Infoln("[TCP] %s --> %s match %s using %s", metadata.SourceDetail(), metadata.RemoteAddress(), rule.RuleType().String(), remoteConn.Chains().String())
|
||||||
}
|
}
|
||||||
case mode == Script:
|
|
||||||
log.Infoln("[TCP] %s --> %s using SCRIPT %s", metadata.SourceDetail(), metadata.RemoteAddress(), remoteConn.Chains().String())
|
|
||||||
case mode == Global:
|
case mode == Global:
|
||||||
log.Infoln("[TCP] %s --> %s using GLOBAL", metadata.SourceDetail(), metadata.RemoteAddress())
|
log.Infoln("[TCP] %s --> %s using GLOBAL", metadata.SourceDetail(), metadata.RemoteAddress())
|
||||||
case mode == Direct:
|
case mode == Direct:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user