Merge branch 'Feature_add_DNS' into AllCurrentWorking
commit
baf4249724
|
@ -1118,6 +1118,7 @@ create_config_string (NMConnection *connection, GError **error)
|
||||||
const char *allowed_ips;
|
const char *allowed_ips;
|
||||||
const char *endpoint;
|
const char *endpoint;
|
||||||
const char *psk;
|
const char *psk;
|
||||||
|
const char *dns;
|
||||||
char *value = NULL;
|
char *value = NULL;
|
||||||
char **ip_list, **ip_iter;
|
char **ip_list, **ip_iter;
|
||||||
GArray *ips;
|
GArray *ips;
|
||||||
|
@ -1143,6 +1144,7 @@ create_config_string (NMConnection *connection, GError **error)
|
||||||
allowed_ips = _arg_is_set(nm_setting_vpn_get_data_item(s_vpn, NM_WG_KEY_ALLOWED_IPS));
|
allowed_ips = _arg_is_set(nm_setting_vpn_get_data_item(s_vpn, NM_WG_KEY_ALLOWED_IPS));
|
||||||
endpoint = _arg_is_set(nm_setting_vpn_get_data_item(s_vpn, NM_WG_KEY_ENDPOINT));
|
endpoint = _arg_is_set(nm_setting_vpn_get_data_item(s_vpn, NM_WG_KEY_ENDPOINT));
|
||||||
psk = _arg_is_set(nm_setting_vpn_get_data_item(s_vpn, NM_WG_KEY_PRESHARED_KEY));
|
psk = _arg_is_set(nm_setting_vpn_get_data_item(s_vpn, NM_WG_KEY_PRESHARED_KEY));
|
||||||
|
dns = _arg_is_set(nm_setting_vpn_get_data_item(s_vpn, NM_WG_KEY_DNS));
|
||||||
|
|
||||||
if(!ip4 && !ip6){
|
if(!ip4 && !ip6){
|
||||||
g_set_error_literal(error,
|
g_set_error_literal(error,
|
||||||
|
@ -1207,6 +1209,9 @@ create_config_string (NMConnection *connection, GError **error)
|
||||||
g_free(value);
|
g_free(value);
|
||||||
|
|
||||||
args_write_line(f, NMV_WG_TAG_LISTEN_PORT, "=", listen_port);
|
args_write_line(f, NMV_WG_TAG_LISTEN_PORT, "=", listen_port);
|
||||||
|
if(dns){
|
||||||
|
args_write_line(f,NMV_WG_TAG_DNS, "=", dns);
|
||||||
|
}
|
||||||
|
|
||||||
if(post_up){
|
if(post_up){
|
||||||
args_write_line(f, NMV_WG_TAG_POST_UP, "=", post_up);
|
args_write_line(f, NMV_WG_TAG_POST_UP, "=", post_up);
|
||||||
|
|
|
@ -94,6 +94,7 @@ typedef struct _Configs{
|
||||||
GVariant *config;
|
GVariant *config;
|
||||||
GVariant *ip4config;
|
GVariant *ip4config;
|
||||||
GVariant *ip6config;
|
GVariant *ip6config;
|
||||||
|
GVariant *dns_config;
|
||||||
} Configs;
|
} Configs;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -346,13 +347,15 @@ set_config(NMVpnServicePlugin *plugin, NMConnection *connection)
|
||||||
{
|
{
|
||||||
NMSettingVpn *s_vpn = nm_connection_get_setting_vpn(connection);
|
NMSettingVpn *s_vpn = nm_connection_get_setting_vpn(connection);
|
||||||
GVariantBuilder builder, ip4builder, ip6builder;
|
GVariantBuilder builder, ip4builder, ip6builder;
|
||||||
GVariant *config, *ip4config, *ip6config;
|
GVariantBuilder dns_builder;
|
||||||
|
GVariant *config, *ip4config, *ip6config, *dns_config;
|
||||||
GVariant *val;
|
GVariant *val;
|
||||||
const char *setting;
|
const char *setting;
|
||||||
const gchar *if_name;
|
const gchar *if_name;
|
||||||
guint64 subnet = 24;
|
guint64 subnet = 24;
|
||||||
gboolean has_ip4 = FALSE;
|
gboolean has_ip4 = FALSE;
|
||||||
gboolean has_ip6 = FALSE;
|
gboolean has_ip6 = FALSE;
|
||||||
|
gboolean has_dns = FALSE;
|
||||||
Configs *configs = malloc(sizeof(Configs));
|
Configs *configs = malloc(sizeof(Configs));
|
||||||
memset(configs, 0, sizeof(Configs));
|
memset(configs, 0, sizeof(Configs));
|
||||||
|
|
||||||
|
@ -361,6 +364,7 @@ set_config(NMVpnServicePlugin *plugin, NMConnection *connection)
|
||||||
g_variant_builder_init(&builder, G_VARIANT_TYPE_VARDICT);
|
g_variant_builder_init(&builder, G_VARIANT_TYPE_VARDICT);
|
||||||
g_variant_builder_init(&ip4builder, G_VARIANT_TYPE_VARDICT);
|
g_variant_builder_init(&ip4builder, G_VARIANT_TYPE_VARDICT);
|
||||||
g_variant_builder_init(&ip6builder, G_VARIANT_TYPE_VARDICT);
|
g_variant_builder_init(&ip6builder, G_VARIANT_TYPE_VARDICT);
|
||||||
|
g_variant_builder_init(&dns_builder, G_VARIANT_TYPE_VARDICT);
|
||||||
|
|
||||||
// build the configs
|
// build the configs
|
||||||
setting = get_setting(s_vpn, NM_WG_KEY_ADDR_IP4);
|
setting = get_setting(s_vpn, NM_WG_KEY_ADDR_IP4);
|
||||||
|
@ -387,6 +391,9 @@ set_config(NMVpnServicePlugin *plugin, NMConnection *connection)
|
||||||
setting = get_setting(s_vpn, NM_WG_KEY_DNS);
|
setting = get_setting(s_vpn, NM_WG_KEY_DNS);
|
||||||
if(setting){
|
if(setting){
|
||||||
// TODO
|
// TODO
|
||||||
|
val = g_variant_new_string(setting);
|
||||||
|
g_variant_builder_add(&dns_builder, "{ss}", NMV_WG_TAG_DNS, val);
|
||||||
|
has_dns = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
setting = get_setting(s_vpn, NM_WG_KEY_ENDPOINT);
|
setting = get_setting(s_vpn, NM_WG_KEY_ENDPOINT);
|
||||||
|
@ -447,10 +454,12 @@ set_config(NMVpnServicePlugin *plugin, NMConnection *connection)
|
||||||
config = g_variant_builder_end(&builder);
|
config = g_variant_builder_end(&builder);
|
||||||
ip4config = g_variant_builder_end(&ip4builder);
|
ip4config = g_variant_builder_end(&ip4builder);
|
||||||
ip6config = g_variant_builder_end(&ip6builder);
|
ip6config = g_variant_builder_end(&ip6builder);
|
||||||
|
dns_config = g_variant_builder_end(&dns_builder);
|
||||||
|
|
||||||
// populate the configs struct and send the configuration asynchronously
|
// populate the configs struct and send the configuration asynchronously
|
||||||
configs->ip4config = (has_ip4) ? ip4config : NULL;
|
configs->ip4config = (has_ip4) ? ip4config : NULL;
|
||||||
configs->ip6config = (has_ip6) ? ip6config : NULL;
|
configs->ip6config = (has_ip6) ? ip6config : NULL;
|
||||||
|
configs->dns_config = (has_dns) ? dns_config : NULL;
|
||||||
configs->plugin = plugin;
|
configs->plugin = plugin;
|
||||||
configs->config = config;
|
configs->config = config;
|
||||||
g_timeout_add(0, send_config, configs);
|
g_timeout_add(0, send_config, configs);
|
||||||
|
|
Loading…
Reference in New Issue