对于科学上网,我强烈建议通过自建的方式。因为使用一些“机场”会有如下的几个问题:
机场主需要公开售卖,使用的人也比较多,所以,都会被重点关注,非常容易被封; 机场需要购买一堆服务器,所以,很容易经营不善跑路;
使用机场很容易泄漏自己的隐私,因为你的所有流量都经过了机场的服务器;
自建梯子会是一条很好的路,不过,问题就是,自建梯子需要一定的技术能力,成本和门槛都比机场要高,但是,在安全性方面会比较好一些。自己动手,自力更生,让人有更多的安全感。所以,如果你不是很有技术能力,或者不想花钱,那么,还是使用“机场”吧。
来自:https://haoel.github.io/
我们这期先来聊聊机场,后续再讲自建。其实自建还是很花费时间的,还要担心各种被封,现在的软件clash/surge会有各种策略来保证高可用,所以机场目前来说不仅能省钱,还能帮我们省不少时间,不想折腾的人选择机场也是非常爽的。
机场的话,有各种各样的,有大的,有小的,有贵的,有便宜的。我的建议是有钱可以直接买一个贵和大的,但是这种非常费钱,不差钱的直接上。这篇主要针对便宜又小的,其实大多人上ai网站也花费不了多少流量,所以我们可以找一些便宜的,然后选里面最便宜的月套餐,一般就是10块/月。不过一个一般不稳定,可以同时买两个,这样可以做到更加高可用。注册的时候尽量用一些不常用的email和密码,这样可以尽量小的泄漏个人信息。
下面我们来讲讲怎么同时使用两个机场,并且实现高可用,主要讲surge和clash,其它的软件用的少,后面有需要可以再添加。
surge
从机场的网站复制下surge的下载地址, 如下图复制surge4的配置
机场的配置会有各种各样的名字的节点,有些是测试的,有些是流量的,这些都需要过滤掉。过滤掉一些试用,用量的节点,然后再将两个机场的各种地域的节点结合到一起,这样可以方便使用不同地域的节点。
🇭🇰 香港节点 = smart, include-other-group="订阅1,订阅2", update-interval=0, no-alert=0, hidden=0, include-all-proxies=0, policy-regex-filter=(🇭🇰)|(香港)|(Hong)|(HK)
🇨🇳 台湾节点 = smart, include-other-group="订阅1,订阅2", update-interval=0, no-alert=0, hidden=0, include-all-proxies=0, policy-regex-filter=(🇨🇳)|(台)|(Tai)|(TW)
🇺🇸 美国节点 = smart, include-other-group="订阅1,订阅2", update-interval=0, no-alert=0, hidden=0, include-all-proxies=0, policy-regex-filter=(🇺🇸)|(美)|(States)|(US)
🇯🇵 日本节点 = smart, include-other-group="订阅1,订阅2", update-interval=0, no-alert=0, hidden=0, include-all-proxies=0, policy-regex-filter=(🇯🇵)|(日)|(Japan)|(JP)
🇸🇬 新加坡节点 = smart, include-other-group="订阅1,订阅2", update-interval=0, no-alert=0, hidden=0, include-all-proxies=0, policy-regex-filter=(🇸🇬)|(新)|(Singapore)|(SG)
订阅1 = smart, policy-path=订阅地址, update-interval=0, no-alert=0, hidden=true, include-all-proxies=0, policy-regex-filter=^(?=.*(.))(?!.*((?i)群|邀请|返利|循环|官网|客服|网站|网址|获取|订阅|流量|到期|机场|下次|版本|官址|备用|过期|已用|联系|邮箱|工单|导航|失联|贩卖|通知|倒卖|防止|国内|地址|频道|无法|说明|使用|提示|特别|访问|支持|教程|关注|更新|作者|加入|(\b(USE|USED|TOTAL|Traffic|Expire|EMAIL|Panel|Channel|Author)\b|(\d{4}-\d{2}-\d{2}|\d+G)))).*$
订阅2 = smart, policy-path=订阅地址, update-interval=0, no-alert=0, hidden=true, include-all-proxies=0, policy-regex-filter=^(?=.*(.))(?!.*((?i)群|邀请|返利|循环|官网|客服|网站|网址|获取|订阅|流量|到期|机场|下次|导航|失联|版本|官址|备用|过期|已用|联系|邮箱|工单|贩卖|通知|倒卖|防止|国内|地址|频道|无法|说明|使用|提示|特别|访问|支持|教程|关注|更新|作者|加入|(\b(USE|USED|TOTAL|Traffic|Expire|EMAIL|Panel|Channel|Author)\b|(\d{4}-\d{2}-\d{2}|\d+G)))).*$
clash
clash premium core也是支持filter的,所以也可以实现直接在本地就下载并且整合多个机场的功能。
proxies:
订阅1:
type: http
filter: "^(?!.*(?:防失联|群|邀请|返利|循环|官网|客服|网站|网址|获取|订阅|流量|到期|机场|下次|版本|官址|备用|过期|已用|联系|邮箱|工单|导航|失联|贩卖|通知|倒卖|防止|国内|地址|频道|无法|说明|使用|提示|特别)).*$"
url: 订阅地址1
path: sub/sub1.txt
interval: 208
health-check:
enable: true
url: http://www.bing.com
interval: 309
订阅2:
type: http
filter: "^(?!.*(?:防失联|群|邀请|返利|循环|官网|客服|网站|网址|获取|订阅|流量|到期|机场|下次|版本|官址|备用|过期|已用|联系|邮箱|工单|导航|失联|贩卖|通知|倒卖|防止|国内|地址|频道|无法|说明|使用|提示|特别)).*$"
url: 订阅地址2
path: sub/sub2.txt
interval: 308
health-check:
enable: true
url: http://www.bing.com
interval: 309
proxy-groups:
- name: auto-hk
type: fallback
filter: "(🇭🇰)|(香港)|(Hong)|(HK)"
url: 'http://www.bing.com'
interval: 308
tolerance: 50
use:
- 订阅1
- 订阅2
- name: auto-sg
type: fallback
filter: "(🇸🇬)|(新)|(Singapore)|(SG)"
url: 'http://www.bing.com'
interval: 308
tolerance: 50
use:
- 订阅1
- 订阅2
others
可以用脚本来自己实现一套整合多个机场的功能,其实也是非常简单的,下面是一个python脚本的实例,可以实现上面的同样的功能。现在ai已经非常发达了,可以在不懂代码的情况下,让ai来实现下面的功能的。
#!/usr/bin/env python3
import yaml
import datetime
import os
from requests import get
airports = [
[
'订阅1',
'订阅地址',
lambda proxy: '重置' not in proxy['name'] and '套餐' not in proxy['name'] and '流量' not in proxy['name'] and '导航' not in proxy['name']
],
[
'订阅2',
'订阅地址',
lambda proxy: '重置' not in proxy['name'] and '套餐' not in proxy['name'] and '流量' not in proxy['name'] and '导航' not in proxy['name']
],
]
def saveToFile(proxies, filename):
cwd = os.getcwd()
if(len(proxies) == 0):
return
with open(cwd + filename + '.txt', 'w') as f:
result = {"proxies": proxies}
yaml.dump(result, f, allow_unicode=True)
def sortPriority(val):
priority = [
'公网转发'
'HK丨',
'香港',
'Hong Kong',
'SG丨',
'新加坡',
'Singapore',
'狮城',
'TW丨',
'台北',
'台湾',
'Taiwan',
'日本',
'Japan',
'US丨',
'美西',
'美国',
'USA'
]
for idx, k in enumerate(priority):
if k in val:
return idx
return 100
def sortProxies(proxies):
proxies.sort(key = lambda x: x['name'], reverse=True)
proxies.sort(key=lambda x: sortPriority(x['name']))
def addPrefix(prefix, proxies):
for proxy in proxies:
proxy['name'] = prefix + ' ' + proxy['name']
# 只读取 Proxy section 的内容,忽略其他部分
def download(url, filters):
headers = {
'User-Agent': 'clash',
}
try:
response = get(url,headers=headers,verify=False)
data = yaml.load(response.content, Loader=yaml.FullLoader)
result = []
if data:
for proxy in data['proxies']:
if filters(proxy):
result.append(proxy)
return result
except:
print("an error when downloading:", url)
def getKind(name):
kinds = [
['香港', 'hk'],
['Hong Kong', 'hk'],
['美西', 'us'],
['美国', 'us'],
['US丨', 'us'],
['USA', 'us'],
['日本', 'jp'],
['Japan', 'jp'],
['新加坡', 'sg'],
['狮城', 'sg'],
['Singapore', 'sg'],
['台湾', 'tw'],
['台北', 'tw'],
['Taiwan', 'tw']
]
for kind in kinds:
if kind[0] in name:
return kind[1]
return 'other'
def processProxies(proxies):
result = {}
for proxy in proxies:
name = proxy['name']
kind = getKind(name)
result.setdefault(kind, [])
result[kind].append(proxy)
for kind in result:
saveToFile(result[kind], kind)
def main():
print("start", datetime.datetime.now())
allProxies = []
for airport in airports:
name,url,filters = airport
proxies = download(url,filters)
if not proxies:
continue
addPrefix(name, proxies)
sortProxies(proxies)
saveToFile(proxies, name)
allProxies += proxies
print("all", len(allProxies))
processProxies(allProxies)
print("finish", datetime.datetime.now())
if __name__ == "__main__":
main()
test