Beispiel #1
0
/**
 * The /hs group command.
 * @param u The user who issued the command
 * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
 **/
int do_group(User * u)
{
    NickAlias *na;
    HostCore *tmp;
    char *vHost = NULL;
    char *vIdent = NULL;
    char *creator = NULL;
    HostCore *head = NULL;
    time_t time;
    boolean found = false;

    head = hostCoreListHead();

    if ((na = findnick(u->nick))) {
        if (na->status & NS_IDENTIFIED) {

            tmp = findHostCore(head, u->nick, &found);
            if (found) {
                if (tmp == NULL) {
                    tmp = head; /* incase first in list */
                } else if (tmp->next) { /* we dont want the previous entry were not inserting! */
                    tmp = tmp->next;    /* jump to the next */
                }

                vHost = sstrdup(tmp->vHost);
                if (tmp->vIdent)
                    vIdent = sstrdup(tmp->vIdent);
                creator = sstrdup(tmp->creator);
                time = tmp->time;

                do_hs_sync(na->nc, vIdent, vHost, creator, time);
                if (tmp->vIdent) {
                    notice_lang(s_HostServ, u, HOST_IDENT_GROUP,
                                na->nc->display, vIdent, vHost);
                } else {
                    notice_lang(s_HostServ, u, HOST_GROUP, na->nc->display,
                                vHost);
                }
                free(vHost);
                if (vIdent)
                    free(vIdent);
                free(creator);

            } else {
                notice_lang(s_HostServ, u, HOST_NOT_ASSIGNED);
            }
        } else {
            notice_lang(s_HostServ, u, HOST_ID);
        }
    } else {
        notice_lang(s_HostServ, u, HOST_NOT_REGED);
    }
    return MOD_CONT;
}
Beispiel #2
0
static int hsreqevt_nick_dropped(int argc, char **argv)
{
    HostCore *tmp;
    boolean found = false;

    if (!argc)
        return MOD_CONT;

    tmp = findHostCore(hs_request_head, argv[0], &found);
    if (found)
        hs_request_head = deleteHostCore(hs_request_head, tmp);

    return MOD_CONT;
}
Beispiel #3
0
static int hs_do_reject(User * u)
{
    char *cur_buffer;
    char *nick;
    char *reason;
    HostCore *tmp, *hc;
    boolean found = false;

    cur_buffer = moduleGetLastBuffer();
    nick = myStrGetToken(cur_buffer, ' ', 0);
    reason = myStrGetTokenRemainder(cur_buffer, ' ', 1);

    if (!nick) {
        moduleNoticeLang(s_HostServ, u, LNG_REJECT_SYNTAX);
        if (reason)
            free(reason);
        return MOD_CONT;
    }

    tmp = findHostCore(hs_request_head, nick, &found);
    if (found) {
        if (!tmp)
            hc = hs_request_head;
        else
            hc = tmp->next;

        if (HSRequestMemoUser) {
            if (reason)
                my_memo_lang(u, hc->nick, 2, NULL, LNG_REJECT_MEMO_REASON,
                             reason);
            else
                my_memo_lang(u, hc->nick, 2, NULL, LNG_REJECT_MEMO);
        }

        hs_request_head = deleteHostCore(hs_request_head, tmp);
        moduleNoticeLang(s_HostServ, u, LNG_REJECTED, nick);
        alog("Host Request for %s rejected by %s (%s)", nick, u->nick,
             reason ? reason : "");
    } else {
        moduleNoticeLang(s_HostServ, u, LNG_NO_REQUEST, nick);
    }

    free(nick);
    if (reason)
        free(reason);

    return MOD_CONT;
}
Beispiel #4
0
static int hs_do_activate(User * u)
{
    char *cur_buffer;
    char *nick;
    NickAlias *na;
    HostCore *tmp, *hc;
    boolean found = false;

    cur_buffer = moduleGetLastBuffer();
    nick = myStrGetToken(cur_buffer, ' ', 0);

    if (!nick) {
        moduleNoticeLang(s_HostServ, u, LNG_ACTIVATE_SYNTAX);
        return MOD_CONT;
    }

    if ((na = findnick(nick))) {
        tmp = findHostCore(hs_request_head, nick, &found);
        if (found) {
            if (!tmp)
                hc = hs_request_head;
            else
                hc = tmp->next;

            addHostCore(hc->nick, hc->vIdent, hc->vHost, u->nick,
                        time(NULL));

            if (HSRequestMemoUser)
                my_memo_lang(u, hc->nick, 2, NULL, LNG_ACTIVATE_MEMO);

            hs_request_head = deleteHostCore(hs_request_head, tmp);
            moduleNoticeLang(s_HostServ, u, LNG_ACTIVATED, nick);
            alog("Host Request for %s activated by %s", nick, u->nick);
        } else {
            moduleNoticeLang(s_HostServ, u, LNG_NO_REQUEST, nick);
        }
    } else {
        notice_lang(s_HostServ, u, NICK_X_NOT_REGISTERED, nick);
    }

    free(nick);
    return MOD_CONT;
}
Beispiel #5
0
static void my_add_host_request(char *nick, char *vIdent, char *vhost,
                         char *creator, int32 tmp_time)
{
    HostCore *tmp;
    boolean found = false;

    if (!hs_request_head) {
        hs_request_head =
            createHostCorelist(hs_request_head, nick, vIdent, vhost,
                               creator, tmp_time);
    } else {
        tmp = findHostCore(hs_request_head, nick, &found);
        if (!found) {
            hs_request_head =
                insertHostCore(hs_request_head, tmp, nick, vIdent, vhost,
                               creator, tmp_time);
        } else {
            hs_request_head = deleteHostCore(hs_request_head, tmp);     /* delete the old entry */
            my_add_host_request(nick, vIdent, vhost, creator, tmp_time);        /* recursive call to add new entry */
        }
    }
}