Skip to content

Commit

Permalink
Propagate server-time implicitly (ugh)
Browse files Browse the repository at this point in the history
  • Loading branch information
edk0 committed Sep 19, 2021
1 parent 1a03242 commit 4eec52d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions include/parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,7 @@ extern char *reconstruct_parv(int parc, const char *parv[]);
extern rb_dictionary *alias_dict;
extern rb_dictionary *cmd_dict;

extern const struct MsgBuf *incoming_message;
extern const struct Client *incoming_client;

#endif /* INCLUDED_parse_h_h */
8 changes: 8 additions & 0 deletions ircd/parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
rb_dictionary *cmd_dict = NULL;
rb_dictionary *alias_dict = NULL;

const struct MsgBuf *incoming_message = NULL;
const struct Client *incoming_client = NULL;

static void cancel_clients(struct Client *, struct Client *);
static void remove_unknown(struct Client *, const char *, char *);

Expand Down Expand Up @@ -153,6 +156,9 @@ parse(struct Client *client_p, char *pbuffer, char *bufend)
return;
}

incoming_message = &msgbuf;
incoming_client = client_p;

if(handle_command(mptr, &msgbuf, client_p, from) < -1)
{
char *p;
Expand All @@ -177,6 +183,8 @@ parse(struct Client *client_p, char *pbuffer, char *bufend)
}
}

incoming_message = NULL;
incoming_client = NULL;
}

/*
Expand Down
7 changes: 7 additions & 0 deletions modules/cap_server_time.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "s_serv.h"
#include "numeric.h"
#include "chmode.h"
#include "parse.h"
#include "inline/stringops.h"

static const char cap_server_time_desc[] =
Expand All @@ -54,9 +55,15 @@ cap_server_time_process(void *data_)
{
hook_data *data = data_;
static char buf[BUFSIZE];
const char *tagged_time;
struct MsgBuf *msgbuf = data->arg1;
struct timeval tv;

if (incoming_client != NULL && IsServer(incoming_client) && !msgbuf_get_tag(msgbuf, "time") && (tagged_time = msgbuf_get_tag(incoming_message, "time")))
{
msgbuf_append_tag(msgbuf, "time", tagged_time, CLICAP_SERVER_TIME);
}

if (!IsMe(data->client) && !MyClient(data->client))
return;

Expand Down

0 comments on commit 4eec52d

Please sign in to comment.