forked from lesderid/salty-ircd
Fix Connection sorting
This commit is contained in:
parent
dd33015ec7
commit
324cee253b
|
@ -50,7 +50,7 @@ class Connection
|
|||
override int opCmp(Object o)
|
||||
{
|
||||
Connection other;
|
||||
if((other = cast(Connection)other) !is null)
|
||||
if((other = cast(Connection)o) !is null)
|
||||
{
|
||||
return cmp(nick, other.nick);
|
||||
}
|
||||
|
@ -614,6 +614,11 @@ class Connection
|
|||
notImplemented("querying the motd of another server");
|
||||
return;
|
||||
}
|
||||
else if(_server.motd is null)
|
||||
{
|
||||
send(Message(_server.name, "422", [nick, "MOTD File is missing"], true));
|
||||
return;
|
||||
}
|
||||
_server.sendMotd(this);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ import std.range;
|
|||
@safe pure
|
||||
bool wildcardMatch(string input, string pattern)
|
||||
{
|
||||
|
||||
foreach (ref pi; 0 .. pattern.length)
|
||||
{
|
||||
const pc = pattern[pi];
|
||||
|
@ -16,24 +15,30 @@ bool wildcardMatch(string input, string pattern)
|
|||
{
|
||||
case '*':
|
||||
if (pi + 1 == pattern.length)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
for (; !input.empty; input.popFront())
|
||||
{
|
||||
auto p = input.save;
|
||||
if (wildcardMatch(p, pattern[pi + 1 .. pattern.length]))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
case '?':
|
||||
if (input.empty)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
input.popFront();
|
||||
break;
|
||||
default:
|
||||
if (input.empty)
|
||||
return false;
|
||||
if (pc != input.front)
|
||||
if (input.empty || pc != input.front)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
input.popFront();
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -76,20 +76,26 @@ class Server
|
|||
|
||||
static bool isValidNick(string name)
|
||||
{
|
||||
import std.ascii : digits, letters;
|
||||
import std.ascii : digits, letters;
|
||||
|
||||
if(name.length > 9)
|
||||
return false;
|
||||
foreach(i, c; name)
|
||||
{
|
||||
auto allowed = letters ~ "[]\\`_^{|}";
|
||||
if(i > 0)
|
||||
allowed = allowed ~ digits ~ "-";
|
||||
|
||||
if (!allowed.canFind(c))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
if(name.length > 9)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
foreach(i, c; name)
|
||||
{
|
||||
auto allowed = letters ~ "[]\\`_^{|}";
|
||||
if(i > 0)
|
||||
{
|
||||
allowed ~= digits ~ "-";
|
||||
}
|
||||
|
||||
if (!allowed.canFind(c))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool isNickAvailable(string nick)
|
||||
|
@ -297,20 +303,13 @@ class Server
|
|||
|
||||
void sendMotd(Connection connection)
|
||||
{
|
||||
if(motd !is null)
|
||||
connection.send(Message(name, "375", [connection.nick, ":- " ~ name ~ " Message of the day - "], true));
|
||||
foreach(line; motd.splitLines)
|
||||
{
|
||||
connection.send(Message(name, "375", [connection.nick, ":- " ~ name ~ " Message of the day - "], true));
|
||||
foreach(line; motd.splitLines)
|
||||
{
|
||||
//TODO: Implement line wrapping
|
||||
connection.send(Message(name, "372", [connection.nick, ":- " ~ line], true));
|
||||
}
|
||||
connection.send(Message(name, "376", [connection.nick, "End of MOTD command"], true));
|
||||
}
|
||||
else
|
||||
{
|
||||
connection.send(Message(name, "422", [connection.nick, "MOTD File is missing"], true));
|
||||
//TODO: Implement line wrapping
|
||||
connection.send(Message(name, "372", [connection.nick, ":- " ~ line], true));
|
||||
}
|
||||
connection.send(Message(name, "376", [connection.nick, "End of MOTD command"], true));
|
||||
}
|
||||
|
||||
void listen(ushort port = 6667)
|
||||
|
|
Loading…
Reference in New Issue