-
Notifications
You must be signed in to change notification settings - Fork 1
feat(rules): expose requester IP to JS (r.requester_ip) and scripts (HTTPJAIL_REQUESTER_IP) #25
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
Conversation
- Pass requester IP address through all proxy handlers - Add HTTPJAIL_REQUESTER_IP environment variable to script execution - Update RuleEngineTrait to accept requester IP as required parameter - Add test to verify requester IP is correctly passed to scripts - Update README documentation with new environment variable This allows scripts to make decisions based on the client's IP address, enabling IP-based filtering, rate limiting, or custom logging scenarios.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codex Review: Here are some suggestions.
Reply with @codex fix comments
to fix any unresolved comments.
About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you open a pull request for review, mark a draft as ready, or comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex fix this CI failure" or "@codex address that feedback".
|
||
#[async_trait] | ||
pub trait RuleEngineTrait: Send + Sync { | ||
async fn evaluate(&self, method: Method, url: &str) -> EvaluationResult; | ||
async fn evaluate(&self, method: Method, url: &str, requester_ip: &str) -> EvaluationResult; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P1] Update tests for new requester_ip parameter
The trait method RuleEngineTrait::evaluate
now requires a requester_ip
argument, but the unit tests still invoke engine.evaluate(method, url)
with the old two-parameter signature (see src/rules/script.rs
and src/rules.rs
). Running cargo test
will fail to compile until those call sites provide an IP value or the API offers a backwards-compatible wrapper. Consider updating the tests to pass a dummy IP so the suite builds again.
Useful? React with 👍 / 👎.
Co-authored-by: ammario <[email protected]>
Fix tests to pass new parameter after API change. Co-authored-by: ammario <[email protected]>
Co-authored-by: ammario <[email protected]>
Co-authored-by: ammario <[email protected]>
…ait\n\n- Add r.requester_ip to JS context\n- Update V8JsRuleEngine to accept requester_ip\n- Adjust tests to pass requester_ip\n- Remove obsolete pattern engine after merge\n\nCo-authored-by: ammario <[email protected]>
…engine\n\nCo-authored-by: ammario <[email protected]>
Co-authored-by: ammario <[email protected]>
Pushed a rustfmt cleanup to fix the format job. Current CI status:
Feature notes:
I’ll keep an eye on the remaining jobs and follow up if anything fails. |
CI is green on the latest commit (031d8a7). All 6 jobs in the Tests workflow succeeded:
No code changes were necessary. Do you want me to request review or proceed with merge once approvals are in? |
Resolve README.md conflicts and retain Advanced Options heading; integrate r.requester_ip in JS API. Co-authored-by: ammario <[email protected]>
Updated the PR branch with the latest main and resolved a README.md merge conflict. Details:
Commit: 1e91f80 CI should kick off on this update. I’ll monitor and follow up if anything goes red. If you prefer a rebase instead of a merge update, say the word and I’ll switch it. |
Summary
Provide the requester IP to both rule engines and propagate it through the proxy, enabling IP-aware policies in JavaScript and shell scripts.
Changes
Use cases
Examples
JavaScript:
Script:
Test plan
Notes
Co-authored-by: ammario [email protected]