diff options
author | BobTheBob <32057864+BobTheBob9@users.noreply.github.com> | 2021-12-19 23:09:48 +0000 |
---|---|---|
committer | BobTheBob <32057864+BobTheBob9@users.noreply.github.com> | 2021-12-19 23:09:48 +0000 |
commit | ebf9e11831b6556bf1cf621ffbad6fb071ac4da2 (patch) | |
tree | e448e8eff7f8bdd92d784235fffcaa8009b8d838 | |
parent | 75b9583a6b66c09596f4c0a25188ba4d99ca34da (diff) | |
download | NorthstarLauncher-ebf9e11831b6556bf1cf621ffbad6fb071ac4da2.tar.gz NorthstarLauncher-ebf9e11831b6556bf1cf621ffbad6fb071ac4da2.zip |
server authentication patch to allow for new url to work
-rw-r--r-- | NorthstarDedicatedTest/serverauthentication.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/NorthstarDedicatedTest/serverauthentication.cpp b/NorthstarDedicatedTest/serverauthentication.cpp index 85dc700e..2b6b16af 100644 --- a/NorthstarDedicatedTest/serverauthentication.cpp +++ b/NorthstarDedicatedTest/serverauthentication.cpp @@ -60,7 +60,16 @@ void ServerAuthenticationManager::StartPlayerAuthServer() }); m_playerAuthServer.Post("/authenticate_incoming_player", [this](const httplib::Request& request, httplib::Response& response) { - if (!request.has_param("id") || !request.has_param("authToken") || request.remote_addr != Cvar_ns_masterserver_hostname->m_pszString) + // can't just do request.remote_addr == Cvar_ns_masterserver_hostname->m_pszString because the cvar can be a url, gotta resolve an ip from it for comparisons + unsigned long remoteAddr = inet_addr(request.remote_addr.c_str()); + + char* addrPtr = Cvar_ns_masterserver_hostname->m_pszString; + char* typeStart = strstr(addrPtr, "://"); + if (typeStart) + addrPtr = typeStart + 3; + hostent* resolvedRemoteAddr = gethostbyname((const char*)addrPtr); + + if (!request.has_param("id") || !request.has_param("authToken") || !resolvedRemoteAddr || ((in_addr**)resolvedRemoteAddr->h_addr_list)[0]->S_un.S_addr != remoteAddr) { response.set_content("{\"success\":false}", "application/json"); return; |