22#include <winpr/collections.h>
24#include <freerdp/version.h>
25#include <freerdp/freerdp.h>
27#include <freerdp/server/proxy/proxy_server.h>
28#include <freerdp/server/proxy/proxy_log.h>
33#define TAG PROXY_TAG("server")
35static proxyServer* server = NULL;
38static const char* strsignal(
int signum)
53static void cleanup_handler(
int signum)
56 WLog_INFO(TAG,
"caught signal %s [%d], starting cleanup...", strsignal(signum), signum);
58 WLog_INFO(TAG,
"stopping all connections.");
59 pf_server_stop(server);
63static void pf_server_register_signal_handlers(
void)
65 (void)signal(SIGINT, cleanup_handler);
66 (void)signal(SIGTERM, cleanup_handler);
68 (void)signal(SIGQUIT, cleanup_handler);
69 (void)signal(SIGKILL, cleanup_handler);
73static int usage(
const char* app)
76 printf(
"%s -h Display this help text.\n", app);
77 printf(
"%s --help Display this help text.\n", app);
78 printf(
"%s --buildconfig Print the build configuration.\n", app);
79 printf(
"%s <config ini file> Start the proxy with <config.ini>\n", app);
80 printf(
"%s --dump-config <config ini file> Create a template <config.ini>\n", app);
81 printf(
"%s -v Print out binary version.\n", app);
82 printf(
"%s --version Print out binary version.\n", app);
86static int version(
const char* app)
88 printf(
"%s version %s", app, freerdp_get_version_string());
92static int buildconfig(WINPR_ATTR_UNUSED
const char* app)
94 printf(
"This is FreeRDP version %s (%s)\n", FREERDP_VERSION_FULL, FREERDP_GIT_REVISION);
95 printf(
"%s", freerdp_get_build_config());
99int main(
int argc,
char* argv[])
103 pf_server_register_signal_handlers();
105 WLog_INFO(TAG,
"freerdp-proxy version info:");
106 WLog_INFO(TAG,
"\tFreeRDP version: %s", FREERDP_VERSION_FULL);
107 WLog_INFO(TAG,
"\tGit commit: %s", FREERDP_GIT_REVISION);
108 WLog_DBG(TAG,
"\tBuild config: %s", freerdp_get_build_config());
112 status = usage(argv[0]);
116 const char* arg = argv[1];
118 if (_stricmp(arg,
"-h") == 0)
120 status = usage(argv[0]);
123 else if (_stricmp(arg,
"--help") == 0)
125 status = usage(argv[0]);
128 else if (_stricmp(arg,
"--buildconfig") == 0)
130 status = buildconfig(argv[0]);
133 else if (_stricmp(arg,
"--dump-config") == 0)
137 status = usage(argv[0]);
143 else if (_stricmp(arg,
"-v") == 0)
145 status = version(argv[0]);
148 else if (_stricmp(arg,
"--version") == 0)
150 status = version(argv[0]);
154 const char* config_path = argv[1];
157 status = usage(argv[0]);
167 server = pf_server_new(config);
173 if (!pf_server_start(server))
176 if (!pf_server_run(server))
182 pf_server_free(server);
FREERDP_API void pf_server_config_free(proxyConfig *config)
pf_server_config_free Releases all resources associated with proxyConfig
FREERDP_API void pf_server_config_print(const proxyConfig *config)
pf_server_config_print Print the configuration to stdout
FREERDP_API BOOL pf_server_config_dump(const char *file)
pf_server_config_dump Dumps a default INI configuration file
FREERDP_API proxyConfig * pf_server_config_load_file(const char *path)
pf_server_config_load_file Create a proxyConfig from a INI file found at path.