From b30cf20f8c70e7eda1c70e908ef06b4819bacf9a Mon Sep 17 00:00:00 2001 From: Iwan Timmer Date: Fri, 1 Apr 2016 19:13:16 +0200 Subject: [PATCH] Check protocol version --- libgamestream/client.c | 10 ++++++++++ libgamestream/client.h | 3 +++ libgamestream/errors.h | 3 ++- src/main.c | 3 +++ 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/libgamestream/client.c b/libgamestream/client.c index b99e866..937cba3 100644 --- a/libgamestream/client.c +++ b/libgamestream/client.c @@ -268,6 +268,16 @@ static int load_server_status(PSERVER_DATA server) { i++; } while (ret != GS_OK && i < 2); + if (ret == GS_OK) { + if (server->serverMajorVersion > MAX_SUPPORTED_GFE_VERSION) { + gs_error = "Ensure you're running the latest version of Moonlight Embedded or downgrade GeForce Experience and try again"; + ret = GS_UNSUPPORTED_VERSION; + } else if (server->serverMajorVersion < MIN_SUPPORTED_GFE_VERSION) { + gs_error = "Moonlight Embedded requires a newer version of GeForce Experience. Please upgrade GFE on your PC and try again."; + ret = GS_UNSUPPORTED_VERSION; + } + } + return ret; } diff --git a/libgamestream/client.h b/libgamestream/client.h index dafc461..9a8fc91 100644 --- a/libgamestream/client.h +++ b/libgamestream/client.h @@ -25,6 +25,9 @@ #include +#define MIN_SUPPORTED_GFE_VERSION 3 +#define MAX_SUPPORTED_GFE_VERSION 7 + typedef struct _SERVER_DATA { const char* address; char* gpuType; diff --git a/libgamestream/errors.h b/libgamestream/errors.h index 441aea3..99e3187 100644 --- a/libgamestream/errors.h +++ b/libgamestream/errors.h @@ -1,7 +1,7 @@ /* * This file is part of Moonlight Embedded. * - * Copyright (C) 2015 Iwan Timmer + * Copyright (C) 2015, 2016 Iwan Timmer * * Moonlight is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,5 +26,6 @@ #define GS_WRONG_STATE -4 #define GS_IO_ERROR -5 #define GS_NOT_SUPPORTED_4K -6 +#define GS_UNSUPPORTED_VERSION -7 const char* gs_error; diff --git a/src/main.c b/src/main.c index ba14d31..378625b 100644 --- a/src/main.c +++ b/src/main.c @@ -226,6 +226,9 @@ int main(int argc, char* argv[]) { } else if (ret == GS_INVALID) { fprintf(stderr, "Invalid data received from server: %s\n", config.address, gs_error); exit(-1); + } else if (ret == GS_UNSUPPORTED_VERSION) { + fprintf(stderr, "Unsupported version: %s\n", gs_error); + exit(-1); } else if (ret != GS_OK) { fprintf(stderr, "Can't connect to server %s\n", config.address); exit(-1);