Skip to content

Plugin for geo-restricting the access to the server#203

Open
gzsombor wants to merge 1 commit into
vicanso:mainfrom
gzsombor:feature/geo-blocker
Open

Plugin for geo-restricting the access to the server#203
gzsombor wants to merge 1 commit into
vicanso:mainfrom
gzsombor:feature/geo-blocker

Conversation

@gzsombor

Copy link
Copy Markdown
Contributor

Allow or deny list, or just reporting to the logs

🎉 Welcome to Pingap! / 欢迎贡献 Pingap!

🇬🇧 English

Thank you for taking the time to contribute to Pingap! 🦀

⚠️ IMPORTANT CONTRIBUTING GUIDELINES:

  1. New Features: Before writing code for a new feature, please open an Issue first to discuss it. This ensures it aligns with our roadmap and saves your time!
  2. Typos & Grammar: Please DO NOT open PRs solely for fixing minor typos, formatting, or grammar issues in documentation/comments. We prefer to batch these or fix them alongside larger code changes.

To help us review your Pull Request efficiently, please provide the following information.

Description

Type of Change

  • ✨ New feature

Developer Checklist

  • I have run cargo fmt to format the code.
  • I have run cargo clippy and resolved any warnings.
  • My code builds and runs successfully.
  • ⚖️ I have read and agree to the Pingap Contributor License Agreement, confirming my contribution is original and licensed under the project's open-source terms.
  • (Optional) I have tested this on: [ ] macOS / [X] Linux.

Allow or deny list, or just reporting to the logs
@vicanso

vicanso commented Jun 6, 2026

Copy link
Copy Markdown
Owner
  1. Stop creating new Strings for every request
    In handle_request, using .to_string() creates a new string every time, which slows down the proxy. Since lookup_country_code already returns a text reference (&str), you should use that directly to save memory and improve speed.

  2. Load the GeoIP database only once
    Right now, if this plugin is used in multiple places, it loads the whole database into memory multiple times. You should use std::sync::LazyLock to make the database global. This way, it only loads once and all plugins share it, which saves memory and makes startup much faster.

  3. Replace the embedded DB with MaxMind DB (.mmdb)

Allow users to specify an external .mmdb file path in their configuration (e.g., db_path = "/path/to/geo.mmdb").

Why it's better:

  • Customizable: Users can easily inject their own custom IP rules into the .mmdb file.
  • Hot-Updatable: You can update the GeoIP database file on the server at any time without needing to recompile the proxy.
  • Memory Efficient: The maxminddb crate reads files very efficiently without blowing up your RAM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants