X-Git-Url: http://git.dolda2000.com/gitweb/?a=blobdiff_plain;f=daemon%2Ftransfer.c;h=bebe01120c93037b95f25f9df46266aa58aa088b;hb=302a260054ea38d3cb97be6d1a3010082c09265d;hp=f5b6b50d4f268252c9d8bd6c3c5426eb18c4a629;hpb=6c6bc9ce5fcb3427089b1439abfba8ebda183f15;p=doldaconnect.git diff --git a/daemon/transfer.c b/daemon/transfer.c index f5b6b50..bebe011 100644 --- a/daemon/transfer.c +++ b/daemon/transfer.c @@ -1,6 +1,6 @@ /* * Dolda Connect - Modular multiuser Direct Connect-style client - * Copyright (C) 2004 Fredrik Tolf (fredrik@dolda2000.com) + * Copyright (C) 2004 Fredrik Tolf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -161,7 +161,7 @@ struct transfer *hasupload(struct fnet *fnet, wchar_t *peerid) for(transfer = transfers; transfer != NULL; transfer = transfer->next) { - if((transfer->fnet == fnet) && !wcscmp(transfer->peerid, peerid)) + if((transfer->dir == TRNSD_UP) && (transfer->fnet == fnet) && !wcscmp(transfer->peerid, peerid)) break; } return(transfer); @@ -528,58 +528,6 @@ static void killfilter(struct transfer *transfer) transfer->filterbufsize = transfer->filterbufdata = 0; } -static char *findfilter(struct passwd *pwd) -{ - char *path, *filtername; - - if((path = sprintf2("%s/.dcdl-filter", pwd->pw_dir)) != NULL) - { - if(!access(path, X_OK)) - return(path); - free(path); - } - if((filtername = icwcstombs(confgetstr("transfer", "filter"), NULL)) == NULL) - { - flog(LOG_WARNING, "could not convert filter name into local charset: %s", strerror(errno)); - } else { - if(strchr(filtername, '/') == NULL) - { - if((path = sprintf2("/etc/%s", filtername)) != NULL) - { - if(!access(path, X_OK)) - { - free(filtername); - return(path); - } - free(path); - } - if((path = sprintf2("/usr/etc/%s", filtername)) != NULL) - { - if(!access(path, X_OK)) - { - free(filtername); - return(path); - } - free(path); - } - if((path = sprintf2("/usr/local/etc/%s", filtername)) != NULL) - { - if(!access(path, X_OK)) - { - free(filtername); - return(path); - } - free(path); - } - } else { - if(!access(filtername, X_OK)) - return(filtername); - } - free(filtername); - } - return(NULL); -} - static void handletranscmd(struct transfer *transfer, wchar_t *cmd, wchar_t *arg) { if(!wcscmp(cmd, L"status")) { @@ -679,7 +627,10 @@ int forkfilter(struct transfer *transfer) errno = EACCES; return(-1); } - if((filtername = findfilter(pwent)) == NULL) + filtername = findfile("dc-filter", pwent->pw_dir, 0); + if(filtername == NULL) + filtername = findfile(icswcstombs(confgetstr("transfer", "filter"), NULL, NULL), NULL, 0); + if(filtername == NULL) { flog(LOG_WARNING, "could not find filter for user %s", pwent->pw_name); errno = ENOENT; @@ -715,7 +666,7 @@ int forkfilter(struct transfer *transfer) { argv = NULL; argvsize = argvdata = 0; - buf = sprintf2("%i", transfer->size); + buf = sprintf2("%zi", transfer->size); addtobuf(argv, filtername); addtobuf(argv, filename); addtobuf(argv, buf); @@ -798,10 +749,23 @@ static int run(void) static struct configvar myvars[] = { + /** The maximum number of simultaneously permitted uploads. A + * common hub rule is that you will need at least as many slots as + * the number of hubs to which you are connected. */ {CONF_VAR_INT, "slots", {.num = 3}}, + /** The TOS value to use for upload connections (see the TOS + * VALUES section). */ {CONF_VAR_INT, "ultos", {.num = SOCK_TOS_MAXTP}}, + /** The TOS value to use for download connections (see the TOS + * VALUES section). */ {CONF_VAR_INT, "dltos", {.num = SOCK_TOS_MAXTP}}, + /** The name of the filter script (see the FILES section for + * lookup information). */ {CONF_VAR_STRING, "filter", {.str = L"dc-filter"}}, + /** If true, only one upload is allowed per remote peer. This + * option is still experimental, so it is recommended to leave it + * off. */ + {CONF_VAR_BOOL, "ulquota", {.num = 0}}, {CONF_VAR_END} };