mirror of
https://github.com/mirage/qubes-mirage-firewall.git
synced 2025-02-10 12:18:33 -05:00
commit
ecb043e669
@ -341,17 +341,12 @@ struct
|
||||
Lwt.return_unit)
|
||||
|
||||
(** Connect to a new client's interface and listen for incoming frames and firewall rule changes. *)
|
||||
let add_vif get_ts { Dao.ClientVif.domid; device_id } dns_client dns_servers
|
||||
~client_ip ~router ~cleanup_tasks qubesDB () =
|
||||
let open Lwt.Syntax in
|
||||
let* backend = Netback.make ~domid ~device_id in
|
||||
let conf_vif get_ts vif backend client_eth dns_client dns_servers
|
||||
~client_ip ~iface ~router ~cleanup_tasks qubesDB () =
|
||||
let { Dao.ClientVif.domid; device_id } = vif in
|
||||
Log.info (fun f ->
|
||||
f "Client %d (IP: %s) ready" domid (Ipaddr.V4.to_string client_ip));
|
||||
let* eth = ClientEth.connect backend in
|
||||
let client_mac = Netback.frontend_mac backend in
|
||||
let client_eth = router.clients in
|
||||
let gateway_ip = Client_eth.client_gw client_eth in
|
||||
let iface = new client_iface eth ~domid ~gateway_ip ~client_ip client_mac in
|
||||
f "Client %d:%d (IP: %s) ready" domid device_id (Ipaddr.V4.to_string client_ip));
|
||||
|
||||
(* update the rules whenever QubesDB notices a change for this IP *)
|
||||
let qubesdb_updater =
|
||||
Lwt.catch
|
||||
@ -379,8 +374,7 @@ struct
|
||||
(function Lwt.Canceled -> Lwt.return_unit | e -> Lwt.fail e)
|
||||
in
|
||||
Cleanup.on_cleanup cleanup_tasks (fun () -> Lwt.cancel qubesdb_updater);
|
||||
add_client router iface >>= fun () ->
|
||||
Cleanup.on_cleanup cleanup_tasks (fun () -> remove_client router iface);
|
||||
|
||||
let fixed_arp = Client_eth.ARP.create ~net:client_eth iface in
|
||||
let fragment_cache = ref (Fragments.Cache.empty (256 * 1024)) in
|
||||
let listener =
|
||||
@ -415,8 +409,28 @@ struct
|
||||
Log.info (fun f ->
|
||||
f "add client vif %a with IP %a" Dao.ClientVif.pp vif Ipaddr.V4.pp
|
||||
client_ip);
|
||||
let { Dao.ClientVif.domid; device_id } = vif in
|
||||
let* backend = Netback.make ~domid ~device_id in
|
||||
let* eth = ClientEth.connect backend in
|
||||
let client_mac = Netback.frontend_mac backend in
|
||||
let client_eth = router.clients in
|
||||
let gateway_ip = Client_eth.client_gw client_eth in
|
||||
let iface = new client_iface eth ~domid ~gateway_ip ~client_ip client_mac in
|
||||
|
||||
Cleanup.on_cleanup cleanup_tasks (fun () -> remove_client router iface);
|
||||
Lwt.async (fun () ->
|
||||
Lwt.catch
|
||||
(fun () ->
|
||||
add_client router iface)
|
||||
(fun ex ->
|
||||
Log.warn (fun f ->
|
||||
f "Error with client %a: %s" Dao.ClientVif.pp vif
|
||||
(Printexc.to_string ex));
|
||||
Lwt.return_unit)) ;
|
||||
|
||||
let* () =
|
||||
Lwt.catch (add_vif get_ts vif dns_client dns_servers ~client_ip ~router
|
||||
Lwt.catch (
|
||||
conf_vif get_ts vif backend client_eth dns_client dns_servers ~client_ip ~iface ~router
|
||||
~cleanup_tasks qubesDB)
|
||||
@@ fun exn ->
|
||||
Log.warn (fun f ->
|
||||
|
@ -1 +1 @@
|
||||
78a1ee52574b9a4fc5eda265922bcbcface90f7c43ed7a68dc8e201a2ac0a7dc dist/qubes-firewall.xen
|
||||
b78d6711b502f8babcc5c4083b0352b78be8e8a6bef044189ce7a00e6e564612 dist/qubes-firewall.xen
|
||||
|
Loading…
x
Reference in New Issue
Block a user