Connect using a DNS

All Helbreath Client Source Discussion here.
Post Reply
xenx
Member
Posts: 169
Joined: Tue Oct 03, 2006 7:08 am

Post by xenx »

Has anyone managed to make a login.cfg and or code for the client so that it can connect using a DNS?

and if so, willing to share?
Sprint
Spamtastic
Posts: 1000
Joined: Tue Jun 06, 2006 6:59 am
Location: Far from home
Contact:

Post by Sprint »

dun think it would be smart, just my oppinion :)
btw what would you need it for?
<span style='color:blue'><span style='font-size:19pt;line-height:100%'><u><b>FUCK Helbreath!</b></u></span></span><br><br><span style='color:gray'><a href='http://www2.analystica.com/users/anttu/online/ngd' target='_blank'>ngdnetwork</a> OFFICIAL WEBSITE OF Northern Game Developers. Do visit! (THEY ARE UP!)<br><a href='http://project3d.x.am' target='_blank'>Project3d development forum</a> plz join and discuss,develop,give ideas,feedback. Anything goes as long it helps the project!</span><br><br>Zepto Znote 6625WD: 1.8Ghz dual core, 2GB, 512mb graphics card(dedicated), 160GB HDD<br><img src='http://www.signaturebar.com/uploads/images/10111.jpg' border='0' alt='user posted image' /><br><img src='http://www.signaturebar.com/uploads/images/13229.jpg' border='0' alt='user posted image' /><br><img src='http://www.signaturebar.com/uploads/images/8852.png' border='0' alt='user posted image' />
isolator
noob
Posts: 28
Joined: Fri Aug 05, 2005 2:37 am

Post by isolator »

Sprint wrote: dun think it would be smart, just my oppinion :)
btw what would you need it for?
obviously, for convenience
xenx
Member
Posts: 169
Joined: Tue Oct 03, 2006 7:08 am

Post by xenx »

if u have hosters that arent on a static ip it can get really annoying having to redistribute the LOGIN.cfg to players all the time,
would be much easyer to use no-ip or something and tell the client to connect to to a DNS

i know its possible i was looking yesterday at some C++ code to resolve DNS addresses, its just getting them to work on the client thats gonna be the problem,

im sure it wouldnt be that hard to make the client accept a http:// adress in LOGIN.cfg
Tafka12
&lt;3 bd long time
Posts: 772
Joined: Wed Dec 28, 2005 6:32 pm

Post by Tafka12 »

<span style='color:purple'>It was posted somewhere already. I don't remember where but Client Source too. Try to look around here.</span>
<img src='http://www.hot.ee/carvanho/taavi.png' border='0' alt='user posted image' /><br><br><img src='http://www.hot.ee/carvanho/Elvine.png' border='0' alt='user posted image' /><br><img src='http://www.hot.ee/carvanho/LieroX.png' border='0' alt='user posted image' /><br><img src='http://www.hot.ee/carvanho/Football.png' border='0' alt='user posted image' />
xenx
Member
Posts: 169
Joined: Tue Oct 03, 2006 7:08 am

Post by xenx »

hmm iv had a look around i cant see anything about it, maybe its an old post thats been deleted, can u remember how they went about it?

EDIT* I found some code on an old post for resolving a DNS address from the ip that used to be in the client,

iv edited it and made it work along side the login.cfg code we have now, so now my login.cfg will accept IP addresses, and http:// addresses

im just too good for my own good, and after only a week of teaching myself C++ muahahaha
xenx
Member
Posts: 169
Joined: Tue Oct 03, 2006 7:08 am

Post by xenx »

Of folks, for your viewing pleasure, heres the code for connecting via a DNS instead of an ip address (ip address still works btw)
i didnt actually code this myself i found a post on how to do it in an old client that u had to hex edit, heres how to do it on a newer client that uses the LOGIN.CFG

Ok in Game.h just under

Code: Select all

	short m_sMonsterID;
	short m_sEventX, m_sEventY;
add this right after:

Code: Select all

	void GetIPByDNS();

	char m_cLogServerAddrBuffer[100];
next go to Game.cpp and find this,

Code: Select all

BOOL CGame::bReadLoginConfigFile(char * cFn)
scroll down a bit till u get to this

Code: Select all

DEFAULT_IP:
	ZeroMemory(m_cLogServerAddr, sizeof(m_cLogServerAddr));
	strcpy(m_cLogServerAddr, DEF_SERVER_IP);
	m_iLogServerPort = DEF_SERVER_PORT;
	return TRUE;
}
right after it, add this :

Code: Select all

void CGame::GetIPByDNS()
{
ZeroMemory(m_cLogServerAddr, sizeof(m_cLogServerAddr));
if (m_cLogServerAddrBuffer[0] >= 65 && m_cLogServerAddrBuffer[0] <= 122) {
 char cDnsResult[40];
 struct hostent *host_entry;

 host_entry = gethostbyname(m_cLogServerAddrBuffer);
 if (host_entry == NULL){
  MessageBox(m_hWnd, "Failed to get DNS entry for the logserver!", "ERROR1", MB_ICONEXCLAMATION | MB_OK);
  _exit(0);
 }
 ZeroMemory(cDnsResult, sizeof(cDnsResult));
 wsprintf(cDnsResult, "%d.%d.%d.%d",
 ( host_entry->h_addr_list[0][0] & 0x00ff ),
 ( host_entry->h_addr_list[0][1] & 0x00ff ),
 ( host_entry->h_addr_list[0][2] & 0x00ff ),
 ( host_entry->h_addr_list[0][3] & 0x00ff ));

 strcpy(m_cLogServerAddr, cDnsResult);
 }
else strcpy(m_cLogServerAddr, m_cLogServerAddrBuffer);
}
next you need to do a search for this:

Code: Select all

m_pLSock = new class XSocket(m_hWnd, DEF_SOCKETBLOCKLIMIT);
there will be a lot of these, right after each one add this:

Code: Select all

GetIPByDNS();
remember theres quite a few so search till u reach the end.

ok thats all the new code, just a few small edits of existing code to go,
go back up to the DEFAULT_IP: part i mentioned earlyer, and scroll up till you come to

Code: Select all

    
ZeroMemory(m_cLogServerAddr, sizeof (m_cLogServerAddr));
    strcpy(m_cLogServerAddr, token);
    cReadMode = 0;
WARNING this is not the one directly under DEFAULT_IP it is above ,it will be in the log-server-address bit
now u need to edit all three of those m_cLogServerAddr
so they say m_cLogServerAddrBuffer

your code will look like this:

Code: Select all

    ZeroMemory(m_cLogServerAddrBuffer, sizeof(m_cLogServerAddrBuffer));
    strcpy(m_cLogServerAddrBuffer, token);
    cReadMode = 0;
ok next look about 5 or 6 lines above the code above and you will see if (strlen(token) > with a value, prolly 15 if (strlen(token) > 15
you will need to make this value larger i suddgest about 30
if (strlen(token) > 30

and last but not least do a search for

Code: Select all

char m_cLogServerAddr
you should find one near the bottom of the file, this also has a value like char m_cLogServerAddr[15]; u need to edit whatever this value to about 30 as well

both these values are so that the client will actually remember a long http:// address, so bear in mind if yours is really long you will need to increase them a little more

and thats it all done, you should now be able to just wack either an ip or a http:// address into LOGIN.cfg and away you go

hope this all made sence to the less experienced of u :)

PS any address that works in internet explorer will alos work in LOGIN.CFG it doesnt have to be http:// it can be whatever as long as it works in internet explorer
Post Reply