Evor 72 Posted January 23, 2015 Share Posted January 23, 2015 Hello folks. Today i will show you have to solve some more or less serious bugs. P2P BASHPANEL: First of all, well mentioned bashpanel. The main cause of this bug is the fact, that game is opening the connection on the Public IP instead of Internal IP. First of all, let's talk about what P2P connections are. P2P is a way for all cores to communicate with each other. The main problem is that, whenever core receives a P2P packet, it doesn't check, if the sender is another core. That's a problem, becouse u can spoof the packet (for ex. using Infinity BashPanel, or simply any packet forge). The fix is really simple and already implemented, but was unnecessarliy commented out. Let's find: (in main.cpp) if ((p2p_socket = socket_tcp_bind(g_szPublicIP, p2p_port)) == INVALID_SOCKET) As we see, p2p is deafult for the PublicIP, but above that, we can see: // if internal ip exists, p2p socket uses internal ip, if not use public ip //if ((p2p_socket = socket_tcp_bind(*g_szInternalIP ? g_szInternalIP : g_szPublicIP, p2p_port)) == INVALID_SOCKET) and that's the way how it should look. To apply it, simply make it look like this: // if internal ip exists, p2p socket uses internal ip, if not use public ip if ((p2p_socket = socket_tcp_bind(*g_szInternalIP ? g_szInternalIP : g_szPublicIP, p2p_port)) == INVALID_SOCKET) //if ((p2p_socket = socket_tcp_bind(g_szPublicIP, p2p_port)) == INVALID_SOCKET) instead of: // if internal ip exists, p2p socket uses internal ip, if not use public ip //if ((p2p_socket = socket_tcp_bind(*g_szInternalIP ? g_szInternalIP : g_szPublicIP, p2p_port)) == INVALID_SOCKET) if ((p2p_socket = socket_tcp_bind(g_szPublicIP, p2p_port)) == INVALID_SOCKET) First bug fixed. Another way (for older revisions) is to use IPFW or other PacketFilters managers to block WAN connection on P2P ports. DB Account BUG: Let's move on. When DB port is Publicly available, user, which knows the account id, can simply use it. To fix it, let's make a "brute" fix, another way (using older revisions) is to write: BIND_IP: 127.0.0.1 in ur config file, but let's fix it more quietly. Simply move to ClientManager.cpp in DB, and change it like so: from: if (!CConfig::instance().GetValue("BIND_IP", szBindIP, 128)) strlcpy(szBindIP, "0", sizeof(szBindIP)); to: if (!CConfig::instance().GetValue("BIND_IP", szBindIP, 128)) strlcpy(szBindIP, "127.0.0.1", sizeof(szBindIP)); That's it. Fixed. Kind regards. 2 10 Link to comment Share on other sites More sharing options...
Premium Galet 510 Posted January 23, 2015 Premium Share Posted January 23, 2015 Wow great ! +1 ! Link to comment Share on other sites More sharing options...
scrabbyyy 20 Posted January 23, 2015 Share Posted January 23, 2015 Hello folks. Today i will show you have to solve some more or less serious bugs. P2P BASHPANEL: First of all, well mentioned bashpanel. The main cause of this bug is the fact, that game is opening the connection on the Public IP instead of Internal IP. First of all, let's talk about what P2P connections are. P2P is a way for all cores to communicate with each other. The main problem is that, whenever core receives a P2P packet, it doesn't check, if the sender is another core. That's a problem, becouse u can spoof the packet (for ex. using Infinity BashPanel, or simply any packet forge). The fix is really simple and already implemented, but was unnecessarliy commented out. Let's find: (in main.cpp) if ((p2p_socket = socket_tcp_bind(g_szPublicIP, p2p_port)) == INVALID_SOCKET) As we see, p2p is deafult for the PublicIP, but above that, we can see: // if internal ip exists, p2p socket uses internal ip, if not use public ip //if ((p2p_socket = socket_tcp_bind(*g_szInternalIP ? g_szInternalIP : g_szPublicIP, p2p_port)) == INVALID_SOCKET) and that's the way how it should look. To apply it, simply make it look like this: // if internal ip exists, p2p socket uses internal ip, if not use public ip if ((p2p_socket = socket_tcp_bind(*g_szInternalIP ? g_szInternalIP : g_szPublicIP, p2p_port)) == INVALID_SOCKET) //if ((p2p_socket = socket_tcp_bind(g_szPublicIP, p2p_port)) == INVALID_SOCKET) instead of: // if internal ip exists, p2p socket uses internal ip, if not use public ip //if ((p2p_socket = socket_tcp_bind(*g_szInternalIP ? g_szInternalIP : g_szPublicIP, p2p_port)) == INVALID_SOCKET) if ((p2p_socket = socket_tcp_bind(g_szPublicIP, p2p_port)) == INVALID_SOCKET) First bug fixed. Another way (for older revisions) is to use IPFW or other PacketFilters managers to block WAN connection on P2P ports. DB Account BUG: Let's move on. When DB port is Publicly available, user, which knows the account id, can simply use it. To fix it, let's make a "brute" fix, another way (using older revisions) is to write: BIND_IP: 127.0.0.1 in ur config file, but let's fix it more quietly. Simply move to ClientManager.cpp in DB, and change it like so: from: if (!CConfig::instance().GetValue("BIND_IP", szBindIP, 128)) strlcpy(szBindIP, "0", sizeof(szBindIP)); to: if (!CConfig::instance().GetValue("BIND_IP", szBindIP, 128)) strlcpy(szBindIP, "127.0.0.1", sizeof(szBindIP)); That's it. Fixed. Kind regards. ohhh friend can i join to my windows server with my local ip 192.168.x.x or localhost with bind_ip of config channel1 ? if that possible with this u are awesome i will check it please look here and reply to me please: so my players connecting with bind_ip of config file from channel 1 but i cant join then with me local ip to my server that both connect will possible with this ? Link to comment Share on other sites More sharing options...
Endymion 319 Posted January 23, 2015 Share Posted January 23, 2015 > BIND_IP in db config are for noobs > BIND_IP: 127.0.0.1 in source when it doesn't exist in conf.txt is for the best developers #Evor 2 Link to comment Share on other sites More sharing options...
scrabbyyy 20 Posted January 23, 2015 Share Posted January 23, 2015 > BIND_IP in db config are for noobs > BIND_IP: 127.0.0.1 in source when it doesn't exist in conf.txt is for the best developers #Evor friend leave to give mind so have u any comment-contribution for this so say it just Link to comment Share on other sites More sharing options...
scrabbyyy 20 Posted January 24, 2015 Share Posted January 24, 2015 Hello folks. Today i will show you have to solve some more or less serious bugs. P2P BASHPANEL: First of all, well mentioned bashpanel. The main cause of this bug is the fact, that game is opening the connection on the Public IP instead of Internal IP. First of all, let's talk about what P2P connections are. P2P is a way for all cores to communicate with each other. The main problem is that, whenever core receives a P2P packet, it doesn't check, if the sender is another core. That's a problem, becouse u can spoof the packet (for ex. using Infinity BashPanel, or simply any packet forge). The fix is really simple and already implemented, but was unnecessarliy commented out. Let's find: (in main.cpp) if ((p2p_socket = socket_tcp_bind(g_szPublicIP, p2p_port)) == INVALID_SOCKET) As we see, p2p is deafult for the PublicIP, but above that, we can see: // if internal ip exists, p2p socket uses internal ip, if not use public ip //if ((p2p_socket = socket_tcp_bind(*g_szInternalIP ? g_szInternalIP : g_szPublicIP, p2p_port)) == INVALID_SOCKET) and that's the way how it should look. To apply it, simply make it look like this: // if internal ip exists, p2p socket uses internal ip, if not use public ip if ((p2p_socket = socket_tcp_bind(*g_szInternalIP ? g_szInternalIP : g_szPublicIP, p2p_port)) == INVALID_SOCKET) //if ((p2p_socket = socket_tcp_bind(g_szPublicIP, p2p_port)) == INVALID_SOCKET) instead of: // if internal ip exists, p2p socket uses internal ip, if not use public ip //if ((p2p_socket = socket_tcp_bind(*g_szInternalIP ? g_szInternalIP : g_szPublicIP, p2p_port)) == INVALID_SOCKET) if ((p2p_socket = socket_tcp_bind(g_szPublicIP, p2p_port)) == INVALID_SOCKET) First bug fixed. Another way (for older revisions) is to use IPFW or other PacketFilters managers to block WAN connection on P2P ports. DB Account BUG: Let's move on. When DB port is Publicly available, user, which knows the account id, can simply use it. To fix it, let's make a "brute" fix, another way (using older revisions) is to write: BIND_IP: 127.0.0.1 in ur config file, but let's fix it more quietly. Simply move to ClientManager.cpp in DB, and change it like so: from: if (!CConfig::instance().GetValue("BIND_IP", szBindIP, 128)) strlcpy(szBindIP, "0", sizeof(szBindIP)); to: if (!CConfig::instance().GetValue("BIND_IP", szBindIP, 128)) strlcpy(szBindIP, "127.0.0.1", sizeof(szBindIP)); That's it. Fixed. Kind regards. so i tested with all arguments that just for close bind_ip or active so still cant connect my server with my local ip adress but players can join with bind_ip channel1 Link to comment Share on other sites More sharing options...
Premium Cataclismo 86 Posted January 25, 2015 Premium Share Posted January 25, 2015 One simple question: for channels to talk to each other needs the same port? I mean P2P_PORT has to be the same in all channels? Link to comment Share on other sites More sharing options...
Endymion 319 Posted January 25, 2015 Share Posted January 25, 2015 No. Link to comment Share on other sites More sharing options...
Active Member Mind Rapist 188 Posted May 17, 2016 Active Member Share Posted May 17, 2016 I did that and the only thing I made was to cause socket_tcp_bind error every time I try to turn the channels on. I undid the p2p proccess and still... And before you ask yes I have my server's IP at all CONFIG files (BIND_IP)... So what can I do to fix this? EDIT: To undo it and work, you have to perform a full build (gmake all) and not just a game build (/game/src && gmake -j20). The reason is unknow, it just works this way I also tried full build with @Evor's fix but that didn't work... Link to comment Share on other sites More sharing options...
Tallywa 35 Posted August 29, 2017 Share Posted August 29, 2017 with this // if internal ip exists, p2p socket uses internal ip, if not use public ip //if ((p2p_socket = socket_tcp_bind(*g_szInternalIP ? g_szInternalIP : g_szPublicIP, p2p_port)) == INVALID_SOCKET) if ((p2p_socket = socket_tcp_bind(g_szPublicIP, p2p_port)) == INVALID_SOCKET) i have this error with start server start.sh: ./game_ch1_1: Text file busy start.sh: ./game_ch1_2: Text file busy Link to comment Share on other sites More sharing options...
colcrt 0 Posted October 30, 2018 Share Posted October 30, 2018 if I have bind_ip: ip publishes in the config that I must do then? Excuse me for reliving this post. Link to comment Share on other sites More sharing options...
OkamiRo 5 Posted May 23, 2020 Share Posted May 23, 2020 On 8/30/2017 at 12:54 AM, Tallywa said: with this // if internal ip exists, p2p socket uses internal ip, if not use public ip //if ((p2p_socket = socket_tcp_bind(*g_szInternalIP ? g_szInternalIP : g_szPublicIP, p2p_port)) == INVALID_SOCKET) if ((p2p_socket = socket_tcp_bind(g_szPublicIP, p2p_port)) == INVALID_SOCKET) // if internal ip exists, p2p socket uses internal ip, if not use public ip //if ((p2p_socket = socket_tcp_bind(*g_szInternalIP ? g_szInternalIP : g_szPublicIP, p2p_port)) == INVALID_SOCKET) if ((p2p_socket = socket_tcp_bind(g_szPublicIP, p2p_port)) == INVALID_SOCKET) i have this error with start server start.sh: ./game_ch1_1: Text file busy start.sh: ./game_ch1_2: Text file busy Just change like this // if internal ip exists, p2p socket uses internal ip, if not use public ip if ((p2p_socket = socket_tcp_bind(*g_szInternalIP ? g_szInternalIP : g_szPublicIP, p2p_port)) == INVALID_SOCKET) //if ((p2p_socket = socket_tcp_bind(g_szPublicIP, p2p_port)) == INVALID_SOCKET) i know it's older answer but perhaps some users will need this even is written above. Link to comment Share on other sites More sharing options...
Recommended Posts