Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Server Code Submissions

Reply
 
Thread Tools Display Modes
  #1  
Old 08-18-2009, 07:46 AM
Shin Noir's Avatar
Shin Noir
Legendary Member
 
Join Date: Apr 2002
Location: Seattle, WA
Posts: 506
Default add lastlogin_ip field to account table submission

It is talked about here: http://www.eqemulator.net/forums/showthread.php?t=28285

Essentially, a lastlogin_ip field contains the last IP the user was known to have logged in as. It is useful for servers that utilize EQEMU's Login server for authentication and wish to have a way to authorize users via a web based tool at least by their IP to allow them to do modifications to their characters (or set options).
It also can be used to discover a player's IP if they try to log off quicker than you can type #iplookup in game.

I used this change, but really you can do this in a number of ways.

First create a patchfile in /utils/sql/svn/REV#_loginip.sql
Code:
ALTER TABLE `character_` ADD `lastlogin_ip` varchar(32) NOT NULL DEFAULT '';

in client.cpp, line 803:
From
Code:
database.UpdateLiveChar(char_name, GetAccountID());
To
Code:
	struct in_addr  in;
			in.s_addr = cle->GetIP();
	database.UpdateLiveChar(char_name, GetAccountID(), inet_ntoa(in));
in database.cpp, line 1805:
From
Code:
bool Database::UpdateLiveChar(char* charname,int32 lsaccount_id) {
To
Code:
bool Database::UpdateLiveChar(char* charname,int32 lsaccount_id, char* loginip) {
same file, line 808
From
Code:
	if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE account SET charname='%s' WHERE id=%i;",charname, lsaccount_id), errbuf)) {
To
Code:
	if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE account SET charname='%s', lastlogin_ip='%s' WHERE id=%i;",charname, loginip, lsaccount_id), errbuf)) {
In database.h line 224
from
Code:
	bool	UpdateLiveChar(char* charname,int32 lsaccount_id);
To
Code:
	bool	UpdateLiveChar(char* charname,int32 lsaccount_id, char* loginip);

That's it.. Pretty sure this would update the IP every time a character logs in, and that's it. Which technically you could update this information when you a char first selects server, but no real reason the above modification is happening even without the ip being utilized.

I may have to release the struct properly, let me know if it's needed I'd like to learn that routine if you do add it.
__________________

~Shin Noir
DungeonEQ.com
Reply With Quote
  #2  
Old 08-29-2009, 04:40 PM
Shin Noir's Avatar
Shin Noir
Legendary Member
 
Join Date: Apr 2002
Location: Seattle, WA
Posts: 506
Default

Edit: My patchfile adds a field into character_ when it was supposed to add to account. Sorry. I can't edit my post, either.

ALTER TABLE `account` ADD `lastlogin_ip` varchar(32) NOT NULL DEFAULT '';
__________________

~Shin Noir
DungeonEQ.com
Reply With Quote
  #3  
Old 09-22-2009, 02:19 AM
Shin Noir's Avatar
Shin Noir
Legendary Member
 
Join Date: Apr 2002
Location: Seattle, WA
Posts: 506
Default

Rogean posted a solution to this on r980 (link). Not sure I agree this needs an entirely new table to get the job done, but it can be useful for seeing a list of IPs a client has used in the past I suppose.
__________________

~Shin Noir
DungeonEQ.com
Reply With Quote
  #4  
Old 09-23-2009, 08:06 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Yeah, personally I would have preferred just a last_used_ip field in the accounts table, but the way he did it should be ok as well. I prefer to use a gui for all MySQL stuff, so having to open the accounts table to find the account ID in it, then checking the new account_ip table for the account ID and entries for it is just 1 extra step. We can always add in the last_used_ip field at any time though. I just don't want to overkill the whole IP tracking idea :P

Really, the best use of tracking every single IP that someone uses would be to tell if it was them cheating or maybe someone else playing their character and cheating with it. But, since we don't log IPs in the hackers table yet, that isn't very useful just yet. I think the only other reason to track all IPs an account has used would be for finding all accounts that this same person has ever used. So, if you wanted to make sure to ban all of their accounts, you could figure out which are theirs fairly easily. Though, you might wind up banning other people's accounts, since people tend to share accounts quite often in EQEmu even though it is a bad habit to get into.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!

Last edited by trevius; 09-23-2009 at 08:14 AM..
Reply With Quote
  #5  
Old 09-23-2009, 09:30 AM
Rogean's Avatar
Rogean
Administrator
 
Join Date: Jul 2003
Location: Massachusetts
Posts: 708
Default

Quote:
Originally Posted by trevius View Post
I prefer to use a gui for all MySQL stuff, so having to open the accounts table to find the account ID in it, then checking the new account_ip table for the account ID and entries for it is just 1 extra step.
select a.*, b.name from account_ip a, account b where b.id = a.accid;

looking for someone's ip's:

select a.name, b.* from account a, account_ip b where a.name = "Rogean" and b.accid = a.id;
__________________
EQEmulator Developer / Administrator

Last edited by Rogean; 09-23-2009 at 09:33 AM..
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 05:34 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3