Skip to content

Ports command line argument handling for proxy and handler to Rust #48232

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

Merged
merged 58 commits into from
Aug 18, 2025

Conversation

serra-fastly
Copy link
Contributor

@serra-fastly serra-fastly commented Jul 3, 2025

This change is a part of the transition from C++ to Rust.

Argument handling has been collapsed into core/[handler/proxy]argsdata.cpp and core/[handler/proxy]cliargs.rs for C++ and Rust respectively. Old argument parsing logic was removed from the C++ modules. Runner was updated with the new command line values to standardize tags. ArgsData in Runner was updated to RunnerArgsData for differentiation.

In the Rust modules, handler and proxy use clap to parse arguments into CliArgs, convert to its FFI struct equivalent [Handler/Proxy]CliArgsFfi, and then call handler_main and proxy_main respectively with the [Handler/Proxy]CliArgsFfi variable being passed in as the argument. cbindgen creates a binding for [Handler/Proxy]CliArgsFfi within "rust/bindings.h" for use by C++ at compilation time. Then in the C++ modules, the [Handler/Proxy]CliArgsFfi gets loaded into an ArgsData struct for use with QT types and loaded into the Settings struct.

cbindgen was used to pass the data through because the linker had trouble with cxx due to QT (that wasn't able to be resolved with cxx-qt), but it'll be good to use cxx in the future for security and stability to create safe bindings (vs the unsafe bindings from cbindgen).

I've created unit testing for both the Rust modules that send the arguments within cliargs.rs and the C++ modules that receive the modules within [handler/proxy]argstest.cpp. Both test with the same values and the same two use cases— all arguments are set and no arguments are set.

Tested on a canary node (lck) on 08/08/2025.

Copy link
Collaborator

@deg4uss3r deg4uss3r left a comment

Choose a reason for hiding this comment

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

PR looks good! Minus one debugging statement left in I think this is ready to test on a node for correctness.

@serra-fastly serra-fastly force-pushed the serra/rust-arg-handler branch from 8319e99 to ce7de89 Compare July 16, 2025 18:53
@serra-fastly serra-fastly changed the title DRAFT: Ports command line argument handling for proxy and handler to Rust Ports command line argument handling for proxy and handler to Rust Jul 25, 2025
Copy link
Collaborator

@deg4uss3r deg4uss3r left a comment

Choose a reason for hiding this comment

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

Everything here looks good to me, going to tag in Justin though for a more thorough review of the c++ pieces.

@deg4uss3r deg4uss3r requested a review from jkarneges July 30, 2025 19:21
@serra-fastly serra-fastly requested a review from jkarneges August 14, 2025 23:29
@serra-fastly serra-fastly force-pushed the serra/rust-arg-handler branch from 9f4e249 to f32d28f Compare August 15, 2025 20:34
@serra-fastly serra-fastly merged commit 0817f58 into main Aug 18, 2025
19 checks passed
@serra-fastly serra-fastly deleted the serra/rust-arg-handler branch August 18, 2025 21:27
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