// liudf added 20160421 void http_callback_temporary_pass(httpd * webserver, request * r) { const s_config *config = config_get_config(); httpVar *mac = httpdGetVariableByName(r, "mac"); if (config->httpdusername && (strcmp(config->httpdusername, r->request.authUser) || strcmp(config->httpdpassword, r->request.authPassword))) { debug(LOG_INFO, "Disconnect requested, forcing authentication"); httpdForceAuthenticate(r, config->httpdrealm); return; } if(mac) { debug(LOG_INFO, "Temporary passed %s", mac->value); fw_set_mac_temporary(mac->value, 0); httpdOutput(r, "startWeChatAuth();"); } else { debug(LOG_INFO, "Temporary pass called without MAC given"); httpdOutput(r, "MAC need to be specified"); return; } return; }
void http_callback_disconnect(httpd * webserver, request * r) { const s_config *config = config_get_config(); /* XXX How do you change the status code for the response?? */ httpVar *token = httpdGetVariableByName(r, "token"); httpVar *mac = httpdGetVariableByName(r, "mac"); if (config->httpdusername && (strcmp(config->httpdusername, r->request.authUser) || strcmp(config->httpdpassword, r->request.authPassword))) { debug(LOG_INFO, "Disconnect requested, forcing authentication"); httpdForceAuthenticate(r, config->httpdrealm); return; } if (token && mac) { t_client *client; LOCK_CLIENT_LIST(); client = client_list_find_by_mac(mac->value); if (!client || strcmp(client->token, token->value)) { UNLOCK_CLIENT_LIST(); debug(LOG_INFO, "Disconnect %s with incorrect token %s", mac->value, token->value); httpdOutput(r, "Invalid token for MAC"); return; } /* TODO: get current firewall counters */ logout_client(client); UNLOCK_CLIENT_LIST(); } else { debug(LOG_INFO, "Disconnect called without both token and MAC given"); httpdOutput(r, "Both the token and MAC need to be specified"); return; } return; }
void http_callback_status(httpd * webserver, request * r) { const s_config *config = config_get_config(); char *status = NULL; char *buf; if (config->httpdusername && (strcmp(config->httpdusername, r->request.authUser) || strcmp(config->httpdpassword, r->request.authPassword))) { debug(LOG_INFO, "Status page requested, forcing authentication"); httpdForceAuthenticate(r, config->httpdrealm); return; } status = get_status_text(); safe_asprintf(&buf, "<pre>%s</pre>", status); send_http_page(r, "WiFiDog Status", buf); free(buf); free(status); }