[raknet] Implement RakPeer::SetIncomingPassword

This commit is contained in:
RD42
2024-01-15 23:48:41 +08:00
parent 36540d90e8
commit 670d61547d
3 changed files with 40 additions and 4 deletions
+25 -2
View File
@@ -45,9 +45,32 @@ unsigned short RakPeer::GetMaximumIncomingConnections( void ) const
return maximumIncomingConnections;
}
void RakPeer::vftable_18()
// --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Description:
// Sets the password incoming connections must match in the call to Connect (defaults to none)
// Pass 0 to passwordData to specify no password
//
// Parameters:
// passwordData: A data block that incoming connections must match. This can be just a password, or can be a stream of data.
// - Specify 0 for no password data
// passwordDataLength: The length in bytes of passwordData
// --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
void RakPeer::SetIncomingPassword( const char* passwordData, int passwordDataLength )
{
// TODO: RakPeer::vftable_18() (saco W: 10038430) (server W: 44FF30 L: 806D1B0) (bot W: 403ED0 L: 8073008)
//if (passwordDataLength > MAX_OFFLINE_DATA_LENGTH)
// passwordDataLength=MAX_OFFLINE_DATA_LENGTH;
if (passwordDataLength > 255)
passwordDataLength=255;
if (passwordData==0)
passwordDataLength=0;
// Not threadsafe but it's not important enough to lock. Who is going to change the password a lot during runtime?
// It won't overflow at least because incomingPasswordLength is an unsigned char
if (passwordDataLength>0)
memcpy(incomingPassword, passwordData, passwordDataLength);
incomingPasswordLength=(unsigned char)passwordDataLength;
}
void RakPeer::vftable_1C()
+9 -1
View File
@@ -16,7 +16,6 @@ public:
void vftable_4();
void vftable_8();
void vftable_C();
void vftable_18();
void vftable_1C();
void vftable_20();
void vftable_24();
@@ -32,6 +31,12 @@ public:
/// \return the maximum number of incoming connections, which is always <= maxConnections
unsigned short GetMaximumIncomingConnections( void ) const;
/// Sets the password incoming connections must match in the call to Connect (defaults to none). Pass 0 to passwordData to specify no password
/// This is a way to set a low level password for all incoming connections. To selectively reject connections, implement your own scheme using CloseConnection() to remove unwanted connections
/// \param[in] passwordData A data block that incoming connections must match. This can be just a password, or can be a stream of data. Specify 0 for no password data
/// \param[in] passwordDataLength The length in bytes of passwordData
void SetIncomingPassword( const char* passwordData, int passwordDataLength );
/// Returns if the network thread is running
/// \return true if the network thread is running, false otherwise
bool IsActive( void ) const;
@@ -120,6 +125,9 @@ protected:
///Store the maximum incoming connection allowed
unsigned short maximumIncomingConnections;
char incomingPassword[256];
unsigned char incomingPasswordLength;
RPCMap rpcMap; // Can't use StrPtrHash because runtime insertions will screw up the indices
};
+6 -1
View File
@@ -13,7 +13,6 @@ public:
virtual void vftable_4()=0;
virtual void vftable_8()=0;
virtual void vftable_C()=0;
virtual void vftable_18()=0;
virtual void vftable_1C()=0;
virtual void vftable_20()=0;
virtual void vftable_24()=0;
@@ -29,6 +28,12 @@ public:
/// \return the maximum number of incoming connections, which is always <= maxConnections
virtual unsigned short GetMaximumIncomingConnections( void ) const=0;
/// Sets the password incoming connections must match in the call to Connect (defaults to none). Pass 0 to passwordData to specify no password
/// This is a way to set a low level password for all incoming connections. To selectively reject connections, implement your own scheme using CloseConnection() to remove unwanted connections
/// \param[in] passwordData A data block that incoming connections must match. This can be just a password, or can be a stream of data. Specify 0 for no password data
/// \param[in] passwordDataLength The length in bytes of passwordData
virtual void SetIncomingPassword( const char* passwordData, int passwordDataLength )=0;
/// Returns if the network thread is running
/// \return true if the network thread is running, false otherwise
virtual bool IsActive( void ) const=0;