Handle incorrect server password
This commit is contained in:
parent
3c06c1b738
commit
21368785d6
|
@ -48,9 +48,14 @@ class Connection
|
||||||
return nick ~ "!" ~ user ~ "@" ~ hostname;
|
return nick ~ "!" ~ user ~ "@" ~ hostname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@property bool registrationAttempted()
|
||||||
|
{
|
||||||
|
return nick !is null && user !is null;
|
||||||
|
}
|
||||||
|
|
||||||
@property bool registered()
|
@property bool registered()
|
||||||
{
|
{
|
||||||
return nick !is null && user !is null && _server.isPassCorrect(pass);
|
return registrationAttempted && (!_server.hasPass || _server.isPassCorrect(pass));
|
||||||
}
|
}
|
||||||
|
|
||||||
@property bool isOperator()
|
@property bool isOperator()
|
||||||
|
@ -61,9 +66,10 @@ class Connection
|
||||||
@property string servername()
|
@property string servername()
|
||||||
{
|
{
|
||||||
return _server.name;
|
return _server.name;
|
||||||
} //TODO: Support server linking
|
}
|
||||||
|
|
||||||
//TODO: Maybe replace string's opEquals (or make a new string class/struct) to compare with toIRCLower
|
//TODO: Support server linking
|
||||||
|
//TODO: Maybe 'replace' string's opEquals (or make a new string class/struct) to compare with toIRCLower
|
||||||
//TODO: Read errata
|
//TODO: Read errata
|
||||||
|
|
||||||
this(TCPConnection connection, Server server)
|
this(TCPConnection connection, Server server)
|
||||||
|
@ -118,6 +124,7 @@ class Connection
|
||||||
|
|
||||||
void closeConnection()
|
void closeConnection()
|
||||||
{
|
{
|
||||||
|
connected = false;
|
||||||
_connection.close();
|
_connection.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,6 +323,10 @@ class Connection
|
||||||
{
|
{
|
||||||
sendWelcome();
|
sendWelcome();
|
||||||
}
|
}
|
||||||
|
else if (registrationAttempted)
|
||||||
|
{
|
||||||
|
onIncorrectPassword();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void onUser(Message message)
|
void onUser(Message message)
|
||||||
|
@ -346,6 +357,10 @@ class Connection
|
||||||
{
|
{
|
||||||
sendWelcome();
|
sendWelcome();
|
||||||
}
|
}
|
||||||
|
else if (registrationAttempted)
|
||||||
|
{
|
||||||
|
onIncorrectPassword();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void onPass(Message message)
|
void onPass(Message message)
|
||||||
|
@ -367,12 +382,6 @@ class Connection
|
||||||
}
|
}
|
||||||
|
|
||||||
pass = message.parameters[0];
|
pass = message.parameters[0];
|
||||||
|
|
||||||
if (!_server.isPassCorrect(pass))
|
|
||||||
{
|
|
||||||
//NOTE: The RFCs don't allow ERR_PASSWDMISMATCH as a response to PASS
|
|
||||||
//TODO: If RFC-strictness is off, do send ERR_PASSWDMISMATCH
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void onQuit(Message message)
|
void onQuit(Message message)
|
||||||
|
@ -1420,6 +1429,19 @@ class Connection
|
||||||
//TODO: If RFC-strictness is off, also send 002, 003, and 004
|
//TODO: If RFC-strictness is off, also send 002, 003, and 004
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void onIncorrectPassword()
|
||||||
|
{
|
||||||
|
//NOTE: The RFCs don't allow ERR_PASSWDMISMATCH as a response to NICK/USER
|
||||||
|
|
||||||
|
version (BasicFixes)
|
||||||
|
{
|
||||||
|
send(Message(_server.name, "464", [nick, "Password incorrect"], true));
|
||||||
|
}
|
||||||
|
|
||||||
|
//NOTE: The RFCs don't actually specify what should happen here
|
||||||
|
closeConnection();
|
||||||
|
}
|
||||||
|
|
||||||
string getHost()
|
string getHost()
|
||||||
{
|
{
|
||||||
auto address = parseAddress(_connection.remoteAddress.toAddressString);
|
auto address = parseAddress(_connection.remoteAddress.toAddressString);
|
||||||
|
|
|
@ -510,6 +510,11 @@ class Server
|
||||||
return pass == _pass;
|
return pass == _pass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool hasPass()
|
||||||
|
{
|
||||||
|
return _pass != null;
|
||||||
|
}
|
||||||
|
|
||||||
void listen(ushort port = 6667)
|
void listen(ushort port = 6667)
|
||||||
{
|
{
|
||||||
listenTCP(port, &acceptConnection);
|
listenTCP(port, &acceptConnection);
|
||||||
|
|
Loading…
Reference in New Issue