|
|
|
|
@ -77,101 +77,6 @@
|
|
|
|
|
- GEOIP,CN,Domestic
|
|
|
|
|
- MATCH,Others
|
|
|
|
|
|
|
|
|
|
script:
|
|
|
|
|
code: |
|
|
|
|
|
def main(ctx,metadata):
|
|
|
|
|
ruleset_action = {
|
|
|
|
|
'AdBlock': 'AdBlock',
|
|
|
|
|
'HTTPDNS': 'HTTPDNS',
|
|
|
|
|
'Special': 'DIRECT',
|
|
|
|
|
'Netflix': 'Netflix',
|
|
|
|
|
'Disney Plus': 'Disney Plus',
|
|
|
|
|
'YouTube': 'YouTube',
|
|
|
|
|
'Max': 'Max',
|
|
|
|
|
'Spotify': 'Spotify',
|
|
|
|
|
'Abema TV': 'Asian TV',
|
|
|
|
|
'Bahamut': 'Asian TV',
|
|
|
|
|
'DMM': 'Asian TV',
|
|
|
|
|
'Fox+': 'Asian TV',
|
|
|
|
|
'Hulu Japan': 'Asian TV',
|
|
|
|
|
'IQ': 'Asian TV',
|
|
|
|
|
'Japonx': 'Asian TV',
|
|
|
|
|
'JOOX': 'Asian TV',
|
|
|
|
|
'KKBOX': 'Asian TV',
|
|
|
|
|
'KKTV': 'Asian TV',
|
|
|
|
|
'Line TV': 'Asian TV',
|
|
|
|
|
'myTV SUPER': 'Asian TV',
|
|
|
|
|
'Niconico': 'Asian TV',
|
|
|
|
|
'ViuTV': 'Asian TV',
|
|
|
|
|
'ABC': 'Global TV',
|
|
|
|
|
'Amazon': 'Global TV',
|
|
|
|
|
'BBC iPlayer': 'Global TV',
|
|
|
|
|
'DAZN': 'Global TV',
|
|
|
|
|
'Discovery Plus': 'Global TV',
|
|
|
|
|
'encoreTVB': 'Global TV',
|
|
|
|
|
'F1 TV': 'Global TV',
|
|
|
|
|
'Fox Now': 'Global TV',
|
|
|
|
|
'Hulu': 'Global TV',
|
|
|
|
|
'Pandora': 'Global TV',
|
|
|
|
|
'PBS': 'Global TV',
|
|
|
|
|
'Pornhub': 'Global TV',
|
|
|
|
|
'Soundcloud': 'Global TV',
|
|
|
|
|
'Bilibili': 'CN Mainland TV',
|
|
|
|
|
'IQIYI': 'CN Mainland TV',
|
|
|
|
|
'Letv': 'CN Mainland TV',
|
|
|
|
|
'Netease Music': 'CN Mainland TV',
|
|
|
|
|
'Tencent Video': 'CN Mainland TV',
|
|
|
|
|
'Youku': 'CN Mainland TV',
|
|
|
|
|
'WeTV': 'CN Mainland TV',
|
|
|
|
|
'Apple Music': 'Apple TV',
|
|
|
|
|
'Apple News': 'Apple TV',
|
|
|
|
|
'Apple TV': 'Apple TV',
|
|
|
|
|
'Apple': 'Apple',
|
|
|
|
|
'Telegram': 'Telegram',
|
|
|
|
|
'Crypto': 'Crypto',
|
|
|
|
|
'Discord': 'Discord',
|
|
|
|
|
'Google FCM': 'Google FCM',
|
|
|
|
|
'Microsoft': 'Microsoft',
|
|
|
|
|
'AI Suite': 'AI Suite',
|
|
|
|
|
'PayPal': 'PayPal',
|
|
|
|
|
'Scholar': 'Scholar',
|
|
|
|
|
'Speedtest': 'Speedtest',
|
|
|
|
|
'Steam': 'Steam',
|
|
|
|
|
'TikTok': 'TikTok',
|
|
|
|
|
'miHoYo': 'miHoYo',
|
|
|
|
|
'PROXY': 'Proxy',
|
|
|
|
|
'Domestic': 'Domestic',
|
|
|
|
|
'Domestic IPs': 'Domestic',
|
|
|
|
|
'LAN': 'DIRECT'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
port = int(metadata['dst_port'])
|
|
|
|
|
|
|
|
|
|
if metadata['network'] == 'UDP' and port == 443:
|
|
|
|
|
ctx.log('[Script] matched QUIC traffic use reject')
|
|
|
|
|
return 'REJECT'
|
|
|
|
|
|
|
|
|
|
port_list = [21,22,23,53,80,123,143,194,443,465,587,853,993,995,998,2052,2053,2082,2083,2086,2095,2096,3389,5222,5228,5229,5230,8080,8443,8880,8888,8889]
|
|
|
|
|
if port not in port_list:
|
|
|
|
|
ctx.log('[Script] not common port use direct')
|
|
|
|
|
return 'DIRECT'
|
|
|
|
|
|
|
|
|
|
if metadata['dst_ip'] == '':
|
|
|
|
|
metadata['dst_ip'] = ctx.resolve_ip(metadata['host'])
|
|
|
|
|
|
|
|
|
|
for ruleset in ruleset_action:
|
|
|
|
|
if ctx.rule_providers[ruleset].match(metadata):
|
|
|
|
|
return ruleset_action[ruleset]
|
|
|
|
|
|
|
|
|
|
if metadata['dst_ip'] != '':
|
|
|
|
|
code = ctx.geoip(metadata['dst_ip'])
|
|
|
|
|
if code == 'CN':
|
|
|
|
|
ctx.log('[Script] Geoip CN')
|
|
|
|
|
return 'Domestic'
|
|
|
|
|
|
|
|
|
|
ctx.log('[Script] FINAL')
|
|
|
|
|
return 'Others'
|
|
|
|
|
|
|
|
|
|
rule-providers:
|
|
|
|
|
AdBlock:
|
|
|
|
|
type: http
|
|
|
|
|
|