Skip to content
This repository has been archived by the owner on Jun 8, 2023. It is now read-only.

Commit

Permalink
Changed IP address text
Browse files Browse the repository at this point in the history
  • Loading branch information
victorrjimenezz committed Feb 5, 2022
1 parent b2beaab commit 4c095e5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ bool Server::startServer() {

memset(&opt, 0, sizeof(opt));
#ifdef _WIN32
opt.host = getIP().c_str();
opt.host = "0.0.0.0";
#endif
opt.port = "80";
opt.handler = event_handler;
Expand Down
2 changes: 0 additions & 2 deletions src/mainView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,12 +375,10 @@ void mainView::runServer() {
runServerButton->setText(tr("Stop Server"));
std::string IPString = "Server Running on ";
IPString+= IPAddress;
IPString+= ":80";
serverStatus->setText(tr(IPString.c_str()));
} else {
std::string IPString = "Could not start server on ";
IPString+= IPAddress;
IPString+= ":80";
serverStatus->setText(tr(IPString.c_str()));
}
}
Expand Down
21 changes: 20 additions & 1 deletion src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,31 @@
#include <netdb.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#elif _WIN32
#include <winsock2.h>
#endif


#ifdef _WIN32
std::string getIP(){
return "0.0.0.0";
std::string IPV4 = "ERROR: NO INTERNET ADAPTER FOUND";
WORD wVersionRequested = MAKEWORD(2, 2);
WSADATA wsaData;
if (WSAStartup(wVersionRequested, &wsaData) != 0)
return 0;
char local[255] = { 0 };
gethostname(local, sizeof(local));
auto hostInfo = gethostbyname(&local[0]);
if(hostInfo)
{
for( int i=0 ; hostInfo->h_addr_list[i] ; ++i )
{
const in_addr* address = (in_addr*)hostInfo->h_addr_list[i] ;
IPV4 = inet_ntoa( *address );
}
}
WSACleanup();
return IPV4;
}
#elif __APPLE__

Expand Down

0 comments on commit 4c095e5

Please sign in to comment.