-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathupload_complete.c
70 lines (66 loc) · 1.76 KB
/
upload_complete.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/* Copyright (C) 2000 [email protected]
This is free software distributed under the terms of the
GNU Public License. See the file COPYING for details.
$Id$ */
#include <string.h>
#include "opennap.h"
#include "debug.h"
/* 608 <recip> "<filename>" */
/* a client sends this message when another user has requested a file from
them and they are accepting the connection. this should be a
response to the 607 upload request */
HANDLER (upload_ok)
{
char *av[2];
USER *recip;
DATUM *info = 0;
int ac;
(void) tag;
(void) len;
CHECK_USER_CLASS ("upload_ok");
ASSERT (validate_connection (con));
if ((ac = split_line (av, sizeof (av) / sizeof (char *), pkt)) != 2)
{
log ("upload_ok(): malformed message from %s", con->user->nick);
print_args (ac, av);
unparsable(con);
return;
}
recip = hash_lookup (Users, av[0]);
if (!recip)
{
nosuchuser(con);
return;
}
/* pull the hash from the data base */
info = hash_lookup (con->uopt->files, av[1]);
if (!info)
{
send_cmd (con, MSG_SERVER_NOSUCH, "Not sharing that file");
return;
}
if (con->user->port == 0)
{
/* firewalled user, give the info back to the uploader */
send_cmd (con, MSG_SERVER_UPLOAD_FIREWALL /* 501 */ ,
"%s %u %d \"%s\" %s %d",
recip->nick, recip->ip, recip->port, av[1],
#if RESUME
info->hash,
#else
"00000000000000000000000000000000",
#endif
recip->speed);
}
else
/* recipient of this message may be on a remote server, use
send_user() here */
send_user (recip, MSG_SERVER_FILE_READY, "%s %u %d \"%s\" %s %d",
con->user->nick, con->user->ip, con->user->port, av[1],
#if RESUME
info->hash,
#else
"00000000000000000000000000000000",
#endif
con->user->speed);
}