Пример #1
0
/**
 * Check for any client that hasn't fully registered.
 * If the abort parameter is set, send an ABORT to the server and client.
 * Returns 1 if any aren't fully registered, 0 if all are registered.
 */
int check_unfinished_clients(int listidx, int abort)
{
    int hostidx, found;
    struct pr_destinfo_t *dest;

    if (group_list[listidx].keytype == KEY_NONE) {
        return 0;
    }

    found = 0;
    for (hostidx = 0; hostidx < group_list[listidx].destcount; hostidx++) {
        dest = &group_list[listidx].destinfo[hostidx];
        if ((group_list[listidx].group_id != 0) &&
                (dest->state != PR_CLIENT_READY)) {
            if (abort) {
                send_downstream_abort(listidx, dest->addr.s_addr,
                        "Client not fully registered at proxy");
                send_upstream_abort(listidx, dest->addr.s_addr,
                        "Client not fully registered at proxy");
            }
            found = 1;
        }
    }
    return found;
}
Пример #2
0
/**
 * Check for any client that hasn't fully registered.
 * If the abort parameter is set, send an ABORT to the server and client.
 * Returns 1 if any aren't fully registered, 0 if all are registered.
 */
int check_unfinished_clients(struct pr_group_list_t *group, int abort_session)
{
    int hostidx, found;
    struct pr_destinfo_t *dest;

    if (group->keytype == KEY_NONE) {
        return 0;
    }

    found = 0;
    for (hostidx = 0; hostidx < group->destcount; hostidx++) {
        dest = &group->destinfo[hostidx];
        if ((group->group_id != 0) &&
                (dest->state != PR_CLIENT_READY)) {
            if (abort_session) {
                send_downstream_abort(group, dest->id,
                        "Client not fully registered at proxy", 0);
                send_upstream_abort(group, dest->id,
                        "Client not fully registered at proxy");
            }
            found = 1;
        }
    }
    return found;
}
Пример #3
0
/**
 * Handles an ABORT message from a client or server
 * and forwards if necessary.
 */
void handle_abort(int listidx, const struct sockaddr_in *src,
                  const unsigned char *packet)
{
    struct uftp_h *header;
    struct abort_h *abort;
    int upstream, hostidx, found, i;

    header = (struct uftp_h *)packet;
    abort = (struct abort_h *)(packet + sizeof(struct uftp_h));

    upstream = (!memcmp(src, &group_list[listidx].up_addr, sizeof(*src)));
    if (ntohs(header->blsize) != sizeof(struct abort_h)) {
        log(group_list[listidx].group_id, 0,
                "Rejecting ABORT from %s: invalid message size",
                upstream ? "server" : "client");
    }

    if (upstream) {
        for (i = 0, found = 0; (i < interface_count) && !found; i++) {
            if (abort->host == m_interface[i].addr.s_addr) {
                found = 1;
            }
        }

        if ((abort->host == 0) || found) {
            log(group_list[listidx].group_id, 0,
                    "Transfer aborted by server: %s", abort->message);
            if (proxy_type != RESPONSE_PROXY) {
                send_downstream_abort(listidx, 0, abort->message);
            }
            group_cleanup(listidx);
        } else {
            if (proxy_type != RESPONSE_PROXY) {
                send_downstream_abort(listidx, header->srcaddr, abort->message);
            }
        }
    } else {
        if ((hostidx = find_client(listidx, header->srcaddr)) != -1) {
            log(group_list[listidx].group_id, 0, "Transfer aborted by %s: %s",
                    group_list[listidx].destinfo[hostidx].name, abort->message);
        } else {
            log(group_list[listidx].group_id, 0, "Transfer aborted by %s: %s",
                    inet_ntoa(to_addr(header->srcaddr)), abort->message);
        }
        send_upstream_abort(listidx, header->srcaddr, abort->message);
    }
}
Пример #4
0
/**
 * Handles an ABORT message from a client or server
 * and forwards if necessary.
 */
void handle_abort(struct pr_group_list_t *group, const union sockaddr_u *src,
                  const unsigned char *message, unsigned meslen,
                  uint32_t src_id)
{
    const struct abort_h *abort_hdr;
    int upstream, hostidx, current;

    abort_hdr = (const struct abort_h *)message;

    upstream = (addr_equal(&group->up_addr, src));
    if (meslen < (abort_hdr->hlen * 4U) ||
            ((abort_hdr->hlen * 4U) < sizeof(struct abort_h))) {
        glog1(group, "Rejecting ABORT from %s: invalid message size",
                     upstream ? "server" : "client");
    }

    if (upstream) {
        if ((abort_hdr->host == 0) || abort_hdr->host == uid ) {
            glog1(group, "Transfer aborted by server: %s", abort_hdr->message);
            current = ((abort_hdr->flags & FLAG_CURRENT_FILE) != 0);
            if (proxy_type != RESPONSE_PROXY) {
                send_downstream_abort(group, 0, abort_hdr->message, current);
            }
            if (!current) {
                group_cleanup(group);
            }
        } else {
            if (proxy_type != RESPONSE_PROXY) {
                send_downstream_abort(group, abort_hdr->host,
                                      abort_hdr->message, 0);
            }
        }
    } else {
        if ((hostidx = find_client(group, src_id)) != -1) {
            glog1(group, "Transfer aborted by %s: %s",
                         group->destinfo[hostidx].name, abort_hdr->message);
        } else {
            glog1(group, "Transfer aborted by %08X: %s",
                         ntohl(src_id), abort_hdr->message);
        }
        send_upstream_abort(group, src_id, abort_hdr->message);
    }
}