mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2025-08-17 17:06:10 +00:00
- Hostnames work when streaming
- GFE 2.1.x is supported - Minor bug fixes
This commit is contained in:
parent
685d7731b7
commit
1aefaf8f73
30
src/client.c
30
src/client.c
@ -39,29 +39,33 @@ static const char *certificateFileName = "client.pem";
|
||||
static const char *p12FileName = "client.p12";
|
||||
static const char *keyFileName = "key.pem";
|
||||
|
||||
static char unique_id[17];
|
||||
#define UNIQUEID_BYTES 8
|
||||
#define UNIQUEID_CHARS (UNIQUEID_BYTES*2)
|
||||
|
||||
static char unique_id[UNIQUEID_CHARS+1];
|
||||
static X509 *cert;
|
||||
static char cert_hex[4096];
|
||||
static EVP_PKEY *privateKey;
|
||||
|
||||
static bool paired;
|
||||
static int currentGame;
|
||||
static int serverMajorVersion;
|
||||
|
||||
static void client_load_unique_id() {
|
||||
FILE *fd = fopen(uniqueFileName, "r");
|
||||
if (fd == NULL) {
|
||||
unsigned char unique_data[16];
|
||||
RAND_bytes(unique_data, 16);
|
||||
for (int i = 0; i < 16; i += 2) {
|
||||
sprintf(unique_id + i, "%02x", unique_data[i]);
|
||||
unsigned char unique_data[UNIQUEID_BYTES];
|
||||
RAND_bytes(unique_data, UNIQUEID_BYTES);
|
||||
for (int i = 0; i < UNIQUEID_BYTES; i++) {
|
||||
sprintf(unique_id + (i * 2), "%02x", unique_data[i]);
|
||||
}
|
||||
fd = fopen(uniqueFileName, "w");
|
||||
fwrite(unique_id, 16, 1, fd);
|
||||
fwrite(unique_id, UNIQUEID_CHARS, 1, fd);
|
||||
} else {
|
||||
fread(unique_id, 16, 1, fd);
|
||||
fread(unique_id, UNIQUEID_CHARS, 1, fd);
|
||||
}
|
||||
fclose(fd);
|
||||
unique_id[16] = 0;
|
||||
unique_id[UNIQUEID_CHARS] = 0;
|
||||
}
|
||||
|
||||
static void client_load_cert() {
|
||||
@ -110,15 +114,20 @@ static void client_load_server_status(const char *address) {
|
||||
|
||||
char *pairedText = NULL;
|
||||
char *currentGameText = NULL;
|
||||
char *versionText = NULL;
|
||||
xml_search(data->memory, data->size, "currentgame", ¤tGameText);
|
||||
xml_search(data->memory, data->size, "PairStatus", &pairedText);
|
||||
xml_search(data->memory, data->size, "appversion", &versionText);
|
||||
http_free_data(data);
|
||||
|
||||
paired = pairedText != NULL && strcmp(pairedText, "1") == 0;
|
||||
currentGame = currentGameText == NULL ? 0 : atoi(currentGameText);
|
||||
strstr(versionText, ".")[0] = 0;
|
||||
serverMajorVersion = atoi(versionText);
|
||||
|
||||
free(pairedText);
|
||||
free(currentGameText);
|
||||
free(versionText);
|
||||
}
|
||||
|
||||
static void bytes_to_hex(unsigned char *in, char *out, size_t len) {
|
||||
@ -241,7 +250,6 @@ void client_pair(const char *address) {
|
||||
|
||||
char *result;
|
||||
xml_search(data->memory, data->size, "challengeresponse", &result);
|
||||
printf("Status %s\n", result);
|
||||
|
||||
char challenge_response_data_enc[48];
|
||||
char challenge_response_data[48];
|
||||
@ -344,3 +352,7 @@ void client_init(const char *address) {
|
||||
|
||||
client_load_server_status(address);
|
||||
}
|
||||
|
||||
int client_get_server_version(void) {
|
||||
return serverMajorVersion;
|
||||
}
|
||||
|
@ -28,3 +28,4 @@ void client_start_app(STREAM_CONFIGURATION *config, const char* serverAddress, i
|
||||
struct app_list* client_applist(const char* serverAddress);
|
||||
int client_get_app_id(const char* serverAddress, char* name);
|
||||
void client_pair(const char *address);
|
||||
int client_get_server_version(void);
|
||||
|
22
src/main.c
22
src/main.c
@ -29,8 +29,11 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <openssl/rand.h>
|
||||
#include <getopt.h>
|
||||
@ -57,9 +60,20 @@ static void stream(STREAM_CONFIGURATION* config, const char* address, const char
|
||||
|
||||
client_start_app(config, address, appId, sops, localaudio);
|
||||
|
||||
struct in_addr addr;
|
||||
inet_aton(address, &addr);
|
||||
LiStartConnection(addr.s_addr, config, &connection_callbacks, &decoder_callbacks, &audio_callbacks, &platform_callbacks, NULL, 0, 4);
|
||||
struct addrinfo hints, *res;
|
||||
memset(&hints, 0, sizeof(hints));
|
||||
hints.ai_family = AF_INET;
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
int err = getaddrinfo(address, NULL, &hints, &res);
|
||||
if (err<0 || res == NULL) {
|
||||
printf("Can't resolve host: %s\n", address);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
struct sockaddr_in *addr = (struct sockaddr_in*)res->ai_addr;
|
||||
LiStartConnection(addr->sin_addr.s_addr, config, &connection_callbacks, &decoder_callbacks,
|
||||
&audio_callbacks, &platform_callbacks, NULL, 0, client_get_server_version());
|
||||
free(res);
|
||||
|
||||
input_loop();
|
||||
|
||||
@ -197,11 +211,11 @@ int main(int argc, char* argv[]) {
|
||||
|
||||
if (address == NULL) {
|
||||
address = malloc(MAX_ADDRESS_SIZE);
|
||||
address[0] = 0;
|
||||
if (address == NULL) {
|
||||
perror("Not enough memory");
|
||||
exit(-1);
|
||||
}
|
||||
address[0] = 0;
|
||||
discover_server(address);
|
||||
if (address[0] == 0) {
|
||||
perror("Can't find server");
|
||||
|
Loading…
x
Reference in New Issue
Block a user