Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
e9195153
Commit
e9195153
authored
Mar 11, 2017
by
Franco Fichtner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
openvpn: merge into plugin
parent
910ee163
Changes
18
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
276 additions
and
1028 deletions
+276
-1028
plist
plist
+4
-5
openvpn_wizard.inc
src/etc/inc/openvpn_wizard.inc
+0
-739
if_openvpn.inc
src/etc/inc/plugins.inc.d/if_openvpn.inc
+0
-106
openvpn.inc
src/etc/inc/plugins.inc.d/openvpn.inc
+146
-27
auth-user.php
src/etc/inc/plugins.inc.d/openvpn/auth-user.php
+0
-0
tls-verify.php
src/etc/inc/plugins.inc.d/openvpn/tls-verify.php
+0
-0
services.inc
src/etc/inc/services.inc
+2
-2
rc.carpbackup
src/etc/rc.carpbackup
+2
-10
rc.carpmaster
src/etc/rc.carpmaster
+2
-18
rc.openvpn
src/etc/rc.openvpn
+110
-110
ovpn_auth_verify
src/sbin/ovpn_auth_verify
+2
-2
openvpn.xml
src/wizard/openvpn.xml
+1
-1
status_openvpn.php
src/www/status_openvpn.php
+1
-1
vpn_openvpn_client.php
src/www/vpn_openvpn_client.php
+1
-1
vpn_openvpn_csc.php
src/www/vpn_openvpn_csc.php
+1
-1
vpn_openvpn_export.php
src/www/vpn_openvpn_export.php
+1
-1
vpn_openvpn_server.php
src/www/vpn_openvpn_server.php
+1
-1
openvpn.widget.php
src/www/widgets/widgets/openvpn.widget.php
+2
-3
No files found.
plist
View file @
e9195153
...
...
@@ -34,20 +34,19 @@
/usr/local/etc/inc/notices.plain_sasl_client.inc
/usr/local/etc/inc/notices.sasl.inc
/usr/local/etc/inc/notices.smtp.inc
/usr/local/etc/inc/openvpn.auth-user.php
/usr/local/etc/inc/openvpn.inc
/usr/local/etc/inc/openvpn.tls-verify.php
/usr/local/etc/inc/openvpn_wizard.inc
/usr/local/etc/inc/plugins.inc
/usr/local/etc/inc/plugins.inc.d/dnsmasq.inc
/usr/local/etc/inc/plugins.inc.d/if_group.inc
/usr/local/etc/inc/plugins.inc.d/if_legacy_opt.inc
/usr/local/etc/inc/plugins.inc.d/if_openvpn.inc
/usr/local/etc/inc/plugins.inc.d/ipfw.inc
/usr/local/etc/inc/plugins.inc.d/ipsec.inc
/usr/local/etc/inc/plugins.inc.d/ipsec/auth-user.php
/usr/local/etc/inc/plugins.inc.d/netflow.inc
/usr/local/etc/inc/plugins.inc.d/ntpd.inc
/usr/local/etc/inc/plugins.inc.d/openvpn.inc
/usr/local/etc/inc/plugins.inc.d/openvpn/auth-user.php
/usr/local/etc/inc/plugins.inc.d/openvpn/tls-verify.php
/usr/local/etc/inc/plugins.inc.d/openvpn/wizard.inc
/usr/local/etc/inc/plugins.inc.d/pf.inc
/usr/local/etc/inc/plugins.inc.d/squid.inc
/usr/local/etc/inc/plugins.inc.d/squid/auth-user.php
...
...
src/etc/inc/openvpn_wizard.inc
deleted
100644 → 0
View file @
910ee163
This diff is collapsed.
Click to expand it.
src/etc/inc/plugins.inc.d/if_openvpn.inc
deleted
100644 → 0
View file @
910ee163
<?php
/*
Copyright (C) 2016 Deciso B.V.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
function
if_openvpn_syslog
()
{
$logfacilities
=
array
();
$logfacilities
[
'openvpn'
]
=
array
(
'facility'
=>
array
(
'openvpn'
),
'remote'
=>
'vpn'
,
);
return
$logfacilities
;
}
function
if_openvpn_services
()
{
global
$config
;
$services
=
array
();
foreach
(
array
(
'server'
,
'client'
)
as
$mode
)
{
if
(
isset
(
$config
[
'openvpn'
][
"openvpn-
{
$mode
}
"
]))
{
foreach
(
$config
[
'openvpn'
][
"openvpn-
{
$mode
}
"
]
as
$setting
)
{
if
(
empty
(
$setting
[
'disable'
]))
{
$pconfig
=
array
();
$pconfig
[
'description'
]
=
"OpenVPN
{
$mode
}
: "
.
htmlspecialchars
(
$setting
[
'description'
]);
$pconfig
[
'pidfile'
]
=
"/var/run/openvpn_
{
$mode
}{
$setting
[
'vpnid'
]
}
.pid"
;
$pconfig
[
'php'
][
'restart'
]
=
array
(
'openvpn_restart_by_id'
);
$pconfig
[
'php'
][
'start'
]
=
array
(
'openvpn_restart_by_id'
);
$pconfig
[
'php'
][
'args'
]
=
array
(
'mode'
,
'id'
);
$pconfig
[
'id'
]
=
$setting
[
'vpnid'
];
$pconfig
[
'name'
]
=
'openvpn'
;
$pconfig
[
'mode'
]
=
$mode
;
$services
[]
=
$pconfig
;
}
}
}
}
return
$services
;
}
function
if_openvpn_interfaces
()
{
global
$config
;
$interfaces
=
array
();
foreach
(
array
(
'server'
,
'client'
)
as
$mode
)
{
if
(
isset
(
$config
[
'openvpn'
][
"openvpn-
{
$mode
}
"
]))
{
foreach
(
$config
[
'openvpn'
][
"openvpn-
{
$mode
}
"
]
as
&
$settings
)
{
if
(
empty
(
$settings
[
'disable'
]))
{
$oic
=
array
(
'enable'
=>
true
);
$oic
[
'if'
]
=
'openvpn'
;
$oic
[
'descr'
]
=
'OpenVPN'
;
$oic
[
'type'
]
=
'group'
;
$oic
[
'virtual'
]
=
true
;
$oic
[
'networks'
]
=
array
();
$interfaces
[
'openvpn'
]
=
$oic
;
break
2
;
}
}
}
}
return
$interfaces
;
}
function
if_openvpn_xmlrpc_sync
()
{
$result
=
array
();
$result
[]
=
array
(
'description'
=>
gettext
(
'OpenVPN'
),
'section'
=>
'openvpn'
,
'id'
=>
'openvpn'
,
);
return
$result
;
}
src/etc/inc/openvpn.inc
→
src/etc/inc/
plugins.inc.d/
openvpn.inc
View file @
e9195153
...
...
@@ -11,11 +11,11 @@
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice
s
,
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice
s
, this list of conditions and the following disclaimer in the
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
...
...
@@ -30,6 +30,85 @@
POSSIBILITY OF SUCH DAMAGE.
*/
function
openvpn_syslog
()
{
$logfacilities
=
array
();
$logfacilities
[
'openvpn'
]
=
array
(
'facility'
=>
array
(
'openvpn'
),
'remote'
=>
'vpn'
,
);
return
$logfacilities
;
}
function
openvpn_services
()
{
global
$config
;
$services
=
array
();
foreach
(
array
(
'server'
,
'client'
)
as
$mode
)
{
if
(
isset
(
$config
[
'openvpn'
][
"openvpn-
{
$mode
}
"
]))
{
foreach
(
$config
[
'openvpn'
][
"openvpn-
{
$mode
}
"
]
as
$setting
)
{
if
(
empty
(
$setting
[
'disable'
]))
{
$pconfig
=
array
();
$pconfig
[
'description'
]
=
"OpenVPN
{
$mode
}
: "
.
htmlspecialchars
(
$setting
[
'description'
]);
$pconfig
[
'pidfile'
]
=
"/var/run/openvpn_
{
$mode
}{
$setting
[
'vpnid'
]
}
.pid"
;
$pconfig
[
'php'
][
'restart'
]
=
array
(
'openvpn_restart_by_id'
);
$pconfig
[
'php'
][
'start'
]
=
array
(
'openvpn_restart_by_id'
);
$pconfig
[
'php'
][
'args'
]
=
array
(
'mode'
,
'id'
);
$pconfig
[
'id'
]
=
$setting
[
'vpnid'
];
$pconfig
[
'name'
]
=
'openvpn'
;
$pconfig
[
'mode'
]
=
$mode
;
$services
[]
=
$pconfig
;
}
}
}
}
return
$services
;
}
function
openvpn_interfaces
()
{
global
$config
;
$interfaces
=
array
();
foreach
(
array
(
'server'
,
'client'
)
as
$mode
)
{
if
(
isset
(
$config
[
'openvpn'
][
"openvpn-
{
$mode
}
"
]))
{
foreach
(
$config
[
'openvpn'
][
"openvpn-
{
$mode
}
"
]
as
&
$settings
)
{
if
(
empty
(
$settings
[
'disable'
]))
{
$oic
=
array
(
'enable'
=>
true
);
$oic
[
'if'
]
=
'openvpn'
;
$oic
[
'descr'
]
=
'OpenVPN'
;
$oic
[
'type'
]
=
'group'
;
$oic
[
'virtual'
]
=
true
;
$oic
[
'networks'
]
=
array
();
$interfaces
[
'openvpn'
]
=
$oic
;
break
2
;
}
}
}
}
return
$interfaces
;
}
function
openvpn_xmlrpc_sync
()
{
$result
=
array
();
$result
[]
=
array
(
'description'
=>
gettext
(
'OpenVPN'
),
'section'
=>
'openvpn'
,
'id'
=>
'openvpn'
,
);
return
$result
;
}
global
$openvpn_verbosity_level
;
$openvpn_verbosity_level
=
array
(
0
=>
gettext
(
'0 (none)'
),
...
...
@@ -1513,29 +1592,69 @@ function openvpn_refresh_crls()
function
openvpn_resync_if_needed
(
$mode
,
$ovpn_settings
,
$interface
)
{
global
$config
;
$resync_needed
=
true
;
if
(
isset
(
$ovpn_settings
[
'disable'
]))
{
$resync_needed
=
false
;
}
else
{
if
(
!
empty
(
$interface
))
{
$mode_id
=
$mode
.
$ovpn_settings
[
'vpnid'
];
$fpath
=
"/var/etc/openvpn/
{
$mode_id
}
.interface"
;
if
(
file_exists
(
$fpath
))
{
$current_device
=
file_get_contents
(
$fpath
);
$current_device
=
trim
(
$current_device
,
"
\t\n
"
);
$new_device
=
get_failover_interface
(
$ovpn_settings
[
'interface'
]);
if
(
isset
(
$config
[
'interfaces'
][
$interface
]))
{
$this_device
=
$config
[
'interfaces'
][
$interface
][
'if'
];
if
((
$current_device
==
$new_device
)
&&
(
$current_device
!=
$this_device
))
$resync_needed
=
false
;
}
}
}
}
if
(
$resync_needed
==
true
)
{
log_error
(
"OpenVPN: Resync "
.
$mode_id
.
" "
.
$ovpn_settings
[
'description'
]);
openvpn_resync
(
$mode
,
$ovpn_settings
);
}
global
$config
;
$resync_needed
=
true
;
if
(
isset
(
$ovpn_settings
[
'disable'
]))
{
$resync_needed
=
false
;
}
else
{
if
(
!
empty
(
$interface
))
{
$mode_id
=
$mode
.
$ovpn_settings
[
'vpnid'
];
$fpath
=
"/var/etc/openvpn/
{
$mode_id
}
.interface"
;
if
(
file_exists
(
$fpath
))
{
$current_device
=
file_get_contents
(
$fpath
);
$current_device
=
trim
(
$current_device
,
"
\t\n
"
);
$new_device
=
get_failover_interface
(
$ovpn_settings
[
'interface'
]);
if
(
isset
(
$config
[
'interfaces'
][
$interface
]))
{
$this_device
=
$config
[
'interfaces'
][
$interface
][
'if'
];
if
((
$current_device
==
$new_device
)
&&
(
$current_device
!=
$this_device
))
$resync_needed
=
false
;
}
}
}
}
if
(
$resync_needed
==
true
)
{
log_error
(
"OpenVPN: Resync "
.
$mode_id
.
" "
.
$ovpn_settings
[
'description'
]);
openvpn_resync
(
$mode
,
$ovpn_settings
);
}
}
function
openvpn_carp_stop
(
$carp_iface
)
{
global
$config
;
$friendly_descr
=
convert_friendly_interface_to_friendly_descr
(
$carp_iface
);
if
(
is_array
(
$config
[
'openvpn'
])
&&
is_array
(
$config
[
'openvpn'
][
'openvpn-client'
]))
{
foreach
(
$config
[
'openvpn'
][
'openvpn-client'
]
as
$settings
)
{
if
(
$settings
[
'interface'
]
==
$carp_iface
)
{
log_error
(
"Stopping OpenVPN client instance on
{
$friendly_descr
}
because of transition to CARP backup."
);
openvpn_restart
(
'client'
,
$settings
);
}
}
}
}
function
openvpn_carp_start
(
$carp_iface
)
{
global
$config
;
$friendly_descr
=
convert_friendly_interface_to_friendly_descr
(
$carp_iface
);
if
(
is_array
(
$config
[
'openvpn'
])
&&
is_array
(
$config
[
'openvpn'
][
'openvpn-client'
]))
{
foreach
(
$config
[
'openvpn'
][
'openvpn-client'
]
as
$settings
)
{
if
(
$settings
[
'interface'
]
==
$carp_iface
)
{
log_error
(
"Starting OpenVPN client instance on
{
$friendly_descr
}
because of transition to CARP master."
);
openvpn_restart
(
'client'
,
$settings
);
}
}
}
if
(
is_array
(
$config
[
'openvpn'
])
&&
is_array
(
$config
[
'openvpn'
][
'openvpn-server'
]))
{
foreach
(
$config
[
'openvpn'
][
'openvpn-server'
]
as
$settings
)
{
if
(
$settings
[
'interface'
]
==
$carp_iface
)
{
log_error
(
"Starting OpenVPN instance on
{
$friendly_descr
}
because of transition to CARP master."
);
openvpn_restart
(
'server'
,
$settings
);
}
}
}
}
src/etc/inc/
openvpn.
auth-user.php
→
src/etc/inc/
plugins.inc.d/openvpn/
auth-user.php
View file @
e9195153
File moved
src/etc/inc/
openvpn.
tls-verify.php
→
src/etc/inc/
plugins.inc.d/openvpn/
tls-verify.php
View file @
e9195153
File moved
src/etc/inc/services.inc
View file @
e9195153
...
...
@@ -43,10 +43,10 @@
* of includes and switch them for a cleaner "services.inc"
* include.
*/
require_once
(
'dyndns.class'
);
require_once
(
'plugins.inc.d/dnsmasq.inc'
);
require_once
(
'dyndns.class'
);
/* XXX move to plugin */
require_once
(
'plugins.inc.d/ipsec.inc'
);
require_once
(
'
openvpn.inc'
);
/* XXX move to plugin */
require_once
(
'
plugins.inc.d/openvpn.inc'
);
require_once
(
'plugins.inc.d/unbound.inc'
);
function
generate_ipv6_from_mac
(
$mac
)
...
...
src/etc/rc.carpbackup
View file @
e9195153
...
...
@@ -28,7 +28,7 @@
*/
require_once
(
"config.inc"
);
require_once
(
"
openvpn
.inc"
);
require_once
(
"
services
.inc"
);
require_once
(
"interfaces.inc"
);
require_once
(
"util.inc"
);
...
...
@@ -48,12 +48,4 @@ notify_via_growl($notificationmsg);
log_error
(
$notificationmsg
);
/* Stop OpenVPN clients running on this VIP, since multiple active OpenVPN clients on a CARP cluster can be problematic. */
global
$config
;
if
(
is_array
(
$config
[
'openvpn'
])
&&
is_array
(
$config
[
'openvpn'
][
'openvpn-client'
]))
{
foreach
(
$config
[
'openvpn'
][
'openvpn-client'
]
as
$settings
)
{
if
(
$settings
[
'interface'
]
==
$carp_iface
)
{
log_error
(
"Stopping OpenVPN client instance on
{
$friendly_descr
}
because of transition to CARP backup."
);
openvpn_restart
(
'client'
,
$settings
);
}
}
}
openvpn_carp_stop
(
$carp_iface
);
src/etc/rc.carpmaster
View file @
e9195153
...
...
@@ -28,7 +28,7 @@
*/
require_once
(
"config.inc"
);
require_once
(
"
openvpn
.inc"
);
require_once
(
"
services
.inc"
);
require_once
(
"interfaces.inc"
);
require_once
(
"util.inc"
);
...
...
@@ -48,20 +48,4 @@ notify_via_growl($notificationmsg);
log_error
(
$notificationmsg
);
/* Start OpenVPN clients running on this VIP, since they should be in the stopped state while the VIP is CARP Backup. */
global
$config
;
if
(
is_array
(
$config
[
'openvpn'
])
&&
is_array
(
$config
[
'openvpn'
][
'openvpn-client'
]))
{
foreach
(
$config
[
'openvpn'
][
'openvpn-client'
]
as
$settings
)
{
if
(
$settings
[
'interface'
]
==
$carp_iface
)
{
log_error
(
"Starting OpenVPN client instance on
{
$friendly_descr
}
because of transition to CARP master."
);
openvpn_restart
(
'client'
,
$settings
);
}
}
}
if
(
is_array
(
$config
[
'openvpn'
])
&&
is_array
(
$config
[
'openvpn'
][
'openvpn-server'
]))
{
foreach
(
$config
[
'openvpn'
][
'openvpn-server'
]
as
$settings
)
{
if
(
$settings
[
'interface'
]
==
$carp_iface
)
{
log_error
(
"Starting OpenVPN instance on
{
$friendly_descr
}
because of transition to CARP master."
);
openvpn_restart
(
'server'
,
$settings
);
}
}
}
openvpn_carp_start
(
$carp_iface
);
src/etc/rc.openvpn
View file @
e9195153
...
...
@@ -2,91 +2,90 @@
<?php
/*
Copyright (C) 2007 Manuel Kasper <mk@neon1.net>.
Copyright (C) 2009 Seth Mos <seth.mos@dds.nl>.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Copyright (C) 2007 Manuel Kasper <mk@neon1.net>.
Copyright (C) 2009 Seth Mos <seth.mos@dds.nl>.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
/* parse the configuration and include all functions used below */
require_once
(
"util.inc"
);
require_once
(
"config.inc"
);
require_once
(
"interfaces.inc"
);
require_once
(
"filter.inc"
);
require_once
(
"openvpn.inc"
);
require_once
(
"
plugins.inc.d/
openvpn.inc"
);
function
gateway_is_gwgroup_member
(
$name
)
{
global
$config
;
if
(
!
isset
(
$config
[
'gateways'
][
'gateway_group'
]))
{
return
false
;
}
$groups
=
$config
[
'gateways'
][
'gateway_group'
];
$members
=
array
();
foreach
(
$groups
as
$group
)
{
if
(
isset
(
$group
[
'item'
]))
{
foreach
(
$group
[
'item'
]
as
$item
)
{
$elements
=
explode
(
"|"
,
$item
);
$gwname
=
$elements
[
0
];
if
(
$name
==
$elements
[
0
])
{
$members
[]
=
$group
[
'name'
];
}
}
}
}
return
$members
;
global
$config
;
if
(
!
isset
(
$config
[
'gateways'
][
'gateway_group'
]))
{
return
false
;
}
$groups
=
$config
[
'gateways'
][
'gateway_group'
];
$members
=
array
();
foreach
(
$groups
as
$group
)
{
if
(
isset
(
$group
[
'item'
]))
{
foreach
(
$group
[
'item'
]
as
$item
)
{
$elements
=
explode
(
"|"
,
$item
);
$gwname
=
$elements
[
0
];
if
(
$name
==
$elements
[
0
])
{
$members
[]
=
$group
[
'name'
];
}
}
}
}
return
$members
;
}
function
try_lock
(
$lock
,
$timeout
=
5
)
{
if
(
!
$lock
)
{
die
(
gettext
(
"WARNING: You must give a name as parameter to try_lock() function."
));
}
if
(
!
file_exists
(
"/tmp/
{
$lock
}
.lock"
))
{
@
touch
(
"/tmp/
{
$lock
}
.lock"
);
@
chmod
(
"/tmp/
{
$lock
}
.lock"
,
0666
);
}
if
(
$fp
=
fopen
(
"/tmp/
{
$lock
}
.lock"
,
"w"
))
{
$trycounter
=
0
;
while
(
!
flock
(
$fp
,
LOCK_EX
|
LOCK_NB
))
{
if
(
$trycounter
>=
$timeout
)
{
fclose
(
$fp
);
return
NULL
;
}
sleep
(
1
);
$trycounter
++
;
}
return
$fp
;
}
return
NULL
;
if
(
!
$lock
)
{
die
(
gettext
(
"WARNING: You must give a name as parameter to try_lock() function."
));
}
if
(
!
file_exists
(
"/tmp/
{
$lock
}
.lock"
))
{
@
touch
(
"/tmp/
{
$lock
}
.lock"
);
@
chmod
(
"/tmp/
{
$lock
}
.lock"
,
0666
);
}
if
(
$fp
=
fopen
(
"/tmp/
{
$lock
}
.lock"
,
"w"
))
{
$trycounter
=
0
;
while
(
!
flock
(
$fp
,
LOCK_EX
|
LOCK_NB
))
{
if
(
$trycounter
>=
$timeout
)
{
fclose
(
$fp
);
return
NULL
;
}
sleep
(
1
);
$trycounter
++
;
}
return
$fp
;
}
return
NULL
;
}
...
...
@@ -99,51 +98,52 @@ if (file_exists('/var/run/booting')) {
$argument
=
trim
(
$argv
[
1
],
"
\n
"
);
if
(
isset
(
$config
[
'openvpn'
][
'openvpn-server'
])
||
isset
(
$config
[
'openvpn'
][
'openvpn-client'
]))
{
if
(
empty
(
$argument
)
||
$argument
==
"all"
)
{
$argument
=
"all"
;
$log_text
=
"all"
;
}
else
{
$log_text
=
"endpoints that may use "
.
$argument
;
}
log_error
(
"OpenVPN: One or more OpenVPN tunnel endpoints may have changed its IP. Reloading "
.
$log_text
.
"."
);
}
else
return
;
if
(
empty
(
$argument
)
||
$argument
==
"all"
)
{
$argument
=
"all"
;
$log_text
=
"all"
;
}
else
{
$log_text
=
"endpoints that may use "
.
$argument
;
}
log_error
(
"OpenVPN: One or more OpenVPN tunnel endpoints may have changed its IP. Reloading "
.
$log_text
.
"."
);
}
else
{
return
;
}
$openvpnlck
=
try_lock
(
'openvpn'
,
10
);
if
(
!
$openvpnlck
)
{
log_error
(
'Could not obtain openvpn lock for executing rc.openvpn for more than 10 seconds continuing...'
);
@
unlink
(
"/tmp/openvpn.lock"
);
$openvpnlck
=
lock
(
'openvpn'
,
LOCK_EX
);
log_error
(
'Could not obtain openvpn lock for executing rc.openvpn for more than 10 seconds continuing...'
);
@
unlink
(
"/tmp/openvpn.lock"
);
$openvpnlck
=
lock
(
'openvpn'
,
LOCK_EX
);
}
$arg_array
=
explode
(
","
,
$argument
);
foreach
(
$arg_array
as
$arg_element
)
{
$gwgroups
=
array
();
if
(
$arg_element
==
"all"
)
$interface
=
""
;
else
{
// e.g. $arg_element = "WANGW", $interface = "wan"
$interface
=
lookup_gateway_interface_by_name
(
$arg_element
);
if
(
empty
(
$interface
))
$interface
=
$arg_element
;
else
// e.g. $arg_element = "WANGW", $gwgroups = array of gateway groups that use "wan"
$gwgroups
=
gateway_is_gwgroup_member
(
$arg_element
);
}
if
(
is_array
(
$config
[
'openvpn'
][
'openvpn-server'
]))
{
foreach
(
$config
[
'openvpn'
][
'openvpn-server'
]
as
&
$server
)
{
if
(
$server
[
'interface'
]
==
$interface
||
empty
(
$interface
)
||
(
!
empty
(
$gwgroups
)
&&
in_array
(
$server
[
'interface'
],
$gwgroups
)))
openvpn_resync_if_needed
(
'server'
,
$server
,
$interface
);
}
}
if
(
is_array
(
$config
[
'openvpn'
][
'openvpn-client'
]))
{
foreach
(
$config
[
'openvpn'
][
'openvpn-client'
]
as
&
$client
)
{
if
(
$client
[
'interface'
]
==
$interface
||
empty
(
$interface
)
||
(
!
empty
(
$gwgroups
)
&&
in_array
(
$client
[
'interface'
],
$gwgroups
)))
openvpn_resync_if_needed
(
'client'
,
$client
,
$interface
);
}
}
$gwgroups
=
array
();
if
(
$arg_element
==
"all"
)
{
$interface
=
""
;
}
else
{
// e.g. $arg_element = "WANGW", $interface = "wan"
$interface
=
lookup_gateway_interface_by_name
(
$arg_element
);
if
(
empty
(
$interface
))
$interface
=
$arg_element
;
else
// e.g. $arg_element = "WANGW", $gwgroups = array of gateway groups that use "wan"
$gwgroups
=
gateway_is_gwgroup_member
(
$arg_element
);
}
if
(
is_array
(
$config
[
'openvpn'
][
'openvpn-server'
]))
{
foreach
(
$config
[
'openvpn'
][
'openvpn-server'
]
as
&
$server
)
{
if
(
$server
[
'interface'
]
==
$interface
||
empty
(
$interface
)
||
(
!
empty
(
$gwgroups
)
&&
in_array
(
$server
[
'interface'
],
$gwgroups
)))
openvpn_resync_if_needed
(
'server'
,
$server
,
$interface
);
}
}
if
(
is_array
(
$config
[
'openvpn'
][
'openvpn-client'
]))
{
foreach
(
$config
[
'openvpn'
][
'openvpn-client'
]
as
&
$client
)
{
if
(
$client
[
'interface'
]
==
$interface
||
empty
(
$interface
)
||
(
!
empty
(
$gwgroups
)
&&
in_array
(
$client
[
'interface'
],
$gwgroups
)))
openvpn_resync_if_needed
(
'client'
,
$client
,
$interface
);
}
}
}
unlock
(
$openvpnlck
);
src/sbin/ovpn_auth_verify
View file @
e9195153
#!/bin/sh
if
[
"
$1
"
=
"tls"
]
;
then
/usr/local/bin/php /usr/local/etc/inc/
openvpn.
tls-verify.php
-d
"
$2
"
"
$3
"
/usr/local/bin/php /usr/local/etc/inc/
plugins.inc.d/openvpn/
tls-verify.php
-d
"
$2
"
"
$3
"
else
# Single quoting $password breaks getting the value from the variable.
# XXX I really don't like going through openssl for this...
password
=
$(
echo
-n
"
${
password
}
"
| /usr/local/bin/openssl enc
-base64
|
sed
-e
's/=/%3D/g'
)
username
=
$(
echo
-n
"
${
username
}
"
| /usr/local/bin/openssl enc
-base64
|
sed
-e
's/=/%3D/g'
)
/usr/local/bin/php /usr/local/etc/inc/
openvpn.
auth-user.php
"
$username
"
"
$password
"
"
$common_name
"
"
$3
"
"
$2
"
"
$4
"
/usr/local/bin/php /usr/local/etc/inc/
plugins.inc.d/openvpn/
auth-user.php
"
$username
"
"
$password
"
"
$common_name
"
"
$3
"
"
$2
"
"
$4
"
fi
exit
$?
src/wizard/openvpn.xml
View file @
e9195153
...
...
@@ -28,7 +28,7 @@
POSSIBILITY OF SUCH DAMAGE.
*/
</copyright>
<includefile>
openvpn_
wizard.inc
</includefile>
<includefile>
plugins.inc.d/openvpn/
wizard.inc
</includefile>
<totalsteps>
12
</totalsteps>
<step>
<id>
1
</id>
...
...
src/www/status_openvpn.php
View file @
e9195153
...
...
@@ -30,7 +30,7 @@
*/
require_once
(
"guiconfig.inc"
);
require_once
(
"openvpn.inc"
);
require_once
(
"
plugins.inc.d/
openvpn.inc"
);
require_once
(
"services.inc"
);
require_once
(
"interfaces.inc"
);
...
...
src/www/vpn_openvpn_client.php
View file @
e9195153
...
...
@@ -28,7 +28,7 @@
*/
require_once
(
"guiconfig.inc"
);
require_once
(
"openvpn.inc"
);
require_once
(
"
plugins.inc.d/
openvpn.inc"
);
require_once
(
"services.inc"
);
require_once
(
"interfaces.inc"
);
...
...
src/www/vpn_openvpn_csc.php
View file @
e9195153
...
...
@@ -28,7 +28,7 @@
*/
require_once
(
"guiconfig.inc"
);
require_once
(
"openvpn.inc"
);
require_once
(
"
plugins.inc.d/
openvpn.inc"
);
require_once
(
"services.inc"
);
require_once
(
"interfaces.inc"
);
...
...
src/www/vpn_openvpn_export.php
View file @
e9195153
...
...
@@ -30,7 +30,7 @@
*/
require_once
(
"guiconfig.inc"
);
require_once
(
"openvpn.inc"
);
require_once
(
"
plugins.inc.d/
openvpn.inc"
);
require_once
(
"services.inc"
);
require_once
(
"filter.inc"
);
require_once
(
"interfaces.inc"
);
...
...
src/www/vpn_openvpn_server.php
View file @
e9195153
...
...
@@ -28,7 +28,7 @@
*/
require_once
(
"guiconfig.inc"
);
require_once
(
"openvpn.inc"
);
require_once
(
"
plugins.inc.d/
openvpn.inc"
);
require_once
(
"services.inc"
);
require_once
(
"interfaces.inc"
);
...
...
src/www/widgets/widgets/openvpn.widget.php
View file @
e9195153
...
...
@@ -27,14 +27,13 @@
*/
require_once
(
"guiconfig.inc"
);
require_once
(
"openvpn.inc"
);
require_once
(
"plugins.inc.d/openvpn.inc"
);
$servers
=
openvpn_get_active_servers
();
$sk_servers
=
openvpn_get_active_servers
(
"p2p"
);
$clients
=
openvpn_get_active_clients
();
?>
?>
<script
type=
"text/javascript"
>
$
(
document
).
ready
(
function
()
{
// link kill buttons
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment