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")
35 static proxyServer* server = NULL;
38 static const char* strsignal(
int signum)
53 static void cleanup_handler(
int signum)
55 WLog_INFO(TAG,
"caught signal %s [%d], starting cleanup...", strsignal(signum), signum);
57 WLog_INFO(TAG,
"stopping all connections.");
58 pf_server_stop(server);
62 static void pf_server_register_signal_handlers(
void)
64 (void)signal(SIGINT, cleanup_handler);
65 (void)signal(SIGTERM, cleanup_handler);
67 (void)signal(SIGQUIT, cleanup_handler);
68 (void)signal(SIGKILL, cleanup_handler);
72 static int usage(
const char* app)
75 printf(
"%s -h Display this help text.\n", app);
76 printf(
"%s --help Display this help text.\n", app);
77 printf(
"%s --buildconfig Print the build configuration.\n", app);
78 printf(
"%s <config ini file> Start the proxy with <config.ini>\n", app);
79 printf(
"%s --dump-config <config ini file> Create a template <config.ini>\n", app);
80 printf(
"%s -v Print out binary version.\n", app);
81 printf(
"%s --version Print out binary version.\n", app);
85 static int version(
const char* app)
87 printf(
"%s version %s", app, freerdp_get_version_string());
91 static int buildconfig(
const char* app)
93 printf(
"This is FreeRDP version %s (%s)\n", FREERDP_VERSION_FULL, FREERDP_GIT_REVISION);
94 printf(
"%s", freerdp_get_build_config());
98 int main(
int argc,
char* argv[])
102 pf_server_register_signal_handlers();
104 WLog_INFO(TAG,
"freerdp-proxy version info:");
105 WLog_INFO(TAG,
"\tFreeRDP version: %s", FREERDP_VERSION_FULL);
106 WLog_INFO(TAG,
"\tGit commit: %s", FREERDP_GIT_REVISION);
107 WLog_DBG(TAG,
"\tBuild config: %s", freerdp_get_build_config());
111 status = usage(argv[0]);
115 const char* arg = argv[1];
117 if (_stricmp(arg,
"-h") == 0)
119 status = usage(argv[0]);
122 else if (_stricmp(arg,
"--help") == 0)
124 status = usage(argv[0]);
127 else if (_stricmp(arg,
"--buildconfig") == 0)
129 status = buildconfig(argv[0]);
132 else if (_stricmp(arg,
"--dump-config") == 0)
136 status = usage(argv[0]);
142 else if (_stricmp(arg,
"-v") == 0)
144 status = version(argv[0]);
147 else if (_stricmp(arg,
"--version") == 0)
149 status = version(argv[0]);
153 const char* config_path = argv[1];
156 status = usage(argv[0]);
166 server = pf_server_new(config);
172 if (!pf_server_start(server))
175 if (!pf_server_run(server))
181 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.