Skip to content

Commit

Permalink
feat: enhance local authentication to handle IP changes for known cli…
Browse files Browse the repository at this point in the history
…ents

Signed-off-by: Dengfeng Liu <[email protected]>
  • Loading branch information
liudf0716 committed Jan 10, 2025
1 parent f4d5e41 commit abc0a44
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/http.c
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,22 @@ ev_http_callback_local_auth(struct evhttp_request *req, void *arg)

// fw_allow the client
LOCK_CLIENT_LIST();
fw_allow_ip_mac(ip, mac);
t_client *client = client_list_find_by_mac(mac);
if (!client) {
client = client_list_add(ip, mac, NULL, NULL);
fw_allow(client, FW_MARK_KNOWN);
} else if (strcmp(client->ip, ip) != 0) {
debug(LOG_INFO, "Local pass %s with different IP %s", mac, ip);
fw_deny(client);
free(client->ip);
client->ip = safe_strdup(ip);
fw_allow(client, FW_MARK_KNOWN);
} else {
UNLOCK_CLIENT_LIST();
debug(LOG_INFO, "Local pass %s already login", mac);
evhttp_send_error(req, HTTP_OK, "Client already login");
goto END;
}
UNLOCK_CLIENT_LIST();

// redirect the client to the internet
Expand Down

0 comments on commit abc0a44

Please sign in to comment.