Repository navigation
Add per-block proxy bypass and proxy variables to Http Request block - #1244
Open
Duc-python wants to merge 2 commits into
Open
Duc-python wants to merge 2 commits into
Duc-python wants to merge 2 commits into
Conversation
Http Request blocks now expose a `useProxy` parameter (default `true`). When disabled, that single request is sent directly even if the job has proxies enabled, which was previously only possible by toggling the proxy at job level and restarting it. The check lives in a new `HttpRequestHandler.ResolveProxy` helper so all three HTTP libraries (RuriLibHttp, SystemNet, CurlImpersonate) honour it through a single choke point. When a block bypasses its proxy, a `[NO PROXY]` line is logged so the reason is visible in the bot log. ScriptGlobals now also exposes the bot proxy as `input.proxy.*` (ip, host, port, username, password, type, country, ping, inUse) so configs can read proxy fields without falling back to `data.Proxy`. Every field is always present, defaulting to empty, so configs do not need null checks. `inUse` reflects whether requests actually go through the proxy, which distinguishes "the bot has a proxy" from "this block is using it". Both additions are backwards compatible: `useProxy` defaults to the previous behaviour and is omitted from LoliCode when unchanged, and a wordlist slice literally named `proxy` keeps precedence over the new object. Also assigns `decodeHtmlSetting` in the native HttpRequestBlockSettingsViewer, which was declared in XAML but never bound, leaving the setting inert there.
The notice condition checked whether a proxy was assigned to the bot rather than whether the job was actually using it, so a job with proxies disabled that still had a proxy object attached would log a misleading bypass notice on every block with `useProxy` off. The debugger and the `SET PROXY` LoliCode statement can both produce that state. ResolveProxy now returns early unless the job is both proxied and has a proxy assigned, and only logs on the branch that actually drops a proxy in use. ResolveProxy is also internal rather than protected so the full decision table is directly testable; RuriLib already grants InternalsVisibleTo to the test assembly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Two related additions to the Http Request block, both aimed at giving configs finer control over proxies.
1. Per-block proxy bypass (
useProxy, defaulttrue)The Http Request block now has a
useProxycheckbox. When unchecked, that single request is sent directly even if the job has proxies enabled.A config could already opt out of the proxy through the
SET USEPROXY FALSEstatement in a LoliCode block, andJobProxyModecontrols it at job level. This adds the missing middle ground: a per-block toggle for the blocks that actually make requests.The difference is scoping and durability.
SET USEPROXYis imperative and mutatesdata.UseProxyfor the bot, so it stays in effect for every subsequent block until you set it back, and it is re-applied at theSTART:label on each retry.useProxyis declarative and scoped to exactly one block, is rebuilt from the block on every retry, and needs no raw script to express "this one request only".Common reasons to want it: fetching a token or captcha from a direct request while the actual target traffic goes through the proxy pool, or issuing a single direct request in a config that is otherwise fully proxied.
The decision is made in a new
HttpRequestHandler.ResolveProxyhelper, so all three HTTP libraries (RuriLibHttp,SystemNet,CurlImpersonate) honour the flag through a single choke point rather than eight scattered checks. When a block bypasses its proxy while the bot has one assigned, a[NO PROXY]line is written to the bot log so it is obvious why the request left from a different IP.2.
input.proxy.*variablesScriptGlobalsnow exposes the proxy assigned to the bot asinput.proxy.*:input.proxy.ip/input.proxy.hostProxy.Hostinput.proxy.portProxy.Portinput.proxy.username/input.proxy.passwordinput.proxy.typehttp,https,socks4,socks4a,socks5input.proxy.country/input.proxy.pinginput.proxy.inUsePreviously configs had to reach for
data.Proxy(and cast??on username/password) to use proxy fields. Every field is always present and defaults to an empty value, so configs never need a null check before interpolating them.inUseis what distinguishes "the bot has a proxy" from "this block is using it", which pairs with theuseProxyflag above.The variables are also added to the input-variable autocomplete in both clients (Angular and WPF).
Backwards compatibility
Both additions are additive and preserve existing behaviour:
useProxydefaults totrue, andLoliCodeWriteromits settings equal to their parameter default, so existing configs neither change behaviour nor grow when re-serialized.proxykeeps precedence over the new object, so configs that slice intoproxyare untouched.Incidental fix
decodeHtmlSettingis declared inHttpRequestBlockSettingsViewer.xamlbut was never assigned in the code-behind, leaving that setting inert in the native client. It is now bound.No new dependencies.
Type of change
How Has This Been Tested?
dotnet build OpenBullet2.slnx -c Release— succeeds, no new warningsdotnet test RuriLib.Tests— 743 passed, 97 skipped (the skips are the pre-existing Testcontainers-based integration tests, which are skipped without Docker)dotnet test OpenBullet2.Web.Tests— 326 passeddotnet test OpenBullet2.Core.Tests— 31 passednpm run buildinopenbullet2-web-client— succeedsNew unit tests:
HttpClientRequestHandlerTests.ResolveProxy_BypassesOnlyWhenRequested— the full decision table forResolveProxyacrossbotUsesProxyxblockUseProxy, asserting both which proxy comes back and exactly when the[NO PROXY]notice is emitted. A config with no proxy at all must resolve tonulland stay silent regardless of the block setting.HttpTests.HttpRequestStandard_Get_WithoutAnyProxy_Succeeds— end-to-end request against the test HTTP server with no proxy assigned, for all three HTTP libraries and both values of the block setting. These use Testcontainers, so they run in CI but are skipped locally without Docker.HttpRequestBlockInstanceTests—useProxydefaults totrueand is emitted asUseProxyin the generated C#; toggling it tofalseis emitted too;ToLComits it when it equals the default and writes it when changed;FromLCround-trips it.ScriptGlobalsTests—input.proxy.*is populated from the assigned proxy; every field defaults to empty when no proxy is assigned; fields remain readable butinUseisfalsewhen the job has proxies disabled; a wordlist slice namedproxytakes precedence.Manual reproduction: in the config stacker, add an Http Request block and toggle
useProxyoff. Start a job with proxies enabled and confirm the request log contains[NO PROXY]and the response comes from the local IP, while other blocks still go through the proxy. In a job with no proxies at all, confirm no block logs[NO PROXY]and all requests succeed.Checklist:
Notes for the reviewer
Two things I deliberately left out, happy to add either if wanted:
UseProxyflag andResolveProxyinputs, but there is no integration test asserting the request actually leaves from a different IP when the box is unchecked. That would need a live proxy server; the existingHttpRequestProxyIntegrationTestsare Testcontainers-based and currently skipped in CI, so I did not add a test that would also never run.ConfigMakingMcpToolsexposes aMcp/Docstopic set for config authors, and neitheruseProxynorinput.proxy.*is documented there yet. TheuseProxyparameter description is picked up automatically byget_block_details, butinput.proxy.*has no home yet.If you would prefer
input.proxy.hostonly (theProxymodel names the fieldHost, soipis an alias), or want the whole thing scoped to a tri-state instead of a bool, say so and I will rework it.