Skip to content

feat(proxy): add allow_hosts whitelist for restricting relay access#39

Open
mkarim1378 wants to merge 1 commit intomasterking32:python_testingfrom
mkarim1378:feature/whitelist
Open

feat(proxy): add allow_hosts whitelist for restricting relay access#39
mkarim1378 wants to merge 1 commit intomasterking32:python_testingfrom
mkarim1378:feature/whitelist

Conversation

@mkarim1378
Copy link
Copy Markdown

Add an opt-in per-host whitelist that, when non-empty, causes the proxy to return HTTP 403 for any host not explicitly listed. Empty by default so existing behavior is unchanged.

  • Add allow_hosts config key to config.example.json (default: [])
  • Load _allow_hosts rules in ProxyServer.init alongside block/bypass
  • Add _is_whitelisted() method using the existing _host_matches_rules() engine (supports exact hostnames and leading-dot suffix patterns)
  • Insert whitelist check in _handle_target_tunnel() after the bypass check so bypass_hosts entries (e.g. .local, .lan) are always reachable regardless of whitelist contents

Routing order is now: block → bypass → whitelist → normal routing

Add an opt-in per-host whitelist that, when non-empty, causes the proxy
to return HTTP 403 for any host not explicitly listed. Empty by default
so existing behavior is unchanged.

- Add `allow_hosts` config key to config.example.json (default: [])
- Load `_allow_hosts` rules in ProxyServer.__init__ alongside block/bypass
- Add _is_whitelisted() method using the existing _host_matches_rules()
  engine (supports exact hostnames and leading-dot suffix patterns)
- Insert whitelist check in _handle_target_tunnel() *after* the bypass
  check so bypass_hosts entries (e.g. .local, .lan) are always reachable
  regardless of whitelist contents

Routing order is now: block → bypass → whitelist → normal routing
Copy link
Copy Markdown

@MOJISELFISH MOJISELFISH left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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