Skip to content
Permalink
Browse files

Add debug option to show http traffic

  • Loading branch information...
irtimmer authored and d3m3vilurr committed Jun 11, 2017
1 parent 933d700 commit e2d79109662d8b9f02377d1f0093e6a9241c03ba
Showing with 19 additions and 7 deletions.
  1. +4 −0 docs/README.pod
  2. +2 −2 libgamestream/client.c
  3. +1 −1 libgamestream/client.h
  4. +10 −2 libgamestream/http.c
  5. +1 −1 libgamestream/http.h
  6. +1 −1 src/gui/ui_connect.c
@@ -132,6 +132,10 @@ By default the encryption keys are stored in $XDG_CACHE_DIR/moonlight or ~/.cach
Use I<MAPPING> as the mapping file for all inputs specified after this B<-mapping>.
If no B<-input> is specified after the B<-mapping> this mapping is used for autoloaded inputs.

=item B<-debug>

Enable verbose and debug output

=item B<-input> [I<INPUT>]

Enable the I<INPUT> device.
@@ -761,15 +761,15 @@ 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;

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 logLevel, bool unsupported);
int gs_init(PSERVER_DATA server, char* address, const char *keyDirectory, int log_level);
int gs_start_app(PSERVER_DATA server, PSTREAM_CONFIGURATION config, int appId, bool sops, bool localaudio, int gamepad_mask, bool custom_res);
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>

@@ -31,6 +32,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;
@@ -47,8 +50,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;

@@ -83,7 +87,8 @@ int http_request(char* url, PHTTP_DATA data) {

char url_tiny[48] = {0};
strncpy(url_tiny, url, sizeof(url_tiny) - 1);
printf("GET %s\n", url_tiny);
if (debug)
printf("GET %s\n", url_tiny);

if (data->size > 0) {
free(data->memory);
@@ -102,6 +107,9 @@ int http_request(char* url, PHTTP_DATA data) {
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);
@@ -228,7 +228,7 @@ int ui_connect(char *address) {
int ret;
if (!connection_is_ready()) {
flash_message("Connecting to:\n %s...", address);
ret = gs_init(&server, address, config.key_dir);
ret = gs_init(&server, address, config.key_dir, 0);
if (ret == GS_OUT_OF_MEMORY) {
display_error("Not enough memory");
return 0;

0 comments on commit e2d7910

Please sign in to comment.
You can’t perform that action at this time.