Merge pull request #450 from mwhds97/master
Make Clash script match IP-CIDR rules correctly
This commit is contained in:
@@ -131,19 +131,22 @@ script:
|
|||||||
return "DIRECT"
|
return "DIRECT"
|
||||||
ctx.log('[Script] not common port use direct')
|
ctx.log('[Script] not common port use direct')
|
||||||
|
|
||||||
|
if metadata["dst_ip"] == "":
|
||||||
|
metadata["dst_ip"] = ctx.resolve_ip(metadata["host"])
|
||||||
|
|
||||||
ruleset_list = [r for r in ruleset_action]
|
ruleset_list = [r for r in ruleset_action]
|
||||||
for rule_name in ruleset_list:
|
for rule_name in ruleset_list:
|
||||||
if ctx.rule_providers[rule_name].match(metadata):
|
if ctx.rule_providers[rule_name].match(metadata):
|
||||||
return ruleset_action[rule_name]
|
return ruleset_action[rule_name]
|
||||||
|
|
||||||
ip = metadata["dst_ip"] or ctx.resolve_ip(metadata["host"])
|
if metadata["dst_ip"] == "":
|
||||||
if ip == "":
|
return "DIRECT"
|
||||||
return "DIRECT"
|
|
||||||
|
|
||||||
code = ctx.geoip(ip)
|
code = ctx.geoip(metadata["dst_ip"])
|
||||||
if code == "CN":
|
if code == "CN":
|
||||||
return "Domestic"
|
return "Domestic"
|
||||||
ctx.log('[Script] Geoip CN')
|
ctx.log('[Script] Geoip CN')
|
||||||
|
|
||||||
return "Others"
|
return "Others"
|
||||||
ctx.log('[Script] FINAL')
|
ctx.log('[Script] FINAL')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user