白嫖 worker 自建短链服务 Url-Shorten-Worker worker.js 配置项增加 password
配置项增加 password
不需要在 KV 中添加 password 条目
const config = {password: "testpwd", // 管理面板使用密码 // if password != null, then use this config; otherwise, read password from KV.result_page: false, // 是否用特定的result 页面来显示 value // After get the value from KV, if use a page to show the result. theme: "", // 管理面板的主题 // Homepage theme, use the empty value for default theme. To use urlcool theme, please fill with "theme/urlcool" .cors: true, // 是否允许CORS 使用 API // Allow Cross-origin resource sharing for API requests. unique_link: false, // 一个长链是否只有唯一的短链(会增加写入的使用量) // If it is true, the same long url will be shorten into the same short url custom_link: true, // 允许自定义短链 // Allow users to customize the short url.overwrite_kv: false, // 允许覆盖已存在的key // Allow user to overwrite an existed key. snapchat_mode: false, // 短链只能访问一次(访问后就删除了) // The link will be distroyed after access. visit_count: false, // 使用记数(会大大增加写入的使用量, 多人共用不推荐打开) // Count visit times. load_kv: false, // 从KV 加载全部数据 (自用推荐打开, 多人共用会看到别人的数据) // Load all from Cloudflare KV system_type: "shorturl", // 系统的功能定义 // shorturl, imghost, other types {pastebin, journal}}
为了兼容旧版本时期的教程部署出来的 KV 和用户使用习惯, 当配置项 password 为空时, 从 KV 读取 password 条目的值.
https://github.com/crazypeace/url-Shorten-Worker/
已按原方法部署的朋友, 可以不用动.
新部署项目时, 不需要在 KV 中添加条目, 只要在 worker.js 配置项中设置密码就好.
部署教程已更新
========
这个项目会归档, 没有 bug 就不动了. 主要是因为怕修改太大会影响已经部署的朋友.
========
当初我在 KV 中设置一个 password 的思路是, 我希望把 KV 看作是一个存储库, 那么使用权限密码也是保存的数据之一.
另一个想法是, 我们要修改 VPS 的 root 密码时, 不是一定要进到 VPS 厂商的后台管理面板中修改的. 是可以在 root 登录后, 在命令行就可以修改.
后来, 在实际使用过程中, 得到大家的反馈, 为了不能暴露 password, 其实是屏蔽了 API 对它的读写操作的.
为了把这个思路实施得彻底, 我会新建一个项目. 作为示例.
评论
发表评论