1
0
mirror of https://github.com/anope/anope.git synced 2026-07-06 10:33:12 +02:00

Fixed a few small problems, including m_ssl's connect feature sometimes failing for no good reason

This commit is contained in:
Adam
2011-07-31 03:22:23 -04:00
parent f29c88bcd5
commit 1cb11bba5d
9 changed files with 227 additions and 84 deletions
+7 -7
View File
@@ -1108,7 +1108,7 @@ ConfigItems::ConfigItems(ServerConfig *conf)
{"options", "botmodes", "", new ValueContainerString(&conf->BotModes), DT_STRING, NoValidation},
{"options", "retrywait", "60", new ValueContainerInt(&conf->RetryWait), DT_INTEGER, ValidateNotZero},
{"options", "hideprivilegedcommands", "no", new ValueContainerBool(&conf->HidePrivilegedCommands), DT_BOOLEAN, NoValidation},
{"nickserv", "name", "NickServ", new ValueContainerString(&conf->NickServ), DT_STRING, NoValidation},
{"nickserv", "name", "", new ValueContainerString(&conf->NickServ), DT_STRING, NoValidation},
{"nickserv", "emailregistration", "no", new ValueContainerBool(&conf->NSEmailReg), DT_BOOLEAN, NoValidation},
{"nickserv", "forceemail", "no", new ValueContainerBool(&conf->NSForceEmail), DT_BOOLEAN, ValidateEmailReg},
{"nickserv", "confirmemailchanges", "no", new ValueContainerBool(&conf->NSConfirmEmailChanges), DT_BOOLEAN, NoValidation},
@@ -1143,7 +1143,7 @@ ConfigItems::ConfigItems(ServerConfig *conf)
{"mail", "dontquoteaddresses", "no", new ValueContainerBool(&conf->DontQuoteAddresses), DT_BOOLEAN, NoValidation},
{"dns", "nameserver", "127.0.0.1", new ValueContainerString(&conf->NameServer), DT_STRING, NoValidation},
{"dns", "timeout", "5", new ValueContainerTime(&conf->DNSTimeout), DT_TIME, NoValidation},
{"chanserv", "name", "ChanServ", new ValueContainerString(&conf->ChanServ), DT_STRING, NoValidation},
{"chanserv", "name", "", new ValueContainerString(&conf->ChanServ), DT_STRING, NoValidation},
{"chanserv", "defaults", "keeptopic secure securefounder signkick", new ValueContainerString(&CSDefaults), DT_STRING, ValidateChanServ},
{"chanserv", "maxregistered", "0", new ValueContainerUInt(&conf->CSMaxReg), DT_UINTEGER, ValidateChanServ},
{"chanserv", "expire", "14d", new ValueContainerTime(&conf->CSExpire), DT_TIME, ValidateChanServ},
@@ -1157,13 +1157,13 @@ ConfigItems::ConfigItems(ServerConfig *conf)
{"chanserv", "listopersonly", "no", new ValueContainerBool(&conf->CSListOpersOnly), DT_BOOLEAN, ValidateChanServ},
{"chanserv", "listmax", "0", new ValueContainerUInt(&conf->CSListMax), DT_UINTEGER, ValidateChanServ},
{"chanserv", "opersonly", "no", new ValueContainerBool(&conf->CSOpersOnly), DT_BOOLEAN, ValidateChanServ},
{"memoserv", "name", "MemoServ", new ValueContainerString(&conf->MemoServ), DT_STRING, NoValidation},
{"memoserv", "name", "", new ValueContainerString(&conf->MemoServ), DT_STRING, NoValidation},
{"memoserv", "maxmemos", "0", new ValueContainerUInt(&conf->MSMaxMemos), DT_UINTEGER, NoValidation},
{"memoserv", "senddelay", "0", new ValueContainerTime(&conf->MSSendDelay), DT_TIME, NoValidation},
{"memoserv", "notifyall", "no", new ValueContainerBool(&conf->MSNotifyAll), DT_BOOLEAN, NoValidation},
{"memoserv", "memoreceipt", "0", new ValueContainerUInt(&conf->MSMemoReceipt), DT_UINTEGER, NoValidation},
{"hostserv", "name", "HostServ", new ValueContainerString(&conf->HostServ), DT_STRING, NoValidation},
{"botserv", "name", "BotServ", new ValueContainerString(&conf->BotServ), DT_STRING, NoValidation},
{"hostserv", "name", "", new ValueContainerString(&conf->HostServ), DT_STRING, NoValidation},
{"botserv", "name", "", new ValueContainerString(&conf->BotServ), DT_STRING, NoValidation},
{"botserv", "defaults", "", new ValueContainerString(&BSDefaults), DT_STRING, NoValidation},
{"botserv", "minusers", "0", new ValueContainerUInt(&conf->BSMinUsers), DT_UINTEGER, ValidateBotServ},
{"botserv", "badwordsmax", "0", new ValueContainerUInt(&conf->BSBadWordsMax), DT_UINTEGER, ValidateBotServ},
@@ -1172,7 +1172,7 @@ ConfigItems::ConfigItems(ServerConfig *conf)
{"botserv", "gentlebadwordreason", "no", new ValueContainerBool(&conf->BSGentleBWReason), DT_BOOLEAN, NoValidation},
{"botserv", "casesensitive", "no", new ValueContainerBool(&conf->BSCaseSensitive), DT_BOOLEAN, NoValidation},
{"botserv", "fantasycharacter", "!", new ValueContainerString(&conf->BSFantasyCharacter), DT_STRING, NoValidation},
{"operserv", "name", "OperServ", new ValueContainerString(&conf->OperServ), DT_STRING, NoValidation},
{"operserv", "name", "", new ValueContainerString(&conf->OperServ), DT_STRING, NoValidation},
{"operserv", "superadmin", "no", new ValueContainerBool(&conf->SuperAdmin), DT_BOOLEAN, NoValidation},
{"operserv", "autokillexpiry", "0", new ValueContainerTime(&conf->AutokillExpiry), DT_TIME, ValidateOperServ},
{"operserv", "chankillexpiry", "0", new ValueContainerTime(&conf->ChankillExpiry), DT_TIME, ValidateOperServ},
@@ -1193,7 +1193,7 @@ ConfigItems::ConfigItems(ServerConfig *conf)
{"operserv", "sessionautokillexpiry", "0", new ValueContainerTime(&conf->SessionAutoKillExpiry), DT_TIME, NoValidation},
{"operserv", "addakiller", "no", new ValueContainerBool(&conf->AddAkiller), DT_BOOLEAN, NoValidation},
{"operserv", "opersonly", "no", new ValueContainerBool(&conf->OSOpersOnly), DT_BOOLEAN, NoValidation},
{"global", "name", "Global", new ValueContainerString(&conf->Global), DT_STRING, NoValidation},
{"global", "name", "", new ValueContainerString(&conf->Global), DT_STRING, NoValidation},
{"global", "globaloncycle", "no", new ValueContainerBool(&conf->GlobalOnCycle), DT_BOOLEAN, NoValidation},
{"global", "globaloncycledown", "", new ValueContainerString(&conf->GlobalOnCycleMessage), DT_STRING, ValidateGlobalOnCycle},
{"global", "globaloncycleup", "", new ValueContainerString(&conf->GlobalOnCycleUP), DT_STRING, ValidateGlobalOnCycle},
+89 -20
View File
@@ -291,6 +291,15 @@ ClientSocket *SocketIO::Accept(ListenSocket *s)
throw SocketException("Unable to accept connection: " + Anope::LastError());
}
/** Check if a connection has been accepted
* @param s The client socket
* @return -1 on error, 0 to wait, 1 on success
*/
int SocketIO::Accepted(ClientSocket *cs)
{
return 1;
}
/** Bind a socket
* @param s The socket
* @param ip The IP to bind to
@@ -321,11 +330,20 @@ void SocketIO::Connect(ConnectionSocket *s, const Anope::string &target, int por
}
else
{
s->OnConnect();
s->connected = true;
s->OnConnect();
}
}
/** Check if this socket is connected
* @param s The socket
* @return -1 for error, 0 for wait, 1 for connected
*/
int SocketIO::Connected(ConnectionSocket *s)
{
return s->connected == true ? 1 : -1;
}
/** Empty constructor, used for things such as the pipe socket
*/
Socket::Socket() : Flags<SocketFlag, 2>(SocketFlagStrings)
@@ -465,16 +483,15 @@ BufferedSocket::~BufferedSocket()
*/
bool BufferedSocket::ProcessRead()
{
char tbuffer[NET_BUFSIZE] = "";
char tbuffer[NET_BUFSIZE];
this->RecvLen = 0;
int len = this->IO->Recv(this, tbuffer, sizeof(tbuffer) - 1);
if (len == -2)
return true;
else if (len <= 0)
if (len <= 0)
return false;
tbuffer[len] = 0;
this->RecvLen = len;
Anope::string sbuffer = this->extrabuf;
@@ -512,9 +529,7 @@ bool BufferedSocket::ProcessRead()
bool BufferedSocket::ProcessWrite()
{
int count = this->IO->Send(this, this->WriteBuffer);
if (count == -2)
return true;
else if (count <= -1)
if (count <= -1)
return false;
this->WriteBuffer = this->WriteBuffer.substr(count);
if (this->WriteBuffer.empty())
@@ -589,7 +604,7 @@ ListenSocket::ListenSocket(const Anope::string &bindip, int port, bool ipv6) : S
this->bindaddr.pton(IPv6 ? AF_INET6 : AF_INET, bindip, port);
this->IO->Bind(this, bindip, port);
if (listen(Sock, 5) == -1)
if (listen(Sock, SOMAXCONN) == -1)
throw SocketException(Anope::string("Unable to listen: ") + Anope::LastError());
}
@@ -642,6 +657,34 @@ void ConnectionSocket::Connect(const Anope::string &TargetHost, int Port)
this->IO->Connect(this, TargetHost, Port);
}
/** Called when there is something to be received for this socket
* @return true on success, false to drop this socket
*/
bool ConnectionSocket::ProcessRead()
{
if (!this->connected)
{
int optval = 0;
socklen_t optlen = sizeof(optval);
if (!getsockopt(this->GetFD(), SOL_SOCKET, SO_ERROR, &optval, &optlen) && !optval)
{
this->connected = true;
this->OnConnect();
}
else
errno = optval;
}
int i = this->IO->Connected(this);
if (i == 1)
return BufferedSocket::ProcessRead();
else if (i == 0)
return true;
this->OnError(Anope::LastError());
return false;
}
/** Called when the socket is ready to be written to
* @return true on success, false to drop this socket
*/
@@ -649,23 +692,25 @@ bool ConnectionSocket::ProcessWrite()
{
if (!this->connected)
{
SocketEngine::ClearWritable(this);
int optval = 0;
socklen_t optlen = sizeof(optval);
if (!getsockopt(this->GetFD(), SOL_SOCKET, SO_ERROR, &optval, &optlen) && !optval)
{
this->OnConnect();
this->connected = true;
return true;
this->OnConnect();
}
errno = optval;
this->OnError(Anope::LastError());
return false;
else
errno = optval;
}
return BufferedSocket::ProcessWrite();
int i = this->IO->Connected(this);
if (i == 1)
return BufferedSocket::ProcessWrite();
else if (i == 0)
return true;
this->OnError(Anope::LastError());
return false;
}
/** Called when there is an error for this socket
@@ -673,8 +718,6 @@ bool ConnectionSocket::ProcessWrite()
*/
void ConnectionSocket::ProcessError()
{
if (!this->connected)
this->ProcessWrite();
}
/** Called on a successful connect
@@ -700,3 +743,29 @@ ClientSocket::ClientSocket(ListenSocket *ls, int fd, const sockaddrs &addr) : Bu
this->Type = SOCKTYPE_CLIENT;
}
/** Called when there is something to be received for this socket
* @return true on success, false to drop this socket
*/
bool ClientSocket::ProcessRead()
{
int i = this->IO->Accepted(this);
if (i == 1)
return BufferedSocket::ProcessRead();
else if (i == 0)
return true;
return false;
}
/** Called when the socket is ready to be written to
* @return true on success, false to drop this socket
*/
bool ClientSocket::ProcessWrite()
{
int i = this->IO->Accepted(this);
if (i == 1)
return BufferedSocket::ProcessWrite();
else if (i == 0)
return true;
return false;
}