Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Runtime placeholders for selected TLS and HTTP matchers #6480

Merged
merged 5 commits into from
Aug 7, 2024

Conversation

vnxme
Copy link
Contributor

@vnxme vnxme commented Jul 26, 2024

This PR follows mholt/caddy-l4#224 and deals with the following mainline matchers only:

  • caddytls.MatchLocalIP
  • caddytls.MatchRemoteIP
  • caddytls.MatchServerName
  • caddyhttp.MatchClientIP
  • caddyhttp.MatchRemoteIP

These changes allow to use runtime placeholders with TLS and HTTP IP matchers, e.g. remote_ip {env.VAR}. Such placeholders, if present, are evaluated once at provision due to the existing optimisations.

In addition, this PR adds runtime placeholders support for TLS SNI matcher, e.g. sni {env.VAR}. Contrary to the above, such placeholders are evaluated each time at match.

vnxme added 4 commits July 26, 2024 23:05
- remove IPs validation in UnmarshalCaddyfile
- add placeholder replacement for IPs in Provision
- add placeholder replacement for other strings
- add placeholder replacement for IPs in Provision
Copy link
Member

@mohammed90 mohammed90 left a comment

Choose a reason for hiding this comment

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

I think the caddy.Context available in Provision contains a replacer already, and it may have some values set already. Try using the existing replacer.

modules/caddytls/matchers.go Outdated Show resolved Hide resolved
@vnxme
Copy link
Contributor Author

vnxme commented Jul 28, 2024

I think the caddy.Context available in Provision contains a replacer already, and it may have some values set already. Try using the existing replacer.

So did I think, but I checked the context, and it's basically empty at provision. I use the existing replacer at match.

- move PrivateRandesCIDR under internal
Copy link
Member

@mholt mholt left a comment

Choose a reason for hiding this comment

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

This LGTM. Nice idea to move the PrivateRangesCIDR function into an internal package.

@mholt mholt merged commit 59cbb2c into caddyserver:master Aug 7, 2024
23 checks passed
vnxme added a commit to vnxme/caddy that referenced this pull request Aug 11, 2024
vnxme added a commit to vnxme/caddy that referenced this pull request Aug 11, 2024
mohammed90 pushed a commit that referenced this pull request Aug 12, 2024
The context may have no replacer
@vnxme vnxme deleted the runtime-placeholders branch August 12, 2024 09:49
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.

3 participants