summaryrefslogtreecommitdiffstats
path: root/src/reverse_proxy.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/reverse_proxy.c')
-rw-r--r--src/reverse_proxy.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/reverse_proxy.c b/src/reverse_proxy.c
index 3f0a839..2fcfdd1 100644
--- a/src/reverse_proxy.c
+++ b/src/reverse_proxy.c
@@ -25,6 +25,9 @@
#endif
#include <string.h>
#include <stdlib.h>
+#define _GNU_SOURCE 1
+#define __USE_GNU 1
+#include <stdio.h>
#include <errno.h>
#include <plist/plist.h>
@@ -91,7 +94,7 @@ static void _reverse_proxy_log(reverse_proxy_client_t client, const char* format
va_list args;
va_start(args, format);
char* buffer = NULL;
- (void)vasprintf(&buffer, format, args);
+ if(vasprintf(&buffer, format, args)<0){}
va_end(args);
client->log_cb(client, buffer, client->log_cb_user_data);
free(buffer);
@@ -113,7 +116,7 @@ static void _reverse_proxy_status(reverse_proxy_client_t client, int status, con
va_list args;
va_start(args, format);
char* buffer = NULL;
- (void)vasprintf(&buffer, format, args);
+ if(vasprintf(&buffer, format, args)<0){}
va_end(args);
client->status_cb(client, status, buffer, client->status_cb_user_data);
free(buffer);
@@ -186,10 +189,10 @@ static int _reverse_proxy_handle_proxy_cmd(reverse_proxy_client_t client)
/* else wait for messages and forward them */
int sockfd = socket_connect(host, port);
- free(host);
if (sockfd < 0) {
free(buf);
_reverse_proxy_log(client, "ERROR: Connection to %s:%u failed: %s", host, port, strerror(errno));
+ free(host);
return -1;
}
@@ -259,6 +262,7 @@ static int _reverse_proxy_handle_proxy_cmd(reverse_proxy_client_t client)
}
}
socket_close(sockfd);
+ free(host);
free(buf);
_reverse_proxy_status(client, RP_STATUS_DISCONNECTED, "Disconnected (out: %u / in: %u)", sent_total, recv_total);
@@ -524,7 +528,7 @@ static void* _reverse_proxy_control_thread(void *cdata)
return NULL;
}
-LIBIMOBILEDEVICE_API reverse_proxy_error_t reverse_proxy_client_start_proxy(reverse_proxy_client_t client, int control_protocol_version)
+reverse_proxy_error_t reverse_proxy_client_start_proxy(reverse_proxy_client_t client, int control_protocol_version)
{
char buf[16] = {0, };
uint32_t bytes = 0;
@@ -603,7 +607,7 @@ LIBIMOBILEDEVICE_API reverse_proxy_error_t reverse_proxy_client_start_proxy(reve
return err;
}
-LIBIMOBILEDEVICE_API reverse_proxy_error_t reverse_proxy_client_create_with_service(idevice_t device, reverse_proxy_client_t* client, const char* label)
+reverse_proxy_error_t reverse_proxy_client_create_with_service(idevice_t device, reverse_proxy_client_t* client, const char* label)
{
reverse_proxy_error_t err = REVERSE_PROXY_E_UNKNOWN_ERROR;
service_client_factory_start_service(device, "com.apple.PurpleReverseProxy.Ctrl", (void**)client, label, SERVICE_CONSTRUCTOR(reverse_proxy_client_new), &err);
@@ -616,7 +620,7 @@ LIBIMOBILEDEVICE_API reverse_proxy_error_t reverse_proxy_client_create_with_serv
return REVERSE_PROXY_E_SUCCESS;
}
-LIBIMOBILEDEVICE_API reverse_proxy_error_t reverse_proxy_client_create_with_port(idevice_t device, reverse_proxy_client_t* client, uint16_t device_port)
+reverse_proxy_error_t reverse_proxy_client_create_with_port(idevice_t device, reverse_proxy_client_t* client, uint16_t device_port)
{
reverse_proxy_client_t client_loc = NULL;
reverse_proxy_error_t err;
@@ -637,7 +641,7 @@ LIBIMOBILEDEVICE_API reverse_proxy_error_t reverse_proxy_client_create_with_port
return REVERSE_PROXY_E_SUCCESS;
}
-LIBIMOBILEDEVICE_API reverse_proxy_error_t reverse_proxy_client_free(reverse_proxy_client_t client)
+reverse_proxy_error_t reverse_proxy_client_free(reverse_proxy_client_t client)
{
if (!client)
return REVERSE_PROXY_E_INVALID_ARG;
@@ -656,14 +660,14 @@ LIBIMOBILEDEVICE_API reverse_proxy_error_t reverse_proxy_client_free(reverse_pro
return err;
}
-LIBIMOBILEDEVICE_API reverse_proxy_client_type_t reverse_proxy_get_type(reverse_proxy_client_t client)
+reverse_proxy_client_type_t reverse_proxy_get_type(reverse_proxy_client_t client)
{
if (!client)
return 0;
return client->type;
}
-LIBIMOBILEDEVICE_API void reverse_proxy_client_set_status_callback(reverse_proxy_client_t client, reverse_proxy_status_cb_t status_callback, void* user_data)
+void reverse_proxy_client_set_status_callback(reverse_proxy_client_t client, reverse_proxy_status_cb_t status_callback, void* user_data)
{
if (!client) {
return;
@@ -672,7 +676,7 @@ LIBIMOBILEDEVICE_API void reverse_proxy_client_set_status_callback(reverse_proxy
client->status_cb_user_data = user_data;
}
-LIBIMOBILEDEVICE_API void reverse_proxy_client_set_log_callback(reverse_proxy_client_t client, reverse_proxy_log_cb_t log_callback, void* user_data)
+void reverse_proxy_client_set_log_callback(reverse_proxy_client_t client, reverse_proxy_log_cb_t log_callback, void* user_data)
{
if (!client) {
return;
@@ -681,7 +685,7 @@ LIBIMOBILEDEVICE_API void reverse_proxy_client_set_log_callback(reverse_proxy_cl
client->log_cb_user_data = user_data;
}
-LIBIMOBILEDEVICE_API void reverse_proxy_client_set_data_callback(reverse_proxy_client_t client, reverse_proxy_data_cb_t data_callback, void* user_data)
+void reverse_proxy_client_set_data_callback(reverse_proxy_client_t client, reverse_proxy_data_cb_t data_callback, void* user_data)
{
if (!client) {
return;