diff --git a/mk/linux/glest.ini b/mk/linux/glest.ini index c59f1b9d2..e7e92cd93 100644 --- a/mk/linux/glest.ini +++ b/mk/linux/glest.ini @@ -66,6 +66,7 @@ MaxLights=3 Masterserver=http://master.megaglest.org/ NetPlayerName=newbie NetworkConsistencyChecks=true +NetworkInterfaces=lo,eth,wlan,vlan,vboxnet,br-lan,br-gest,enp0s,enp1s,enp2s,enp3s,enp4s,enp5s,enp6s,enp7s,enp8s,enp9s PhotoMode=false PortList=61357,61367,61377,61387,61397 PortServer=61357 diff --git a/source/glest_game/main/main.cpp b/source/glest_game/main/main.cpp index 24b2b34e5..47a4157d7 100644 --- a/source/glest_game/main/main.cpp +++ b/source/glest_game/main/main.cpp @@ -4615,6 +4615,14 @@ int glestMain(int argc, char** argv) { removeFile(binaryNameOld); } + string netInterfaces = config.getString("NetworkInterfaces",""); + if(netInterfaces != "") { + //printf("Using network interfaces: %s\n",netInterfaces.c_str()); + std::vector intfList; + Tokenize(netInterfaces,intfList,","); + Socket::setIntfTypes(intfList); + } + if(hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_USE_PORTS]) == true) { int foundParamIndIndex = -1; hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_USE_PORTS]) + string("="),&foundParamIndIndex); diff --git a/source/shared_lib/include/platform/posix/socket.h b/source/shared_lib/include/platform/posix/socket.h index d76c71d53..637685774 100644 --- a/source/shared_lib/include/platform/posix/socket.h +++ b/source/shared_lib/include/platform/posix/socket.h @@ -153,6 +153,7 @@ protected: time_t lastSocketError; static string host_name; + static std::vector intfTypes; public: Socket(PLATFORM_SOCKET sock); @@ -163,6 +164,7 @@ public: static const char * getLastSocketErrorText(int *errNumber=NULL); static string getLastSocketErrorFormattedText(int *errNumber=NULL); + static void setIntfTypes(std::vector intfTypes) { Socket::intfTypes = intfTypes; } static bool disableNagle; static int DEFAULT_SOCKET_SENDBUF_SIZE; static int DEFAULT_SOCKET_RECVBUF_SIZE; diff --git a/source/shared_lib/sources/platform/posix/socket.cpp b/source/shared_lib/sources/platform/posix/socket.cpp index 7a90e0174..d82aad968 100644 --- a/source/shared_lib/sources/platform/posix/socket.cpp +++ b/source/shared_lib/sources/platform/posix/socket.cpp @@ -69,6 +69,7 @@ bool Socket::disableNagle = false; int Socket::DEFAULT_SOCKET_SENDBUF_SIZE = -1; int Socket::DEFAULT_SOCKET_RECVBUF_SIZE = -1; string Socket::host_name = ""; +std::vector Socket::intfTypes; int Socket::broadcast_portno = 61357; int ServerSocket::ftpServerPort = 61358; @@ -701,27 +702,29 @@ std::vector Socket::getLocalIPAddressList() { #ifndef WIN32 // Now check all linux network devices - std::vector intfTypes; - intfTypes.push_back("lo"); - intfTypes.push_back("eth"); - intfTypes.push_back("wlan"); - intfTypes.push_back("vlan"); - intfTypes.push_back("vboxnet"); - intfTypes.push_back("br-lan"); - intfTypes.push_back("br-gest"); - intfTypes.push_back("enp0s"); - intfTypes.push_back("enp1s"); - intfTypes.push_back("enp2s"); - intfTypes.push_back("enp3s"); - intfTypes.push_back("enp4s"); - intfTypes.push_back("enp5s"); - intfTypes.push_back("enp6s"); - intfTypes.push_back("enp7s"); - intfTypes.push_back("enp8s"); - intfTypes.push_back("enp9s"); + //std::vector intfTypes; + if(Socket::intfTypes.empty()) { + Socket::intfTypes.push_back("lo"); + Socket::intfTypes.push_back("eth"); + Socket::intfTypes.push_back("wlan"); + Socket::intfTypes.push_back("vlan"); + Socket::intfTypes.push_back("vboxnet"); + Socket::intfTypes.push_back("br-lan"); + Socket::intfTypes.push_back("br-gest"); + Socket::intfTypes.push_back("enp0s"); + Socket::intfTypes.push_back("enp1s"); + Socket::intfTypes.push_back("enp2s"); + Socket::intfTypes.push_back("enp3s"); + Socket::intfTypes.push_back("enp4s"); + Socket::intfTypes.push_back("enp5s"); + Socket::intfTypes.push_back("enp6s"); + Socket::intfTypes.push_back("enp7s"); + Socket::intfTypes.push_back("enp8s"); + Socket::intfTypes.push_back("enp9s"); + } - for(int intfIdx = 0; intfIdx < (int)intfTypes.size(); intfIdx++) { - string intfName = intfTypes[intfIdx]; + for(unsigned int intfIdx = 0; intfIdx < Socket::intfTypes.size(); intfIdx++) { + string intfName = Socket::intfTypes[intfIdx]; for(int idx = 0; idx < 10; ++idx) { PLATFORM_SOCKET fd = socket(AF_INET, SOCK_DGRAM, 0); //PLATFORM_SOCKET fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);