along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id: conf.c,v 1.9.4.7 2000/08/07 14:52:14 guus Exp $
+ $Id: conf.c,v 1.9.4.8 2000/08/09 14:02:15 guus Exp $
*/
{ "Hostnames", resolve_dns, TYPE_BOOL },
{ "IndirectData", indirectdata, TYPE_BOOL },
{ "TCPonly", tcponly, TYPE_BOOL },
+ { "Interface", interface, TYPE_NAME },
+ { "InterfaceIP", interfaceip, TYPE_IP },
{ NULL, 0, 0 }
};
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id: conf.h,v 1.6.4.7 2000/08/07 16:27:27 guus Exp $
+ $Id: conf.h,v 1.6.4.8 2000/08/09 14:02:16 guus Exp $
*/
#ifndef __TINC_CONF_H__
resolve_dns,
indirectdata,
tcponly,
+ interface,
+ interfaceip,
} which_t;
typedef struct config_t {
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id: net.c,v 1.35.4.25 2000/08/09 09:34:21 guus Exp $
+ $Id: net.c,v 1.35.4.26 2000/08/09 14:02:16 guus Exp $
*/
#include "config.h"
rp->from = ntohl(rp->from);
total_socket_in += rp->len;
-
+
if(rp->len >= 0)
{
f = lookup_conn(rp->from);
int nfd, flags;
struct sockaddr_in a;
const int one = 1;
+ config_t const *cfg;
cp
if((nfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0)
{
return -1;
}
+ if((cfg = get_config_val(interface)))
+ {
+ if(setsockopt(nfd, SOL_SOCKET, SO_KEEPALIVE, cfg->data.ptr, strlen(cfg->data.ptr)))
+ {
+ syslog(LOG_ERR, _("Unable to bind listen socket to interface %s: %m"), cfg->data.ptr);
+ return -1;
+ }
+ }
+
memset(&a, 0, sizeof(a));
a.sin_family = AF_INET;
a.sin_port = htons(port);
- a.sin_addr.s_addr = htonl(INADDR_ANY);
+
+ if((cfg = get_config_val(interfaceip)))
+ a.sin_addr.s_addr = htonl(cfg->data.ip->ip);
+ else
+ a.sin_addr.s_addr = htonl(INADDR_ANY);
if(bind(nfd, (struct sockaddr *)&a, sizeof(struct sockaddr)))
{
return -1;
}
- lenin = read(cl->meta_socket, cl->buffer, MAXBUFSIZE-cl->buflen);
+ lenin = read(cl->meta_socket, cl->buffer, MAXBUFSIZE - cl->buflen);
if(lenin<=0)
{