Skip to content

Commit

Permalink
fixed load of known hosts
Browse files Browse the repository at this point in the history
  • Loading branch information
mariotaku committed Oct 15, 2024
1 parent 55cb13d commit 4b10b62
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ target_link_libraries(moonlight-lib PUBLIC commons-ss4s-modules-list commons-sps

target_link_libraries(moonlight-lib PUBLIC commons-logging commons-gamecontrollerdb-updater commons-lazy
commons-refcounter commons-executor commons-linked-list commons-wol commons-ini-writer commons-copyfile
commons-sockaddr commons-host)
commons-sockaddr commons-hostport)

configure_file(src/app/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h @ONLY)
target_include_directories(moonlight-lib PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
Expand Down
2 changes: 1 addition & 1 deletion src/app/backend/pcmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "libgamestream/client.h"
#include "uuidstr.h"
#include "sockaddr.h"
#include "host.h"
#include "hostport.h"

typedef struct app_t app_t;
typedef struct pcmanager_t pcmanager_t;
Expand Down
13 changes: 6 additions & 7 deletions src/app/backend/pcmanager/known_hosts.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "util/ini_ext.h"
#include "util/path.h"
#include "app_settings.h"
#include "sockaddr.h"

#define LINKEDLIST_IMPL
#define LINKEDLIST_MODIFIER static
Expand All @@ -36,9 +35,9 @@ void pcmanager_load_known_hosts(pcmanager_t *manager) {
bool selected_set = false;
for (known_host_t *cur = hosts; cur; cur = cur->next) {
const char *mac = cur->mac, *hostname = cur->hostname;
const struct sockaddr *address = cur->address;
char address_buf[64] = {0};
sockaddr_get_ip_str(address, address_buf, sizeof(address_buf));
const host_t *address = cur->address;
char address_buf[256] = {0};
host_to_string(address, address_buf, sizeof(address_buf));
if (!mac || !hostname || !address) {
commons_log_warn("PCManager", "Unknown host entry: mac=%s, hostname=%s, address=%s", mac, hostname,
address_buf);
Expand All @@ -49,8 +48,8 @@ void pcmanager_load_known_hosts(pcmanager_t *manager) {
server->uuid = uuidstr_tostr(&cur->uuid);
server->mac = mac;
server->hostname = hostname;
server->serverInfo.address = strdup(address_buf);
server->extPort = sockaddr_get_port(address);
server->serverInfo.address = strdup(host_get_hostname(address));
server->extPort = host_get_port(address);

pclist_t *node = pclist_insert_known(manager, &cur->uuid, server);

Expand Down Expand Up @@ -128,7 +127,7 @@ static int known_hosts_handle(known_host_t **list, const char *section, const ch
} else if (INI_NAME_MATCH("hostname")) {
host->hostname = SDL_strdup(value);
} else if (INI_NAME_MATCH("address")) {
host->address = sockaddr_parse(value);
host->address = host_parse(value);
} else if (INI_NAME_MATCH("selected")) {
host->selected = INI_IS_TRUE(value);
} else if (INI_NAME_MATCH("favorite")) {
Expand Down
4 changes: 2 additions & 2 deletions src/app/backend/pcmanager/known_hosts.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@

#include "backend/types.h"
#include "uuidstr.h"
#include "sockaddr.h"
#include "hostport.h"

typedef struct known_host_t {
uuidstr_t uuid;
char *mac;
char *hostname;
struct sockaddr *address;
host_t *address;
bool selected;
appid_list_t *favs;
appid_list_t *hidden;
Expand Down
2 changes: 1 addition & 1 deletion src/app/backend/pcmanager/pcmanager.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void pcmanager_destroy(pcmanager_t *manager) {


void pcmanager_auto_discovery_start(pcmanager_t *manager) {
discovery_start(&manager->discovery);
// discovery_start(&manager->discovery);
}

void pcmanager_auto_discovery_stop(pcmanager_t *manager) {
Expand Down

0 comments on commit 4b10b62

Please sign in to comment.