1
|
#!/usr/local/bin/php-cgi -f
|
2
|
<?php
|
3
|
/*
|
4
|
* rc.newipsecdns
|
5
|
*
|
6
|
* part of pfSense (https://www.pfsense.org)
|
7
|
* Copyright (c) 2009 Seth Mos <seth.mos@dds.nl>.
|
8
|
* Copyright (c) 2004-2016 Rubicon Communications, LLC (Netgate)
|
9
|
* All rights reserved.
|
10
|
*
|
11
|
* Originally part of m0n0wall (http://m0n0.ch/wall)
|
12
|
* Copyright (c) 2007 Manuel Kasper <mk@neon1.net>.
|
13
|
* All rights reserved.
|
14
|
*
|
15
|
* Redistribution and use in source and binary forms, with or without
|
16
|
* modification, are permitted provided that the following conditions are met:
|
17
|
*
|
18
|
* 1. Redistributions of source code must retain the above copyright notice,
|
19
|
* this list of conditions and the following disclaimer.
|
20
|
*
|
21
|
* 2. Redistributions in binary form must reproduce the above copyright
|
22
|
* notice, this list of conditions and the following disclaimer in
|
23
|
* the documentation and/or other materials provided with the
|
24
|
* distribution.
|
25
|
*
|
26
|
* 3. All advertising materials mentioning features or use of this software
|
27
|
* must display the following acknowledgment:
|
28
|
* "This product includes software developed by the pfSense Project
|
29
|
* for use in the pfSense® software distribution. (http://www.pfsense.org/).
|
30
|
*
|
31
|
* 4. The names "pfSense" and "pfSense Project" must not be used to
|
32
|
* endorse or promote products derived from this software without
|
33
|
* prior written permission. For written permission, please contact
|
34
|
* coreteam@pfsense.org.
|
35
|
*
|
36
|
* 5. Products derived from this software may not be called "pfSense"
|
37
|
* nor may "pfSense" appear in their names without prior written
|
38
|
* permission of the Electric Sheep Fencing, LLC.
|
39
|
*
|
40
|
* 6. Redistributions of any form whatsoever must retain the following
|
41
|
* acknowledgment:
|
42
|
*
|
43
|
* "This product includes software developed by the pfSense Project
|
44
|
* for use in the pfSense software distribution (http://www.pfsense.org/).
|
45
|
*
|
46
|
* THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
|
47
|
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
48
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
49
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
|
50
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
51
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
52
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
53
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
54
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
55
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
56
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
57
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
58
|
*/
|
59
|
|
60
|
require_once("util.inc");
|
61
|
require_once("globals.inc");
|
62
|
|
63
|
/* make sure to wait until the boot scripts have finished */
|
64
|
if (file_exists("{$g['varrun_path']}/booting")) {
|
65
|
return;
|
66
|
}
|
67
|
|
68
|
$ipseclck_pending = try_lock('ipsecdns_pending', 0);
|
69
|
if (!$ipseclck_pending) {
|
70
|
/* if a vpn_ipsec_configure() is still pending no need to stack up another one */
|
71
|
return;
|
72
|
}
|
73
|
|
74
|
/* parse the configuration and include all functions used below */
|
75
|
require_once("config.inc");
|
76
|
require_once("gwlb.inc");
|
77
|
require_once("functions.inc");
|
78
|
require_once("filter.inc");
|
79
|
require_once("shaper.inc");
|
80
|
require_once("auth.inc");
|
81
|
require_once("ipsec.inc");
|
82
|
require_once("vpn.inc");
|
83
|
|
84
|
if (!ipsec_enabled()) {
|
85
|
unlock($ipseclck_pending);
|
86
|
return;
|
87
|
}
|
88
|
|
89
|
$ipseclck = lock('ipsecdns', LOCK_EX);
|
90
|
sleep(12);
|
91
|
unlock($ipseclck_pending);
|
92
|
sleep(3);
|
93
|
log_error("IPSEC: One or more IPsec tunnel endpoints has changed its IP. Refreshing.");
|
94
|
|
95
|
/* make sure we have the latest configuration changes loaded. */
|
96
|
$config = parse_config();
|
97
|
|
98
|
vpn_ipsec_configure();
|
99
|
|
100
|
unlock($ipseclck);
|