0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-26 15:33:54 +01:00

ircd/authd: cleanups

This commit is contained in:
Elizabeth Myers 2016-04-02 01:05:21 -05:00
parent 1de169a248
commit b1a577f224
2 changed files with 38 additions and 8 deletions

View file

@ -47,7 +47,8 @@ void rehash_authd(void);
void check_authd(void);
void authd_initiate_client(struct Client *);
void authd_decide_client(struct Client *client_p, const char *ident, const char *host, bool accept, char cause, const char *data, const char *reason);
void authd_accept_client(struct Client *client_p, const char *ident, const char *host);
void authd_reject_client(struct Client *client_p, const char *ident, const char *host, char cause, const char *data, const char *reason);
void authd_abort_client(struct Client *);
const char *get_provider_string(char cause);
@ -56,6 +57,8 @@ void del_blacklist(const char *host);
void del_blacklist_all(void);
bool set_authd_timeout(const char *key, int timeout);
void ident_check_enable(bool enabled);
bool create_opm_listener(const char *ip, uint16_t port);
void create_opm_listener(const char *ip, uint16_t port);
void opm_check_enable(bool enabled);
void create_opm_proxy_scan(const char *scan, uint16_t port);
#endif

View file

@ -151,7 +151,7 @@ parse_authd_reply(rb_helper * helper)
return;
}
authd_decide_client(client_p, parv[2], parv[3], true, '\0', NULL, NULL);
authd_accept_client(client_p, parv[2], parv[3]);
break;
case 'R': /* Reject client */
if(parc != 7)
@ -178,7 +178,7 @@ parse_authd_reply(rb_helper * helper)
return;
}
authd_decide_client(client_p, parv[3], parv[4], false, toupper(*parv[2]), parv[5], parv[6]);
authd_reject_client(client_p, parv[3], parv[4], toupper(*parv[2]), parv[5], parv[6]);
break;
case 'N': /* Notice to client */
if(parc != 3)
@ -398,7 +398,7 @@ authd_initiate_client(struct Client *client_p)
*
* After this point authd no longer "owns" the client.
*/
void
static inline void
authd_decide_client(struct Client *client_p, const char *ident, const char *host, bool accept, char cause, const char *data, const char *reason)
{
if(client_p->preClient == NULL || client_p->preClient->authd_cid == 0)
@ -435,6 +435,20 @@ authd_decide_client(struct Client *client_p, const char *ident, const char *host
read_packet(client_p->localClient->F, client_p);
}
/* Convenience function to accept client */
void
authd_accept_client(struct Client *client_p, const char *ident, const char *host)
{
authd_decide_client(client_p, ident, host, true, '\0', NULL, NULL);
}
/* Convenience function to reject client */
void
authd_reject_client(struct Client *client_p, const char *ident, const char *host, char cause, const char *data, const char *reason)
{
authd_decide_client(client_p, ident, host, false, cause, data, reason);
}
void
authd_abort_client(struct Client *client_p)
{
@ -450,7 +464,7 @@ authd_abort_client(struct Client *client_p)
rb_helper_write(authd_helper, "E %x", client_p->preClient->authd_cid);
/* XXX should we blindly allow like this? */
authd_decide_client(client_p, "*", "*", true, '\0', NULL, NULL);
authd_accept_client(client_p, "*", "*");
client_p->preClient->authd_cid = 0;
}
@ -563,9 +577,22 @@ ident_check_enable(bool enabled)
}
/* Create an OPM listener */
bool
void
create_opm_listener(const char *ip, uint16_t port)
{
rb_helper_write(authd_helper, "O opm_listener %s %hu", ip, port);
return true;
}
/* Disable all OPM scans */
void
opm_check_enable(bool enabled)
{
rb_helper_write(authd_helper, "O opm_enable %d", enabled ? 1 : 0);
}
/* Create an OPM proxy scan */
void
create_opm_proxy_scan(const char *scan, uint16_t port)
{
rb_helper_write(authd_helper, "O opm_scanner %s %hu", scan, port);
}