-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Update ClashConfigBuilder and SingboxConfigBuilder to handle se…
…lectedRules parameter correctly
- Loading branch information
Showing
8 changed files
with
541 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,80 +1,85 @@ | ||
# Sublink Worker | ||
|
||
这是一个可部署在Cloudflare Worker的轻量级订阅转换工具,用于将各种代理协议的分享url转换为不同客户端可用的订阅链接。 | ||
Sublink Worker 是一个轻量级的订阅转换工具,可部署在 Cloudflare Worker 上。它可以将各种代理协议的分享 URL 转换为不同客户端可用的订阅链接。 | ||
|
||
![image](/doc/main.png) | ||
|
||
演示地址:[https://sublink-worker.seven7-ade.workers.dev/](https://sublink-worker.seven7-ade.workers.dev/) | ||
> 提示:请保护自己的数据,建议[自行部署](#最近更新) | ||
## 功能特点 | ||
|
||
- 支持协议:SS, VMess, VLESS, Hysteria2, Trojan, TUIC | ||
- 支持导入Base64的http/https订阅链接 | ||
- [一键部署](#最近更新),Vanilla JS + Cloudflare Worker,无需后端 | ||
- 支持协议:ShadowSocks, VMess, VLESS, Hysteria2, Trojan, TUIC | ||
- 支持导入 Base64 的 http/https 订阅链接 | ||
- 一键部署,Vanilla JS + Cloudflare Worker,无需后端 | ||
- 支持客户端: | ||
- Sing-Box | ||
- Clash | ||
- Xray/V2Ray | ||
- 支持短链接生成(基于R2) | ||
- 支持短链接生成(基于 R2) | ||
- 浅色/深色主题切换 | ||
- 快速上手的Web界面,提供主流自定义路由规则: | ||
- 用户友好的 Web 界面,提供主流自定义路由规则 | ||
- 灵活的 API,支持脚本化操作 | ||
|
||
![image](/doc/rules.png) | ||
|
||
## 快速开始 | ||
|
||
## 最近更新 | ||
### 部署 | ||
|
||
### 13/8 | ||
|
||
- 修复hy2协议解析问题 | ||
[![Deploy to Cloudflare Workers](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/7Sageer/sublink-worker) | ||
|
||
--- | ||
> 注意:确保你的 Cloudflare 账户已经开通 R2 存储服务 | ||
### 10/8 | ||
## API 文档 | ||
|
||
- 添加快速选择规则集 | ||
- 细化规则集 | ||
- 增添更多分类 | ||
- 将OpenAI改为AI服务,包含Claude,Jetbrains-AI等规则 | ||
- 优化显示 | ||
详细的 API 文档可以在 [API-doc.md](/doc/API-doc.md) 中找到。 | ||
|
||
--- | ||
主要端点包括: | ||
|
||
### 7/8 | ||
- `/singbox`:生成 Sing-Box 配置 | ||
- `/clash`:生成 Clash 配置 | ||
- `/xray`:生成 Xray 配置 | ||
- `/shorten`:生成短链接 | ||
|
||
- 优化UI | ||
## 最近更新 | ||
|
||
### 2023-08-13 | ||
|
||
## 部署 | ||
- 优化 API 架构 | ||
- 更新了文档,增加了详细的 API 说明 | ||
- 修复 hy2 协议解析问题 | ||
|
||
[![Deploy to Cloudflare Workers](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/7Sageer/sublink-worker) | ||
### 2023-08-10 | ||
|
||
> 提示:确保你的Cloudflare账户已经开通R2储存服务 | ||
- 添加快速选择规则集 | ||
- 细化规则集 | ||
- 增添更多分类 | ||
- 将 OpenAI 改为 AI 服务,包含 Claude,Jetbrains-AI 等规则 | ||
- 优化显示 | ||
|
||
## 项目结构 | ||
|
||
- `index.js`: 主要的服务器逻辑,处理请求路由 | ||
- `BaseConfigBuilder.js`: 构建基础配置 | ||
- `SingboxConfigBuilder.js`: 构建Sing-Box配置 | ||
- `ClashConfigBuilder.js`: 构建Clash配置 | ||
- `ProxyParsers.js`: 解析各种代理协议的URL | ||
- `SingboxConfigBuilder.js`: 构建 Sing-Box 配置 | ||
- `ClashConfigBuilder.js`: 构建 Clash 配置 | ||
- `ProxyParsers.js`: 解析各种代理协议的 URL | ||
- `utils.js`: 提供各种实用函数 | ||
- `htmlBuilder.js`: 生成Web界面的HTML | ||
- `htmlBuilder.js`: 生成 Web 界面的 HTML | ||
- `config.js`: 保存配置信息 | ||
|
||
## API 端点 | ||
## 贡献 | ||
|
||
- `/`: Web界面 | ||
- `/singbox`: 获取Sing-Box配置 | ||
- `/xray`: 获取XRay基础配置 | ||
- `/clash`: 获取Clash配置 | ||
- `/shorten-all`: 短链接生成API | ||
- `/s`, `/x`, `/c`: 短链接跳转 | ||
欢迎提交 Issues 和 Pull Requests 来改进这个项目。 | ||
|
||
## 许可证 | ||
|
||
这个项目采用 MIT 许可证 - 查看 [LICENSE](LICENSE) 文件了解详情 | ||
这个项目采用 MIT 许可证 - 查看 [LICENSE](LICENSE) 文件了解详情。 | ||
|
||
## 免责声明 | ||
|
||
本项目仅供学习交流使用,请勿用于非法用途。使用本项目所造成的一切后果由使用者自行承担,与开发者无关 | ||
本项目仅供学习交流使用,请勿用于非法用途。使用本项目所造成的一切后果由使用者自行承担,与开发者无关。 | ||
|
||
## Star History | ||
|
||
感谢所有为本项目点亮 Star 的朋友们!🌟 | ||
|
||
[![Star History Chart](https://api.star-history.com/svg?repos=7Sageer/sublink-worker&type=Date)](https://star-history.com/#7Sageer/sublink-worker&Date) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
# Sublink Worker API Documentation | ||
|
||
## Overview | ||
|
||
Sublink Worker is a lightweight subscription conversion tool deployed on Cloudflare Workers. It converts various proxy protocol share URLs into subscription links usable by different clients. This document outlines the API endpoints and their usage. | ||
|
||
## Base URL | ||
|
||
All API requests should be made to: | ||
|
||
``` | ||
https://your-worker-domain.workers.dev | ||
``` | ||
|
||
Replace `your-worker-domain` with your actual Cloudflare Workers domain. | ||
|
||
## Endpoints | ||
|
||
### 1. Generate Configuration | ||
|
||
#### Sing-Box Configuration | ||
|
||
- **URL**: `/singbox` | ||
- **Method**: GET | ||
- **Parameters**: | ||
- `config` (required): URL-encoded string containing one or more proxy configurations | ||
- `selectedRules` (optional): Either a predefined rule set name or a JSON array of custom rules | ||
|
||
**Example**: | ||
``` | ||
/singbox?config=vmess%3A%2F%2Fexample&selectedRules=balanced | ||
``` | ||
or | ||
``` | ||
/singbox?config=vmess%3A%2F%2Fexample&selectedRules=%5B%22Ad%20Block%22%2C%22Private%22%5D | ||
``` | ||
|
||
#### Clash Configuration | ||
|
||
- **URL**: `/clash` | ||
- **Method**: GET | ||
- **Parameters**: Same as Sing-Box configuration | ||
|
||
#### Xray Configuration | ||
|
||
- **URL**: `/xray` | ||
- **Method**: GET | ||
- **Parameters**: | ||
- `config` (required): URL-encoded string containing one or more proxy configurations | ||
|
||
### 2. Shorten URL | ||
|
||
- **URL**: `/shorten` | ||
- **Method**: GET | ||
- **Parameters**: | ||
- `url` (required): The original URL to be shortened | ||
|
||
**Example**: | ||
``` | ||
/shorten?url=https%3A%2F%2Fexample.com%2Fvery-long-url | ||
``` | ||
|
||
**Response**: | ||
```json | ||
{ | ||
"shortUrl": "https://your-worker-domain.workers.dev/s/abcdefg" | ||
} | ||
``` | ||
|
||
### 3. Redirect Short URL | ||
|
||
- **URL**: `/s/{shortCode}` | ||
- **Method**: GET | ||
- **Description**: Redirects to the original URL associated with the short code | ||
|
||
## Predefined Rule Sets | ||
|
||
The API supports the following predefined rule sets: | ||
|
||
- `minimal`: Basic set of rules | ||
- `balanced`: Moderate set of rules | ||
- `comprehensive`: Full set of rules | ||
|
||
These can be used in the `selectedRules` parameter for Sing-Box and Clash configurations. | ||
|
||
## Custom Rules | ||
|
||
Instead of using predefined rule sets, you can provide a custom list of rules as a JSON array in the `selectedRules` parameter. Available rules include: | ||
|
||
- Ad Block | ||
- AI Services | ||
- Bilibili | ||
- Youtube | ||
- Private | ||
- Location:CN | ||
- Telegram | ||
- Microsoft | ||
- Apple | ||
- Bahamut | ||
- Social Media | ||
- Streaming | ||
- Gaming | ||
- Github | ||
- Education | ||
- Financial | ||
- Cloud Services | ||
|
||
## Error Handling | ||
|
||
The API will return appropriate HTTP status codes along with error messages in case of issues: | ||
|
||
- 400 Bad Request: When required parameters are missing or invalid | ||
- 404 Not Found: When a requested resource (e.g., short URL) doesn't exist | ||
- 500 Internal Server Error: For server-side errors | ||
|
||
## Usage Notes | ||
|
||
1. All proxy configurations in the `config` parameter should be URL-encoded. | ||
2. Multiple proxy configurations can be included in a single request by separating them with newline characters (`%0A`) in the URL-encoded `config` parameter. | ||
3. When using custom rules, ensure the rule names exactly match those listed in the Custom Rules section. | ||
4. The shortened URLs are meant to be temporary and may expire after a certain period. | ||
|
||
## Examples | ||
|
||
1. Generate a Sing-Box configuration with a balanced rule set: | ||
``` | ||
/singbox?config=vmess%3A%2F%2Fexample&selectedRules=balanced | ||
``` | ||
|
||
2. Generate a Clash configuration with custom rules: | ||
``` | ||
/clash?config=vless%3A%2F%2Fexample&selectedRules=%5B%22Ad%20Block%22%2C%22Google%22%2C%22Streaming%22%5D | ||
``` | ||
|
||
3. Shorten a URL: | ||
``` | ||
/shorten?url=https%3A%2F%2Fyour-worker-domain.workers.dev%2Fsingbox%3Fconfig%3Dvmess%253A%252F%252Fexample%26selectedRules%3Dbalanced | ||
``` | ||
|
||
## Conclusion | ||
|
||
This API provides a flexible and powerful way to generate and manage proxy configurations. It supports multiple proxy protocols, various client types, and customizable routing rules. The URL shortening feature allows for easy sharing and management of complex configurations. | ||
|
||
For any issues or feature requests, please contact the repository maintainer. |
Oops, something went wrong.