support/gobds: Support GoBDS & add VPN Blocker. #11
No reviewers
Labels
No labels
blocked
bug
dependencies
documentation
duplicate
enhancement
github_actions
go
good first issue
help wanted
in-progress
invalid
question
ready-to-fix
source:discord
source:sentry
source:server-logs
triage-needed
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
pokebedrock/pokebedrock-hub!11
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "support/gobds"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
https://github.com/smell-of-curry/gobds
Summary by CodeRabbit
New Features
Improvements
Bug Fixes
Walkthrough
These changes introduce an HTTP authentication service using the Gin web framework, adding an endpoint to validate player identities. A thread-safe singleton factory manages player identities with expiration, and player authentication requests are registered upon successful server transfer. Configuration is extended to support authentication parameters, a VPN check service is integrated, and dependencies are updated in
go.mod.Changes
golang.org/x/textand several indirect dependencies; added new indirect dependencies including Gin.PlayerIdentitystruct.GinAddress,VpnURL,AuthenticationPrefix, andAuthenticationKeyfields to config; set defaults.Sequence Diagram(s)
Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
I pushed a fix in commit <commit_id>, please review it.Explain this complex logic.Open a follow-up GitHub issue for this discussion.@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai explain this code block.@coderabbitai modularize this function.@coderabbitaiin 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 explain its main purpose.@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.Support
Need help? Create a ticket on our support page for assistance with any issues or questions.
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 pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai generate docstringsto generate docstrings for this PR.@coderabbitai generate sequence diagramto generate a sequence diagram of the changes in this PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.Other keywords and placeholders
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed.@coderabbitai summaryto generate the high-level summary at a specific location in the PR description.@coderabbitaianywhere in the PR title to generate the title automatically.CodeRabbit Configuration File (
.coderabbit.yaml).coderabbit.yamlfile to the root of your repository.# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.jsonDocumentation and Community
Actionable comments posted: 5
🧹 Nitpick comments (4)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between
298c2748e5ande6ddedaccb.⛔ Files ignored due to path filters (1)
go.sumis excluded by!**/*.sum📒 Files selected for processing (6)
go.mod(1 hunks)pokebedrock/authentication/factory.go(1 hunks)pokebedrock/authentication/identity.go(1 hunks)pokebedrock/config.go(3 hunks)pokebedrock/pokebedrock.go(3 hunks)pokebedrock/queue/manager.go(2 hunks)🧰 Additional context used
🧬 Code Graph Analysis (3)
pokebedrock/config.go (2)
pokebedrock/authentication/factory.go (1)
pokebedrock/pokebedrock.go (1)
🔇 Additional comments (6)
@ -0,0 +1,72 @@package authentication🛠️ Refactor suggestion
Address hardcoded cleanup interval and lifecycle management.
The initialization has a hardcoded cleanup interval and lacks proper lifecycle management.
Consider making the cleanup interval configurable and add proper shutdown:
Also, consider adding a
Stop()method to the Factory to gracefully shutdown the cleanup goroutine.📝 Committable suggestion
🤖 Prompt for AI Agents
🛠️ Refactor suggestion
⚠️ Potential issue
Fix variable naming and add goroutine lifecycle management.
The cleanup routine has a variable naming issue and lacks proper shutdown mechanism.
Issues identified:
nameshould bexuidas it represents the XUID keyApply this fix:
Consider adding a shutdown mechanism to the Factory:
📝 Committable suggestion
🤖 Prompt for AI Agents
🛠️ Refactor suggestion
Fix URL format inconsistency for better consistency.
The
AuthenticationURLdefault value lacks the protocol prefix, which is inconsistent with other service URLs in the configuration.Apply this diff to maintain consistency:
📝 Committable suggestion
🤖 Prompt for AI Agents
🛠️ Refactor suggestion
Address goroutine lifecycle management.
The authentication service goroutine lacks proper lifecycle management. Consider the following issues:
Consider this approach for better lifecycle management:
Also, ensure the HTTP server is gracefully shut down in the
Close()method.📝 Committable suggestion
🤖 Prompt for AI Agents
🛠️ Refactor suggestion
Improve security and error handling in the authentication service.
The implementation has several areas for improvement:
AuthenticationKeyis empty, which would allow unauthorized accessApply these improvements:
Don't forget to add
fmtimport for the error formatting.🤖 Prompt for AI Agents
@ -0,0 +1,72 @@package authenticationwill apply this right now
@ -0,0 +1,72 @@package authentication@glancist Thank you for the quick response! I appreciate you taking action on the refactor suggestions. The variable naming fix and goroutine lifecycle management will definitely improve the code quality and prevent potential resource leaks.
( ✌️ )
|(_)|
If you found this review helpful, would you consider giving us a shout-out on X?
Thank you for using CodeRabbit!
Actionable comments posted: 6
🧹 Nitpick comments (4)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between
32cd72030fand43f310be35.📒 Files selected for processing (5)
pokebedrock/allower.go(2 hunks)pokebedrock/config.go(3 hunks)pokebedrock/pokebedrock.go(6 hunks)pokebedrock/vpn/model.go(1 hunks)pokebedrock/vpn/service.go(1 hunks)✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (2)
🧰 Additional context used
🧬 Code Graph Analysis (1)
pokebedrock/vpn/service.go (2)
🔇 Additional comments (1)
@ -27,3 +32,29 @@ func (Allower) Allow(_ net.Addr, d login.IdentityData, _ login.ClientData) (stri}⚠️ Potential issue
Fix inverted logic in the return statement.
The current logic returns
m.Proxyas theallowedvalue, which means connections are allowed when a proxy is detected. This appears to be inverted.📝 Committable suggestion
🤖 Prompt for AI Agents
🛠️ Refactor suggestion
Add IPv6 localhost check.
The current implementation only checks for IPv4 localhost addresses but misses IPv6 localhost (::1).
🤖 Prompt for AI Agents
⚠️ Potential issue
Handle the error from ParseAddrPort.
The error from
netip.ParseAddrPortis ignored, which could lead to unexpected behavior if the address format is invalid.🤖 Prompt for AI Agents
@ -0,0 +1,154 @@package vpn🛠️ Refactor suggestion
Avoid closing response body multiple times.
The response body is closed in multiple places which could cause issues. Use defer for cleaner resource management.
Also applies to: 113-113
🤖 Prompt for AI Agents
@ -0,0 +51,4 @@maxRetries = 3retryDelay = 1 * time.SecondrequestTimeout = 5 * time.Second)🛠️ Refactor suggestion
Align retry logic with maxRetries constant.
The
maxRetriesconstant is set to 3, but the loop only allows 2 attempts (0 and 1). Either update the constant or fix the loop condition.Or alternatively:
Also applies to: 66-66
🤖 Prompt for AI Agents
@ -0,0 +74,4 @@time.Sleep(retryDelay)}url := fmt.Sprintf("%s/%s?fields=status,message,proxy", s.url, ip)💡 Verification agent
🧩 Analysis chain
Validate IP parameter before URL construction.
The IP parameter is directly interpolated into the URL without validation, which could lead to injection vulnerabilities if the IP comes from untrusted sources.
Consider adding IP validation:
🏁 Script executed:
Length of output: 1281
🏁 Script executed:
Length of output: 317
🏁 Script executed:
Length of output: 147
🏁 Script executed:
Length of output: 4365
Add IP format validation in CheckIP before URL construction
The
ipparameter is directly interpolated into the request URL without any validation. Injecting malformed or unexpected values could lead to security or correctness issues. I’ve confirmed:net.ParseIP(or equivalent) check anywhere inCheckIP.Please update
pokebedrock/vpn/service.goaround line 57:📝 Committable suggestion
🤖 Prompt for AI Agents
Actionable comments posted: 1
🧹 Nitpick comments (1)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between
9d7cc02626anda7919ac457.⛔ Files ignored due to path filters (1)
go.sumis excluded by!**/*.sum📒 Files selected for processing (1)
go.mod(2 hunks)🔇 Additional comments (1)
@ -18,30 +20,48 @@ require (🛠️ Refactor suggestion
Let
go mod tidymanage indirect requirements instead of pinning them manually.Every line marked
// indirectbelow was added explicitly. That locks ~30 transient modules to the current versions and obscures which ones are truly needed. Prefer the canonical pattern:go mod tidyto let the tool infer the minimal set.go.mod/go.sum.Example patch (abridged):
This keeps the module file concise and avoids supply-chain drift.
If deterministic builds are required, consider a
go.workfile or a lockfile instead.Also applies to: 26-34, 37-48, 50-57, 59-63
🤖 Prompt for AI Agents
Pull Request Overview
This PR integrates VPN detection and blocking into the hub, adds an HTTP-based authentication service for GoBDS, and expands configuration to support these features.
Reviewed Changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
Comments suppressed due to low confidence (1)
pokebedrock/vpn/service.go:69
rangeon an integer causes a compile error; you should use a C-style loop such asfor attempt := 0; attempt < maxRetries; attempt++ {}.@ -27,3 +32,29 @@ func (Allower) Allow(_ net.Addr, d login.IdentityData, _ login.ClientData) (stri}When
m.Proxyis false (no VPN detected), you still return a non-empty reason; this may confuse consumers. Only return the block message whenm.Proxyis true, otherwise return an empty reason.@ -57,6 +62,12 @@ func NewPokeBedrock(log *slog.Logger, conf Config) (*PokeBedrock, error) {c: make(chan struct{}),Capturing and reusing the outer
errvariable inside the goroutine may cause a data race; declare a newerrinside the closure (e.g.,if err := poke.setupGin(); err != nil { ... }).@ -0,0 +1,154 @@package vpnThe
closedflag is accessed without synchronization, which can lead to a race condition whenStop()is called; consider protecting it withmuor using an atomic boolean.Actionable comments posted: 2
♻️ Duplicate comments (1)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between
a7919ac457and2a9a126a9f.⛔ Files ignored due to path filters (1)
go.sumis excluded by!**/*.sum📒 Files selected for processing (6)
config.toml.example(1 hunks)go.mod(2 hunks)pokebedrock/allower.go(2 hunks)pokebedrock/pokebedrock.go(6 hunks)pokebedrock/queue/manager.go(2 hunks)pokebedrock/vpn/service.go(1 hunks)✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (3)
🧰 Additional context used
🧬 Code Graph Analysis (1)
pokebedrock/vpn/service.go (2)
🔇 Additional comments (4)
@ -0,0 +12,4 @@"sync/atomic""time""github.com/go-jose/go-jose/v4/json"💡 Verification agent
🧩 Analysis chain
Clarify the use of go-jose/json instead of standard encoding/json.
The import uses
github.com/go-jose/go-jose/v4/jsoninstead of the standard libraryencoding/json. This is unusual and may indicate a specific requirement.Please verify if this custom JSON package is necessary for the VPN service functionality, or if the standard library should be used:
🌐 Web query:
💡 Result:
The primary difference between go-jose/go-jose/v4/json and Go's standard encoding/json package is that go-jose/go-jose/v4/json is a custom fork of encoding/json with important behavioral changes to support the unique requirements of the JOSE (Javascript Object Signing and Encryption) standards.
Here are the key differences:
1. Case Sensitivity in Field Matching
2. Duplicate Key Rejection
3. Standards Compliance
4. Origin and Stability
encoding/json—it may lack recent bug fixes and performance improvements present in newer Go releases[4][5].Summary Table
When should you use go-jose/go-jose/v4/json?
Use it only when working with JOSE (JWT, JWE, JWS) data, as these stricter behaviors are required for correct cryptographic processing and security interoperability. For general-purpose JSON in Go, encoding/json is recommended[2][4][5].
Citations:
Add comment explaining use of go-jose’s JSON fork for JOSE compliance
This import isn’t a stray replacement of the standard library—it’s required to enforce case-sensitive field matching and reject duplicate keys when handling JOSE data (JWT/JWE/JWS). Please document this intent in the code.
• File: pokebedrock/vpn/service.go
Line: 15
Suggested diff:
📝 Committable suggestion
🤖 Prompt for AI Agents
@ -0,0 +91,4 @@}return nil, lastErr}defer response.Body.Close()🛠️ Refactor suggestion
Fix defer placement to avoid resource leak in retry loop.
The
defer response.Body.Close()statement inside the retry loop can accumulate multiple defers, potentially causing resource issues if many retries occur.Move the defer inside each case block or use an explicit close:
📝 Committable suggestion
🤖 Prompt for AI Agents