• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Feature Auto Global IP

gm neo colombia

Biosoft-OTP
Joined
Jul 4, 2007
Messages
45
Reaction score
0
Location
Medellin / Colombia
in otserv.cpp
after:
Code:
ip = g_config.getString(ConfigManager::IP);

add:
Code:
    hostent *he = gethostbyname(szHostName);
    unsigned char** addr = (unsigned char**)he->h_addr_list;
    std::ostringstream localIP;
    localIP 
    << (unsigned int)(addr[0][0]) << "."
    << (unsigned int)(addr[0][1]) << "."
    << (unsigned int)(addr[0][2]) << "."
    << (unsigned int)(addr[0][3]) << "  ";
    if (ip == "auto")
    ip = localIP.str().c_str();

Edit config.lua
and
ip = "*.*.*.*"
change:
ip = "auto"
 
this only gets local interfaces ip number ><

won't work with people behind nat routers
 
Because of this error when I try to compile?

error:
2pqrsp4.jpg
 
use curl
Code:
#include <cstdlib>
#include <iostream>
#include <curl/curl.h>

using namespace std;

std::string buffer;

size_t curl_write( void *ptr, size_t size, size_t nmemb, void *stream)
{
    string temp(static_cast<const char*>(ptr), size * nmemb);
    buffer=temp;
    return size*nmemb;
}

std::string getGlobalIP()
{
    curl_global_init(CURL_GLOBAL_ALL);
    CURL * curl = curl_easy_init();
    curl_easy_setopt(curl, CURLOPT_URL, "http://dynupdate.no-ip.com/ip.php");
    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_write);
    curl_easy_perform(curl);
    curl_easy_cleanup(curl);
    return buffer;
}

int main(int argc, char *argv[])
{
    std::cout << getGlobalIP() << std::endl;
    system("PAUSE");
    return EXIT_SUCCESS;
}
 
friend, why this error happens when I try to compile, install curl got everything correct, however when this error appears compiles.

Code:
C:\Documents and Settings\Renan\Desktop\TFS 0.4\otserv.cpp||In function 'void otserv(ServiceManager*)':|
C:\Documents and Settings\Renan\Desktop\TFS 0.4\otserv.cpp|902|error: a function-definition is not allowed here before '{' token|
C:\Documents and Settings\Renan\Desktop\TFS 0.4\otserv.cpp|909|error: a function-definition is not allowed here before '{' token|
C:\Documents and Settings\Renan\Desktop\TFS 0.4\otserv.cpp|920|error: a function-definition is not allowed here before '{' token|
||=== Build finished: 3 errors, 0 warnings ===|
 
Last edited:
Back
Top