Best way to connect with server on dynamic IP.

Support for the latest build of L2J Server, get help here with installations, upgrades, problems.
Do not post bugs reports here, use viewforum.php?f=77 instead.
There is no support for other server builds than the official provided by l2jserver.com
Forum rules
READ NOW: L2j Forums Rules of Conduct
morozaw
Posts: 5
Joined: Sun Sep 15, 2013 10:38 am

Best way to connect with server on dynamic IP.

Post by morozaw »

If you want to receive support we need this info to help you properly.
» Find Revision
L2J Revision Number: newest / all
L2JDP Revision Number: newest /all

Hello guys, i'm looking for from about 3 hours a solution for this problem.
How i can connect to my server on dynamic ip without editing l2.ini?
Editing and patching system is the only best way or did You have better solution of this problem? I know - client mods are prohibited on this forum.
Client H5 - server l2j newest.
I've find in web some scripts / program to automatic editing hosts file but of course links are dead.

Any other ideas?

My server dns:
morozaw.dyndns.org

Cheers!
User avatar
BiggBoss
L2j Veteran
L2j Veteran
Posts: 1104
Joined: Wed Apr 15, 2009 3:11 pm
Location: Spain

Re: Best way to connect with server on dynamic IP.

Post by BiggBoss »

inject connect function to redirect the host. Any socket based app will go througt this function
Image
morozaw
Posts: 5
Joined: Sun Sep 15, 2013 10:38 am

Re: Best way to connect with server on dynamic IP.

Post by morozaw »

Could You write a short tutorial what do You mean or give link to smth? :)
Did You mean shortcut with added comand in line with hostname?
User avatar
tukune
Posts: 533
Joined: Sun Mar 29, 2009 2:35 pm
Location: Japan

Re: Best way to connect with server on dynamic IP.

Post by tukune »

:!:

Code: Select all

