- Fixed indirectdata=no problem
- Added support for multiple ConnectTo lines in tinc.conf.
This commit is contained in:
parent
4faed1b854
commit
45a28b1e89
3 changed files with 51 additions and 22 deletions
20
src/conf.c
20
src/conf.c
|
@ -19,7 +19,7 @@
|
||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
|
||||||
$Id: conf.c,v 1.9.4.1 2000/06/17 20:55:54 zarq Exp $
|
$Id: conf.c,v 1.9.4.2 2000/06/27 15:08:57 guus Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
@ -219,3 +219,21 @@ get_config_val(which_t type)
|
||||||
/* Not found */
|
/* Not found */
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Support for multiple config lines.
|
||||||
|
Index is used to get a specific value, 0 being the first, 1 the second etc.
|
||||||
|
*/
|
||||||
|
const config_t *
|
||||||
|
get_next_config_val(which_t type, int index)
|
||||||
|
{
|
||||||
|
config_t *p;
|
||||||
|
|
||||||
|
for(p = config; p != NULL; p = p->next)
|
||||||
|
if(p->which == type)
|
||||||
|
if(--index < 0)
|
||||||
|
return p;
|
||||||
|
|
||||||
|
/* Not found */
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
|
||||||
$Id: conf.h,v 1.6.4.1 2000/06/17 20:55:54 zarq Exp $
|
$Id: conf.h,v 1.6.4.2 2000/06/27 15:08:57 guus Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __TINC_CONF_H__
|
#ifndef __TINC_CONF_H__
|
||||||
|
@ -74,5 +74,6 @@ extern int timeout;
|
||||||
extern config_t *add_config_val(config_t **, int, char *);
|
extern config_t *add_config_val(config_t **, int, char *);
|
||||||
extern int read_config_file(const char *);
|
extern int read_config_file(const char *);
|
||||||
extern const config_t *get_config_val(which_t type);
|
extern const config_t *get_config_val(which_t type);
|
||||||
|
extern const config_t *get_next_config_val(which_t type, int);
|
||||||
|
|
||||||
#endif /* __TINC_CONF_H__ */
|
#endif /* __TINC_CONF_H__ */
|
||||||
|
|
50
src/net.c
50
src/net.c
|
@ -17,7 +17,7 @@
|
||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
|
||||||
$Id: net.c,v 1.35.4.8 2000/06/26 20:30:20 guus Exp $
|
$Id: net.c,v 1.35.4.9 2000/06/27 15:08:58 guus Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
@ -548,7 +548,8 @@ cp
|
||||||
|
|
||||||
if(setup_outgoing_meta_socket(ncn) < 0)
|
if(setup_outgoing_meta_socket(ncn) < 0)
|
||||||
{
|
{
|
||||||
syslog(LOG_ERR, _("Could not set up a meta connection!"));
|
syslog(LOG_ERR, _("Could not set up a meta connection to %s"),
|
||||||
|
ncn->hostname);
|
||||||
free_conn_element(ncn);
|
free_conn_element(ncn);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -587,7 +588,7 @@ cp
|
||||||
myself->port = cfg->data.val;
|
myself->port = cfg->data.val;
|
||||||
|
|
||||||
if(cfg = get_config_val(indirectdata))
|
if(cfg = get_config_val(indirectdata))
|
||||||
if(cfg->data.val)
|
if(cfg->data.val == stupid_true)
|
||||||
myself->flags |= EXPORTINDIRECTDATA;
|
myself->flags |= EXPORTINDIRECTDATA;
|
||||||
|
|
||||||
if((myself->meta_socket = setup_listen_meta_socket(myself->port)) < 0)
|
if((myself->meta_socket = setup_listen_meta_socket(myself->port)) < 0)
|
||||||
|
@ -614,23 +615,27 @@ RETSIGTYPE
|
||||||
sigalrm_handler(int a)
|
sigalrm_handler(int a)
|
||||||
{
|
{
|
||||||
config_t const *cfg;
|
config_t const *cfg;
|
||||||
|
int index = 1;
|
||||||
cp
|
cp
|
||||||
cfg = get_config_val(upstreamip);
|
cfg = get_config_val(upstreamip);
|
||||||
|
|
||||||
if(!setup_outgoing_connection(cfg->data.ip->ip))
|
while(cfg)
|
||||||
{
|
{
|
||||||
signal(SIGALRM, SIG_IGN);
|
if(!setup_outgoing_connection(cfg->data.ip->ip)) /* function returns 0 when there are no problems */
|
||||||
}
|
{
|
||||||
else
|
signal(SIGALRM, SIG_IGN);
|
||||||
{
|
return;
|
||||||
signal(SIGALRM, sigalrm_handler);
|
}
|
||||||
seconds_till_retry += 5;
|
cfg = get_next_config_val(upstreamip, index++); /* Or else we try the next ConnectTo line */
|
||||||
if(seconds_till_retry>300) /* Don't wait more than 5 minutes. */
|
|
||||||
seconds_till_retry = 300;
|
|
||||||
alarm(seconds_till_retry);
|
|
||||||
syslog(LOG_ERR, _("Still failed to connect to other, will retry in %d seconds"),
|
|
||||||
seconds_till_retry);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
signal(SIGALRM, sigalrm_handler);
|
||||||
|
seconds_till_retry += 5;
|
||||||
|
if(seconds_till_retry>300) /* Don't wait more than 5 minutes. */
|
||||||
|
seconds_till_retry = 300;
|
||||||
|
alarm(seconds_till_retry);
|
||||||
|
syslog(LOG_ERR, _("Still failed to connect to other, will retry in %d seconds"),
|
||||||
|
seconds_till_retry);
|
||||||
cp
|
cp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -640,6 +645,7 @@ cp
|
||||||
int setup_network_connections(void)
|
int setup_network_connections(void)
|
||||||
{
|
{
|
||||||
config_t const *cfg;
|
config_t const *cfg;
|
||||||
|
int index = 1;
|
||||||
cp
|
cp
|
||||||
if((cfg = get_config_val(pingtimeout)) == NULL)
|
if((cfg = get_config_val(pingtimeout)) == NULL)
|
||||||
timeout = 5;
|
timeout = 5;
|
||||||
|
@ -656,13 +662,17 @@ cp
|
||||||
/* No upstream IP given, we're listen only. */
|
/* No upstream IP given, we're listen only. */
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if(setup_outgoing_connection(cfg->data.ip->ip))
|
while(cfg)
|
||||||
{
|
{
|
||||||
signal(SIGALRM, sigalrm_handler);
|
if(!setup_outgoing_connection(cfg->data.ip->ip)) /* function returns 0 when there are no problems */
|
||||||
seconds_till_retry = 300;
|
return 0;
|
||||||
alarm(seconds_till_retry);
|
cfg = get_next_config_val(upstreamip, index++); /* Or else we try the next ConnectTo line */
|
||||||
syslog(LOG_NOTICE, _("Trying to re-establish outgoing connection in 5 minutes"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
signal(SIGALRM, sigalrm_handler);
|
||||||
|
seconds_till_retry = 300;
|
||||||
|
alarm(seconds_till_retry);
|
||||||
|
syslog(LOG_NOTICE, _("Trying to re-establish outgoing connection in 5 minutes"));
|
||||||
cp
|
cp
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue