Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 5 additions & 5 deletions src/bin/pushpin-handler.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2023 Fastly, Inc.
* Copyright (C) 2023-2025 Fastly, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -15,20 +15,20 @@
*/

use clap::Parser;
use pushpin::handler::handlercliargs::ffi::HandlerCliArgs;
use pushpin::handler::handlercliargs::{destroy_handler_cli_args, CliArgs};
use pushpin::handler::cliargs::ffi::HandlerCliArgs;
use pushpin::handler::cliargs::{destroy_handler_cli_args, CliArgs};
use pushpin::import_cpp;
use std::process::ExitCode;

import_cpp! {
fn handler_main(args: *const HandlerCliArgs) -> libc::c_int;
fn handler_init(args: *const HandlerCliArgs) -> libc::c_int;
}

fn main() -> ExitCode {
let cli_args = CliArgs::parse().verify();
let cli_args_ffi = cli_args.to_ffi();

let exit_code = unsafe { handler_main(&cli_args_ffi) };
let exit_code = unsafe { handler_init(&cli_args_ffi) };

// Clean up the allocated memory
unsafe { destroy_handler_cli_args(cli_args_ffi) };
Expand Down
10 changes: 5 additions & 5 deletions src/bin/pushpin-proxy.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2023 Fastly, Inc.
* Copyright (C) 2023-2025 Fastly, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,19 +16,19 @@

use clap::Parser;
use pushpin::import_cpp;
use pushpin::proxy::proxycliargs::ffi::ProxyCliArgs;
use pushpin::proxy::proxycliargs::{destroy_proxy_cli_args, CliArgs};
use pushpin::proxy::cliargs::ffi::ProxyCliArgs;
use pushpin::proxy::cliargs::{destroy_proxy_cli_args, CliArgs};
use std::process::ExitCode;

import_cpp! {
fn proxy_main(args: *const ProxyCliArgs) -> libc::c_int;
fn proxy_init(args: *const ProxyCliArgs) -> libc::c_int;
}

fn main() -> ExitCode {
let cli_args = CliArgs::parse().verify();
let cli_args_ffi = cli_args.to_ffi();

let exit_code = unsafe { proxy_main(&cli_args_ffi) };
let exit_code = unsafe { proxy_init(&cli_args_ffi) };

// Clean up the allocated memory
unsafe { destroy_proxy_cli_args(cli_args_ffi) };
Expand Down
File renamed without changes.
9 changes: 3 additions & 6 deletions src/handler/handler.pri
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ HEADERS += \
$$PWD/filter.h \
$$PWD/filterstack.h \
$$PWD/handlerengine.h \
$$PWD/handlerapp.h \
$$PWD/main.h \
$$PWD/handlerargsdata.h
$$PWD/handlerargsdata.h

SOURCES += \
$$PWD/deferred.cpp \
Expand All @@ -56,6 +54,5 @@ SOURCES += \
$$PWD/filter.cpp \
$$PWD/filterstack.cpp \
$$PWD/handlerengine.cpp \
$$PWD/handlerapp.cpp \
$$PWD/handlermain.cpp \
$$PWD/handlerargsdata.cpp
$$PWD/handlerargsdata.cpp \
$$PWD/handlerapp.cpp
41 changes: 34 additions & 7 deletions src/handler/handlerapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,15 @@
* $FANOUT_END_LICENSE$
*/

#include "handlerapp.h"
#include "handlerargsdata.h"
#include "rust/bindings.h"

#include <assert.h>
#include <iostream>
#include <QCoreApplication>
#include <QCommandLineParser>
#include <QStringList>
#include <QFile>
#include <QFileInfo>
#include <QDir>
#include "rust/bindings.h"
#include "timer.h"
#include "defercall.h"
#include "eventloop.h"
Expand All @@ -42,9 +40,9 @@
#include "wssession.h"
#include "httpsessionupdatemanager.h"
#include "settings.h"
#include "handlerengine.h"
#include "config.h"
#include <iostream>
#include "handlerengine.h"
#include "handlerargsdata.h"

#define DEFAULT_HTTP_MAX_HEADERS_SIZE 10000
#define DEFAULT_HTTP_MAX_BODY_SIZE 1000000
Expand Down Expand Up @@ -85,6 +83,18 @@ static QString firstSpec(const QString &s, int peerCount)
return s;
}

class HandlerApp
{
public:
HandlerApp();
~HandlerApp();

int run(const ffi::HandlerCliArgs *argsFfi);

private:
class Private;
};

class HandlerApp::Private
{
public:
Expand Down Expand Up @@ -379,4 +389,21 @@ HandlerApp::~HandlerApp() = default;
int HandlerApp::run(const ffi::HandlerCliArgs *argsFfi)
{
return Private::run(argsFfi);
}
}

extern "C" {

int handler_init(const ffi::HandlerCliArgs *argsFfi)
{
// Create dummy argc/argv for QCoreApplication
int argc = 1;
char app_name[] = "pushpin-handler";
char* argv[] = { app_name, nullptr };

QCoreApplication qapp(argc, argv);

HandlerApp app;
return app.run(argsFfi);
}

}
40 changes: 0 additions & 40 deletions src/handler/handlerapp.h

This file was deleted.

43 changes: 0 additions & 43 deletions src/handler/handlermain.cpp

This file was deleted.

2 changes: 1 addition & 1 deletion src/handler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

pub mod handlercliargs;
pub mod cliargs;

#[cfg(test)]
mod tests {
Expand Down
41 changes: 0 additions & 41 deletions src/proxy/app.h

This file was deleted.

File renamed without changes.
43 changes: 0 additions & 43 deletions src/proxy/main.cpp

This file was deleted.

8 changes: 0 additions & 8 deletions src/proxy/main.h

This file was deleted.

2 changes: 1 addition & 1 deletion src/proxy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

pub mod proxycliargs;
pub mod cliargs;

#[cfg(test)]
mod tests {
Expand Down
13 changes: 5 additions & 8 deletions src/proxy/proxy.pri
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ HEADERS += \
$$PWD/proxyutil.h \
$$PWD/proxysession.h \
$$PWD/wsproxysession.h \
$$PWD/engine.h \
$$PWD/app.h \
$$PWD/main.h \
$$PWD/proxyargsdata.h
$$PWD/proxyengine.h \
$$PWD/proxyargsdata.h

SOURCES += \
$$PWD/testhttprequest.cpp \
Expand All @@ -43,7 +41,6 @@ SOURCES += \
$$PWD/proxyutil.cpp \
$$PWD/proxysession.cpp \
$$PWD/wsproxysession.cpp \
$$PWD/engine.cpp \
$$PWD/app.cpp \
$$PWD/main.cpp \
$$PWD/proxyargsdata.cpp
$$PWD/proxyengine.cpp \
$$PWD/proxyargsdata.cpp \
$$PWD/proxyapp.cpp
Loading
Loading