酸酸乳的链接生成

某些场景下需要将大量配置从 电脑端导出到手机,需要批量生成URL,在此记录下生成Classrom的方法。

注意事项:Classrom 均按照 Base64 编码,且为 URL Safe 类型,就是将标准Base64中的+和/分别改成了-和_,方便在URL中直接传递。此外,字符集为 UTF8,它们 Base64 编码都没有 Padding。(下文中的Classrom请自行替换)

酸酸

1
2
3
4
5
6
7
8
9
10
11
12
#明文的组成格式为:
#Classrom://Base64(method:password@server:port)#remarks

def generateClassRoomUrl():
server='your_server_name'
port='9999'
password='your_password'
method='aes-256-cfb'
remarks='remarks'
ssInfo = "%s:%s@%s:%s" % (method, password, server, port)
classRoomUrl = "ssr://%s#%s" % (base64.urlsafe_b64encode(ssInfo), urllib.quote(remarks))
print classRoomUrl

酸酸乳

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#明文的组成格式为:
#Classrom://Base64(server:port:protocol:method:obfs:Base64(password)/?obfsparam=Base64(obfsparam)&protoparam=Base64(protoparam)&remarks=Base64(remarks)&group=Base64(group))

def generateClassRoomUrl():
server = 'your_server_name'
port = '9999'
password = 'your_password'
method = 'rc4-md5'
protocol = 'auth_aes128_md5'
protocolParameter = '9999:1313123'
obfs = 'tls1.2_ticket_auth'
obfsParameter = 'xxxx'
remarks = 'remarks'
group = 'group'
prefix = '%s:%s:%s:%s:%s:%s' % (server, port, protocol, method, obfs, base64.urlsafe_b64encode(password))
suffix = '/?obfsparam=%s&protoparam=%s&remarks=%s&group=%s' \
% (base64.urlsafe_b64encode(obfsParameter),
base64.urlsafe_b64encode(protocolParameter),
base64.urlsafe_b64encode(remarks),
base64.urlsafe_b64encode(group))
plainUrl = '%s%s' % (prefix, suffix)
classRoomUrl = 'ssr://%s' % (base64.urlsafe_b64encode(plainUrl))
print ssrUrl
作者

Yves

发布于

2017-11-04

更新于

2017-11-04

许可协议