Skip to content
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
51e93a8
Added boost path for Mac Silicon Brew installations
serra-fastly May 30, 2025
8dd26f2
Adds C compatible struct and conversion function
serra-fastly Jun 2, 2025
1a9c8c3
Updates call_c_main call to include new arguments
serra-fastly Jun 6, 2025
a74311f
Changes into_c_struct to into_osstring_vec
serra-fastly Jun 6, 2025
c56ec9d
Updates args to work with existing ffi functions and modules
serra-fastly Jun 9, 2025
7326fb7
Adds unit test for Rust handler args
serra-fastly Jun 10, 2025
6df9c3e
Adds loading settings from cli and unit testing
serra-fastly Jun 11, 2025
3f4f54b
changed name of test fxn
serra-fastly Jun 11, 2025
1cf7cee
Adds new arg vars to test mod
serra-fastly Jun 16, 2025
a8d5978
Adds ArgsData to proxy
serra-fastly Jun 16, 2025
2ee4081
Updated args values in runner
serra-fastly Jun 18, 2025
8f18304
Adds proxy argument handling unit tests
serra-fastly Jul 3, 2025
5b24d05
Resolves clippy warnings and removes reduntant comments
serra-fastly Jul 7, 2025
153588a
Resolves linter issues
serra-fastly Jul 7, 2025
63d6109
Resolves clippy warning
serra-fastly Jul 7, 2025
ce7de89
Removes stray debuggging statement
serra-fastly Jul 16, 2025
db0624d
Adds new C++ compatible struct for bindgen compatibility for CCliArgs
serra-fastly Aug 5, 2025
3d0d861
Updates run functions in proxy and handler to accept new CCliArgsFfi
serra-fastly Aug 7, 2025
4c22bb8
Changes routes from string list to array of strings and removes Osst…
serra-fastly Aug 7, 2025
76640e7
Updates Settings to use ArgsData
serra-fastly Aug 7, 2025
ee677db
Refactors ArgsData to accept CCliArgsFfi instead of argc/argv
serra-fastly Aug 7, 2025
aa1c279
Integrates FFI argument handling into proxy and handler components
serra-fastly Aug 7, 2025
13dc80a
Restores old Settings constructor for backwards compatibility
serra-fastly Aug 7, 2025
73bcf06
Fixes warning about int vs unsigned int
serra-fastly Aug 7, 2025
66ffacb
Changes routes to return empty array instead of nullptr when empty
serra-fastly Aug 7, 2025
dda5e95
Refactors handler and proxy tests to use new FFI structs
serra-fastly Aug 7, 2025
8981999
Resolves circular dependency issues in ArgsData and Settings
serra-fastly Aug 7, 2025
7b905d7
Renames ArgsData in runner to RunnerArgsData
serra-fastly Aug 7, 2025
999c09d
Integrates FFI structs into the module calls for handler and proxy
serra-fastly Aug 7, 2025
e5e1927
Fix for FFI config_file to use proper valid default instead of empty …
serra-fastly Aug 7, 2025
bbde02b
Fixes incorrect empty str check and adds new getters in Settings
serra-fastly Aug 7, 2025
7bc65c3
Adds new Settings tests
serra-fastly Aug 7, 2025
8bfd1dd
Merge remote-tracking branch 'origin' into serra/rust-arg-handler
serra-fastly Aug 8, 2025
c7b3bcc
Replaces run_serial with run_cpp for tests, fixes a linking bug, remo…
serra-fastly Aug 8, 2025
0649f0c
Calls fromUtf8 on arguments for better parsing
serra-fastly Aug 8, 2025
3f1dc5b
Deletes unnecessary equivalency operator
serra-fastly Aug 11, 2025
ad3cd49
Splits and refactors CliArgs into individual structs for handler and …
serra-fastly Aug 11, 2025
5142efb
Removes getters/setters from CliArgsFfi and makes fields public instead
serra-fastly Aug 11, 2025
88b92ca
Removes unnecessary fields and renames Ffi structs to resolve duplica…
serra-fastly Aug 12, 2025
0161b9a
Removes unncessary IntoIterator
serra-fastly Aug 12, 2025
1890fa2
Removes unnecessary storage of routeCount in ProxyArgsData
serra-fastly Aug 12, 2025
bae6603
Adds safety documentation FFI destroy functions, per clippy
serra-fastly Aug 12, 2025
8e80e75
Adds destruction of args at end of execution
serra-fastly Aug 12, 2025
a561fa2
Refactors iteration from i..num to enumerate, per clippy
serra-fastly Aug 12, 2025
dbf51be
Moves destroy and to_ffi fxns out of the ffi mod
serra-fastly Aug 14, 2025
d45330d
Reverts arg styles
serra-fastly Aug 14, 2025
515d64a
Removes Ffi suffix from args struct
serra-fastly Aug 14, 2025
f5b2f5d
Removes unnecessary import
serra-fastly Aug 14, 2025
7a64c9c
Removes qapp from testing
serra-fastly Aug 14, 2025
c0810ce
Removes log.txt and adds it to gitignore
serra-fastly Aug 14, 2025
bb5eb4d
Moves handler and proxy cliargs into respective folders
serra-fastly Aug 14, 2025
c175539
Removes extra whitespace line
serra-fastly Aug 14, 2025
fa77189
Changed pushpin-handler test back to false
serra-fastly Aug 14, 2025
c279256
Creates test log file in log dir and removes log.txt from gitignore
serra-fastly Aug 15, 2025
09d4edc
Changes routes arg to route in proxy
serra-fastly Aug 15, 2025
2fbe712
Changes log file failure from throws exception to exit
serra-fastly Aug 15, 2025
f32d28f
Relocates log set up to run and adds unique log filename to tests
serra-fastly Aug 15, 2025
a84eef1
Changes error handling exit(1) to return 1
serra-fastly Aug 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 74 additions & 27 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ zmq = "0.9"
[dev-dependencies]
criterion = "0.5"
env_logger = { version = "0.9", default-features = false }
tempfile = "3.20.0"
test-log = "0.2"

