mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2026-04-16 21:40:00 +00:00
Add debug option to show http traffic
This commit is contained in:
@@ -727,7 +727,7 @@ int gs_quit_app(PSERVER_DATA server) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
int gs_init(PSERVER_DATA server, char *address, const char *keyDirectory) {
|
||||
int gs_init(PSERVER_DATA server, char *address, const char *keyDirectory, int log_level) {
|
||||
mkdirtree(keyDirectory);
|
||||
if (load_unique_id(keyDirectory) != GS_OK)
|
||||
return GS_FAILED;
|
||||
@@ -735,7 +735,7 @@ int gs_init(PSERVER_DATA server, char *address, const char *keyDirectory) {
|
||||
if (load_cert(keyDirectory))
|
||||
return GS_FAILED;
|
||||
|
||||
http_init(keyDirectory);
|
||||
http_init(keyDirectory, log_level);
|
||||
|
||||
LiInitializeServerInformation(&server->serverInfo);
|
||||
server->serverInfo.address = address;
|
||||
|
||||
@@ -40,7 +40,7 @@ typedef struct _SERVER_DATA {
|
||||
SERVER_INFORMATION serverInfo;
|
||||
} SERVER_DATA, *PSERVER_DATA;
|
||||
|
||||
int gs_init(PSERVER_DATA server, char* address, const char *keyDirectory);
|
||||
int gs_init(PSERVER_DATA server, char* address, const char *keyDirectory, int logLevel);
|
||||
int gs_start_app(PSERVER_DATA server, PSTREAM_CONFIGURATION config, int appId, bool sops, bool localaudio);
|
||||
int gs_applist(PSERVER_DATA server, PAPP_LIST *app_list);
|
||||
int gs_unpair(PSERVER_DATA server);
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "http.h"
|
||||
#include "errors.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <curl/curl.h>
|
||||
|
||||
@@ -28,6 +29,8 @@ static CURL *curl;
|
||||
static const char *pCertFile = "./client.pem";
|
||||
static const char *pKeyFile = "./key.pem";
|
||||
|
||||
static bool debug;
|
||||
|
||||
static size_t _write_curl(void *contents, size_t size, size_t nmemb, void *userp)
|
||||
{
|
||||
size_t realsize = size * nmemb;
|
||||
@@ -44,8 +47,9 @@ static size_t _write_curl(void *contents, size_t size, size_t nmemb, void *userp
|
||||
return realsize;
|
||||
}
|
||||
|
||||
int http_init(const char* keyDirectory) {
|
||||
int http_init(const char* keyDirectory, int logLevel) {
|
||||
curl = curl_easy_init();
|
||||
debug = logLevel >= 2;
|
||||
if (!curl)
|
||||
return GS_FAILED;
|
||||
|
||||
@@ -73,6 +77,9 @@ int http_request(char* url, PHTTP_DATA data) {
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, data);
|
||||
curl_easy_setopt(curl, CURLOPT_URL, url);
|
||||
|
||||
if (debug)
|
||||
printf("Request %s\n", url);
|
||||
|
||||
if (data->size > 0) {
|
||||
free(data->memory);
|
||||
data->memory = malloc(1);
|
||||
@@ -89,6 +96,9 @@ int http_request(char* url, PHTTP_DATA data) {
|
||||
} else if (data->memory == NULL) {
|
||||
return GS_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
if (debug)
|
||||
printf("Response:\n%s\n\n", data->memory);
|
||||
|
||||
return GS_OK;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ typedef struct _HTTP_DATA {
|
||||
size_t size;
|
||||
} HTTP_DATA, *PHTTP_DATA;
|
||||
|
||||
int http_init(const char* keyDirectory);
|
||||
int http_init(const char* keyDirectory, int logLevel);
|
||||
PHTTP_DATA http_create_data();
|
||||
int http_request(char* url, PHTTP_DATA data);
|
||||
void http_free_data(PHTTP_DATA data);
|
||||
|
||||
Reference in New Issue
Block a user