ip-based account authentication and authorization

protocol extension fix to properly support pre-login packets
refactored skill title calculation
This commit is contained in:
krrios 2007-07-29 00:49:06 +00:00
parent 944d12be39
commit b1a05c68dd
3 changed files with 41 additions and 24 deletions

View file

@ -853,9 +853,10 @@ namespace Server.Accounting
/// <returns>True if allowed, false if not.</returns> /// <returns>True if allowed, false if not.</returns>
public bool HasAccess( NetState ns ) public bool HasAccess( NetState ns )
{ {
if ( ns == null ) return ( ns != null && HasAccess( ns.Address ) );
return false; }
public bool HasAccess( IPAddress ipAddress ) {
AccessLevel level = Misc.AccountHandler.LockdownLevel; AccessLevel level = Misc.AccountHandler.LockdownLevel;
if ( level > AccessLevel.Player ) if ( level > AccessLevel.Player )
@ -881,8 +882,6 @@ namespace Server.Accounting
return false; return false;
} }
IPAddress ipAddress = ns.Address;
bool accessAllowed = ( m_IPRestrictions.Length == 0 || IPLimiter.IsExempt( ipAddress ) ); bool accessAllowed = ( m_IPRestrictions.Length == 0 || IPLimiter.IsExempt( ipAddress ) );
for ( int i = 0; !accessAllowed && i < m_IPRestrictions.Length; ++i ) for ( int i = 0; !accessAllowed && i < m_IPRestrictions.Length; ++i )
@ -897,19 +896,21 @@ namespace Server.Accounting
/// <param name="ns">NetState instance to record.</param> /// <param name="ns">NetState instance to record.</param>
public void LogAccess( NetState ns ) public void LogAccess( NetState ns )
{ {
if ( ns == null ) if ( ns != null ) {
return; LogAccess( ns.Address );
}
IPAddress ipAddress = ns.Address; }
public void LogAccess( IPAddress ipAddress ) {
if ( IPLimiter.IsExempt( ipAddress ) ) if ( IPLimiter.IsExempt( ipAddress ) )
return; return;
if ( m_LoginIPs.Length == 0 ) if ( m_LoginIPs.Length == 0 ) {
if ( AccountHandler.IPTable.ContainsKey( ipAddress ) ) if ( AccountHandler.IPTable.ContainsKey( ipAddress ) )
AccountHandler.IPTable[ipAddress]++; AccountHandler.IPTable[ipAddress]++;
else else
AccountHandler.IPTable[ipAddress] = 1; AccountHandler.IPTable[ipAddress] = 1;
}
bool contains = false; bool contains = false;
@ -935,11 +936,17 @@ namespace Server.Accounting
/// <returns>True if allowed, false if not.</returns> /// <returns>True if allowed, false if not.</returns>
public bool CheckAccess( NetState ns ) public bool CheckAccess( NetState ns )
{ {
if ( !HasAccess( ns ) ) return ( ns != null && CheckAccess( ns.Address ) );
return false; }
LogAccess( ns ); public bool CheckAccess( IPAddress ipAddress ) {
return true; bool hasAccess = this.HasAccess( ipAddress );
if ( hasAccess ) {
LogAccess( ipAddress );
}
return hasAccess;
} }
/// <summary> /// <summary>

View file

@ -12,7 +12,7 @@ namespace Server.Misc
public static void Initialize() public static void Initialize()
{ {
PacketHandlers.Register( 0xF0, 0, true, new OnPacketReceive( DecodeBundledPacket ) ); PacketHandlers.Register( 0xF0, 0, false, new OnPacketReceive( DecodeBundledPacket ) );
Register( 0x00, true, new OnPacketReceive( QueryPartyLocations ) ); Register( 0x00, true, new OnPacketReceive( QueryPartyLocations ) );
} }

View file

@ -214,23 +214,33 @@ namespace Server.Misc
} }
else if ( showSkillTitle && beheld.Player ) else if ( showSkillTitle && beheld.Player )
{ {
Skill highest = GetHighestSkill( beheld );// beheld.Skills.Highest; string skillTitle = GetSkillTitle( beheld );
if ( highest != null && highest.BaseFixedPoint >= 300 ) if ( skillTitle != null ) {
{ title.Append( ", " ).Append( skillTitle );
string skillLevel = GetSkillLevel( highest );
string skillTitle = highest.Info.Title;
if ( beheld.Female && skillTitle.EndsWith( "man" ) )
skillTitle = skillTitle.Substring( 0, skillTitle.Length - 3 ) + "woman";
title.AppendFormat( ", {0} {1}", skillLevel, skillTitle );
} }
} }
return title.ToString(); return title.ToString();
} }
public static string GetSkillTitle( Mobile mob ) {
Skill highest = GetHighestSkill( mob );// beheld.Skills.Highest;
if ( highest != null && highest.BaseFixedPoint >= 300 )
{
string skillLevel = GetSkillLevel( highest );
string skillTitle = highest.Info.Title;
if ( mob.Female && skillTitle.EndsWith( "man" ) )
skillTitle = skillTitle.Substring( 0, skillTitle.Length - 3 ) + "woman";
return String.Concat( skillLevel, " ", skillTitle );
}
return null;
}
private static Skill GetHighestSkill( Mobile m ) private static Skill GetHighestSkill( Mobile m )
{ {
Skills skills = m.Skills; Skills skills = m.Skills;