The universal proxy platform.
For extended features
要使用 Dynamic API 功能,需编译时添加 with_dynamic_api
标签,你可以在运行时动态管理入站、出站和路由规则。
在配置文件的 experimental
部分添加:
{
"experimental": {
"dynamic_api": {
"listen": "127.0.0.1:9091",
"secret": "your_api_secret"
}
}
}
Dynamic API 提供以下功能:
- 动态添加/删除入站
- 动态添加/删除出站
- 动态添加/删除路由规则
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer your_api_secret" \
http://127.0.0.1:9091/api/inbound \
-d '{
"tag": "http_in",
"type": "http",
"listen": "127.0.0.1",
"listen_port": 10080,
"users": [
{
"username": "user",
"password": "pass"
}
]
}'
curl -X DELETE -H "Authorization: Bearer your_api_secret" \
http://127.0.0.1:9091/api/inbound/http_in
curl -H "Authorization: Bearer your_api_secret" \
http://127.0.0.1:9091/api/inbound
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer your_api_secret" \
http://127.0.0.1:9091/api/outbound \
-d '{
"tag": "proxy_out",
"type": "vmess",
"server": "example.com",
"server_port": 443,
"security": "auto",
"uuid": "bf000d23-0752-40b4-affe-68f7707a9661",
"alter_id": 0,
"tls": {
"enabled": true,
"server_name": "example.com"
}
}'
#
{
"type": "vless",
"tag": "proxy1",
"server": "shen.86782889.xyz",
"server_port": 55536,
"uuid": "1ecd415e-6b5a-5988-c66f-2e67f28d1e72",
"flow": "",
"network": "tcp",
"tls": {
"enabled": true,
"server_name": "shen.86782889.xyz",
"insecure": false
},
"transport": {
"type": "ws",
"path": "/SHDsdfsjk2365"
}
}
#
curl -X DELETE -H "Authorization: Bearer your_api_secret" \
http://127.0.0.1:9091/api/outbound/proxy_out
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer your_api_secret" \
http://127.0.0.1:9091/api/route/rule \
-d '{
"domain": ["example.com"],
"outbound": "proxy_out"
}'
路由规则通过索引删除,首先可以列出所有规则:
curl -H "Authorization: Bearer your_api_secret" \
http://127.0.0.1:9091/api/route/rules
然后删除指定索引的规则(例如删除索引为0的规则):
curl -X DELETE -H "Authorization: Bearer your_api_secret" \
http://127.0.0.1:9091/api/route/rule/0
Copyright (C) 2022 by nekohasekai <contact-sagernet@sekai.icu>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
In addition, no derivative work may use the name or imply association
with this application without prior consent.