Merge branch 'pf_use_ext_ip_addr'
This commit is contained in:
commit
239d048489
|
@ -1,5 +1,7 @@
|
|||
$Id: Changelog.txt,v 1.438 2018/04/06 09:17:45 nanard Exp $
|
||||
$Id: Changelog.txt,v 1.439 2018/04/12 09:32:22 nanard Exp $
|
||||
|
||||
2018/04/12:
|
||||
pf: set dst address in rule if use_ext_ip_addr is set
|
||||
2018/04/06:
|
||||
Add options for netfilter scripts
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/* $Id: obsdrdr.c,v 1.86 2016/02/12 13:11:03 nanard Exp $ */
|
||||
/* $Id: obsdrdr.c,v 1.88 2018/04/12 09:27:53 nanard Exp $ */
|
||||
/* vim: tabstop=4 shiftwidth=4 noexpandtab
|
||||
* MiniUPnP project
|
||||
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
||||
* (c) 2006-2016 Thomas Bernard
|
||||
* (c) 2006-2018 Thomas Bernard
|
||||
* This software is subject to the conditions detailed
|
||||
* in the LICENCE file provided within the distribution */
|
||||
|
||||
|
@ -336,6 +336,11 @@ add_redirect_rule2(const char * ifname,
|
|||
inet_pton(AF_INET, rhost, &pcr.rule.src.addr.v.a.addr.v4.s_addr);
|
||||
pcr.rule.src.addr.v.a.mask.v4.s_addr = htonl(INADDR_NONE);
|
||||
}
|
||||
if(use_ext_ip_addr && use_ext_ip_addr[0] != '\0')
|
||||
{
|
||||
inet_pton(AF_INET, use_ext_ip_addr, &pcr.rule.dst.addr.v.a.addr.v4.s_addr);
|
||||
pcr.rule.dst.addr.v.a.mask.v4.s_addr = htonl(INADDR_NONE);
|
||||
}
|
||||
#ifndef PF_NEWSTYLE
|
||||
pcr.rule.rpool.proxy_port[0] = iport;
|
||||
pcr.rule.rpool.proxy_port[1] = iport;
|
||||
|
@ -1081,6 +1086,7 @@ void
|
|||
list_rules(void)
|
||||
{
|
||||
char buf[32];
|
||||
char buf2[32];
|
||||
int i, n;
|
||||
struct pfioc_rule pr;
|
||||
#ifndef PF_NEWSTYLE
|
||||
|
@ -1105,11 +1111,12 @@ list_rules(void)
|
|||
pr.nr = i;
|
||||
if(ioctl(dev, DIOCGETRULE, &pr) < 0)
|
||||
perror("DIOCGETRULE");
|
||||
printf(" %s %s %d:%d -> %d:%d proto %d keep_state=%d action=%d\n",
|
||||
printf(" %s %s %d:%d -> %s %d:%d proto %d keep_state=%d action=%d\n",
|
||||
pr.rule.ifname,
|
||||
inet_ntop(AF_INET, &pr.rule.src.addr.v.a.addr.v4.s_addr, buf, 32),
|
||||
(int)ntohs(pr.rule.dst.port[0]),
|
||||
(int)ntohs(pr.rule.dst.port[1]),
|
||||
inet_ntop(AF_INET, &pr.rule.dst.addr.v.a.addr.v4.s_addr, buf2, 32),
|
||||
#ifndef PF_NEWSTYLE
|
||||
(int)pr.rule.rpool.proxy_port[0],
|
||||
(int)pr.rule.rpool.proxy_port[1],
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $Id: testobsdrdr.c,v 1.28 2014/03/06 13:02:47 nanard Exp $ */
|
||||
/* $Id: testobsdrdr.c,v 1.30 2018/04/12 09:27:54 nanard Exp $ */
|
||||
/* MiniUPnP project
|
||||
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
||||
* (c) 2006-2017 Thomas Bernard
|
||||
* (c) 2006-2018 Thomas Bernard
|
||||
* This software is subject to the conditions detailed
|
||||
* in the LICENCE file provided within the distribution */
|
||||
|
||||
|
@ -19,6 +19,7 @@ int runtime_flags = 0;
|
|||
const char * tag = 0;
|
||||
const char * anchor_name = "miniupnpd";
|
||||
const char * queue = NULL;
|
||||
const char * use_ext_ip_addr = "42.42.42.42";
|
||||
|
||||
void
|
||||
list_rules(void);
|
||||
|
@ -99,6 +100,7 @@ main(int argc, char * * argv)
|
|||
if(add_redirect_rule2("ep0", "8.8.8.8", 12123, "192.168.1.125", 1234,
|
||||
IPPROTO_UDP, "test description", 0) < 0)
|
||||
printf("add_redirect_rule2() #3 failed\n");
|
||||
use_ext_ip_addr = NULL;
|
||||
if(add_redirect_rule2("em0", NULL, 12123, "127.1.2.3", 1234,
|
||||
IPPROTO_TCP, "test description tcp", 0) < 0)
|
||||
printf("add_redirect_rule2() #4 failed\n");
|
||||
|
|
Loading…
Reference in New Issue