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