dahlia / hollo

Federated single-user microblogging software
https://docs.hollo.social/
GNU Affero General Public License v3.0
236 stars 16 forks source link

Enable setting the port and allowPrivateAddress through environment vars #53

Closed HelgeKrueger closed 3 weeks ago

HelgeKrueger commented 3 weeks ago

By setting

  BEHIND_PROXY: "true"
  HOLLO_PORT: 80
  ALLOW_PRIVATE_ADDRESS: "true"

one allows private addresses and runs on port 80.

Summary by CodeRabbit

coderabbitai[bot] commented 3 weeks ago

[!WARNING]

Rate limit exceeded

@dahlia has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 23 minutes and 18 seconds before requesting another review.

⌛ How to resolve this issue? After the wait time has elapsed, a review can be triggered using the `@coderabbitai review` command as a PR comment. Alternatively, push new commits to this PR. We recommend that you space out your commits to avoid hitting the rate limit.
🚦 How do rate limits work? CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our [FAQ](https://coderabbit.ai/docs/faq) for further information.
📥 Commits Reviewing files that changed from the base of the PR and between 06da44dfe9b33ace6018ef6814138a9f1dae0ddc and 4fd03b957538415f5cf5929deb4927fe26f51915.

Walkthrough

The changes introduce a new property allowPrivateAddress in src/federation/index.ts, determined by the environment variable ALLOW_PRIVATE_ADDRESS. In src/index.tsx, a constant LISTEN_PORT is added, retrieving its value from the environment variable LISTEN_PORT, defaulting to 3000. This constant is incorporated into the export statement, modifying the exported object to include both the fetch method and the new port property when BEHIND_PROXY is true. The .env.sample file is also updated to include these new environment variables.

Changes

File Change Summary
src/federation/index.ts Added allowPrivateAddress to createFederation based on ALLOW_PRIVATE_ADDRESS environment variable.
src/index.tsx Introduced LISTEN_PORT constant from LISTEN_PORT environment variable, defaulting to 3000. Modified export to include fetch and port properties.
.env.sample Added new environment variables LISTEN_PORT=3000 and ALLOW_PRIVATE_ADDRESS=false with comments.
CHANGES.md Documented the addition of LISTEN_PORT and ALLOW_PRIVATE_ADDRESS environment variables.
docs/src/content/docs/install/env.mdx Updated documentation to include LISTEN_PORT and ALLOW_PRIVATE_ADDRESS with descriptions and defaults.
docs/src/content/docs/ja/install/env.mdx Updated Japanese documentation to include LISTEN_PORT and ALLOW_PRIVATE_ADDRESS with descriptions.
docs/src/content/docs/ko/install/env.mdx Updated Korean documentation to include LISTEN_PORT and ALLOW_PRIVATE_ADDRESS with descriptions.
docs/src/content/docs/zh-cn/install/env.mdx Updated Chinese documentation to include LISTEN_PORT and ALLOW_PRIVATE_ADDRESS with descriptions.

Possibly related PRs

Poem

In the code where rabbits play,
New properties hop in today!
A port to fetch, a flag to see,
Private addresses, oh so free!
With each change, we leap and cheer,
For better code is finally here! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
🪧 Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: - `I pushed a fix in commit , please review it.` - `Generate unit testing code for this file.` - `Open a follow-up GitHub issue for this discussion.` - Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples: - `@coderabbitai generate unit testing code for this file.` - `@coderabbitai modularize this function.` - PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples: - `@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.` - `@coderabbitai read src/utils.ts and generate unit testing code.` - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.` - `@coderabbitai help me debug CodeRabbit configuration file.` Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. ### CodeRabbit Commands (Invoked using PR comments) - `@coderabbitai pause` to pause the reviews on a PR. - `@coderabbitai resume` to resume the paused reviews. - `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository. - `@coderabbitai full review` to do a full review from scratch and review all the files again. - `@coderabbitai summary` to regenerate the summary of the PR. - `@coderabbitai resolve` resolve all the CodeRabbit review comments. - `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository. - `@coderabbitai help` to get help. ### Other keywords and placeholders - Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed. - Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description. - Add `@coderabbitai` anywhere in the PR title to generate the title automatically. ### CodeRabbit Configuration File (`.coderabbit.yaml`) - You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository. - Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information. - If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json` ### Documentation and Community - Visit our [Documentation](https://coderabbit.ai/docs) for detailed information on how to use CodeRabbit. - Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.
ThisIsMissEm commented 3 weeks ago

An option like this does make sense, however, it should be a comma separated string of private IP addresses or ranges not to enforce checking on, not a simple Boolean value.

e.g., https://docs.joinmastodon.org/admin/config/#allowed_private_addresses

HelgeKrueger commented 3 weeks ago

Added change to .env.sample

I also created https://github.com/dahlia/fedify/issues/157

HelgeKrueger commented 3 weeks ago

It is strange when I run biome, there is no erro rrmessage ...

docker compose run --rm hollo bunx biome check
WARN[0000] The "LOG_LEVEL" variable is not set. Defaulting to a blank string. 
WARN[0000] The "BEHIND_PROXY" variable is not set. Defaulting to a blank string. 
WARN[0000] The "SECRET_KEY" variable is not set. Defaulting to a blank string. 
[+] Creating 3/0
 ✔ Container hollo-minio-1          Running                                                                                                                         0.0s 
 ✔ Container hollo-postgres-1       Running                                                                                                                         0.0s 
 ✔ Container hollo-create-bucket-1  Created                                                                                                                         0.0s 
[+] Running 1/1
 ✔ Container hollo-create-bucket-1  Started                                                                                                                         0.2s 
Checked 77 files in 1322ms. No fixes applied.
dahlia commented 3 weeks ago

These errors came from TypeScript (bunx tsc):

src/federation/index.ts(112,36): error TS4111: Property 'ALLOW_PRIVATE_ADDRESS' comes from an index signature, so it must be accessed with ['ALLOW_PRIVATE_ADDRESS'].
src/index.tsx(34,48): error TS4111: Property 'LISTEN_PORT' comes from an index signature, so it must be accessed with ['LISTEN_PORT'].
HelgeKrueger commented 3 weeks ago

Sorry, for needing so many tries to get everything working. I still cannot get biome working in the docker environment. But it works on the host. Not sure what is going on.

As far as tsc, I get the errors. Are they expected?

/app # bunx tsc
src/components/AccountForm.tsx:28:11 - error TS2322: Type 'string' is not assignable to type 'HTMLAttributeFormMethod | undefined'.

28     <form method={props.method ?? "post"} action={props.action}>
             ~~~~~~

  node_modules/hono/dist/types/jsx/intrinsic-elements.d.ts:272:9
    272         method?: HTMLAttributeFormMethod | undefined;
                ~~~~~~
    The expected type comes from property 'method' which is declared here on type 'FormHTMLAttributes'

src/components/LoginForm.tsx:16:11 - error TS2322: Type 'string' is not assignable to type 'HTMLAttributeFormMethod | undefined'.

16     <form method={props.method ?? "post"} action={props.action}>
             ~~~~~~

  node_modules/hono/dist/types/jsx/intrinsic-elements.d.ts:272:9
    272         method?: HTMLAttributeFormMethod | undefined;
                ~~~~~~
    The expected type comes from property 'method' which is declared here on type 'FormHTMLAttributes'

src/components/OtpForm.tsx:12:11 - error TS2322: Type 'string' is not assignable to type 'HTMLAttributeFormMethod | undefined'.

12     <form method={props.method ?? "post"} action={props.action}>
             ~~~~~~

  node_modules/hono/dist/types/jsx/intrinsic-elements.d.ts:272:9
    272         method?: HTMLAttributeFormMethod | undefined;
                ~~~~~~
    The expected type comes from property 'method' which is declared here on type 'FormHTMLAttributes'

src/components/SetupForm.tsx:16:11 - error TS2322: Type 'string' is not assignable to type 'HTMLAttributeFormMethod | undefined'.

16     <form method={props.method ?? "post"} action={props.action}>
             ~~~~~~

  node_modules/hono/dist/types/jsx/intrinsic-elements.d.ts:272:9
    272         method?: HTMLAttributeFormMethod | undefined;
                ~~~~~~
    The expected type comes from property 'method' which is declared here on type 'FormHTMLAttributes'

Found 4 errors in 4 files.

Errors  Files
     1  src/components/AccountForm.tsx:28
     1  src/components/LoginForm.tsx:16
     1  src/components/OtpForm.tsx:12
     1  src/components/SetupForm.tsx:16
dahlia commented 3 weeks ago

Did you run bun install?