Skip to content

Commit 7ec52ac

Browse files
committed
First Commit
0 parents  commit 7ec52ac

18 files changed

+23626
-0
lines changed

.editorconfig

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = tab
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
11+
[*.yml]
12+
indent_style = space

.github/workflows/main.yml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Deploy to Cloudflare Workers and Create R2 Bucket if Not Exists
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
14+
- name: Setup Node.js
15+
uses: actions/setup-node@v3
16+
with:
17+
node-version: '21'
18+
19+
- name: Install dependencies
20+
run: npm install
21+
22+
- name: Install wrangler
23+
run: npm install -g wrangler
24+
25+
- name: Check and Create R2 Bucket
26+
env:
27+
CLOUDFLARE_API_TOKEN: ${{ secrets.CF_API_TOKEN }}
28+
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }}
29+
run: |
30+
BUCKET_NAME="sublink-worker"
31+
if ! wrangler r2 bucket list | grep -q "$BUCKET_NAME"; then
32+
echo "Bucket $BUCKET_NAME does not exist. Creating..."
33+
wrangler r2 bucket create "$BUCKET_NAME"
34+
echo "Bucket $BUCKET_NAME created successfully."
35+
else
36+
echo "Bucket $BUCKET_NAME already exists. Skipping creation."
37+
fi
38+
39+
- name: Deploy to Cloudflare Workers
40+
uses: cloudflare/wrangler-action@2.0.0
41+
with:
42+
apiToken: ${{ secrets.CF_API_TOKEN }}

.gitignore

+173
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
# Logs
2+
test
3+
4+
logs
5+
_.log
6+
npm-debug.log_
7+
yarn-debug.log*
8+
yarn-error.log*
9+
lerna-debug.log*
10+
.pnpm-debug.log*
11+
12+
# Diagnostic reports (https://nodejs.org/api/report.html)
13+
14+
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
15+
16+
# Runtime data
17+
18+
pids
19+
_.pid
20+
_.seed
21+
\*.pid.lock
22+
23+
# Directory for instrumented libs generated by jscoverage/JSCover
24+
25+
lib-cov
26+
27+
# Coverage directory used by tools like istanbul
28+
29+
coverage
30+
\*.lcov
31+
32+
# nyc test coverage
33+
34+
.nyc_output
35+
36+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
37+
38+
.grunt
39+
40+
# Bower dependency directory (https://bower.io/)
41+
42+
bower_components
43+
44+
# node-waf configuration
45+
46+
.lock-wscript
47+
48+
# Compiled binary addons (https://nodejs.org/api/addons.html)
49+
50+
build/Release
51+
52+
# Dependency directories
53+
54+
node_modules/
55+
jspm_packages/
56+
57+
# Snowpack dependency directory (https://snowpack.dev/)
58+
59+
web_modules/
60+
61+
# TypeScript cache
62+
63+
\*.tsbuildinfo
64+
65+
# Optional npm cache directory
66+
67+
.npm
68+
69+
# Optional eslint cache
70+
71+
.eslintcache
72+
73+
# Optional stylelint cache
74+
75+
.stylelintcache
76+
77+
# Microbundle cache
78+
79+
.rpt2_cache/
80+
.rts2_cache_cjs/
81+
.rts2_cache_es/
82+
.rts2_cache_umd/
83+
84+
# Optional REPL history
85+
86+
.node_repl_history
87+
88+
# Output of 'npm pack'
89+
90+
\*.tgz
91+
92+
# Yarn Integrity file
93+
94+
.yarn-integrity
95+
96+
# dotenv environment variable files
97+
98+
.env
99+
.env.development.local
100+
.env.test.local
101+
.env.production.local
102+
.env.local
103+
104+
# parcel-bundler cache (https://parceljs.org/)
105+
106+
.cache
107+
.parcel-cache
108+
109+
# Next.js build output
110+
111+
.next
112+
out
113+
114+
# Nuxt.js build / generate output
115+
116+
.nuxt
117+
dist
118+
119+
# Gatsby files
120+
121+
.cache/
122+
123+
# Comment in the public line in if your project uses Gatsby and not Next.js
124+
125+
# https://nextjs.org/blog/next-9-1#public-directory-support
126+
127+
# public
128+
129+
# vuepress build output
130+
131+
.vuepress/dist
132+
133+
# vuepress v2.x temp and cache directory
134+
135+
.temp
136+
.cache
137+
138+
# Docusaurus cache and generated files
139+
140+
.docusaurus
141+
142+
# Serverless directories
143+
144+
.serverless/
145+
146+
# FuseBox cache
147+
148+
.fusebox/
149+
150+
# DynamoDB Local files
151+
152+
.dynamodb/
153+
154+
# TernJS port file
155+
156+
.tern-port
157+
158+
# Stores VSCode versions used for testing VSCode extensions
159+
160+
.vscode-test
161+
162+
# yarn v2
163+
164+
.yarn/cache
165+
.yarn/unplugged
166+
.yarn/build-state.yml
167+
.yarn/install-state.gz
168+
.pnp.\*
169+
170+
# wrangler project
171+
172+
.dev.vars
173+
.wrangler/

.prettierrc

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"printWidth": 140,
3+
"singleQuote": true,
4+
"semi": true,
5+
"useTabs": true
6+
}

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License
2+
3+
Copyright (c) 2024 7Sageer
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Sublink Worker
2+
3+
这是一个可部署在Cloudflare Worker的轻量级订阅转换工具,用于将各种代理协议的订阅链接转换为不同客户端可用的配置格式。
4+
5+
![image](/doc/image.png)
6+
7+
演示地址:[https://sublink-worker.seven7-ade.workers.dev/](https://sublink-worker.seven7-ade.workers.dev/)
8+
> 提示:请保护自己的数据,建议自行部署
9+
10+
## 功能特点
11+
12+
- 支持协议:SS、VMess、VLESS、Hysteria2
13+
- 支持客户端:
14+
- Sing-Box
15+
- Clash
16+
- XRay/V2Ray
17+
- 提供Web界面用于便捷操作
18+
- 支持短链接生成(基于R2)
19+
- 浅色/深色主题切换
20+
21+
## 部署
22+
23+
[![Deploy to Cloudflare Workers](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/7Sageer/sublink-worker)
24+
25+
> 提示:确保你的Cloudflare账户已经开通R2储存服务
26+
27+
## 项目结构
28+
29+
- `index.js`: 主要的服务器逻辑,处理请求路由
30+
- `SingboxConfigBuilder.js`: 构建Sing-Box配置
31+
- `ClashConfigBuilder.js`: 构建Clash配置
32+
- `ProxyParsers.js`: 解析各种代理协议的URL
33+
- `utils.js`: 提供各种实用函数
34+
- `htmlBuilder.js`: 生成Web界面的HTML
35+
- `config.js`: 保存配置信息
36+
37+
## API 端点
38+
39+
- `/`: Web界面
40+
- `/singbox`: 获取Sing-Box配置
41+
- `/xray`: 获取XRay基础配置
42+
- `/clash`: 获取Clash配置
43+
- `/shorten-all`: 短链接生成API
44+
- `/s`, `/x`, `/c`: 短链接跳转
45+
46+
## 许可证
47+
48+
这个项目采用 MIT 许可证 - 查看 [LICENSE](LICENSE) 文件了解详情
49+
50+
<div style="background-color: #ffe6e6; border: 1px solid #ff8080; padding: 10px; border-radius: 5px; margin-bottom: 20px;">
51+
<strong>免责声明:</strong><br>
52+
本项目仅供学习交流使用,请勿用于非法用途。使用本项目所造成的一切后果由使用者自行承担,与开发者无关。
53+
</div>

doc/image.png

275 KB
Loading

0 commit comments

Comments
 (0)