diff --git a/src/vpn_manager_globalprotect/vpnc.py b/src/vpn_manager_globalprotect/vpnc.py index a15f5b3..66aeac8 100644 --- a/src/vpn_manager_globalprotect/vpnc.py +++ b/src/vpn_manager_globalprotect/vpnc.py @@ -117,21 +117,21 @@ class Config: if self.vpnd_enforce_split_tunnel: stream.writelines( [ - "[RoutingPolicyRule]", - f"To={net}", - f"Table={self.split_enforcement_table}" - f"Priority={self.routingpolicyrule_prio}", + "[RoutingPolicyRule]\n", + f"To={net}\n", + f"Table={self.split_enforcement_table}\n" + f"Priority={self.routingpolicyrule_prio}\n", ] ) else: stream.writelines( [ - "[Route]", - "Gateway=0.0.0.0", - f"To={net}", + "[Route]\n", + "Gateway=0.0.0.0\n", + f"To={net}\n", # systemd-networkd defaults to a route metric of 1024. We set a very low metric to shadow any routes that aren't meant # to explicitly override this, but still allows explicit overrides if desired. - "Metric=64", + "Metric=64\n", ] ) @@ -141,10 +141,10 @@ class Config: return stream.writelines( [ - "[RoutingPolicyRule]", - f"To={net}", - f"Table=main", - f"Priority={self.routingpolicyrule_prio}", + "[RoutingPolicyRule]\n", + f"To={net}\n", + f"Table=main\n", + f"Priority={self.routingpolicyrule_prio}\n", ] ) @@ -156,20 +156,20 @@ class Config: raise ValueError("Stream is not writable") stream.writelines( [ - "#Generated by vpn-manager-globalprotect vpnc script. Do not edit.", - "[Match]", - f"Name={self.tun_device}", - "Kind=tun", - "[Network]", - f"Address={self.internal_ipv4_address}", - f"DNS={' '.join(str(self.internal_ipv4_dns))}", - f"Domains={self.default_domain} {' '.join(str(self.search_domains))}", - "[Route]", - "Gateway=0.0.0.0", - "GatewayOnLink=yes", - "Type=global", - "Metric=64", - f"Table={self.split_enforcement_table if self.vpnd_enforce_split_tunnel else 'main'}", + "#Generated by vpn-manager-globalprotect vpnc script. Do not edit.\n", + "[Match]\n", + f"Name={self.tun_device}\n", + "Kind=tun\n", + "[Network]\n", + f"Address={self.internal_ipv4_address}\n", + f"DNS={' '.join(str(self.internal_ipv4_dns))}\n", + f"Domains={self.default_domain} {' '.join(str(self.search_domains))}\n", + "[Route]\n", + "Gateway=0.0.0.0\n", + "GatewayOnLink=yes\n", + "Type=global\n", + "Metric=64\n", + f"Table={self.split_enforcement_table if self.vpnd_enforce_split_tunnel else 'main'}\n", ] ) if self.vpnd_uplink_table_id is not None: @@ -177,10 +177,10 @@ class Config: # traffic to the VPN gateway through this routing table, so we don't need to modify other network configurations. stream.writelines( [ - "[RoutingPolicyRule]", - f"To={self.vpn_gateway}", - f"Table={self.vpnd_uplink_table_id}", - f"Priority={self.routingpolicyrule_prio}", + "[RoutingPolicyRule]\n", + f"To={self.vpn_gateway}\n", + f"Table={self.vpnd_uplink_table_id}\n", + f"Priority={self.routingpolicyrule_prio}\n", ] ) for net in self.split_tunnel_inclusions: @@ -193,11 +193,11 @@ class Config: # anything not intended for the gateway IP itself to our routing table. stream.writelines( [ - "[RoutingPolicyRule]", - f"To={self.vpn_gateway}", - "InvertRule=yes", - f"Table={self.split_enforcement_table}", - f"Priority={self.routingpolicyrule_prio}", + "[RoutingPolicyRule]\n", + f"To={self.vpn_gateway}\n", + "InvertRule=yes\n", + f"Table={self.split_enforcement_table}\n", + f"Priority={self.routingpolicyrule_prio}\n", ] )