@ECHO OFFSET YOURHOST=morozaw.dyndns.orgSET AUTHHOST=l2authd.lineage2.com TITLE %YOURHOST%perl -e "use Socket;print """127.0.0.1 localhost\r\n$ip %AUTHHOST%\r\n""" if $ip=join('.',unpack C4=>(gethostbyname '%YOURHOST%')[4]);exit not $ip;">hosts.txt||(ECHO Error: %YOURHOST% - Cannot Resolve IP Address.& PAUSE & GOTO :EOF)COPY hosts.txt %SystemRoot%\system32\drivers\etc\hostsCD /D "%ProgramFiles%\NCZ0ft\Lineage II\system"CD /D "%ProgramFiles(x86)%\NCZ0ft\Lineage II\system"START L2.bin
Last edited by tukune on Sun Sep 15, 2013 1:45 pm, edited 1 time in total.
User avatar
BiggBoss
L2j Veteran
L2j Veteran
Posts: 1104
Joined: Wed Apr 15, 2009 3:11 pm
Location: Spain

Re: Best way to connect with server on dynamic IP.

Post by BiggBoss »

Image
morozaw
Posts: 5
Joined: Sun Sep 15, 2013 10:38 am

Re: Best way to connect with server on dynamic IP.

Post by morozaw »

Thank You for reply.
BiggBoss, it is not my level of programming yet.
I thought it is something more simple. Maybe somewhere is a complete app?

JOJO, this script editing host file?
As I conjecture, I must have perl binaries installed in Windows?
Sorry for stupid question - how to run it?
Somewhere i see this code in batch script.Unfortunately, this script is not universal.
Script works only with English version of system. I must edit it every time, when player has other default language in system.

Something else? :)
I think, this will be helpfull not only for me :)
User avatar
UnAfraid
L2j Veteran
L2j Veteran
Posts: 4199
Joined: Mon Jul 23, 2007 4:25 pm
Location: Bulgaria
Contact:

Re: Best way to connect with server on dynamic IP.

Post by UnAfraid »

perl?

that's simple bat scripting
Image
User avatar
jurchiks
Posts: 6769
Joined: Sat Sep 19, 2009 4:16 pm
Location: Eastern Europe

Re: Best way to connect with server on dynamic IP.

Post by jurchiks »

JOJO's code clearly says "perl -e"...
If you have problems, FIRST TRY SOLVING THEM YOURSELF, and if you get errors, TRY TO ANALYZE THEM, and ONLY if you can't help it, THEN ask here.
Otherwise you will never learn anything if all you do is copy-paste!
Discussion breeds innovation.
morozaw
Posts: 5
Joined: Sun Sep 15, 2013 10:38 am

Re: Best way to connect with server on dynamic IP.

Post by morozaw »

Guys, maybe somebody would like to help?
Jurchiks, thanks! :)
User avatar
UnAfraid
L2j Veteran
L2j Veteran
Posts: 4199
Joined: Mon Jul 23, 2007 4:25 pm
Location: Bulgaria
Contact:

Re: Best way to connect with server on dynamic IP.

Post by UnAfraid »

I'd rather code some launcher on C#
Image
User avatar
jurchiks
Posts: 6769
Joined: Sat Sep 19, 2009 4:16 pm
Location: Eastern Europe

Re: Best way to connect with server on dynamic IP.

Post by jurchiks »

You need to maintain the connection throughout the game session (we're talking about dynamic IP here), can a launcher do that?
If you have problems, FIRST TRY SOLVING THEM YOURSELF, and if you get errors, TRY TO ANALYZE THEM, and ONLY if you can't help it, THEN ask here.
Otherwise you will never learn anything if all you do is copy-paste!
Discussion breeds innovation.
User avatar
BiggBoss
L2j Veteran
L2j Veteran
Posts: 1104
Joined: Wed Apr 15, 2009 3:11 pm
Location: Spain

Re: Best way to connect with server on dynamic IP.

Post by BiggBoss »

[c] #include <windows.h>#include <winsock2.h>#include <stdlib.h> #pragma comment(lib,"ws2_32.lib"); typedef int (__stdcall* new_connect)(SOCKET socket, sockaddr *name, int namelen);new_connect hook; int __stdcall InjectedConnect(SOCKET socket, sockaddr *name, int namelen) {    sockaddr_in * name_in = (sockaddr_in*)name;    name_in->sin_addr->S_un.S_addr = inet_addr("your.hostname.goes.here");        return hook(socket,name,namelen);} void inject() {    char * alloc_mem = (char*)VirtualAlloc(NULL, 0x1000, MEM_COMMIT, PAGE_EXECUTE_READWRITE);        HMODULE ws2_32 = GetModuleHandle(L"ws2_32.dll");    if(ws2_32 == 0) {        ws2_32 = LoadLibrary(L"ws2_32.dll");    }        char * old_connect_addr = (char*)GetProcAddress(ws2_32, "connect");        if(*old_connect_addr == 0xe9) {        int old_relative = *(int*)(old_connect_addr + 1);        DWORD32 absolute = (DWORD32)(old_connect_addr + old_relative + 5);        *alloc_mem = 0xe9;        *(int*)(alloc_mem + 1) = (int)(absolute - (alloc_mem + 5));    } else {        memcpy(alloc_mem,old_connect_addr,5);        *(alloc_mem + 5)= 0xe9;        *(int*)(alloc_mem + 6) = (int)(old_connect_addr + 5 - (alloc_mem + 10));    }        DWORD prot;    VirtualProtect(old_connect_addr,5,PAGE_EXECUTE_READWRITE, &prot);    *old_connect_addr = 0xe9;    *(int*)(old_connect_addr + 1) = (int)( &InjectedConnect - (old_connect_addr + 5));    VirtualProtect(old_connect_addr,5,prot,&prot);        hook = (new_connect)alloc_mem;} _declspec(dllexport) BOOL APIENTRY DllMain( HMODULE hModule, DWORD  ul_reason_for_call, LPVOID lpReserved) {    if(ul_reason_for_call == DLL_PROCESS_ATTACH || ul_reason_for_call == DLL_THREAD_ATTACH)        inject();    return TRUE;} [/c]
Image
User avatar
UnAfraid
L2j Veteran
L2j Veteran
Posts: 4199
Joined: Mon Jul 23, 2007 4:25 pm
Location: Bulgaria
Contact:

Re: Best way to connect with server on dynamic IP.

Post by UnAfraid »

jurchiks wrote:You need to maintain the connection throughout the game session (we're talking about dynamic IP here), can a launcher do that?
Yes why not?
Image
morozaw
Posts: 5
Joined: Sun Sep 15, 2013 10:38 am

Re: Best way to connect with server on dynamic IP.

Post by morozaw »

Many many thanks BiggBoss.
I think You should sticky this code for other users if it works :)

Could You tell me in short how it works and how to compile it?
I must inject this into running program? How to make it automatically?
Sorry, i am newbie in this :)

UnAfraid, what about the launcher?
Maybe this is good base for that?

Cheers!
User avatar
BiggBoss
L2j Veteran
L2j Veteran
Posts: 1104
Joined: Wed Apr 15, 2009 3:11 pm
Location: Spain

Re: Best way to connect with server on dynamic IP.

Post by BiggBoss »

compile to a dll. Now, you have 2 ways, attach it to the l2 executable header or create a remote thread in the l2 process, thats all.
Image
Post Reply