-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
重构框架 提供更多API 无需json&&新增Surge-RULE-SET转换&&修复singbox转换bug
- Loading branch information
1 parent
0905aa8
commit 6cc145b
Showing
23 changed files
with
169 additions
and
228 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,4 @@ | ||
1010pic.com | ||
123.56.23.22 | ||
182.254.116.116 | ||
203.205.137.89 | ||
8le8le.com | ||
a0.app.xiaomi.com | ||
aaid.umeng.com | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
123.56.23.22 | ||
182.254.116.116 | ||
203.205.137.89 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,18 @@ | ||
def format_domain(domain_file): | ||
def format_domain(List): | ||
domain = [] | ||
with open(domain_file, 'r') as file: | ||
lines = file.readlines() | ||
for line in lines: | ||
for line in List: | ||
domain_lines = f"{line.strip()}" | ||
domain.append(domain_lines) | ||
return domain | ||
|
||
|
||
def format_regex(regex_file): | ||
def format_regex(List): | ||
regex = [] | ||
|
||
with open(regex_file, 'r') as file: | ||
lines = file.readlines() | ||
for line in lines: | ||
for line in List: | ||
regex_lines = f"{line.strip()}" | ||
regex.append(regex_lines) | ||
return regex | ||
|
||
def build(domain_file, regex_file): | ||
Adclose_list = format_domain(domain_file) + format_regex(regex_file) | ||
return Adclose_list | ||
def build(rule): | ||
Adclose_list = format_domain(rule.domain_list) + format_regex(rule.regex_list) | ||
return Adclose_list, ".txt" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,18 @@ | ||
def format_domain(domain_file): | ||
def format_domain(List): | ||
domain = [] | ||
with open(domain_file, 'r') as file: | ||
lines = file.readlines() | ||
for line in lines: | ||
for line in List: | ||
domain_lines = f"||{line.strip()}^" | ||
domain.append(domain_lines) | ||
return domain | ||
|
||
|
||
def format_regex(regex_file): | ||
def format_regex(List): | ||
regex = [] | ||
|
||
with open(regex_file, 'r') as file: | ||
lines = file.readlines() | ||
for line in lines: | ||
for line in List: | ||
regex_lines = f"/{line.strip()}/".replace("\.","\\\.").replace("\*","\.\*") | ||
regex.append(regex_lines) | ||
return regex | ||
|
||
def build(domain_file, regex_file): | ||
Adblock_list = format_domain(domain_file) + format_regex(regex_file) | ||
return Adblock_list | ||
def build(rule): | ||
Adblock_list = format_domain(rule.domain_list) + format_regex(rule.regex_list) | ||
return Adblock_list, ".txt" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,18 @@ | ||
def format_domain(domain_file): | ||
def format_domain(List): | ||
domain = [] | ||
with open(domain_file, 'r') as file: | ||
lines = file.readlines() | ||
for line in lines: | ||
for line in List: | ||
domain_lines = f"||{line.strip()}^" | ||
domain.append(domain_lines) | ||
return domain | ||
|
||
|
||
def format_regex(regex_file): | ||
def format_regex(List): | ||
regex = [] | ||
|
||
with open(regex_file, 'r') as file: | ||
lines = file.readlines() | ||
for line in lines: | ||
for line in List: | ||
regex_lines = f"/{line.strip()}/".replace("\.","\\\.").replace("\*","\.\*") | ||
regex.append(regex_lines) | ||
return regex | ||
|
||
def build(domain_file, regex_file): | ||
Adguard_list = format_domain(domain_file) + format_regex(regex_file) | ||
return Adguard_list | ||
def build(rule): | ||
Adguard_list = format_domain(rule.domain_list) + format_regex(rule.regex_list) | ||
return Adguard_list, ".txt" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,25 @@ | ||
|
||
def format_domain(domain_file): | ||
def format_domain(List): | ||
domain = [] | ||
with open(domain_file, 'r') as file: | ||
lines = file.readlines() | ||
for line in lines: | ||
for line in List: | ||
domain_lines = f" - '{line.strip()}'" | ||
domain.append(domain_lines) | ||
return domain | ||
|
||
def format_regex(regex_file): | ||
def format_regex(List): | ||
regex = [] | ||
|
||
with open(regex_file, 'r') as file: | ||
lines = file.readlines() | ||
for line in lines: | ||
for line in List: | ||
regex_lines = f" - '{line.strip()}'".replace("$","").replace("^","") | ||
regex.append(regex_lines) | ||
return regex | ||
|
||
def build(domain_file, regex_file): | ||
clash_list = ["payload:"] + format_domain(domain_file) + format_regex(regex_file) | ||
return clash_list | ||
def format_ip(List): | ||
ip = [] | ||
for line in List: | ||
ip_lines = f" - '{line.strip()}'".replace("$","").replace("^","") | ||
ip.append(ip_lines) | ||
return ip | ||
|
||
def build(rule): | ||
clash_list = ["payload:"] + format_ip(rule.ip_list) + format_domain(rule.domain_list) + format_regex(rule.regex_list) | ||
return clash_list, ".yaml" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,12 @@ | ||
import json | ||
|
||
def format_domain(domain_file): | ||
def format_domain(List): | ||
domain = [] | ||
with open(domain_file, 'r') as file: | ||
lines = file.readlines() | ||
|
||
for line in lines: | ||
for line in List: | ||
domain_lines = f"domain:{line.strip()}" | ||
domain.append(domain_lines) | ||
return domain | ||
|
||
|
||
def build(domain_file, regex_file): | ||
return format_domain(domain_file) | ||
def build(rule): | ||
return format_domain(rule.domain_list), ".txt" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,24 @@ | ||
|
||
def format_domain(domain_file): | ||
def format_domain(List): | ||
domain = [] | ||
with open(domain_file, 'r') as file: | ||
lines = file.readlines() | ||
for line in lines: | ||
for line in List: | ||
domain_lines = f"DOMAIN,{line.strip()},reject" | ||
domain.append(domain_lines) | ||
return domain | ||
|
||
def format_regex(regex_file): | ||
def format_regex(List): | ||
regex = [] | ||
|
||
with open(regex_file, 'r') as file: | ||
lines = file.readlines() | ||
for line in lines: | ||
for line in List: | ||
regex_lines = f"DOMAIN-KEYWORD,{line.strip()},reject".replace("$","").replace("^","").replace("*","") | ||
regex.append(regex_lines) | ||
return regex | ||
|
||
def build(domain_file, regex_file): | ||
return format_domain(domain_file) + format_regex(regex_file) | ||
def format_ip(List): | ||
ip = [] | ||
for line in List: | ||
ip_lines = f"IP-CIDR,{line.strip()},reject" | ||
ip.append(ip_lines) | ||
return ip | ||
|
||
def build(rule): | ||
return format_ip(rule.ip_list) + format_domain(rule.domain_list) + format_regex(rule.regex_list), ".list" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,28 @@ | ||
## 插件开发文档 | ||
|
||
插件入口函数为`build()` | ||
插件入口函数为`build(rule)` | ||
|
||
参考[Clash.py](./Clash.py) | ||
|
||
插件返回的list格式参考下面的模板 | ||
插件返回的list格式参考: | ||
|
||
`Adguard.py`: | ||
|
||
```python | ||
["||xxx.com^","||xxx.cc^"] | ||
["||xxx.com^","||xxx.cc^"], ".txt" | ||
``` | ||
> 后缀名以及注释符请在build.json中添加 如果不存在则不执行此插件 | ||
提供的变量: | ||
> **有两个返回值** | ||
API: | ||
- rule.domain_list(获取域名列表) | ||
- rule.regex_list(获取正则表达式的域名列表) | ||
- rule.ip_list(获取ip列表) | ||
|
||
## domain_file | ||
> 获取 rule目录的 domain.txt 路径 | ||
> 所有变量均为列表 无需读取文件 | ||
## regex_file | ||
>获取 rule目录的 domain_regex.txt 路径 | ||
模板: | ||
``` | ||
# 主函数并且引入rule(对象) | ||
def build(rule): | ||
list = rule.domain_list + rule.regex_list + rule.ip_list | ||
return list, ".yaml" # 返回处理后的列表和文件后缀名 | ||
``` | ||
> 输出文件名=插件名 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,12 @@ | ||
import json | ||
|
||
def format_domain(domain_file): | ||
def format_domain(List): | ||
domain = ["0.0.0.0 localhost", "::1 localhost", "", ""] | ||
with open(domain_file, 'r') as file: | ||
lines = file.readlines() | ||
|
||
for line in lines: | ||
for line in List: | ||
domain_lines = f"0.0.0.0 {line.strip()}" | ||
domain.append(domain_lines) | ||
return domain | ||
|
||
|
||
def build(domain_file, regex_file): | ||
return format_domain(domain_file) | ||
def build(rule): | ||
return format_domain(rule.domain_list), ".txt" |
Oops, something went wrong.