Comments (19)
上述clash转为v2ray的格式为:
{"v": "2", "ps": "vmess-h2", "add": "server", "port": 443, "id": "uuid", "aid": 32, "net": "h2", "scy": "auto", "type": "none", "host": ["http.example.com", "http-alt.example.com"], "path": "/", "tls": "tls"}
此host我写的是否有误。
转为sing-box格式:
{
"tag": "vmess-h2",
"type": "vmess",
"server": "server",
"server_port": 443,
"uuid": "uuid",
"security": "auto",
"alter_Id": 32,
"packet_encoding": "xudp",
"tls": {
"enabled": true,
"insecure": true,
"server_name": ""
},
"transport": {
"type": "http",
"host": [
"http.example.com",
"http-alt.example.com"
],
"path": "/"
}
}
此singbox格式是否正确
from sing-box-subscribe.
有没有h2的vmess URI示例
from sing-box-subscribe.
- name: "vmess-h2"
type: vmess
server: server
port: 443
uuid: uuid
alterId: 32
cipher: auto
network: h2
tls: true
h2-opts:
host:
- http.example.com
- http-alt.example.com
path: /
当net为“ws”时,我server_name是直接取ws里的host而不是'sni'的值。这个h2示例里的host有两个,那么server_name怎么写?
from sing-box-subscribe.
这是我用clash.meta验证过的vmess文件
各参数格式可以在Clash.Meta/Alpha/outbound/vmess.go找到
我改了vmess部分
if share_link['type'] == 'vmess':
vmess_info = {
"v": "2",
"ps": share_link['name'].encode('utf-8', 'surrogatepass').decode('utf-8'),
"add": share_link['server'],
"port": share_link['port'],
"id": share_link['uuid'],
"aid": share_link['alterId'],
"net": share_link.get('network', 'tcp'),
"scy": share_link.get('cipher', 'auto'),
"type": "none",
"tls": '',
"alpn": share_link.get('alpn', [])
}
if share_link.get('skip-cert-verify') == True:
vmess_info['verify_cert'] = True
if share_link.get('tls') and share_link['tls'] != False:
vmess_info['tls'] = 'tls'
vmess_info["sni"] = share_link.get('servername', '')
if vmess_info['net'] == 'ws':
vmess_info["host"] = share_link.get('ws-opts', {}).get('headers', {}).get('Host', '')
vmess_info["path"] = share_link.get('ws-opts', {}).get('path', '/')
elif vmess_info['net'] == 'grpc':
vmess_info["path"] = share_link.get('grpc-opts', {}).get('grpc-service-name', '/')
elif vmess_info['net'] == 'http':
vmess_info["host"] = share_link.get('http-opts', {}).get('headers', {}).get('Host', [])
vmess_info["path"] = share_link.get('http-opts', {}).get('path', '[]')
elif vmess_info['net'] == 'h2':
vmess_info["host"] = share_link.get('h2-opts', {}).get('host', [])
vmess_info["path"] = share_link.get('h2-opts', {}).get('path', '/')
vmess_json = json.dumps(vmess_info).encode('utf-8')
vmess_base64 = base64.b64encode(vmess_json).decode('utf-8')
link = f"vmess://{vmess_base64}"
return link
# TODO
多个h2 host写成json格式就好,就像
{
"server": "a.v2ray.world",
"server_port": 443,
"tag": "🇺🇸US-199.59.243.225-0880",
"transport": {
"path": "/",
"type": "http",
"host": [
"a.v2ray.world",
"a.world"
]
},
"type": "vmess",
"alter_id": 64,
"security": "auto",
"uuid": "05b6b25b-bb5d-4dcd-9710-31e374ffa584"
}
from sing-box-subscribe.
改好了,有些跟你写有出入,好像是以前测试过我写的才能运行,我就不改了
from sing-box-subscribe.
en,vmess的http类型转换到sing-box有一些问题,因为您是先clash转为v2ray再到sing-box,原来clash中的http-opts.method(参见Clash.Meta/Alpha/outbound/vmess.go)在v2ray中没有对应参数,但在sing-box里有(参见SagerNet/sing-box/transport/v2rayhttp/client.go),所以会出现这种情况:
- {name: 🇺🇸US-5.161.177.114-3389, server: 5.161.177.114, port: 3389, type: vmess, uuid: 9c050a86-d612-48f1-ec32-e573df08a1b7, alterId: 0, cipher: auto, tls: false, tfo: false, skip-cert-verify: true, network: http, http-opts: {method: GET, path: [/]}, udp: true}
被转成
{
"tag": "❤️🇺🇸US-5.161.177.114-3389",
"type": "vmess",
"server": "5.161.177.114",
"server_port": 3389,
"uuid": "9c050a86-d612-48f1-ec32-e573df08a1b7",
"security": "auto",
"alter_Id": 0,
"packet_encoding": "xudp",
"transport": {
"type": "http",
"path": "/"
}
}
实际应是:
{
"tag": "❤️🇺🇸US-5.161.177.114-3389",
"type": "vmess",
"server": "5.161.177.114",
"server_port": 3389,
"uuid": "9c050a86-d612-48f1-ec32-e573df08a1b7",
"security": "auto",
"alter_Id": 0,
"packet_encoding": "xudp",
"transport": {
"type": "http",
"method": "GET",
"path": "/"
}
}
method参数虽无大用,但有时导入软件缺失会报错,推荐v2ray转sing-box时默认添加"method": "GET",即在vmess.py的line 81后部分进行添加
from sing-box-subscribe.
修正好了
from sing-box-subscribe.
还有一个不妥之处,在vmess的v2ray转sing-box的配置参数中,alter_Id(1处、2处,暂不知他处是否需要修改)实际应为alter_id(sing-box相关参数参见SagerNet/sing-box/option/vmess.go)
from sing-box-subscribe.
netquery.get('alterId','99')的含义是,是否获取到{“alterId”:“数字”},没有获取到alterId就设置99,99是我乱写的但不影响。好像我遇到过奇葩的vmess格式才这样写的。
from sing-box-subscribe.
不是指v2ray的alterld,是指sing-box的alter_id
from sing-box-subscribe.
这导致转换出来的sing-box节点像:
{
"tag": "❤️🇦🇺AU-158.179.22.148-80",
"type": "vmess",
"server": "mrb2.shabijichang.com",
"server_port": 80,
"uuid": "c458695d-6908-45c3-9512-e0c46418454c",
"security": "auto",
"alter_Id": 0,
"packet_encoding": "xudp",
"transport": {
"type": "ws",
"path": "/",
"headers": {
"Host": "mrb2.shabijichang.com"
}
}
}
alter_Id应该为alter_id
from sing-box-subscribe.
em,就是变量名写错了
from sing-box-subscribe.
from sing-box-subscribe.
sing-box没检查到alter_id,估计是默认为0处理了
from sing-box-subscribe.
如果为alter为0.那我这个节点不可能通
from sing-box-subscribe.
关于parsers/clash2base64.py的vless部分的修改:
elif share_link['type'] == 'vless':
vless_info = {
"uuid": share_link['uuid'],
"server": share_link['server'],
"port": share_link['port'],
"sni": share_link.get('servername', ''),
"fp": share_link.get('client-fingerprint', ''),
"type": share_link.get('network', 'tcp'),
"flow": share_link.get('flow', ''),
"allowInsecure": '0' if share_link.get('skip-cert-verify', True) == False else '1',
"name": quote(share_link['name'], 'utf-8'),
"alpn": ''
}
if share_link.get('alpn', []) != []:
vless_info['alpn'] = quote(','.join(share_link.get('alpn', [])), 'utf-8')
if vless_info['type'] == 'ws':
vless_info["path"] = quote(share_link['ws-opts'].get('path', '') or share_link['ws-path'], 'utf-8')
vless_info["host"] = share_link['ws-opts'].get('headers', {}).get('Host', '') or share_link.get('ws-headers', {}).get('Host', '') or share_link['ws-opts'].get('headers', {}).get('host', '') or share_link.get('ws-headers', {}).get('host', '')
if share_link.get('tls', '') and share_link['tls'] != False:
vless_info["security"] = 'tls'
else:
vless_info["security"] = 'none'
link = "vless://{uuid}@{server}:{port}?encryption=none&security={security}&sni={sni}&type={type}&host={host}&path={path}&fp={fp}&flow={flow}&alpn={alpn}&allowInsecure={allowInsecure}".format(**vless_info)
elif vless_info['type'] == 'grpc':
if share_link.get('grpc-opts', {}).get('grpc-service-name', '') != '/' :
vless_info["serviceName"] = unquote(share_link.get('grpc-opts', {}).get('grpc-service-name', ''))
if share_link.get('reality-opts', {}):
vless_info["security"] = 'reality'
vless_info["pbk"] = share_link['reality-opts'].get('public-key', '')
vless_info["sid"] = share_link['reality-opts'].get('short-id', '')
link = "vless://{uuid}@{server}:{port}?encryption=none&security={security}&sni={sni}&type={type}&serviceName={serviceName}&fp={fp}&flow={flow}&alpn={alpn}&allowInsecure={allowInsecure}&pbk={pbk}&sid={sid}".format(**vless_info)
elif share_link.get('tls', '') and share_link['tls'] != False:
vless_info["security"] = 'tls'
link = "vless://{uuid}@{server}:{port}?encryption=none&security={security}&sni={sni}&type={type}&serviceName={serviceName}&fp={fp}&flow={flow}&alpn={alpn}&allowInsecure={allowInsecure}".format(**vless_info)
else:
vless_info["security"] = 'none'
link = "vless://{uuid}@{server}:{port}?encryption=none&security={security}&sni={sni}&type={type}&serviceName={serviceName}&fp={fp}&flow={flow}&alpn={alpn}&allowInsecure={allowInsecure}".format(**vless_info)
elif vless_info['type'] == 'h2':
vless_info["path"] = quote(share_link.get('h2-opts', {}).get('path', ''), 'utf-8')
vless_info["host"] = ','.join(share_link.get('h2-opts', {}).get('host', []))
if share_link.get('reality-opts', {}):
vless_info["security"] = 'reality'
vless_info["pbk"] = share_link['reality-opts'].get('public-key', '')
vless_info["sid"] = share_link['reality-opts'].get('short-id', '')
link = "vless://{uuid}@{server}:{port}?encryption=none&security={security}&sni={sni}&type={type}&host={host}&path={path}&fp={fp}&flow={flow}&alpn={alpn}&allowInsecure={allowInsecure}&pbk={pbk}&sid={sid}".format(**vless_info)
elif share_link.get('tls', '') and share_link['tls'] != False:
vless_info["security"] = 'tls'
link = "vless://{uuid}@{server}:{port}?encryption=none&security={security}&sni={sni}&type={type}&host={host}&path={path}&fp={fp}&flow={flow}&alpn={alpn}&allowInsecure={allowInsecure}".format(**vless_info)
else:
vless_info["security"] = 'none'
link = "vless://{uuid}@{server}:{port}?encryption=none&security={security}&sni={sni}&type={type}&host={host}&path={path}&fp={fp}&flow={flow}&alpn={alpn}&allowInsecure={allowInsecure}".format(**vless_info)
elif vless_info['type'] == 'http':
vless_info["path"] = ','.join(share_link.get('http-opts', {}).get('path', []))
vless_info["host"] = share_link.get('http-opts', {}).get('headers', {}).get('Host', [''])[0] or share_link.get('http-opts', {}).get('headers', {}).get('host', [''])[0]
if share_link.get('reality-opts', {}):
vless_info["security"] = 'reality'
vless_info["pbk"] = share_link['reality-opts'].get('public-key', '')
vless_info["sid"] = share_link['reality-opts'].get('short-id', '')
link = "vless://{uuid}@{server}:{port}?encryption=none&security={security}&sni={sni}&type={type}&host={host}&path={path}&fp={fp}&flow={flow}&alpn={alpn}&allowInsecure={allowInsecure}&pbk={pbk}&sid={sid}".format(**vless_info)
elif share_link.get('tls', '') and share_link['tls'] != False:
vless_info["security"] = 'tls'
link = "vless://{uuid}@{server}:{port}?encryption=none&security={security}&sni={sni}&type={type}&host={host}&path={path}&fp={fp}&flow={flow}&alpn={alpn}&allowInsecure={allowInsecure}".format(**vless_info)
else:
vless_info["security"] = 'none'
link = "vless://{uuid}@{server}:{port}?encryption=none&security={security}&sni={sni}&type={type}&host={host}&path={path}&fp={fp}&flow={flow}&alpn={alpn}&allowInsecure={allowInsecure}".format(**vless_info)
elif vless_info['type'] == 'tcp':
if share_link.get('reality-opts', {}):
vless_info["security"] = 'reality'
vless_info["pbk"] = share_link['reality-opts'].get('public-key', '')
vless_info["sid"] = share_link['reality-opts'].get('short-id', '')
link = "vless://{uuid}@{server}:{port}?encryption=none&security={security}&sni={sni}&type={type}&fp={fp}&flow={flow}&alpn={alpn}&allowInsecure={allowInsecure}&pbk={pbk}&sid={sid}".format(**vless_info)
elif share_link.get('tls', '') and share_link['tls'] != False:
vless_info["security"] = 'tls'
link = "vless://{uuid}@{server}:{port}?encryption=none&security={security}&sni={sni}&type={type}&fp={fp}&flow={flow}&alpn={alpn}&allowInsecure={allowInsecure}".format(**vless_info)
else:
vless_info["security"] = 'none'
link = "vless://{uuid}@{server}:{port}?encryption=none&security={security}&sni={sni}&type={type}&fp={fp}&flow={flow}&alpn={alpn}&allowInsecure={allowInsecure}".format(**vless_info)
if share_link.get('smux',{}).get('enabled', '') == True:
vless_info["protocol"] = share_link['smux']['protocol']
vless_info["max_connections"] = share_link['smux'].get('max-connections','')
vless_info["min_streams"] = share_link['smux'].get('min-streams','')
vless_info["max_streams"] = share_link['smux'].get('max-streams','')
vless_info["padding"] = share_link['smux'].get('padding','')
link += "&protocol={protocol}&max-connections={max_connections}&min-streams={min_streams}&max-streams={max_streams}&padding={padding}#{name}".format(**vless_info)
else:
link += f"#{vless_info['name']}"
return link
# TODO
- 增加http、h2协议
- 修改了link中部分变量的输入
from sing-box-subscribe.
没有network为http、h2
而且我不想再改动vless协议。当时做vless头疼很久,目前根据大量测试已经能运行良好不想改动
from sing-box-subscribe.
好吧
from sing-box-subscribe.
不好意思,昨天代码有地方我写的不对,vmess_info["path"] = share_link.get('http-opts', {}).get('path', '[]')应改为vmess_info["path"] = share_link.get('http-opts', {}).get('path', []),多打了引号见谅;其他协议我打算都搓一遍,隔段时间再在这统一提交一次issue可好
from sing-box-subscribe.
Related Issues (20)
- hysteria节点转换后使用问题 HOT 3
- vercel.app部署成功后,不能自动下载json文件 HOT 6
- 使用Docker的本地问题 HOT 1
- 本地安装要如何自动运行 HOT 7
- 是否可以修改远程配置的模版,改用自己Fork后的模版 HOT 4
- 改进:能否考虑从机场导入节点时就排除一部分节点。 HOT 13
- Unable to deploy the project to the vercel HOT 10
- 关于纯V6节点,订阅转换后不支持 HOT 2
- 使用https://xxxxxxx.vercel.app/config/+订阅地址的方式,是否支持多个订阅地址分别加tag的形式 HOT 3
- 新模版遇到点问题 HOT 2
- 我希望默认DNS是国外的而不是国内的,有配置项可以修改吗? HOT 1
- 能否讲一下怎么设置链式代理? HOT 1
- 改进: Vercel 免费从10s升级到60s
- 请问我的机场提供singbox订阅链接,可以把多个singbox订阅链接合并吗,提取出来节点用自己的规则 HOT 8
- 对于多个要转换的文件,其中一个若发生错误直接跳过并进行下一步,而不是只要其中一个文件转换错误就退出执行了 HOT 3
- 新更新的模板出现错误。需清理缓存 HOT 4
- clash格式的UoT配置在转换时丢失 HOT 6
- 请问可以使用cloudflare pages部署吗 HOT 1
- 请问使用本地部署怎样通过url进行转换 HOT 7
- parsers/clash2base64.py 的 wireguard 部分的修改建议 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sing-box-subscribe.