… | |
… | |
97 | free (hostname); |
97 | free (hostname); |
98 | } |
98 | } |
99 | |
99 | |
100 | void configuration::init () |
100 | void configuration::init () |
101 | { |
101 | { |
102 | asprintf (&confbase, "%s/vpe", CONFDIR); |
|
|
103 | |
|
|
104 | memset (this, 0, sizeof (*this)); |
102 | memset (this, 0, sizeof (*this)); |
105 | |
103 | |
106 | mtu = DEFAULT_MTU; |
104 | mtu = DEFAULT_MTU; |
107 | rekey = DEFAULT_REKEY; |
105 | rekey = DEFAULT_REKEY; |
108 | keepalive = DEFAULT_KEEPALIVE; |
106 | keepalive = DEFAULT_KEEPALIVE; |
… | |
… | |
115 | default_node.udp_port = DEFAULT_UDPPORT; |
113 | default_node.udp_port = DEFAULT_UDPPORT; |
116 | default_node.tcp_port = DEFAULT_UDPPORT; // ehrm |
114 | default_node.tcp_port = DEFAULT_UDPPORT; // ehrm |
117 | default_node.connectmode = conf_node::C_ALWAYS; |
115 | default_node.connectmode = conf_node::C_ALWAYS; |
118 | default_node.compress = true; |
116 | default_node.compress = true; |
119 | default_node.protocols = PROT_UDPv4; |
117 | default_node.protocols = PROT_UDPv4; |
|
|
118 | default_node.max_retry = DEFAULT_MAX_RETRY; |
120 | |
119 | |
121 | conf.pidfilename = strdup (LOCALSTATEDIR "/run/vped.pid"); |
120 | conf.pidfilename = strdup (LOCALSTATEDIR "/run/gvpe.pid"); |
122 | } |
121 | } |
123 | |
122 | |
124 | void configuration::cleanup() |
123 | void configuration::cleanup() |
125 | { |
124 | { |
126 | if (rsa_key) |
125 | if (rsa_key) |
… | |
… | |
165 | char *fname; |
164 | char *fname; |
166 | FILE *f; |
165 | FILE *f; |
167 | |
166 | |
168 | clear_config (); |
167 | clear_config (); |
169 | |
168 | |
170 | asprintf (&fname, "%s/vped.conf", confbase); |
169 | asprintf (&fname, "%s/gvpe.conf", confbase); |
171 | f = fopen (fname, "r"); |
170 | f = fopen (fname, "r"); |
172 | |
171 | |
173 | if (f) |
172 | if (f) |
174 | { |
173 | { |
175 | char line[16384]; |
174 | char line[16384]; |
… | |
… | |
340 | node->tcp_port = atoi (val); |
339 | node->tcp_port = atoi (val); |
341 | else if (!strcmp (var, "dns-port")) |
340 | else if (!strcmp (var, "dns-port")) |
342 | node->dns_port = atoi (val); |
341 | node->dns_port = atoi (val); |
343 | else if (!strcmp (var, "router-priority")) |
342 | else if (!strcmp (var, "router-priority")) |
344 | node->routerprio = atoi (val); |
343 | node->routerprio = atoi (val); |
|
|
344 | else if (!strcmp (var, "max-retry")) |
|
|
345 | node->max_retry = atoi (val); |
345 | else if (!strcmp (var, "connect")) |
346 | else if (!strcmp (var, "connect")) |
346 | { |
347 | { |
347 | if (!strcmp (val, "ondemand")) |
348 | if (!strcmp (val, "ondemand")) |
348 | node->connectmode = conf_node::C_ONDEMAND; |
349 | node->connectmode = conf_node::C_ONDEMAND; |
349 | else if (!strcmp (val, "never")) |
350 | else if (!strcmp (val, "never")) |
… | |
… | |
352 | node->connectmode = conf_node::C_ALWAYS; |
353 | node->connectmode = conf_node::C_ALWAYS; |
353 | else if (!strcmp (val, "disabled")) |
354 | else if (!strcmp (val, "disabled")) |
354 | node->connectmode = conf_node::C_DISABLED; |
355 | node->connectmode = conf_node::C_DISABLED; |
355 | else |
356 | else |
356 | slog (L_WARN, |
357 | slog (L_WARN, |
357 | _("illegal value for 'connectmode', use one of 'ondemand', 'never', 'always' or 'disabled', at '%s' line %d"), |
358 | _("illegal value for 'connectmode', use one of 'ondemand', 'never', 'always' or 'disabled', at '%s' line %d"), |
358 | var, fname, lineno); |
359 | var, fname, lineno); |
359 | } |
360 | } |
360 | else if (!strcmp (var, "inherit-tos")) |
361 | else if (!strcmp (var, "inherit-tos")) |
361 | { |
362 | { |
362 | parse_bool (node->inherit_tos, "inherit-tos", true, false); |
363 | parse_bool (node->inherit_tos, "inherit-tos", true, false); |
363 | } |
364 | } |
… | |
… | |
487 | printf ("\n"); |
488 | printf ("\n"); |
488 | } |
489 | } |
489 | |
490 | |
490 | configuration::configuration () |
491 | configuration::configuration () |
491 | { |
492 | { |
|
|
493 | asprintf (&confbase, "%s/gvpe", CONFDIR); |
|
|
494 | |
492 | init (); |
495 | init (); |
493 | } |
496 | } |
494 | |
497 | |
495 | configuration::~configuration () |
498 | configuration::~configuration () |
496 | { |
499 | { |