Skip to content

Commit

Permalink
add temporary access to internet for client
Browse files Browse the repository at this point in the history
Signed-off-by: staylightblow8 <[email protected]>
  • Loading branch information
liudf0716 committed Dec 27, 2023
1 parent b35afd0 commit 5e6ca4a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/fw4_nft.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const char *nft_wifidogx_init_script[] = {
"add set inet fw4 set_wifidogx_inner_trust_domains { type ipv4_addr; }",
"add set inet fw4 set_wifidogx_bypass_clients { type ipv4_addr; flags interval; }",
"add set inet fw4 set_wifidogx_trust_clients { type ether_addr; }",
"add set inet fw4 set_wifidogx_tmp_trust_clients { type ether_addr; flags timeout; }",
"add set inet fw4 set_wifidogx_tmp_trust_clients { type ether_addr; timeout 5m; }",
"add chain inet fw4 dstnat_wifidogx_auth_server",
"add chain inet fw4 dstnat_wifidogx_wan",
"add chain inet fw4 dstnat_wifidogx_outgoing",
Expand Down
5 changes: 5 additions & 0 deletions src/fw_iptables.c
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,11 @@ iptables_fw_set_mac_temporary(const char *mac, int which)
ipset_do_command("add " CHAIN_UNTRUSTED " %s timeout 60 ", mac);
}
#else
if(which == 0) { // trusted
nftables_do_command("add element inet fw4 set_wifidogx_tmp_trust_clients { %s }", mac);
} else if(which == 1) { // untrusted
// TODO
}
#endif
}

Expand Down
5 changes: 5 additions & 0 deletions src/http.c
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,11 @@ ev_http_callback_disconnect(struct evhttp_request *req, void *arg)
void
ev_http_callback_temporary_pass(struct evhttp_request *req, void *arg)
{
if (evhttp_request_get_command(req) == EVHTTP_REQ_OPTIONS) {
ev_http_respond_options(req);
return;
}

const char *mac = ev_http_find_query(req, "mac");

evhttp_add_header(evhttp_request_get_output_headers(req), "Access-Control-Allow-Origin", "*");
Expand Down

0 comments on commit 5e6ca4a

Please sign in to comment.