From 233f1c81528280fdab89a94ba313af435b58426e Mon Sep 17 00:00:00 2001 From: Tony Date: Fri, 11 Mar 2022 21:12:42 +0700 Subject: [PATCH] refactor: config.js (#9305) * refactor: reorder lib/config.js * docs: reorder config --- docs/en/install/README.md | 164 ++++++++-------- docs/install/README.md | 385 +++++++++++++++++++------------------- lib/config.js | 291 ++++++++++++++-------------- 3 files changed, 433 insertions(+), 407 deletions(-) diff --git a/docs/en/install/README.md b/docs/en/install/README.md index c28942119..21df941bf 100644 --- a/docs/en/install/README.md +++ b/docs/en/install/README.md @@ -358,6 +358,24 @@ If you would like to test routes or avoid IP limits, etc., you may build your ow Configure RSSHub by setting environment variables +### Network Configuration + +`PORT`: listening port, default to `1200` + +`SOCKET`: listening Unix Socket, default to `null` + +`LISTEN_INADDR_ANY`: open up for external access, default to `1` + +`REQUEST_RETRY`: retries allowed for failed requests, default to `2` + +`REQUEST_TIMEOUT`: milliseconds to wait for the server to end the response before aborting the request with error, default to `3000` + +`UA`: user agent, default to `Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36` + +### CORS Request + +RSSHub by default reject CORS requests. This behavior can be modified via setting `ALLOW_ORIGIN: *` or `ALLOW_ORIGIN: www.example.com`. + ### Cache Configurations RSSHub supports two caching methods: memory and redis @@ -419,10 +437,6 @@ For readers that do not support HTTP Basic authentication, please refer to [Acce `HTTP_BASIC_AUTH_PASS`: HTTP basic authentication password, default to `passw0rd`, please change asap -### CORS Request - -RSSHub by default reject CORS requests. This behavior can be modified via setting `ALLOW_ORIGIN: *` or `ALLOW_ORIGIN: www.example.com`. - ### Access Control Configuration RSSHub supports access control via access key/code, whitelisting and blacklisting, enabling any will activate access control for all routes. `ALLOW_LOCALHOST: true` will grant access to all localhost IP addresses. @@ -456,37 +470,33 @@ See the relation between access key/code and white/blacklisting. | Whitelisted | ✅ | ✅ | ✅ | ✅ | ✅ | | Blacklisted | ✅ | ❌ | ✅ | ❌ | ❌ | -### Other Application Configurations - -`PORT`: listening port, default to `1200` - -`SOCKET`: listening Unix Socket, default to `null` - -`LISTEN_INADDR_ANY`: open up for external access, default to `1` - -`TITLE_LENGTH_LIMIT`: limit the length of feed title generated in bytes, an English alphabet counts as 1 byte, the rest such as Chinese, Japanese, Korean or Arabic counts as 2 bytes by design, default to `100` - -`REQUEST_RETRY`: retries allowed for failed requests, default to `2` - -`REQUEST_TIMEOUT`: milliseconds to wait for the server to end the response before aborting the request with error, default to `3000` +### Logging Configurations `DEBUG_INFO`: display route information on the homepage for debugging purposes. When set to neither `true` nor `false`, use parameter `debug` to enable display, eg: . Default to `true` -`NODE_ENV`: display error message on pages for authentication failing, default to `production` (i.e. no display) - `LOGGER_LEVEL`: specifies the maximum [level](https://github.com/winstonjs/winston#logging-levels) of messages to the console and log file, default to `info` -`NODE_NAME`: node name, used for load balancing, identify the current node - -`PUPPETEER_WS_ENDPOINT`: Browser WebSocket endpoint which can be used as an argument to puppeteer.connect, refer to [browserWSEndpoint](https://pptr.dev/#?product=Puppeteer&version=v1.14.0&show=api-browserwsendpoint) +`NO_LOGFILES`: disable logging to log files, default to `false` `SENTRY`: [Sentry](https://sentry.io) dsn, used for error tracking `SENTRY_ROUTE_TIMEOUT`: Report Sentry if route execution takes more than this milliseconds, default to `3000` +### Other Application Configurations + `DISALLOW_ROBOT`: prevent indexing by search engine, default to enable, set false or 0 to disable -`HOTLINK_TEMPLATE`: Replace image link in the description to avoid anti-hotlink protection, leave blank to disable this function. Usage reference [#2769](https://github.com/DIYgod/RSSHub/issues/2769). You may use any property listed in [URL](https://developer.mozilla.org/en-US/docs/Web/API/URL#Properties), format of JS template literal. e.g. `${protocol}//${host}${pathname}`, `https://i3.wp.com/${host}${pathname}` +`ENABLE_CLUSTER`: enable cluster mode, default to `false` + +`HOTLINK_TEMPLATE`: replace image link in the description to avoid anti-hotlink protection, leave blank to disable this function. Usage reference [#2769](https://github.com/DIYgod/RSSHub/issues/2769). You may use any property listed in [URL](https://developer.mozilla.org/en-US/docs/Web/API/URL#Properties), format of JS template literal. e.g. `${protocol}//${host}${pathname}`, `https://i3.wp.com/${host}${pathname}` + +`NODE_ENV`: display error message on pages for authentication failing, default to `production` (i.e. no display) + +`NODE_NAME`: node name, used for load balancing, identify the current node + +`PUPPETEER_WS_ENDPOINT`: browser WebSocket endpoint which can be used as an argument to puppeteer.connect, refer to [browserWSEndpoint](https://pptr.dev/#?product=Puppeteer&show=api-browserwsendpoint) + +`TITLE_LENGTH_LIMIT`: limit the length of feed title generated in bytes, an English alphabet counts as 1 byte, the rest such as Chinese, Japanese, Korean or Arabic counts as 2 bytes by design, default to `150` ### Route-specific Configurations @@ -498,55 +508,32 @@ See docs of the specified route and `lib/config.js` for detailed information. ::: -- pixiv: [Registration](https://accounts.pixiv.net/signup) +- Discuz cookie - - `PIXIV_REFRESHTOKEN`: Please refer to [this article](https://gist.github.com/ZipFile/c9ebedb224406f4f11845ab700124362) to get a `refresh_token` - - - `PIXIV_BYPASS_CDN`: bypass Cloudflare bot check by directly accessing Pixiv source server, defaults to disable, set `true` or `1` to enable - - - `PIXIV_BYPASS_HOSTNAME`: Pixiv source server hostname or IP address, hostname will be resolved to IPv4 address via `PIXIV_BYPASS_DOH`, defaults to `public-api.secure.pixiv.net` - - - `PIXIV_BYPASS_DOH`: DNS over HTTPS endpoint, it must be compatible with Cloudflare or Google DoH JSON schema, defaults to `https://1.1.1.1/dns-query` - - - `PIXIV_IMG_PROXY`: Used as a proxy for image addresses, as pixiv images have anti-theft, default to `https://i.pixiv.cat` - -- pixiv fanbox: Get paid content - - - `FANBOX_SESSION_ID`: equals to `FANBOXSESSID` in site cookies. + - `DISCUZ_COOKIE_{cid}`: Cookie of a forum powered by Discuz, cid can be anything from 00 to 99. When visiting a Discuz route, use cid to specify this cookie. - disqus: [API Key application](https://disqus.com/api/applications/) - `DISQUS_API_KEY`: Disqus API -- twitter: [Application creation](https://apps.twitter.com) +- douban - - `TWITTER_CONSUMER_KEY`: Twitter Consumer Key, support multiple keys, split them with `,` + - `DOUBAN_COOKIE`: Cookie of douban user - - `TWITTER_CONSUMER_SECRET`: Twitter Consumer Secret, support multiple keys, split them with `,` +- E-Hentai - - `TWITTER_TOKEN_{handler}`: The token generated by the corresponding Twitter handler, replace `{handler}` with the Twitter handler, the value is a combination of `Twitter API key, Twitter API key secret, Access token, Access token secret` connected by a comma `,`. Eg. `TWITTER_TOKEN_RSSHub=bX1zry5nG4d1RbESQbnADpVIo,2YrD8qo9sXbB8VlYfVmo1Qtw0xsexnOliU5oZofq7aPIGou0Xx,123456789-hlkUHFYmeXrRcf6SEQciP8rP4lzmRgMgwdqIN9aK,pHcPnfa28rCIKhSICUCiaw9ppuSSl7T2f3dnGYpSM0bod`. - -- youtube: [API Key application](https://console.developers.google.com/) - - - `YOUTUBE_KEY`: YouTube API Key, support multiple keys, split them with `,` - -- telegram: [Bot application](https://telegram.org/blog/bot-revolution) - - - `TELEGRAM_TOKEN`: Telegram bot token + - `EH_IPB_MEMBER_ID`: The value of `ipb_member_id` in the cookie header after logging in E-Hentai + - `EH_IPB_PASS_HASH`: The value of `ipb_pass_hash` in the cookie header after logging in E-Hentai + - `EH_SK`: The value of `sk` in the cookie header after logging in E-Hentai + - `EH_IGNEOUS`: The value of `igneous` in the cookie header after logging in ExHentai. If this value is set, RSS will be generated from ExHentai, `EH_SK` will be ignored. - github: [Access Token application](https://github.com/settings/tokens) - `GITHUB_ACCESS_TOKEN`: GitHub Access Token -- spotify: [API key registration](https://developer.spotify.com) +- Google Fonts: [API key application](https://developers.google.com/fonts/docs/developer_api#a_quick_example) - - `SPOTIFY_CLIENT_ID`:Client ID of the application - - - `SPOTIFY_CLIENT_SECRET`:Client secret of the application - -- spotify (user data related routes): - - - `SPOTIFY_REFRESHTOKEN`:The refresh token of the user f the Spotify application. Check [this gist](https://gist.github.com/outloudvi/d1bbeb5e989db5385384a223a7263744) for detailed information. + - `GOOGLE_FONTS_API_KEY`: API key - Instagram: @@ -556,35 +543,62 @@ See docs of the specified route and `lib/config.js` for detailed information. Warning: Two Factor Authentication is **not** supported. +- Last.fm + + - `LASTFM_API_KEY`: Last.fm API Key + - mail: - `EMAIL_CONFIG_{email}`: Mail setting, replace `{email}` with the email account, replace `@` in email account with `.`, eg. `EMAIL_CONFIG_xxx.gmail.com`. The value is in the format of `password=password&host=server&port=port`, eg: - Linux env: `EMAIL_CONFIG_xxx_qq_com="password=123456&host=imap.qq.com&port=993"` - docker env: `EMAIL_CONFIG_xxx_qq_com=password=123456&host=imap.qq.com&port=993`, please do not include quotations `'`,`"` -- nhentai torrent: [Registration](https://nhentai.net/register/) - - - `NHENTAI_USERNAME`: nhentai username or email - - `NHENTAI_PASSWORD`: nhentai password - -- Discuz cookie - - - `DISCUZ_COOKIE_{cid}`: Cookie of a forum powered by Discuz, cid can be anything from 00 to 99. When visiting a Discuz route, use cid to specify this cookie. - -- Last.fm - - - `LASTFM_API_KEY`: Last.fm API Key - - Mastodon user timeline: apply API here `https://mastodon.example/settings/applications`(repalce `mastodon.example`), please check scope `read:search` - `MASTODON_API_HOST`: API instance domain - `MASTODON_API_ACCESS_TOKEN`: user access token - `MASTODON_API_ACCT_DOMAIN`: acct domain for particular instance +- nhentai torrent: [Registration](https://nhentai.net/register/) + + - `NHENTAI_USERNAME`: nhentai username or email + - `NHENTAI_PASSWORD`: nhentai password + +- pixiv: [Registration](https://accounts.pixiv.net/signup) + + - `PIXIV_REFRESHTOKEN`: Please refer to [this article](https://gist.github.com/ZipFile/c9ebedb224406f4f11845ab700124362) to get a `refresh_token` + - `PIXIV_BYPASS_CDN`: bypass Cloudflare bot check by directly accessing Pixiv source server, defaults to disable, set `true` or `1` to enable + - `PIXIV_BYPASS_HOSTNAME`: Pixiv source server hostname or IP address, hostname will be resolved to IPv4 address via `PIXIV_BYPASS_DOH`, defaults to `public-api.secure.pixiv.net` + - `PIXIV_BYPASS_DOH`: DNS over HTTPS endpoint, it must be compatible with Cloudflare or Google DoH JSON schema, defaults to `https://1.1.1.1/dns-query` + - `PIXIV_IMG_PROXY`: Used as a proxy for image addresses, as pixiv images have anti-theft, default to `https://i.pixiv.cat` + +- pixiv fanbox: Get paid content + + - `FANBOX_SESSION_ID`: equals to `FANBOXSESSID` in site cookies. + - Sci-hub for scientific journal routes: - `SCIHUB_HOST`: The Sci-hub mirror address that is accessible from your location, default to `https://sci-hub.se`. +- spotify: [API key registration](https://developer.spotify.com) + + - `SPOTIFY_CLIENT_ID`:Client ID of the application + - `SPOTIFY_CLIENT_SECRET`:Client secret of the application + +- spotify (user data related routes): + + - `SPOTIFY_REFRESHTOKEN`:The refresh token of the user from the Spotify application. Check [this gist](https://gist.github.com/outloudvi/d1bbeb5e989db5385384a223a7263744) for detailed information. + +- telegram: [Bot application](https://telegram.org/blog/bot-revolution) + + - `TELEGRAM_TOKEN`: Telegram bot token + +- twitter: [Application creation](https://apps.twitter.com) + + - `TWITTER_CONSUMER_KEY`: Twitter Consumer Key, support multiple keys, split them with `,` + - `TWITTER_CONSUMER_SECRET`: Twitter Consumer Secret, support multiple keys, split them with `,` + - `TWITTER_TOKEN_{handler}`: The token generated by the corresponding Twitter handler, replace `{handler}` with the Twitter handler, the value is a combination of `Twitter API key, Twitter API key secret, Access token, Access token secret` connected by a comma `,`. Eg. `TWITTER_TOKEN_RSSHub=bX1zry5nG4d1RbESQbnADpVIo,2YrD8qo9sXbB8VlYfVmo1Qtw0xsexnOliU5oZofq7aPIGou0Xx,123456789-hlkUHFYmeXrRcf6SEQciP8rP4lzmRgMgwdqIN9aK,pHcPnfa28rCIKhSICUCiaw9ppuSSl7T2f3dnGYpSM0bod`. + - Wordpress: - `WORDPRESS_CDN`: Proxy HTTP image link with HTTPS link. Consider using: @@ -597,12 +611,6 @@ See docs of the specified route and `lib/config.js` for detailed information. | https://cors.netnr.workers.dev/ | cloudflare | | https://netnr-proxy.openode.io/ | digitalocean | -- E-Hentai - - `EH_IPB_MEMBER_ID`: The value of `ipb_member_id` in the cookie header after logging in E-Hentai - - `EH_IPB_PASS_HASH`: The value of `ipb_pass_hash` in the cookie header after logging in E-Hentai - - `EH_SK`: The value of `sk` in the cookie header after logging in E-Hentai +- youtube: [API Key application](https://console.developers.google.com/) -- Google Fonts: [API key application](https://developers.google.com/fonts/docs/developer_api#a_quick_example) - - `GOOGLE_FONTS_API_KEY`: API key -- douban - - `DOUBAN_COOKIE`: Cookie of douban user \ No newline at end of file + - `YOUTUBE_KEY`: YouTube API Key, support multiple keys, split them with `,` diff --git a/docs/install/README.md b/docs/install/README.md index 863b10b6d..4f8f90cc8 100644 --- a/docs/install/README.md +++ b/docs/install/README.md @@ -362,6 +362,24 @@ gcloud app deploy 通过设置环境变量来配置 RSSHub +### 网络配置 + +`PORT`: 监听端口,默认为 `1200` + +`SOCKET`: 监听 Unix Socket,默认 `null` + +`LISTEN_INADDR_ANY`: 是否允许公网连接,默认 `1` + +`REQUEST_RETRY`: 请求失败重试次数,默认 `2` + +`REQUEST_TIMEOUT`: 请求超时毫秒数,默认 `3000` + +`UA`: 用户代理,默认 `Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36` + +### 跨域请求 + +RSSHub 默认对跨域请求限制为当前连接所在的域名,即不允许跨域。可以通过 `ALLOW_ORIGIN: *` 或者 `ALLOW_ORIGIN: www.example.com` 以对跨域访问进行修改。 + ### 缓存配置 RSSHub 支持 `memory` 和 `redis` 两种缓存方式 @@ -422,10 +440,6 @@ RSSHub 支持 `memory` 和 `redis` 两种缓存方式 `HTTP_BASIC_AUTH_PASS`: Http basic authentication 密码,默认为 `passw0rd`,请务必修改 -### 跨域请求 - -RSSHub 默认对跨域请求限制为当前连接所在的域名,即不允许跨域。可以通过 `ALLOW_ORIGIN: *` 或者 `ALLOW_ORIGIN: www.example.com` 以对跨域访问进行修改。 - ### 访问控制配置 RSSHub 支持使用访问密钥 / 码,白名单和黑名单三种方式进行访问控制。开启任意选项将会激活全局访问控制,没有访问权限将会导致访问被拒绝。同时可以通过 `ALLOW_LOCALHOST: true` 赋予所有本地 IP 访问权限。 @@ -460,38 +474,34 @@ RSSHub 支持使用访问密钥 / 码,白名单和黑名单三种方式进行 | 在黑名单中 | ✅ | ❌ | ❌ | | 无黑白名单 | ✅ | ❌ | ❌ | -### 其他应用配置 - -`PORT`: 监听端口,默认为 `1200` - -`SOCKET`: 监听 Unix Socket,默认 `null` - -`LISTEN_INADDR_ANY`: 是否允许公网连接,默认 `1` - -`TITLE_LENGTH_LIMIT`: 限制输出标题的字节长度,一个英文字符的长度为 1 字节,部分语言如中文,日文,韩文或阿拉伯文等,统一算作 2 字节,默认 `100` - -`REQUEST_RETRY`: 请求失败重试次数,默认 `2` - -`REQUEST_TIMEOUT`: 请求超时毫秒数,默认 `3000` +### 日志配置 `DEBUG_INFO`: 是否在首页显示路由信息。值为非 `true` `false` 时,在请求中带上参数 `debug` 开启显示,例如: 。默认 `true` -`NODE_ENV`: 是否显示错误输出,默认 `production` (即关闭输出) - `LOGGER_LEVEL`: 指明输出到 console 和日志文件的日志的最大 [等级](https://github.com/winstonjs/winston#logging-levels),默认 `info` -`NODE_NAME`: 节点名,用于负载均衡,识别当前节点 - -`PUPPETEER_WS_ENDPOINT`: 用于 puppeteer.connect 的浏览器 websocket 链接,见 [browserWSEndpoint](https://zhaoqize.github.io/puppeteer-api-zh_CN/#?product=Puppeteer\&version=v1.14.0\&show=api-browserwsendpoint) +`NO_LOGFILES`: 是否禁用日志文件输出,默认 `false` `SENTRY`: [Sentry](https://sentry.io) dsn,用于错误追踪 `SENTRY_ROUTE_TIMEOUT`: 路由耗时超过此毫秒值上报 Sentry,默认 `3000` +### 其他应用配置 + `DISALLOW_ROBOT`: 阻止搜索引擎收录,默认开启,设置 false 或 0 关闭 +`ENABLE_CLUSTER`: 是否开启集群模式,默认 `false` + `HOTLINK_TEMPLATE`: 用于处理描述中图片的链接,绕过防盗链等限制,留空不生效。用法参考 [#2769](https://github.com/DIYgod/RSSHub/issues/2769)。可以使用 [URL](https://developer.mozilla.org/en-US/docs/Web/API/URL#Properties) 的所有属性,格式为 JS 变量模板。例子:`${protocol}//${host}${pathname}`, `https://i3.wp.com/${host}${pathname}` +`NODE_ENV`: 是否显示错误输出,默认 `production` (即关闭输出) + +`NODE_NAME`: 节点名,用于负载均衡,识别当前节点 + +`PUPPETEER_WS_ENDPOINT`: 用于 puppeteer.connect 的浏览器 websocket 链接,见 [browserWSEndpoint](hhttps://zhaoqize.github.io/puppeteer-api-zh_CN/#?product=Puppeteer\&show=api-browserwsendpoint) + +`TITLE_LENGTH_LIMIT`: 限制输出标题的字节长度,一个英文字符的长度为 1 字节,部分语言如中文,日文,韩文或阿拉伯文等,统一算作 2 字节,默认 `150` + ### 部分 RSS 模块配置 ::: tip 提示 @@ -500,45 +510,12 @@ RSSHub 支持使用访问密钥 / 码,白名单和黑名单三种方式进行 ::: -- pixiv 全部路由:[注册地址](https://accounts.pixiv.net/signup) +- 4399 论坛 - - `PIXIV_REFRESHTOKEN`: Pixiv Refresh Token, 请参考 [此文](https://gist.github.com/ZipFile/c9ebedb224406f4f11845ab700124362) 获取,或自行对客户端抓包获取 - - - `PIXIV_BYPASS_CDN`: 绕过 Pixiv 前置的 Cloudflare CDN, 使用`PIXIV_BYPASS_HOSTNAME`指示的 IP 地址访问 Pixiv API, 可以解决因 Cloudflare 机器人验证导致的登录失败问题,默认关闭,设置 true 或 1 开启 - - - `PIXIV_BYPASS_HOSTNAME`: Pixiv 源站的主机名或 IP 地址,主机名会被解析为 IPv4 地址,默认为`public-api.secure.pixiv.net`;仅在`PIXIV_BYPASS_CDN`开启时生效 - - - `PIXIV_BYPASS_DOH`: 用于解析 `PIXIV_BYPASS_HOSTNAME` 的 DoH 端点 URL,需要兼容 Cloudflare 或 Google 的 DoH 服务的 JSON 查询格式,默认为 `https://1.1.1.1/dns-query` - - - `PIXIV_IMG_PROXY`: 用于图片地址的代理,因为 pixiv 图片有防盗链,默认为 `https://i.pixiv.cat` - -- pixiv fanbox 用于获取付费内容 - - - `FANBOX_SESSION_ID`: 对应 cookies 中的`FANBOXSESSID`。 - -- disqus 全部路由:[申请地址](https://disqus.com/api/applications/) - - - `DISQUS_API_KEY`: Disqus API - -- twitter 全部路由:[申请地址](https://apps.twitter.com) - - - `TWITTER_CONSUMER_KEY`: Twitter API key,支持多个 key,用英文逗号 `,` 隔开 - - - `TWITTER_CONSUMER_SECRET`: Twitter API key secret,支持多个 key,用英文逗号 `,` 隔开,顺序与 key 对应 - - - `TWITTER_TOKEN_{handler}`: 对应 Twitter 用户名生成的 token,`{handler}` 替换为用于生成该 token 的 Twitter 用户名,值为 `Twitter API key, Twitter API key secret, Access token, Access token secret` 用逗号隔开,例如:`TWITTER_TOKEN_RSSHub=bX1zry5nG4d1RbESQbnADpVIo,2YrD8qo9sXbB8VlYfVmo1Qtw0xsexnOliU5oZofq7aPIGou0Xx,123456789-hlkUHFYmeXrRcf6SEQciP8rP4lzmRgMgwdqIN9aK,pHcPnfa28rCIKhSICUCiaw9ppuSSl7T2f3dnGYpSM0bod` - -- youtube 全部路由:[申请地址](https://console.developers.google.com/) - - - `YOUTUBE_KEY`: YouTube API Key,支持多个 key,用英文逗号 `,` 隔开 - -- telegram - 贴纸包路由:[Telegram 机器人](https://telegram.org/blog/bot-revolution) - - - `TELEGRAM_TOKEN`: Telegram 机器人 token - -- github 全部路由:[申请地址](https://github.com/settings/tokens) - - - `GITHUB_ACCESS_TOKEN`: GitHub Access Token + - `GAME_4399`: 对应登录后的 cookie 值,获取方式: + 1. 在 4399 首页登录。 + 2. 打开开发者工具,切换到 Network 面板,刷新 + 3. 查找`www.4399.com`的访问请求,点击请求,在右侧 Headers 中找到 Cookie. - bilibili 用户关注动态系列路由 @@ -548,39 +525,58 @@ RSSHub 支持使用访问密钥 / 码,白名单和黑名单三种方式进行 3. 点击 dynamic_new 请求,找到 Cookie 4. 视频和专栏只要求 `SESSDATA` 字段,动态需复制整段 Cookie -- spotify 全部路由: [注册地址](https://developer.spotify.com) +- BTBYR - - `SPOTIFY_CLIENT_ID`:Spotify 应用的 client ID - - - `SPOTIFY_CLIENT_SECRET`:Spotify 应用的 client secret - -- spotify 用户相关路由 - - - `SPOTIFY_REFRESHTOKEN`:用户在此 Spotify 应用的 refresh token。可以利用 [此 gist](https://gist.github.com/outloudvi/d1bbeb5e989db5385384a223a7263744) 获取。 - -- 语雀 全部路由:[注册地址](https://www.yuque.com/register) - - - `YUQUE_TOKEN`: 语雀 Token,[获取地址](https://www.yuque.com/settings/tokens)。语雀接口做了访问频率限制,为保证正常访问建议配置 Token,详见 [语雀开发者文档](https://www.yuque.com/yuque/developer/api#5b3a1535)。 - -- 邮箱 邮件列表路由: - - - `EMAIL_CONFIG_{email}`: 邮箱设置,替换 `{email}` 为 邮箱账号,邮件账户的 `@` 替换为 `.`,例如 `EMAIL_CONFIG_xxx.qq.com`。Linux 内容格式为 `password=密码&host=服务器&port=端口`,docker 内容格式为 `password=密码\&host=服务器\&port=端口`,例如: - - Linux 环境变量:`EMAIL_CONFIG_xxx_qq_com="password=123456&host=imap.qq.com&port=993"` - - docker 环境变量:`EMAIL_CONFIG_xxx_qq_com=password=123456\&host=imap.qq.com\&port=993`,请勿添加引号 `'`,`"`。 - -- 吹牛部落 栏目更新 - - - `CHUINIU_MEMBER`: 吹牛部落登录后的 x-member,获取方式 - 1. 登陆后点开文章正文 + - `BTBYR_HOST`: 支持 ipv4 访问的 BTBYR 镜像,默认为原站 `https://bt.byr.cn/`。 + - `BTBYR_COOKIE`: 注册用户登录后的 Cookie 值,获取方式: + 1. 登录后打开网站首页 2. 打开控制台,刷新 - 3. 找到 开头的请求 - 4. 找到请求头中的 x-member + 3. 找到 请求 + 4. 找到请求头中的 Cookie -- 微博 个人时间线路由:[申请地址](https://open.weibo.com/connect) +- BUPT - - `WEIBO_APP_KEY`: 微博 App Key - - `WEIBO_APP_SECRET`: 微博 App Secret - - `WEIBO_REDIRECT_URL`: 微博登录授权回调地址,默认为 `RSSHub 地址/weibo/timeline/0`,自定义回调地址请确保最后可以转跳到 `RSSHub 地址/weibo/timeline/0?code=xxx` + - `BUPT_PORTAL_COOKIE`: 登录后获得的 Cookie 值,获取方式 + 1. 打开并登录 + 2. 无视掉报错,并打开 + 3. 打开控制台,刷新 + 4. 找到 请求 + 5. 找到请求头中的 Cookie + +- discuz cookies 设定 + + - `DISCUZ_COOKIE_{cid}`: 某 Discuz 驱动的论坛,用户注册后的 Cookie 值,cid 可自由设定,取值范围 \[00, 99], 使用 discuz 通用路由时,通过指定 cid 来调用该 cookie + +- disqus 全部路由:[申请地址](https://disqus.com/api/applications/) + + - `DISQUS_API_KEY`: Disqus API + +- E-Hentai + + - `EH_IPB_MEMBER_ID`: E-Hentai 账户登录后 cookie 的 `ipb_member_id` 值 + - `EH_IPB_PASS_HASH`: E-Hentai 账户登录后 cookie 的 `ipb_pass_hash` 值 + - `EH_SK`: E-Hentai 账户登录后 cookie 中的`sk`值 + - `EH_IGNEOUS`: ExHentai 账户登录后 cookie 中的`igneous`值。若设置此值,RSS 数据将全部从里站获取,`EH_SK`将被忽略 + +- github 全部路由:[申请地址](https://github.com/settings/tokens) + + - `GITHUB_ACCESS_TOKEN`: GitHub Access Token + +- Google Fonts:[申请地址](https://developers.google.com/fonts/docs/developer_api#a_quick_example) + + - `GOOGLE_FONTS_API_KEY`: API key + +- Instagram: + + - `IG_USERNAME`: Instagram 用户名。 + - `IG_PASSWORD`: Instagram 密码。 + - `IG_PROXY`: Instagram 代理 URL。 + + 注意,暂**不支持**两步验证。 + +- Last.fm 全部路由:[申请地址](https://www.last.fm/api/) + + - `LASTFM_API_KEY`: Last.fm API Key - Mastodon 用户时间线路由:访问 `https://mastodon.example/settings/applications` 申请(替换掉 `mastodon.example`)。需要 `read:search` 权限 @@ -593,117 +589,50 @@ RSSHub 支持使用访问密钥 / 码,白名单和黑名单三种方式进行 - `MINIFLUX_INSTANCE`: 用户所用的实例,默认为 MiniFlux 官方提供的 [付费服务地址](https://reader.miniflux.app) - `MINIFLUX_TOKEN`: 用户的 API 密钥,请登录所用实例后于 `设置` -> `API 密钥` -> `创建一个新的 API 密钥` 处获取 -- 饭否 全部路由:[申请地址](https://github.com/FanfouAPI/FanFouAPIDoc/wiki/Oauth) +- NGA BBS 用于获取帖子内文 - - `FANFOU_CONSUMER_KEY`: 饭否 Consumer Key - - `FANFOU_CONSUMER_SECRET`: 饭否 Consumer Secret - - `FANFOU_USERNAME`: 饭否登录用户名、邮箱、手机号 - - `FANFOU_PASSWORD`: 饭否密码 - -- Last.fm 全部路由:[申请地址](https://www.last.fm/api/) - - - `LASTFM_API_KEY`: Last.fm API Key - -- 北大未名 BBS 全站十大 - - - `PKUBBS_COOKIE`: BBS 注册用户登录后的 Cookie 值,获取方式: - 1. 登录后打开论坛首页 - 2. 打开控制台, 刷新 - 3. 找到 请求 - 4. 找到请求头中的 Cookie + - `NGA_PASSPORT_UID`: 对应 cookie 中的 `ngaPassportUid`. + - `NGA_PASSPORT_CID`: 对应 cookie 中的 `ngaPassportCid`. - nhentai torrent: [注册地址](https://nhentai.net/register/) - `NHENTAI_USERNAME`: nhentai 用户名或邮箱 - `NHENTAI_PASSWORD`: nhentai 密码 -- discuz cookies 设定 +- pixiv 全部路由:[注册地址](https://accounts.pixiv.net/signup) - - `DISCUZ_COOKIE_{cid}`: 某 Discuz 驱动的论坛,用户注册后的 Cookie 值,cid 可自由设定,取值范围 \[00, 99], 使用 discuz 通用路由时,通过指定 cid 来调用该 cookie + - `PIXIV_REFRESHTOKEN`: Pixiv Refresh Token, 请参考 [此文](https://gist.github.com/ZipFile/c9ebedb224406f4f11845ab700124362) 获取,或自行对客户端抓包获取 + - `PIXIV_BYPASS_CDN`: 绕过 Pixiv 前置的 Cloudflare CDN, 使用`PIXIV_BYPASS_HOSTNAME`指示的 IP 地址访问 Pixiv API, 可以解决因 Cloudflare 机器人验证导致的登录失败问题,默认关闭,设置 true 或 1 开启 + - `PIXIV_BYPASS_HOSTNAME`: Pixiv 源站的主机名或 IP 地址,主机名会被解析为 IPv4 地址,默认为`public-api.secure.pixiv.net`;仅在`PIXIV_BYPASS_CDN`开启时生效 + - `PIXIV_BYPASS_DOH`: 用于解析 `PIXIV_BYPASS_HOSTNAME` 的 DoH 端点 URL,需要兼容 Cloudflare 或 Google 的 DoH 服务的 JSON 查询格式,默认为 `https://1.1.1.1/dns-query` + - `PIXIV_IMG_PROXY`: 用于图片地址的代理,因为 pixiv 图片有防盗链,默认为 `https://i.pixiv.cat` + +- pixiv fanbox 用于获取付费内容 + + - `FANBOX_SESSION_ID`: 对应 cookies 中的`FANBOXSESSID`。 - Sci-hub 设置,用于科学期刊路由。 - `SCIHUB_HOST`: 可访问的 sci-hub 镜像地址,默认为 `https://sci-hub.se`。 -- 端传媒设置,用于获取付费内容全文: +- spotify 全部路由: [注册地址](https://developer.spotify.com) - - `INITIUM_BEARER_TOKEN`: 端传媒 Web 版认证 token。获取方式:登陆后打开端传媒站内任意页面,打开浏览器开发者工具中 “网络”(Network) 选项卡,筛选 URL 找到任一个地址为`api.initium.com`开头的请求,点击检查其 “消息头”,在 “请求头” 中找到`Authorization`字段,将其值复制填入配置即可。你的配置应该形如`INITIUM_BEARER_TOKEN: 'Bearer eyJxxxx......xx_U8'`。使用 token 部署的好处是避免占据登陆设备数的额度,但这个 token 一般有效期为两周,因此只可作临时测试使用。 + - `SPOTIFY_CLIENT_ID`:Spotify 应用的 client ID + - `SPOTIFY_CLIENT_SECRET`:Spotify 应用的 client secret - - `INITIUM_IAP_RECEIPT`: 端传媒 iOS 版内购回执认证 token。获取方式:登陆后打开端传媒 iOS app 内任意页面,打开抓包工具,筛选 URL 找到任一个地址为`api.initium.com`开头的请求,点击检查其 “消息头”,在 “请求头” 中找到`X-IAP-Receipt`字段,将其值复制填入配置即可。你的配置应该形如`INITIUM_IAP_RECEIPT: 'ef81dee9e4e2fe084a0af1ea82da2f7b16e75f756db321618a119fa62b52550e'`。 +- spotify 用户相关路由 - Web 版认证 token 和 iOS 内购回执认证 token 只需选择其一填入即可。你也可选择直接在环境设置中填写明文的用户名和密码: + - `SPOTIFY_REFRESHTOKEN`:用户在此 Spotify 应用的 refresh token。可以利用 [此 gist](https://gist.github.com/outloudvi/d1bbeb5e989db5385384a223a7263744) 获取。 - - `INITIUM_USERNAME`: 端传媒用户名 (邮箱) - - `INITIUM_PASSWORD`: 端传媒密码 +- telegram - 贴纸包路由:[Telegram 机器人](https://telegram.org/blog/bot-revolution) -- Instagram: + - `TELEGRAM_TOKEN`: Telegram 机器人 token - - `IG_USERNAME`: Instagram 用户名。 - - `IG_PASSWORD`: Instagram 密码。 - - `IG_PROXY`: Instagram 代理 URL。 +- twitter 全部路由:[申请地址](https://apps.twitter.com) - 注意,暂不支持两步验证。 - -- BUPT - - - `BUPT_PORTAL_COOKIE`: 登录后获得的 Cookie 值,获取方式 - 1. 打开并登录 - 2. 无视掉报错,并打开 - 3. 打开控制台,刷新 - 4. 找到 请求 - 5. 找到请求头中的 Cookie - -- BTBYR - - - `BTBYR_HOST`: 支持 ipv4 访问的 BTBYR 镜像,默认为原站 `https://bt.byr.cn/`。 - - `BTBYR_COOKIE`: 注册用户登录后的 Cookie 值,获取方式: - 1. 登录后打开网站首页 - 2. 打开控制台,刷新 - 3. 找到 请求 - 4. 找到请求头中的 Cookie - -- 小宇宙:需要 App 登陆后抓包获取相应数据。 - - - `XIAOYUZHOU_ID`: 即数据包中的 `x-jike-device-id`。 - - `XIAOYUZHOU_TOKEN`: 即数据包中的 `x-jike-refresh-token`。 - -- 新榜 - - - `NEWRANK_COOKIE`: 登陆后的 COOKIE 值,其中 token 是必要的,其他可删除 - -- NGA BBS 用于获取帖子内文 - - - `NGA_PASSPORT_UID`: 对应 cookie 中的 `ngaPassportUid`. - - - `NGA_PASSPORT_CID`: 对应 cookie 中的 `ngaPassportCid`. - -- 喜马拉雅 - - - `XIMALAYA_TOKEN`: 对应 cookie 中的 `1&_token`,获取方式: - 1. 登陆喜马拉雅网页版 - 2. 打开控制台,刷新 - 3. 查找名称为`1&_token`的`cookie`,其内容即为`XIMALAYA_TOKEN`的值(即在`cookie` 中查找 `1&_token=***;`,并设置 `XIMALAYA_TOKEN = ***`) - -- 4399 论坛 - - - `GAME_4399`: 对应登录后的 cookie 值,获取方式: - 1. 在 4399 首页登录。 - 2. 打开开发者工具,切换到 Network 面板,刷新 - 3. 查找`www.4399.com`的访问请求,点击请求,在右侧 Headers 中找到 Cookie. - -- 滴答清单 - - - `DIDA365_USERNAME`: 滴答清单用户名 - - `DIDA365_PASSWORD`: 滴答清单密码 - -- 知乎用户关注时间线 - - - `ZHIHU_COOKIES`: 知乎登录后的 cookie 值. - 1. 可以在知乎网页版的一些请求的请求头中找到,如 `GET /moments` 请求头中的 `cookie` 值. - -- 网易云歌单及听歌排行 - - - `NCM_COOKIES`: 网易云音乐登陆后的 cookie 值. + - `TWITTER_CONSUMER_KEY`: Twitter API key,支持多个 key,用英文逗号 `,` 隔开 + - `TWITTER_CONSUMER_SECRET`: Twitter API key secret,支持多个 key,用英文逗号 `,` 隔开,顺序与 key 对应 + - `TWITTER_TOKEN_{handler}`: 对应 Twitter 用户名生成的 token,`{handler}` 替换为用于生成该 token 的 Twitter 用户名,值为 `Twitter API key, Twitter API key secret, Access token, Access token secret` 用逗号隔开,例如:`TWITTER_TOKEN_RSSHub=bX1zry5nG4d1RbESQbnADpVIo,2YrD8qo9sXbB8VlYfVmo1Qtw0xsexnOliU5oZofq7aPIGou0Xx,123456789-hlkUHFYmeXrRcf6SEQciP8rP4lzmRgMgwdqIN9aK,pHcPnfa28rCIKhSICUCiaw9ppuSSl7T2f3dnGYpSM0bod` - Wordpress @@ -717,20 +646,98 @@ RSSHub 支持使用访问密钥 / 码,白名单和黑名单三种方式进行 | | cloudflare | | | digitalocean | -- E-Hentai - - `EH_IPB_MEMBER_ID`: E-Hentai 账户登录后 cookie 的 `ipb_member_id` 值 - - `EH_IPB_PASS_HASH`: E-Hentai 账户登录后 cookie 的 `ipb_pass_hash` 值 - - `EH_SK`: E-Hentai 账户登录后 cookie 中的`sk`值 - - `EH_IGNEOUS`: ExHentai 账户登录后 cookie 中的`igneous`值。若设置此值,RSS 数据将全部从里站获取,`EH_SK`将被忽略 +- youtube 全部路由:[申请地址](https://console.developers.google.com/) + + - `YOUTUBE_KEY`: YouTube API Key,支持多个 key,用英文逗号 `,` 隔开 + +- 北大未名 BBS 全站十大 + + - `PKUBBS_COOKIE`: BBS 注册用户登录后的 Cookie 值,获取方式: + 1. 登录后打开论坛首页 + 2. 打开控制台, 刷新 + 3. 找到 请求 + 4. 找到请求头中的 Cookie + +- 吹牛部落 栏目更新 + + - `CHUINIU_MEMBER`: 吹牛部落登录后的 x-member,获取方式 + 1. 登陆后点开文章正文 + 2. 打开控制台,刷新 + 3. 找到 开头的请求 + 4. 找到请求头中的 x-member + +- 滴答清单 + + - `DIDA365_USERNAME`: 滴答清单用户名 + - `DIDA365_PASSWORD`: 滴答清单密码 + +- 端传媒设置,用于获取付费内容全文: + + - `INITIUM_BEARER_TOKEN`: 端传媒 Web 版认证 token。获取方式:登陆后打开端传媒站内任意页面,打开浏览器开发者工具中 “网络”(Network) 选项卡,筛选 URL 找到任一个地址为`api.initium.com`开头的请求,点击检查其 “消息头”,在 “请求头” 中找到`Authorization`字段,将其值复制填入配置即可。你的配置应该形如`INITIUM_BEARER_TOKEN: 'Bearer eyJxxxx......xx_U8'`。使用 token 部署的好处是避免占据登陆设备数的额度,但这个 token 一般有效期为两周,因此只可作临时测试使用。 + + - `INITIUM_IAP_RECEIPT`: 端传媒 iOS 版内购回执认证 token。获取方式:登陆后打开端传媒 iOS app 内任意页面,打开抓包工具,筛选 URL 找到任一个地址为`api.initium.com`开头的请求,点击检查其 “消息头”,在 “请求头” 中找到`X-IAP-Receipt`字段,将其值复制填入配置即可。你的配置应该形如`INITIUM_IAP_RECEIPT: 'ef81dee9e4e2fe084a0af1ea82da2f7b16e75f756db321618a119fa62b52550e'`。 + + Web 版认证 token 和 iOS 内购回执认证 token 只需选择其一填入即可。你也可选择直接在环境设置中填写明文的用户名和密码: + + - `INITIUM_USERNAME`: 端传媒用户名 (邮箱) + - `INITIUM_PASSWORD`: 端传媒密码 + +- 豆瓣想看 + + - `DOUBAN_COOKIE`: 豆瓣登陆后的 Cookie 值 + +- 饭否 全部路由:[申请地址](https://github.com/FanfouAPI/FanFouAPIDoc/wiki/Oauth) + + - `FANFOU_CONSUMER_KEY`: 饭否 Consumer Key + - `FANFOU_CONSUMER_SECRET`: 饭否 Consumer Secret + - `FANFOU_USERNAME`: 饭否登录用户名、邮箱、手机号 + - `FANFOU_PASSWORD`: 饭否密码 - 南方周末付费全文 + - `INFZM_COOKIE`: infzm 账户登陆后的 cookie,目前只需要 `passport_session=...` 即可获取全文 - 轻小说文库 + - `WENKU8_COOKIE`: 登陆轻小说文库后的 cookie -- Google Fonts:[申请地址](https://developers.google.com/fonts/docs/developer_api#a_quick_example) - - `GOOGLE_FONTS_API_KEY`: API key +- 语雀 全部路由:[注册地址](https://www.yuque.com/register) -- 豆瓣想看 - - `DOUBAN_COOKIE`: 豆瓣登陆后的 Cookie 值 + - `YUQUE_TOKEN`: 语雀 Token,[获取地址](https://www.yuque.com/settings/tokens)。语雀接口做了访问频率限制,为保证正常访问建议配置 Token,详见 [语雀开发者文档](https://www.yuque.com/yuque/developer/api#5b3a1535)。 + +- 邮箱 邮件列表路由: + + - `EMAIL_CONFIG_{email}`: 邮箱设置,替换 `{email}` 为 邮箱账号,邮件账户的 `@` 替换为 `.`,例如 `EMAIL_CONFIG_xxx.qq.com`。Linux 内容格式为 `password=密码&host=服务器&port=端口`,docker 内容格式为 `password=密码\&host=服务器\&port=端口`,例如: + - Linux 环境变量:`EMAIL_CONFIG_xxx_qq_com="password=123456&host=imap.qq.com&port=993"` + - docker 环境变量:`EMAIL_CONFIG_xxx_qq_com=password=123456\&host=imap.qq.com\&port=993`,请勿添加引号 `'`,`"`。 + +- 网易云歌单及听歌排行 + + - `NCM_COOKIES`: 网易云音乐登陆后的 cookie 值. + +- 微博 个人时间线路由:[申请地址](https://open.weibo.com/connect) + + - `WEIBO_APP_KEY`: 微博 App Key + - `WEIBO_APP_SECRET`: 微博 App Secret + - `WEIBO_REDIRECT_URL`: 微博登录授权回调地址,默认为 `RSSHub 地址/weibo/timeline/0`,自定义回调地址请确保最后可以转跳到 `RSSHub 地址/weibo/timeline/0?code=xxx` + +- 小宇宙:需要 App 登陆后抓包获取相应数据。 + + - `XIAOYUZHOU_ID`: 即数据包中的 `x-jike-device-id`。 + - `XIAOYUZHOU_TOKEN`: 即数据包中的 `x-jike-refresh-token`。 + +- 新榜 + + - `NEWRANK_COOKIE`: 登陆后的 COOKIE 值,其中 token 是必要的,其他可删除 + +- 喜马拉雅 + + - `XIMALAYA_TOKEN`: 对应 cookie 中的 `1&_token`,获取方式: + 1. 登陆喜马拉雅网页版 + 2. 打开控制台,刷新 + 3. 查找名称为`1&_token`的`cookie`,其内容即为`XIMALAYA_TOKEN`的值(即在`cookie` 中查找 `1&_token=***;`,并设置 `XIMALAYA_TOKEN = ***`) + +- 知乎用户关注时间线 + + - `ZHIHU_COOKIES`: 知乎登录后的 cookie 值. + 1. 可以在知乎网页版的一些请求的请求头中找到,如 `GET /moments` 请求头中的 `cookie` 值. diff --git a/lib/config.js b/lib/config.js index fa66e17ec..337c5d316 100644 --- a/lib/config.js +++ b/lib/config.js @@ -25,83 +25,34 @@ const calculateValue = () => { } value = { + // app config + disallowRobot: envs.DISALLOW_ROBOT !== '0' && envs.DISALLOW_ROBOT !== 'false', + enableCluster: envs.ENABLE_CLUSTER, isPackage: envs.IS_PACKAGE, - noLogfiles: envs.NO_LOGFILES, + nodeName: envs.NODE_NAME, + puppeteerWSEndpoint: envs.PUPPETEER_WS_ENDPOINT, + // network connect: { port: envs.PORT || 1200, // 监听端口 socket: envs.SOCKET || null, // 监听 Unix Socket, null 为禁用 }, + listenInaddrAny: envs.LISTEN_INADDR_ANY || 1, // 是否允许公网连接,取值 0 1 + requestRetry: parseInt(envs.REQUEST_RETRY) || 2, // 请求失败重试次数 + requestTimeout: parseInt(envs.REQUEST_TIMEOUT) || 30000, // Milliseconds to wait for the server to end the response before aborting the request + ua: envs.UA || 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36', + // cors request + allowOrigin: envs.ALLOW_ORIGIN, + // cache cache: { type: typeof envs.CACHE_TYPE === 'undefined' ? 'memory' : envs.CACHE_TYPE, // 缓存类型,支持 'memory' 和 'redis',设为空可以禁止缓存 requestTimeout: parseInt(envs.CACHE_REQUEST_TIMEOUT) || 60, routeExpire: parseInt(envs.CACHE_EXPIRE) || 5 * 60, // 路由缓存时间,单位为秒 contentExpire: parseInt(envs.CACHE_CONTENT_EXPIRE) || 1 * 60 * 60, // 不变内容缓存时间,单位为秒 }, - ua: envs.UA || 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36', - listenInaddrAny: envs.LISTEN_INADDR_ANY || 1, // 是否允许公网连接,取值 0 1 - requestRetry: parseInt(envs.REQUEST_RETRY) || 2, // 请求失败重试次数 - requestTimeout: parseInt(envs.REQUEST_TIMEOUT) || 30000, // Milliseconds to wait for the server to end the response before aborting the request - // 是否显示 Debug 信息,取值 'true' 'false' 'some_string' ,取值为 'true' 时永久显示,取值为 'false' 时永远隐藏,取值为 'some_string' 时请求带上 '?debug=some_string' 显示 - debugInfo: envs.DEBUG_INFO || 'true', - disallowRobot: envs.DISALLOW_ROBOT !== '0' && envs.DISALLOW_ROBOT !== 'false', - titleLengthLimit: parseInt(envs.TITLE_LENGTH_LIMIT) || 150, redis: { url: envs.REDIS_URL || 'redis://localhost:6379/', }, - nodeName: envs.NODE_NAME, - suffix: envs.SUFFIX, - pixiv: { - refreshToken: envs.PIXIV_REFRESHTOKEN, - bypassCdn: envs.PIXIV_BYPASS_CDN !== '0' && envs.PIXIV_BYPASS_CDN !== 'false', - bypassCdnHostname: envs.PIXIV_BYPASS_HOSTNAME || 'public-api.secure.pixiv.net', - bypassCdnDoh: envs.PIXIV_BYPASS_DOH || 'https://1.1.1.1/dns-query', - imgProxy: envs.PIXIV_IMG_PROXY || 'https://i.pixiv.cat', - }, - fanbox: { - session: envs.FANBOX_SESSION_ID, - }, - disqus: { - api_key: envs.DISQUS_API_KEY, - }, - spotify: { - clientId: envs.SPOTIFY_CLIENT_ID, - clientSecret: envs.SPOTIFY_CLIENT_SECRET, - refreshToken: envs.SPOTIFY_REFRESHTOKEN, - }, - twitter: { - consumer_key: envs.TWITTER_CONSUMER_KEY, - consumer_secret: envs.TWITTER_CONSUMER_SECRET, - tokens: twitter_tokens, - authorization: envs.TWITTER_WEBAPI_AUTHORIZAION || 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA', - // 此处硬编码参考自https://github.com/mikf/gallery-dl/blob/master/gallery_dl/extractor/twitter.py#L550 - }, - youtube: { - key: envs.YOUTUBE_KEY, - }, - telegram: { - token: envs.TELEGRAM_TOKEN, - }, - github: { - access_token: envs.GITHUB_ACCESS_TOKEN, - }, - authentication: { - name: envs.HTTP_BASIC_AUTH_NAME || 'usernam3', - pass: envs.HTTP_BASIC_AUTH_PASS || 'passw0rd', - }, - bilibili: { - cookies: bilibili_cookies, - }, - yuque: { - token: envs.YUQUE_TOKEN, - }, - zhihu: { - cookies: envs.ZHIHU_COOKIES, - }, - ncm: { - cookies: envs.NCM_COOKIES || '', - }, - puppeteerWSEndpoint: envs.PUPPETEER_WS_ENDPOINT, - loggerLevel: envs.LOGGER_LEVEL || 'info', + // proxy proxyUri: envs.PROXY_URI, proxy: { protocol: envs.PROXY_PROTOCOL, @@ -110,100 +61,58 @@ const calculateValue = () => { auth: envs.PROXY_AUTH, url_regex: envs.PROXY_URL_REGEX || '.*', }, - allowOrigin: envs.ALLOW_ORIGIN, + // auth + authentication: { + name: envs.HTTP_BASIC_AUTH_NAME || 'usernam3', + pass: envs.HTTP_BASIC_AUTH_PASS || 'passw0rd', + }, + // access control blacklist: envs.BLACKLIST && envs.BLACKLIST.split(','), whitelist: envs.WHITELIST && envs.WHITELIST.split(','), allowLocalhost: envs.ALLOW_LOCALHOST, accessKey: envs.ACCESS_KEY, - enableCluster: envs.ENABLE_CLUSTER, - email: { - config: email_config, - }, + // logging + // 是否显示 Debug 信息,取值 'true' 'false' 'some_string' ,取值为 'true' 时永久显示,取值为 'false' 时永远隐藏,取值为 'some_string' 时请求带上 '?debug=some_string' 显示 + debugInfo: envs.DEBUG_INFO || 'true', + loggerLevel: envs.LOGGER_LEVEL || 'info', + noLogfiles: envs.NO_LOGFILES, sentry: { dsn: envs.SENTRY, routeTimeout: parseInt(envs.SENTRY_ROUTE_TIMEOUT) || 30000, }, - chuiniu: { - member: envs.CHUINIU_MEMBER, - }, - weibo: { - app_key: envs.WEIBO_APP_KEY, - app_secret: envs.WEIBO_APP_SECRET, - redirect_url: envs.WEIBO_REDIRECT_URL, - }, - fanfou: { - consumer_key: envs.FANFOU_CONSUMER_KEY, - consumer_secret: envs.FANFOU_CONSUMER_SECRET, - username: envs.FANFOU_USERNAME, - password: envs.FANFOU_PASSWORD, - }, - lastfm: { - api_key: envs.LASTFM_API_KEY, - }, - pkubbs: { - cookie: envs.PKUBBS_COOKIE, - }, - bupt: { - portal_cookie: envs.BUPT_PORTAL_COOKIE, - }, - nhentai: { - username: envs.NHENTAI_USERNAME, - password: envs.NHENTAI_PASSWORD, - }, - discuz: { - cookies: discuz_cookies, - }, - scihub: { - host: envs.SCIHUB_HOST || 'https://sci-hub.se/', - }, + // feed config hotlink: { template: envs.HOTLINK_TEMPLATE, }, - initium: { - username: envs.INITIUM_USERNAME, - password: envs.INITIUM_PASSWORD, - bearertoken: envs.INITIUM_BEARER_TOKEN, - iap_receipt: envs.INITIUM_IAP_RECEIPT, + suffix: envs.SUFFIX, + titleLengthLimit: parseInt(envs.TITLE_LENGTH_LIMIT) || 150, + + // Route-specific Configurations + bilibili: { + cookies: bilibili_cookies, }, btbyr: { host: envs.BTBYR_HOST, cookies: envs.BTBYR_COOKIE, }, - mastodon: { - apiHost: envs.MASTODON_API_HOST, - accessToken: envs.MASTODON_API_ACCESS_TOKEN, - acctDomain: envs.MASTODON_API_ACCT_DOMAIN, + bupt: { + portal_cookie: envs.BUPT_PORTAL_COOKIE, }, - xiaoyuzhou: { - device_id: envs.XIAOYUZHOU_ID, - refresh_token: envs.XIAOYUZHOU_TOKEN, - }, - miniflux: { - instance: envs.MINIFLUX_INSTANCE || 'https://reader.miniflux.app', - token: envs.MINIFLUX_TOKEN || '', - }, - nga: { - uid: envs.NGA_PASSPORT_UID, - cid: envs.NGA_PASSPORT_CID, - }, - newrank: { - cookie: envs.NEWRANK_COOKIE, - }, - ximalaya: { - token: envs.XIMALAYA_TOKEN, - }, - game4399: { - cookie: envs.GAME_4399, + chuiniu: { + member: envs.CHUINIU_MEMBER, }, dida365: { username: envs.DIDA365_USERNAME, password: envs.DIDA365_PASSWORD, }, - scboy: { - token: envs.SCBOY_BBS_TOKEN, + discuz: { + cookies: discuz_cookies, }, - wordpress: { - cdnUrl: envs.WORDPRESS_CDN, + disqus: { + api_key: envs.DISQUS_API_KEY, + }, + douban: { + cookie: envs.DOUBAN_COOKIE, }, ehentai: { ipb_member_id: envs.EH_IPB_MEMBER_ID, @@ -211,22 +120,124 @@ const calculateValue = () => { sk: envs.EH_SK, igneous: envs.EH_IGNEOUS, }, - infzm: { - cookie: envs.INFZM_COOKIE, + email: { + config: email_config, }, - wenku8: { - cookie: envs.WENKU8_COOKIE, + fanbox: { + session: envs.FANBOX_SESSION_ID, + }, + fanfou: { + consumer_key: envs.FANFOU_CONSUMER_KEY, + consumer_secret: envs.FANFOU_CONSUMER_SECRET, + username: envs.FANFOU_USERNAME, + password: envs.FANFOU_PASSWORD, + }, + game4399: { + cookie: envs.GAME_4399, + }, + github: { + access_token: envs.GITHUB_ACCESS_TOKEN, }, google: { fontsApiKey: envs.GOOGLE_FONTS_API_KEY, }, + infzm: { + cookie: envs.INFZM_COOKIE, + }, + initium: { + username: envs.INITIUM_USERNAME, + password: envs.INITIUM_PASSWORD, + bearertoken: envs.INITIUM_BEARER_TOKEN, + iap_receipt: envs.INITIUM_IAP_RECEIPT, + }, instagram: { username: envs.IG_USERNAME, password: envs.IG_PASSWORD, proxy: envs.IG_PROXY, }, - douban: { - cookie: envs.DOUBAN_COOKIE, + lastfm: { + api_key: envs.LASTFM_API_KEY, + }, + mastodon: { + apiHost: envs.MASTODON_API_HOST, + accessToken: envs.MASTODON_API_ACCESS_TOKEN, + acctDomain: envs.MASTODON_API_ACCT_DOMAIN, + }, + miniflux: { + instance: envs.MINIFLUX_INSTANCE || 'https://reader.miniflux.app', + token: envs.MINIFLUX_TOKEN || '', + }, + ncm: { + cookies: envs.NCM_COOKIES || '', + }, + newrank: { + cookie: envs.NEWRANK_COOKIE, + }, + nga: { + uid: envs.NGA_PASSPORT_UID, + cid: envs.NGA_PASSPORT_CID, + }, + nhentai: { + username: envs.NHENTAI_USERNAME, + password: envs.NHENTAI_PASSWORD, + }, + pixiv: { + refreshToken: envs.PIXIV_REFRESHTOKEN, + bypassCdn: envs.PIXIV_BYPASS_CDN !== '0' && envs.PIXIV_BYPASS_CDN !== 'false', + bypassCdnHostname: envs.PIXIV_BYPASS_HOSTNAME || 'public-api.secure.pixiv.net', + bypassCdnDoh: envs.PIXIV_BYPASS_DOH || 'https://1.1.1.1/dns-query', + imgProxy: envs.PIXIV_IMG_PROXY || 'https://i.pixiv.cat', + }, + pkubbs: { + cookie: envs.PKUBBS_COOKIE, + }, + scboy: { + token: envs.SCBOY_BBS_TOKEN, + }, + scihub: { + host: envs.SCIHUB_HOST || 'https://sci-hub.se/', + }, + spotify: { + clientId: envs.SPOTIFY_CLIENT_ID, + clientSecret: envs.SPOTIFY_CLIENT_SECRET, + refreshToken: envs.SPOTIFY_REFRESHTOKEN, + }, + telegram: { + token: envs.TELEGRAM_TOKEN, + }, + twitter: { + consumer_key: envs.TWITTER_CONSUMER_KEY, + consumer_secret: envs.TWITTER_CONSUMER_SECRET, + tokens: twitter_tokens, + authorization: envs.TWITTER_WEBAPI_AUTHORIZAION || 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA', + // 此处硬编码参考自https://github.com/mikf/gallery-dl/blob/master/gallery_dl/extractor/twitter.py#L550 + }, + weibo: { + app_key: envs.WEIBO_APP_KEY, + app_secret: envs.WEIBO_APP_SECRET, + redirect_url: envs.WEIBO_REDIRECT_URL, + }, + wenku8: { + cookie: envs.WENKU8_COOKIE, + }, + wordpress: { + cdnUrl: envs.WORDPRESS_CDN, + }, + xiaoyuzhou: { + device_id: envs.XIAOYUZHOU_ID, + refresh_token: envs.XIAOYUZHOU_TOKEN, + }, + ximalaya: { + token: envs.XIMALAYA_TOKEN, + }, + youtube: { + key: envs.YOUTUBE_KEY, + }, + yuque: { + token: envs.YUQUE_TOKEN, + }, + zhihu: { + cookies: envs.ZHIHU_COOKIES, }, }; };