Skip to content

Commit

Permalink
docs: update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jonssonyan committed Jul 28, 2024
1 parent af82a4d commit 066319e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ Cloudflare Workers HTTP 反向代理
| PROXY_HOSTNAME || | github.com | 代理地址 hostname |
| PROXY_PROTOCOL | × | https | https | 代理地址协议 |
| PATHNAME_REGEX | × | | ^./jonssonyan/ | 代理地址路径正则表达式 |
| UA_REGEX | × | | (curl) | User-Agent 白名单正则表达式 |
| UA_WHITELIST_REGEX | × | | (curl) | User-Agent 白名单正则表达式 |
| UA_BLACKLIST_REGEX | × | | (curl) | User-Agent 黑名单正则表达式 |
| IP_WHITELIST_REGEX | × | | (192.168.1) | IP 白名单正则表达式 |
| IP_BLACKLIST_REGEX | × | | (192.168.1) | IP 黑名单正则表达式 |
| REGION_WHITELIST_REGEX | × | | (JP) | 地区白名单正则表达式 |
Expand Down
3 changes: 2 additions & 1 deletion README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ PROXY_HOSTNAME to the blocked domain name, and then access it through your worke
| PROXY_HOSTNAME || | github.com | Proxy address hostname |
| PROXY_PROTOCOL | × | https | https | Proxy address protocol |
| PATHNAME_REGEX | × | | ^./jonssonyan/ | Regular expression for proxy address path |
| UA_REGEX | × | | (curl) | Regular expression for User-Agent whitelist |
| UA_WHITELIST_REGEX | × | | (curl) | Regular expression for User-Agent whitelist |
| UA_BLACKLIST_REGEX | × | | (curl) | Regular expression for User-Agent blacklist |
| IP_WHITELIST_REGEX | × | | (192.168.1) | Regular expression for IP whitelist |
| IP_BLACKLIST_REGEX | × | | (192.168.1) | Regular expression for IP blacklist |
| REGION_WHITELIST_REGEX | × | | (JP) | Regular expression for region whitelist |
Expand Down
11 changes: 8 additions & 3 deletions _worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ export default {
PROXY_HOSTNAME,
PROXY_PROTOCOL = "https",
PATHNAME_REGEX,
UA_REGEX,
UA_WHITELIST_REGEX,
UA_BLACKLIST_REGEX,
URL302,
IP_WHITELIST_REGEX,
IP_BLACKLIST_REGEX,
Expand All @@ -125,10 +126,14 @@ export default {
if (
!PROXY_HOSTNAME ||
(PATHNAME_REGEX && !new RegExp(PATHNAME_REGEX).test(url.pathname)) ||
(UA_REGEX &&
!new RegExp(UA_REGEX).test(
(UA_WHITELIST_REGEX &&
!new RegExp(UA_WHITELIST_REGEX).test(
request.headers.get("user-agent").toLowerCase()
)) ||
(UA_BLACKLIST_REGEX &&
new RegExp(UA_BLACKLIST_REGEX).test(
request.headers.get("user-agent")
)) ||
(IP_WHITELIST_REGEX &&
!new RegExp(IP_WHITELIST_REGEX).test(
request.headers.get("cf-connecting-ip")
Expand Down

0 comments on commit 066319e

Please sign in to comment.