Giter Club home page Giter Club logo

url-shorten-worker's Introduction

020短链

利用Cloudflare Worker实现的简单免费的短链接平台,
主要支持自用以及防滥用演示,

API

中文API文档

Getting start

去Workers KV中创建一个命名空间

Go to Workers KV and create a namespace.

img

去Worker的Settings选选项卡中绑定KV Namespace

Bind an instance of a KV Namespace to access its data in a Worker.

img

其中Variable name填写LINKS, KV namespace填写你刚刚创建的命名空间

Where Variable name should set as LINKS and KV namespace is the namespace you just created in the first step.

img

复制本项目中的index.js的代码到Cloudflare Worker

Copy the index.js code from this project to Cloudflare Worker.

调整超时设置

演示模式生成的短链接超时无法访问,
白名单或者密码正确情况超时设置无效,
修改脚本开头的变量shorten_timeout, 单位毫秒,0表示不设置超时,

调整白名单

白名单中的域名设置短链接无视超时,
修改脚本开头的变量white_list, 是个json数组,写顶级域名就可以,自动通过顶级域名和所有二级域名,

关闭演示模式

只有演示模式开启才允许访客无密码添加非白名单地址,超时短链接会失效,
修改脚本开头的变量demo_mode,为true开启演示,为false无密码且非白名单请求不受理,

自动删除演示记录

针对演示模式开启情况下的超时失效的短链接记录是否自动删除,
修改脚本开头的变量remove_completely,为true自动删除超时的演示短链接记录,否则仅是标记过期,以便在后台查询历史记录,

修改密码

网页有个隐藏输入框可以输入密码,
密码正确情况无视白名单和超时设置,且支持自定义短链接,
修改脚本开头的变量password,这个私密信息比较建议直接在环境变量里配置,

修改短链长度

短链长度就是随机生成的key也就是短链接的path部分的长度,
长度不够时容易出现重复,遇到重复时会自动延长,
修改脚本开头的变量default_len,

以上几个配置都可以在worker -> 设置 -> 环境变量中配置,key均为对应大写,

img

点击Save and Deploy

Click Save and Deploy

Demo

https://020.name

Note: Because someone abuse this demo website, all the generated link may be deleted at any time. For long-term use, please deploy your own.

注意:由于该示例服务被人滥用,用于转发诈骗网站,故所有由demo网站生成的链接随时可能失效,如需长期使用请自行搭建。

感谢

项目基于xyTom/Url-Shorten-Worker(MIT)

  1. 改进了正则匹配,
  2. 添加了超时判断处理,
  3. 添加了白名单支持,
  4. 添加了演示模式,
  5. 添加了隐藏密码支持,
  6. 添加了隐藏自定义短链接支持,
  7. 所有配置可以脱离脚本在环境变量配置,
  8. 支持回车键提交,
  9. 生成的短链接包含协议https,
  10. 添加了短链长度设置和自动延长,
  11. 支持开关自动删除演示过期记录,

url-shorten-worker's People

Contributors

aoeiuv020 avatar xytom avatar belm avatar 0xflotus avatar vanillapod-ze avatar cloudtom avatar a7t avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.