Support numeric 908

This commit is contained in:
TingPing 2014-01-12 07:10:26 -05:00
parent a817072e6f
commit 0f0dabdcf4
2 changed files with 32 additions and 20 deletions

View File

@ -1829,34 +1829,44 @@ static const char *sasl_mechanisms[] =
"EXTERNAL" "EXTERNAL"
}; };
void
inbound_sasl_supportedmechs (server *serv, char *list)
{
int i;
if (serv->sasl_mech != MECH_EXTERNAL)
{
/* Use most secure one supported */
for (i = MECH_AES; i >= MECH_PLAIN; i--)
{
if (strstr (list, sasl_mechanisms[i]) != NULL)
{
serv->sasl_mech = i;
serv->retry_sasl = TRUE;
tcp_sendf (serv, "AUTHENTICATE %s\r\n", sasl_mechanisms[i]);
return;
}
}
}
/* Abort, none supported */
serv->sent_saslauth = TRUE;
tcp_sendf (serv, "AUTHENTICATE *\r\n");
return;
}
void void
inbound_sasl_authenticate (server *serv, char *data) inbound_sasl_authenticate (server *serv, char *data)
{ {
ircnet *net = (ircnet*)serv->network; ircnet *net = (ircnet*)serv->network;
char *user, *pass = NULL; char *user, *pass = NULL;
const char *mech = sasl_mechanisms[serv->sasl_mech]; const char *mech = sasl_mechanisms[serv->sasl_mech];
int i;
/* Got a list of supported mechanisms */ /* Got a list of supported mechanisms from inspircd */
if (strchr (data, ',') != NULL) if (strchr (data, ',') != NULL)
{ {
if (serv->sasl_mech == MECH_EXTERNAL) inbound_sasl_supportedmechs (serv, data);
goto sasl_abort; return;
/* Use most secure one supported */
for (i = MECH_AES; i >= MECH_PLAIN; i--)
{
if (strstr (data, sasl_mechanisms[i]) != NULL)
{
serv->sasl_mech = i;
serv->retry_sasl = TRUE;
tcp_sendf (serv, "AUTHENTICATE %s\r\n", sasl_mechanisms[i]);
return;
}
}
/* Nothing we support */
goto sasl_abort;
} }
if (net->user && !(net->flags & FLAG_USE_GLOBAL)) if (net->user && !(net->flags & FLAG_USE_GLOBAL))
@ -1882,7 +1892,6 @@ inbound_sasl_authenticate (server *serv, char *data)
#endif #endif
} }
sasl_abort:
if (pass == NULL) if (pass == NULL)
{ {
/* something went wrong abort */ /* something went wrong abort */

View File

@ -968,6 +968,9 @@ process_numeric (session * sess, int n,
tcp_send_len (serv, "CAP END\r\n", 9); tcp_send_len (serv, "CAP END\r\n", 9);
} }
break; break;
case 908: /* Supported SASL Mechs */
inbound_sasl_supportedmechs (serv, word_eol[3]+1);
break;
default: default: