Skip to content

Commit

Permalink
Update the Wi-Fi Dog authentication interface to allow input of clien…
Browse files Browse the repository at this point in the history
…t IP and MAC addresses,

enabling the authentication server to grant client access.

Signed-off-by: staylightblow8 <[email protected]>
  • Loading branch information
liudf0716 committed Feb 19, 2024
1 parent 9df8c8c commit ca80159
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions src/http.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,12 +403,28 @@ ev_http_callback_auth(struct evhttp_request *req, void *arg)
return;
}

char *remote_host;
uint16_t port;
evhttp_connection_get_peer(evhttp_request_get_connection(req), &remote_host, &port);
char *mac = arp_get(remote_host);
if (!mac) {
char *remote_host = NULL;
char *mac = NULL;
// get remote_host and mac from request if possible
// which support auth server side to permit client to login/logout
remote_host = ev_http_find_query(req, "client_ip");
mac = ev_http_find_query(req, "client_mac");
if (!remote_host || !mac) {
char *remote_ip = NULL;
uint16_t port;
if (mac) free(mac);
if (remote_host) free(remote_host);
mac = NULL;
remote_host = NULL;
evhttp_connection_get_peer(evhttp_request_get_connection(req), &remote_ip, &port);
remote_host = safe_strdup(remote_ip);
mac = arp_get(remote_host);
}

if (!mac || !remote_host) {
free(token);
if (mac) free(mac);
if (remote_host) free(remote_host);
evhttp_send_error(req, 200, "Failed to retrieve your MAC address");
return;
}
Expand All @@ -428,6 +444,7 @@ ev_http_callback_auth(struct evhttp_request *req, void *arg)
}
UNLOCK_CLIENT_LIST();
free(mac);
free(remote_host);

char *logout = ev_http_find_query(req, "logout");
if (logout) {
Expand Down

0 comments on commit ca80159

Please sign in to comment.