mirror of
https://github.com/unrealircd/unrealircd.git
synced 2026-07-06 03:53:13 +02:00
Code cleanups: moving { /* comment */ to a new line.
And at the same time for extjwt.c generate some doxygen stuff since it had top-function comments (non-doxygen style).
This commit is contained in:
+2
-1
@@ -1031,7 +1031,8 @@ static void open_debugfile(void)
|
||||
/*(void)printf("isatty = %d ttyname = %#x\n",
|
||||
isatty(2), (u_int)ttyname(2)); */
|
||||
if (!(bootopt & BOOT_TTY))
|
||||
{ /* leave debugging output on fd 2 */
|
||||
{
|
||||
/* leave debugging output on fd 2 */
|
||||
if (truncate(LOGFILE, 0) < 0)
|
||||
fprintf(stderr, "WARNING: could not truncate log file '%s'\n", LOGFILE);
|
||||
if ((fd = open(LOGFILE, O_WRONLY | O_CREAT, 0600)) < 0)
|
||||
|
||||
@@ -66,7 +66,8 @@ CMD_FUNC(cmd_connect)
|
||||
const char *str;
|
||||
|
||||
if (!IsServer(client) && MyConnect(client) && !ValidatePermissionsForPath("route:global", client, NULL, NULL, NULL) && parc > 3)
|
||||
{ /* Only allow LocOps to make */
|
||||
{
|
||||
/* Only allow LocOps to make */
|
||||
/* local CONNECTS --SRB */
|
||||
sendnumeric(client, ERR_NOPRIVILEGES);
|
||||
return;
|
||||
|
||||
+29
-10
@@ -151,7 +151,8 @@ MOD_LOAD()
|
||||
ISupportAdd(modinfo->handle, "EXTJWT", "1");
|
||||
#endif
|
||||
while (service)
|
||||
{ /* copy default exp to all services not having one specified */
|
||||
{
|
||||
/* copy default exp to all services not having one specified */
|
||||
if (service->cfg->exp_delay == 0)
|
||||
service->cfg->exp_delay = cfg.exp_delay;
|
||||
service = service->next;
|
||||
@@ -239,8 +240,13 @@ int vfy_url_is_valid(const char *string)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Test whether a private key file is usable for the given method.
|
||||
* @param file Filename of the key file
|
||||
* @param method One of EXTJWT_METHOD_*
|
||||
* @returns NULL when the key is valid, otherwise an error message.
|
||||
*/
|
||||
char *extjwt_test_key(const char *file, int method)
|
||||
{ /* returns NULL when valid */
|
||||
{
|
||||
int fsize;
|
||||
char *fcontent = NULL;
|
||||
char *retval = NULL;
|
||||
@@ -660,8 +666,9 @@ int extjwt_configposttest(int *errs)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/** Config run hook: actually use the new set::extjwt configuration data */
|
||||
int extjwt_configrun(ConfigFile *cf, ConfigEntry *ce, int type)
|
||||
{ /* actually use the new configuration data */
|
||||
{
|
||||
ConfigEntry *cep, *cep2;
|
||||
struct jwt_service **ss = &jwt_services;
|
||||
if (*ss)
|
||||
@@ -701,7 +708,8 @@ int extjwt_configrun(ConfigFile *cf, ConfigEntry *ce, int type)
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(cep->name, "service"))
|
||||
{ /* nested block */
|
||||
{
|
||||
/* nested block */
|
||||
*ss = safe_alloc(sizeof(struct jwt_service));
|
||||
(*ss)->cfg = safe_alloc(sizeof(struct extjwt_config));
|
||||
safe_strdup((*ss)->name, cep->value); /* copy the service name */
|
||||
@@ -821,11 +829,13 @@ CMD_FUNC(cmd_extjwt)
|
||||
do
|
||||
{
|
||||
if (strlen(token) <= MAX_TOKEN_CHUNK)
|
||||
{ /* the remaining data (or whole token) will fit a single irc message */
|
||||
{
|
||||
/* the remaining data (or whole token) will fit a single irc message */
|
||||
last = 1;
|
||||
strcpy(message, token);
|
||||
} else
|
||||
{ /* send a chunk and shift buffer */
|
||||
{
|
||||
/* send a chunk and shift buffer */
|
||||
strlcpy(message, token, MAX_TOKEN_CHUNK + 1);
|
||||
token += MAX_TOKEN_CHUNK;
|
||||
}
|
||||
@@ -863,7 +873,8 @@ char *extjwt_make_payload(Client *client, Channel *channel, struct extjwt_config
|
||||
json_object_set_new(payload, "umodes", umodes);
|
||||
|
||||
if (channel)
|
||||
{ /* fill in channel information and user flags */
|
||||
{
|
||||
/* fill in channel information and user flags */
|
||||
lp = find_membership_link(client->user->channel, channel);
|
||||
modes = json_array();
|
||||
if (lp)
|
||||
@@ -885,8 +896,12 @@ char *extjwt_make_payload(Client *client, Channel *channel, struct extjwt_config
|
||||
return result;
|
||||
}
|
||||
|
||||
/** Convert a base64 string to base64-url, in place.
|
||||
* Replaces '+' with '-' and '/' with '_', and cuts the
|
||||
* string short at the first '=' (padding).
|
||||
*/
|
||||
void b64url(char *b64)
|
||||
{ /* convert base64 to base64-url */
|
||||
{
|
||||
while (*b64)
|
||||
{
|
||||
if (*b64 == '+')
|
||||
@@ -1067,7 +1082,8 @@ unsigned char *extjwt_hmac_extjwt_hash(int method, const void *key, int keylen,
|
||||
break;
|
||||
}
|
||||
if (HMAC(typ, key, keylen, data, datalen, hmac, resultlen))
|
||||
{ /* openssl call */
|
||||
{
|
||||
/* openssl call */
|
||||
return hmac;
|
||||
} else
|
||||
{
|
||||
@@ -1076,8 +1092,11 @@ unsigned char *extjwt_hmac_extjwt_hash(int method, const void *key, int keylen,
|
||||
}
|
||||
}
|
||||
|
||||
/** Generate the JWT header for the given method (one of EXTJWT_METHOD_*).
|
||||
* @returns The header as JSON text.
|
||||
*/
|
||||
char *extjwt_gen_header(int method)
|
||||
{ /* returns header json */
|
||||
{
|
||||
json_t *header = NULL;
|
||||
json_t *alg;
|
||||
char *result;
|
||||
|
||||
+18
-7
@@ -435,7 +435,8 @@ static int geoip_csv_read_ipv4(char *file)
|
||||
|
||||
mask = 0;
|
||||
while (cidr)
|
||||
{ /* calculate netmask */
|
||||
{
|
||||
/* calculate netmask */
|
||||
mask >>= 1;
|
||||
mask |= (1 << 31);
|
||||
cidr--;
|
||||
@@ -443,7 +444,8 @@ static int geoip_csv_read_ipv4(char *file)
|
||||
|
||||
i = 0;
|
||||
do
|
||||
{ /* multiple iterations in case CIDR is <8 and we have multiple first octets matching */
|
||||
{
|
||||
/* multiple iterations in case CIDR is <8 and we have multiple first octets matching */
|
||||
uint8_t index = addr >> 24;
|
||||
if (!curr[index])
|
||||
{
|
||||
@@ -467,8 +469,13 @@ static int geoip_csv_read_ipv4(char *file)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Convert an IPv6 address from text to binary form.
|
||||
* @param ip IPv6 address as text
|
||||
* @param out Result: eight 16-bit groups
|
||||
* @returns 1 on success, 0 if the address is invalid.
|
||||
*/
|
||||
static int geoip_csv_ip6_convert(char *ip, uint16_t out[8])
|
||||
{ /* convert text to binary form */
|
||||
{
|
||||
uint16_t tmp[8];
|
||||
int i;
|
||||
if (inet_pton(AF_INET6, ip, out) < 1)
|
||||
@@ -554,7 +561,8 @@ static int geoip_csv_read_ipv6(char *file)
|
||||
|
||||
int mask_bit = 0;
|
||||
while (cidr)
|
||||
{ /* calculate netmask */
|
||||
{
|
||||
/* calculate netmask */
|
||||
mask[mask_bit / 16] |= 1 << (15 - (mask_bit % 16));
|
||||
mask_bit++;
|
||||
cidr--;
|
||||
@@ -618,7 +626,8 @@ static int geoip_csv_read_countries(char *file)
|
||||
return 1;
|
||||
}
|
||||
while (fscanf(u, "%d,%" STR(BUFLEN) "[^\n]", &id, buf) == 2)
|
||||
{ /* getting country ID integer and all other data in string */
|
||||
{
|
||||
/* getting country ID integer and all other data in string */
|
||||
char *ptr = buf;
|
||||
char *codeptr = code;
|
||||
char *contptr = continent;
|
||||
@@ -760,7 +769,8 @@ static int geoip_csv_get_v4_geoid(char *iip)
|
||||
tmp_addr = addr;
|
||||
tmp_addr &= curr->mask; /* mask the address to filter out net prefix only */
|
||||
if (tmp_addr == curr->addr)
|
||||
{ /* ... and match it to the loaded data */
|
||||
{
|
||||
/* ... and match it to the loaded data */
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
@@ -793,7 +803,8 @@ static int geoip_csv_get_v6_geoid(char *iip)
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
if (curr->addr[i] != (addr[i] & curr->mask[i]))
|
||||
{ /* compare net address to loaded data */
|
||||
{
|
||||
/* compare net address to loaded data */
|
||||
found = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
+4
-2
@@ -763,13 +763,15 @@ int do_extmode_char(Channel *channel, Cmode *handler, const char *param, u_int w
|
||||
}
|
||||
|
||||
if (what == MODE_ADD)
|
||||
{ /* + */
|
||||
{
|
||||
/* + */
|
||||
channel->mode.mode |= handler->mode;
|
||||
if (handler->paracount)
|
||||
cm_putparameter(channel, handler->letter, param);
|
||||
RunHook(HOOKTYPE_MODECHAR_ADD, channel, (int)mode);
|
||||
} else
|
||||
{ /* - */
|
||||
{
|
||||
/* - */
|
||||
channel->mode.mode &= ~(handler->mode);
|
||||
RunHook(HOOKTYPE_MODECHAR_DEL, channel, (int)mode);
|
||||
if (handler->paracount)
|
||||
|
||||
+4
-2
@@ -94,11 +94,13 @@ static void chacha_keysetup(chacha_ctx *x, const u8 *k, u32 kbits, u32 ivbits)
|
||||
x->input[6] = U8TO32_LITTLE(k + 8);
|
||||
x->input[7] = U8TO32_LITTLE(k + 12);
|
||||
if (kbits == 256)
|
||||
{ /* recommended */
|
||||
{
|
||||
/* recommended */
|
||||
k += 16;
|
||||
constants = sigma;
|
||||
} else
|
||||
{ /* kbits == 128 */
|
||||
{
|
||||
/* kbits == 128 */
|
||||
constants = tau;
|
||||
}
|
||||
x->input[8] = U8TO32_LITTLE(k + 0);
|
||||
|
||||
+2
-1
@@ -555,7 +555,8 @@ int b64_decode(char const *src, unsigned char *target, size_t targsize)
|
||||
*/
|
||||
|
||||
if (ch == Pad64)
|
||||
{ /* We got a pad char. */
|
||||
{
|
||||
/* We got a pad char. */
|
||||
ch = *src++; /* Skip it, get next. */
|
||||
switch (state)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user