mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 11:42:43 +08:00
chore: remove Script mode residual code.
This commit is contained in:
parent
cd8c87aad5
commit
c3e7173187
|
@ -543,7 +543,6 @@ func parseRules(cfg *RawConfig, proxies map[string]C.Proxy) ([]C.Rule, map[strin
|
|||
|
||||
var rules []C.Rule
|
||||
rulesConfig := cfg.Rule
|
||||
mode := cfg.Mode
|
||||
|
||||
// parse rules
|
||||
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])
|
||||
)
|
||||
|
||||
if mode == T.Script && ruleName != "GEOSITE" {
|
||||
continue
|
||||
}
|
||||
|
||||
l := len(rule)
|
||||
|
||||
if ruleName == "NOT" || ruleName == "OR" || ruleName == "AND" {
|
||||
|
|
|
@ -29,7 +29,6 @@ var Path = func() *path {
|
|||
type path struct {
|
||||
homeDir string
|
||||
configFile string
|
||||
scriptDir string
|
||||
}
|
||||
|
||||
// SetHomeDir is used to set the configuration path
|
||||
|
@ -123,23 +122,6 @@ func (p *path) GeoSite() string {
|
|||
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 {
|
||||
return P.Join(p.homeDir, file)
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@ const (
|
|||
DstPort
|
||||
Process
|
||||
ProcessPath
|
||||
Script
|
||||
RuleSet
|
||||
Network
|
||||
Uid
|
||||
|
@ -49,8 +48,6 @@ func (rt RuleType) String() string {
|
|||
return "Process"
|
||||
case ProcessPath:
|
||||
return "ProcessPath"
|
||||
case Script:
|
||||
return "Script"
|
||||
case MATCH:
|
||||
return "Match"
|
||||
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("/providers/proxies", proxyProviderRouter())
|
||||
r.Mount("/providers/rules", ruleProviderRouter())
|
||||
r.Mount("/script", scriptRouter())
|
||||
r.Mount("/cache", cacheRouter())
|
||||
})
|
||||
|
||||
|
|
|
@ -12,14 +12,12 @@ type TunnelMode int
|
|||
var ModeMapping = map[string]TunnelMode{
|
||||
Global.String(): Global,
|
||||
Rule.String(): Rule,
|
||||
Script.String(): Script,
|
||||
Direct.String(): Direct,
|
||||
}
|
||||
|
||||
const (
|
||||
Global TunnelMode = iota
|
||||
Rule
|
||||
Script
|
||||
Direct
|
||||
)
|
||||
|
||||
|
@ -63,8 +61,6 @@ func (m TunnelMode) String() string {
|
|||
return "global"
|
||||
case Rule:
|
||||
return "rule"
|
||||
case Script:
|
||||
return "script"
|
||||
case Direct:
|
||||
return "direct"
|
||||
default:
|
||||
|
|
|
@ -291,8 +291,6 @@ func handleUDPConn(packet *inbound.PacketAdapter) {
|
|||
} else {
|
||||
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:
|
||||
log.Infoln("[UDP] %s --> %s using GLOBAL", metadata.SourceDetail(), metadata.RemoteAddress())
|
||||
case mode == Direct:
|
||||
|
@ -362,8 +360,6 @@ func handleTCPConn(connCtx C.ConnContext) {
|
|||
} else {
|
||||
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:
|
||||
log.Infoln("[TCP] %s --> %s using GLOBAL", metadata.SourceDetail(), metadata.RemoteAddress())
|
||||
case mode == Direct:
|
||||
|
|
Loading…
Reference in New Issue
Block a user