add custom twikoo host config for self-hosted#969
Merged
Conversation
Contributor
审阅者指南(在小型 PR 上折叠)审阅者指南新增一个 文件级变更
技巧与命令与 Sourcery 交互
自定义你的体验访问你的 控制面板 来:
获取帮助Original review guide in EnglishReviewer's guide (collapsed on small PRs)Reviewer's GuideAdds a new TWIKOO_HOST environment variable to control the bind host of the self-hosted server, wiring it into the Node HTTP server listen call and documenting its behavior alongside existing env vars. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Hey - 我在这里给出了一些总体反馈:
- 由于现在
TWIKOO_HOST会覆盖TWIKOO_LOCALHOST_ONLY,建议在环境变量表中明确记录这一优先级,这样当两个变量同时设置时,用户能清楚知道是哪一个生效。 - 文档中将
TWIKOO_HOST的默认值写为null,但实际运行时会回退到localhost或::;为避免混淆,可能更清晰的做法是描述真实的回退行为,而不是写成null。
给 AI 助手的提示
Please address the comments from this code review:
## Overall Comments
- Since `TWIKOO_HOST` now overrides `TWIKOO_LOCALHOST_ONLY`, consider explicitly documenting this precedence in the env var table so users understand which setting wins when both are set.
- The docs list `TWIKOO_HOST` default as `null`, but the runtime behavior falls back to `localhost` or `::`; it may be clearer to describe the actual fallback behavior rather than `null` to avoid confusion.帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进以后的评审。
Original comment in English
Hey - I've left some high level feedback:
- Since
TWIKOO_HOSTnow overridesTWIKOO_LOCALHOST_ONLY, consider explicitly documenting this precedence in the env var table so users understand which setting wins when both are set. - The docs list
TWIKOO_HOSTdefault asnull, but the runtime behavior falls back tolocalhostor::; it may be clearer to describe the actual fallback behavior rather thannullto avoid confusion.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Since `TWIKOO_HOST` now overrides `TWIKOO_LOCALHOST_ONLY`, consider explicitly documenting this precedence in the env var table so users understand which setting wins when both are set.
- The docs list `TWIKOO_HOST` default as `null`, but the runtime behavior falls back to `localhost` or `::`; it may be clearer to describe the actual fallback behavior rather than `null` to avoid confusion.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Contributor
Author
|
@sourcery-ai review |
Contributor
There was a problem hiding this comment.
Hey - 我在这里给出一些高层次的反馈:
- 建议把显式为空的
TWIKOO_HOST(例如TWIKOO_HOST='')视为无效配置,而不是静默地回退到::。比如,可以在传入server.listen之前先对该值进行 trim 和校验,这样更容易发现配置错误。 - 文档中写的是
TWIKOO_HOST的默认值为null,但运行时行为实际上会回退到::;为了避免概念默认值和实际默认行为之间的混淆,或许可以直接用“最终监听地址”的角度来描述默认值(例如“未设置 → 行为等同于::”)。
给 AI 代理的提示
Please address the comments from this code review:
## Overall Comments
- Consider treating an explicitly empty `TWIKOO_HOST` (e.g. `TWIKOO_HOST=''`) as invalid rather than silently falling back to `::`, for example by trimming and validating the value before passing it to `server.listen` so misconfigurations are easier to spot.
- The docs say `TWIKOO_HOST` default is `null` but runtime behavior is a fallback to `::`; it may be clearer to describe the default directly in terms of the effective listen address (e.g. “unset → behaves as `::`”) to avoid confusion between conceptual and actual defaults.帮我变得更有用!请在每条评论上点击 👍 或 👎,我会根据你的反馈改进后续评审。
Original comment in English
Hey - I've left some high level feedback:
- Consider treating an explicitly empty
TWIKOO_HOST(e.g.TWIKOO_HOST='') as invalid rather than silently falling back to::, for example by trimming and validating the value before passing it toserver.listenso misconfigurations are easier to spot. - The docs say
TWIKOO_HOSTdefault isnullbut runtime behavior is a fallback to::; it may be clearer to describe the default directly in terms of the effective listen address (e.g. “unset → behaves as::”) to avoid confusion between conceptual and actual defaults.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider treating an explicitly empty `TWIKOO_HOST` (e.g. `TWIKOO_HOST=''`) as invalid rather than silently falling back to `::`, for example by trimming and validating the value before passing it to `server.listen` so misconfigurations are easier to spot.
- The docs say `TWIKOO_HOST` default is `null` but runtime behavior is a fallback to `::`; it may be clearer to describe the default directly in terms of the effective listen address (e.g. “unset → behaves as `::`”) to avoid confusion between conceptual and actual defaults.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
动机
添加环境变量 TWIKOO_HOST 支持指定 server binding 的 ip 地址
原因:在支持 IPV6 的vps上,禁用IPv6后(gemini对IPV6的来源流量审查特别严格),tkserver binding
::会启动失败修改前:
5/26/2026, 2:40:18 AM Twikoo: Connecting to database... node:events:486 throw er; // Unhandled 'error' event ^ Error: listen EAFNOSUPPORT: address family not supported :::8080 at Server.setupListenHandle [as _listen2] (node:net:1918:21) at listenInCluster (node:net:1997:12) at node:net:2206:7 at process.processTicksAndRejections (node:internal/process/task_queues:89:21) Emitted 'error' event on Server instance at: at emitErrorNT (node:net:1976:8) at process.processTicksAndRejections (node:internal/process/task_queues:89:21) { code: 'EAFNOSUPPORT', errno: -97, syscall: 'listen', address: '::', port: 8080 } Node.js v24.11.1修改后:
启动命令:
输出:
Summary by Sourcery
为自托管的 Twikoo 服务器新增可配置的主机绑定,并在文档中说明新的环境变量。
新特性:
TWIKOO_HOST环境变量,用于自定义自托管服务器监听的主机/IP 地址;当设置该变量时,其优先级高于TWIKOO_LOCALHOST_ONLY。文档:
TWIKOO_HOST环境变量的说明,包括其行为和使用示例。Original summary in English
Summary by Sourcery
Add configurable host binding for the self-hosted Twikoo server and document the new environment variable.
New Features:
Documentation:
Original summary in English
Summary by Sourcery
为自托管的 Twikoo 服务器新增可配置的主机绑定,并在文档中说明新的环境变量。
新特性:
TWIKOO_HOST环境变量,用于自定义自托管服务器监听的主机/IP 地址;当设置该变量时,其优先级高于TWIKOO_LOCALHOST_ONLY。文档:
TWIKOO_HOST环境变量的说明,包括其行为和使用示例。Original summary in English
Summary by Sourcery
Add configurable host binding for the self-hosted Twikoo server and document the new environment variable.
New Features:
Documentation: