Management Karbust 4910 Posted November 13, 2021 Management Share Posted November 13, 2021 Sup bois and grils I still see a lot of people not being able to select the character when using a local server for friends or VPS behind a internal router or firewall. Disclaimer: This code (apart from the changes to support DNS names) wasn't made by me, it was originally posted on the metin2dev's French brother Funky-Emu by @Veltor88. On service.h add this: #define ENABLE_PROXY_IP On char.cpp: After: p.lAddr = lAddr; Add: #ifdef ENABLE_PROXY_IP if (!g_stProxyIP.empty()) p.lAddr = inet_addr(g_stProxyIP.c_str()); #endif Like this: On config.cpp: After (or anywhere within the global variables definition): char g_szInternalIP[16] Add: #ifdef ENABLE_PROXY_IP std::string g_stProxyIP = ""; #endif Like this: Still on config.cpp: After: the last TOKEN Add: #ifdef ENABLE_PROXY_IP TOKEN("proxy_ip") { #ifndef WIN32 if (validateIpAddress(value_string)) g_stProxyIP = value_string; else { struct hostent *host = gethostbyname(value_string); g_stProxyIP = inet_ntoa(*(struct in_addr *)host->h_addr_list[0]); fprintf(stderr, "PROXY_IP: [%s] resolves to [%s]\n", value_string, g_stProxyIP.c_str()); } #else g_stProxyIP = value_string; #endif fprintf(stderr, "PROXY_IP: %s\n", g_stProxyIP.c_str()); } #endif Like this: Still on config.cpp: Before: void config_init(const string& st_localeServiceName) Add: bool validateIpAddress(const std::string &ipAddress) { #ifndef WIN32 struct sockaddr_in sa; int result = inet_pton(AF_INET, ipAddress.c_str(), &(sa.sin_addr)); return result != 0; #else return true; #endif } Like this: On config.h: After (or anywhere in the file): extern char g_szInternalIP[16]; Add: #ifdef ENABLE_PROXY_IP extern std::string g_stProxyIP; #endif Like this: On desc.cpp: Within the function: void DESC::SendLoginSuccessPacket() Inside: for (int i = 0; i < PLAYER_PER_ACCOUNT; ++i) Add in the beginning: #ifdef ENABLE_PROXY_IP if (!g_stProxyIP.empty()) rTable.players[i].lAddr=inet_addr(g_stProxyIP.c_str()); #endif Like this: On input_db.cpp: Withing the function: bool GetServerLocation(TAccountTable & rTab, BYTE bEmpire) After: rTab.players[i].szName); Add: #ifdef ENABLE_PROXY_IP if (!g_stProxyIP.empty()) rTab.players[i].lAddr=inet_addr(g_stProxyIP.c_str()); #endif Still on input_db.cpp and within the same function: After: struct in_addr in; Add: #ifdef ENABLE_PROXY_IP if (!g_stProxyIP.empty()) rTab.players[i].lAddr=inet_addr(g_stProxyIP.c_str()); #endif Like this: Still on the same file: Within the function: void CInputDB::PlayerCreateSuccess(LPDESC d, const char * data) After: pack.player = pPacketDB->player; Add: #ifdef ENABLE_PROXY_IP if (!g_stProxyIP.empty()) pack.player.lAddr=inet_addr(g_stProxyIP.c_str()); #endif Like this: Done on the source, you can compile. On every channel config, add this: BIND_IP: <Private IPv4 IP> (it will be something within a private IP class. Check the IP of the machine using the "ifconfig" command) PROXY_IP: <Public IPv4 IP or a domain name (like example.com)> (check out something like https://www.whatismyip.com) DNS names will only work on FreeBSD. I didn't make the code for Windows. Private IPv4 classes: On some sources (like the one from vanilla, BIND_IP was renamed to PUBLIC_IP, just check which TOKEN is responsible to set the value on the variable g_szPublicIP. You will need to open the ports on your router, even for yourself on localhost with the virtual machine because the game server will try to "proxy" you through the public IP you defined. This wasn't tested using a VPN, like Hamachi or ZeroTier. 2 2 2 5 Link to comment Share on other sites More sharing options...
tomika1997 2 Posted November 22, 2022 Share Posted November 22, 2022 Hi no work this on (ceteus2) Link to comment Share on other sites More sharing options...
Management Karbust 4910 Posted February 22, 2023 Author Management Share Posted February 22, 2023 Added support for DNS names. All the changes are on config.cpp. Link to comment Share on other sites More sharing options...
Stadi 14 Posted January 14 Share Posted January 14 (edited) Hello developers, I apologize for reaching out here, but something seems to be not working for me with this content, or perhaps I am doing something wrong Everything is set up exactly as described, including the server files and the recommended TMP... After choosing the character, the game still returns to the login screen. There are no syserr logs. From this, I suspect it might not be an error but some other issue. Ports are open and verified. I will attach images of the AUTH and GAME first log files. If you could help me figure out where to start looking for the problem, I would appreciate it auth and game first,and DB log file: sorry for my English, I'm not asking to be replaced! I just want to finally figure out what could be wrong with being able to play with 10-15 friends online. I might even pay for the help if the information is really useful for me or if this problem can be solved DC: it can be found on my profile or I can be reached here Thanks in advance!!!! Edited January 14 by Metin2 Dev International Core X - External 2 Internal Link to comment Share on other sites More sharing options...
amerikai12 0 Posted May 21 Share Posted May 21 On 11/13/2021 at 12:25 PM, Karbust said: BIND_IP: <Private IPv4 IP> (it will be something within a private IP class. Check the IP of the machine using the "ifconfig" command) PROXY_IP: <Public IPv4 IP or a domain name (like example.com)> (check out something like https://www.whatismyip.com) On every channel config, add this: I dont realy understand this last thing. Where are these channel configs? Link to comment Share on other sites More sharing options...
Recommended Posts