[build-dependencies]
Expand Down Expand Up @@ -82,7 +83,7 @@ bench = false

[[bin]]
name = "pushpin-handler"
test = false
test = true
bench = false

[[bin]]
Expand Down
6 changes: 5 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,11 @@ fn get_qt_lib_prefix(lib_dir: &Path, version_maj: u16) -> Result<String, Box<dyn
}

fn find_boost_include_dir() -> Result<PathBuf, Box<dyn Error>> {
let paths = ["/usr/local/include", "/usr/include"];
let paths = [
"/usr/local/include",
"/usr/include",
"/opt/homebrew/include",
];
let version_filename = "boost/version.hpp";

for path in paths {
Expand Down
Empty file added log.txt
Empty file.
7 changes: 5 additions & 2 deletions src/bin/pushpin-handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,18 @@
* limitations under the License.
*/

use clap::Parser;
use pushpin::core::call_c_main;
use pushpin::core::ccliargs::CCliArgs;
use pushpin::import_cpp;
use std::env;
use std::process::ExitCode;

import_cpp! {
fn handler_main(argc: libc::c_int, argv: *const *const libc::c_char) -> libc::c_int;
}

fn main() -> ExitCode {
unsafe { ExitCode::from(call_c_main(handler_main, env::args_os())) }
let c_cli_args = CCliArgs::parse().verify();

unsafe { ExitCode::from(call_c_main(handler_main, c_cli_args.into_osstring_vec())) }
}
7 changes: 5 additions & 2 deletions src/bin/pushpin-proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,18 @@
* limitations under the License.
*/

use clap::Parser;
use pushpin::core::call_c_main;
use pushpin::core::ccliargs::CCliArgs;
use pushpin::import_cpp;
use std::env;
use std::process::ExitCode;

import_cpp! {
fn proxy_main(argc: libc::c_int, argv: *const *const libc::c_char) -> libc::c_int;
}

fn main() -> ExitCode {
unsafe { ExitCode::from(call_c_main(proxy_main, env::args_os())) }
let c_cli_args = CCliArgs::parse().verify();

unsafe { ExitCode::from(call_c_main(proxy_main, c_cli_args.into_osstring_vec())) }
}
88 changes: 88 additions & 0 deletions src/core/argsdata.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*
* Copyright (C) 2015-2022 Fanout, Inc.
* Copyright (C) 2024-2025 Fastly, Inc.
*
* This file is part of Pushpin.
*
* $FANOUT_BEGIN_LICENSE:APACHE2$
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* $FANOUT_END_LICENSE$
*/

#include "argsdata.h"
#include "settings.h"
#include "config.h"
#include "log.h"
#include <QCoreApplication>
#include <QFile>


Settings ArgsData::loadIntoSettings()
{
Settings settings(configFile);

if(!ipcPrefix.isEmpty())
settings.setIpcPrefix(ipcPrefix);

if(portOffset != -1)
settings.setPortOffset(portOffset);

return settings;
}

ArgsData::ArgsData(QStringList &extArgs)
{
if(extArgs.isEmpty())
{
log_error("Error processing arguments. Use --help for usage.");
throw std::exception();
}

configFile = extArgs[0];
logFile = !extArgs[1].isEmpty() ? extArgs[1] : QString();
logLevel = extArgs[2].toInt();
ipcPrefix = extArgs[3];
portOffset = !extArgs[4].isEmpty() ? extArgs[4].toInt() : -1;
routeLines = extArgs[5].isEmpty() ? QStringList() : extArgs[5].split(',');
quietCheck = extArgs[6] == "true" ? true : false;

// Set the log level
if(logLevel != -1)
log_setOutputLevel(logLevel);
else
log_setOutputLevel(LOG_LEVEL_INFO);

// Set the log file if specified
if(!logFile.isEmpty())
{
if(!log_setFile(logFile))
{
log_error("failed to open log file: %s", qPrintable(logFile));
throw std::exception();
}
}

log_debug("starting...");

// QSettings doesn't inform us if the config file can't be opened, so do that ourselves
{
QFile file(configFile);
if(!file.open(QIODevice::ReadOnly))
{
log_error("failed to open %s", qPrintable(configFile));
throw std::exception();
}
}
}
Loading