]>
jfr.im git - irc/quakenet/newserv.git/blob - miscreply/rping.c
4 #include "../irc/irc.h"
5 #include "../core/error.h"
13 /* handle remote rping request
15 * RPING from requesting user to start server:
16 * <user numeric> RPING/RI <server> <target server numeric> :<comment>
19 * server(mask) as given by user
20 * a * indicates the request is for all servers (future snircd extension?)
21 * cargv[1] = target server numeric
25 * RPING from start server to destination server:
26 * <start server numeric> RPING/RI <target server numeric> <requesting user numeric> <start seconds> <start milliseconds> :<comment>
28 * cargv[0] = target server numeric
29 * can be a * in which case the request is for all servers (future snircd extension?)
30 * cargv[1] = requesting user numeric
31 * cargv[2] = start time in seconds
32 * cargv[3] = start time in milliseconds
36 int handlerpingmsg(void *source
, int cargc
, char **cargv
) {
38 nick
*snick
; /* struct nick for source nick */
39 long i
; /* index for serverlist[] */
40 char *sourcenum
= (char *)source
; /* source numeric */
41 char *server
; /* target server parameter */
42 char *destserver
; /* destination server mask */
43 char *destnum
; /* destination server numeric */
44 char *sourceoper
; /* requesting operator numeric */
45 char *time_s
; /* time in seconds */
46 char *time_us
; /* time in milliseconds */
47 char *comment
; /* comment by client */
48 struct timeval tv
; /* get start time in seconds and milliseconds */
51 if (strlen(sourcenum
) == 2) {
53 /* check parameters */
55 miscreply_needmoreparams(sourcenum
, "RPING");
59 /* get the parameters */
61 sourceoper
= cargv
[1];
66 /* find source server */
67 if (miscreply_findserver(sourcenum
, "RPING") == -1)
70 /* find source user */
71 if (!(snick
= miscreply_finduser(sourceoper
, "RPING")))
74 /* send RPONG to operator */
75 irc_send("%s RO %s %s %s %s :%s", getmynumeric(), sourcenum
,
76 sourceoper
, time_s
, time_us
, comment
);
80 else if (strlen(sourcenum
) == 5) {
82 /* check parameters */
84 miscreply_needmoreparams(sourcenum
, "RPING");
88 /* get the parameters */
89 destserver
= cargv
[0];
93 /* find source user */
94 if (!(snick
= miscreply_finduser(sourcenum
, "RPING")))
97 /* request is for * (all servers) */
98 if ((destserver
[0] == '*' && destserver
[1] == '\0'))
101 /* find destination server */
102 else if ((i
= miscreply_findservermatch(sourcenum
, destserver
)) == -1)
106 * do the same as ircu in this case, nothing
108 else if (i
== mylongnum
)
111 /* found valid destination server */
113 destnum
= longtonumeric(i
, 2);
116 gettimeofday(&tv
, NULL
);
118 /* send RPING to server */
119 irc_send("%s RI %s %s %lu %lu :%s", getmynumeric(), destnum
,
120 sourcenum
, tv
.tv_sec
, tv
.tv_usec
, comment
);