// Verify given socket address against the ACL. // Return -1 if ACL is malformed, 0 if address is disallowed, 1 if allowed. static int check_acl(struct mg_context *ctx, uint32_t remote_ip) { int allowed, flag; uint32_t net, mask; struct vec vec; const char *list = ctx->config[ACCESS_CONTROL_LIST];
// If any ACL is set, deny by default allowed = list == NULL ? '+' : '-';
while ((list = next_option(list, &vec, NULL)) != NULL) { flag = vec.ptr[0]; if ((flag != '+' && flag != '-') || parse_net(&vec.ptr[1], &net, &mask) == 0) { cry(fc(ctx), "%s: subnet must be [+|-]x.x.x.x[/x]", __func__); return -1; }