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
65c3270c
Commit
65c3270c
authored
Mar 06, 2016
by
Franco Fichtner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vpn: apply sytle
parent
a8006f27
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
379 additions
and
364 deletions
+379
-364
vpn.inc
src/etc/inc/plugins.inc.d/vpn.inc
+379
-364
No files found.
src/etc/inc/plugins.inc.d/vpn.inc
View file @
65c3270c
...
...
@@ -134,7 +134,7 @@ function vpn_pptpd_configure()
@
mkdir
(
'/var/etc/pptp-vpn'
);
switch
(
$pptpdcfg
[
'mode'
])
{
case
'server'
:
case
'server'
:
/* write mpd.conf */
$fd
=
fopen
(
'/var/etc/pptp-vpn/mpd.conf'
,
'w'
);
if
(
!
$fd
)
{
...
...
@@ -189,7 +189,7 @@ pts:
EOD
;
if
(
!
isset
(
$pptpdcfg
[
'req128'
]))
{
if
(
!
isset
(
$pptpdcfg
[
'req128'
]))
{
$mpdconf
.=<<<
EOD
set
ccp
yes
mpp
-
e40
set
ccp
yes
mpp
-
e56
...
...
@@ -197,36 +197,40 @@ EOD;
EOD
;
}
if
(
isset
(
$pptpdcfg
[
"wins"
])
&&
$pptpdcfg
[
'wins'
]
!=
""
)
if
(
isset
(
$pptpdcfg
[
"wins"
])
&&
$pptpdcfg
[
'wins'
]
!=
""
)
{
$mpdconf
.=
" set ipcp nbns
{
$pptpdcfg
[
'wins'
]
}
\n
"
;
}
if
(
!
empty
(
$pptpdcfg
[
'dns1'
]))
{
$mpdconf
.=
" set ipcp dns "
.
$pptpdcfg
[
'dns1'
];
if
(
!
empty
(
$pptpdcfg
[
'dns2'
]))
if
(
!
empty
(
$pptpdcfg
[
'dns2'
]))
{
$mpdconf
.=
" "
.
$pptpdcfg
[
'dns2'
];
}
$mpdconf
.=
"
\n
"
;
}
elseif
(
isset
(
$config
[
'dnsmasq'
][
'enable'
]))
{
}
elseif
(
isset
(
$config
[
'dnsmasq'
][
'enable'
]))
{
$mpdconf
.=
" set ipcp dns "
.
get_interface_ip
(
"lan"
);
if
(
$syscfg
[
'dnsserver'
][
0
])
if
(
$syscfg
[
'dnsserver'
][
0
])
{
$mpdconf
.=
" "
.
$syscfg
[
'dnsserver'
][
0
];
}
$mpdconf
.=
"
\n
"
;
}
elseif
(
isset
(
$config
[
'unbound'
][
'enable'
]))
{
$mpdconf
.=
" set ipcp dns "
.
get_interface_ip
(
"lan"
);
if
(
$syscfg
[
'dnsserver'
][
0
])
if
(
$syscfg
[
'dnsserver'
][
0
])
{
$mpdconf
.=
" "
.
$syscfg
[
'dnsserver'
][
0
];
}
$mpdconf
.=
"
\n
"
;
}
elseif
(
is_array
(
$syscfg
[
'dnsserver'
])
&&
(
$syscfg
[
'dnsserver'
][
0
]))
{
$mpdconf
.=
" set ipcp dns "
.
join
(
" "
,
$syscfg
[
'dnsserver'
])
.
"
\n
"
;
}
if
(
isset
(
$pptpdcfg
[
'radius'
][
'server'
][
'enable'
]))
{
if
(
isset
(
$pptpdcfg
[
'radius'
][
'server'
][
'enable'
]))
{
$authport
=
(
isset
(
$pptpdcfg
[
'radius'
][
'server'
][
'port'
])
&&
strlen
(
$pptpdcfg
[
'radius'
][
'server'
][
'port'
])
>
1
)
?
$pptpdcfg
[
'radius'
][
'server'
][
'port'
]
:
1812
;
$acctport
=
$authport
+
1
;
$mpdconf
.=<<<
EOD
set
radius
server
{
$pptpdcfg
[
'radius'
][
'server'
][
'ip'
]}
"
{
$pptpdcfg
[
'radius'
][
'server'
][
'secret'
]
}
"
{
$authport
}
{
$acctport
}
EOD
;
if
(
isset
(
$pptpdcfg
[
'radius'
][
'server2'
][
'enable'
]))
{
if
(
isset
(
$pptpdcfg
[
'radius'
][
'server2'
][
'enable'
]))
{
$authport
=
(
isset
(
$pptpdcfg
[
'radius'
][
'server2'
][
'port'
])
&&
strlen
(
$pptpdcfg
[
'radius'
][
'server2'
][
'port'
])
>
1
)
?
$pptpdcfg
[
'radius'
][
'server2'
][
'port'
]
:
1812
;
$acctport
=
$authport
+
1
;
$mpdconf
.=<<<
EOD
...
...
@@ -241,7 +245,7 @@ EOD;
EOD
;
if
(
isset
(
$pptpdcfg
[
'radius'
][
'accounting'
]))
{
if
(
isset
(
$pptpdcfg
[
'radius'
][
'accounting'
]))
{
$mpdconf
.=<<<
EOD
set
auth
enable
radius
-
acct
set
radius
acct
-
update
300
...
...
@@ -308,7 +312,7 @@ EOD;
break
;
case
'redir'
:
case
'redir'
:
break
;
}
...
...
@@ -370,17 +374,17 @@ function vpn_pppoe_configure(&$pppoecfg)
switch
(
$pppoecfg
[
'mode'
])
{
case
'server'
:
case
'server'
:
/* create directory if it does not exist */
@
mkdir
(
"/var/etc/pppoe
{
$pppoecfg
[
'pppoeid'
]
}
-vpn"
);
$pppoe_interface
=
get_real_interface
(
$pppoecfg
[
'interface'
]);
if
(
$pppoecfg
[
'paporchap'
]
==
"chap"
)
if
(
$pppoecfg
[
'paporchap'
]
==
"chap"
)
{
$paporchap
=
"set link enable chap"
;
else
}
else
{
$paporchap
=
"set link enable pap"
;
}
/* write mpd.conf */
$fd
=
fopen
(
"/var/etc/pppoe
{
$pppoecfg
[
'pppoeid'
]
}
-vpn/mpd.conf"
,
"w"
);
...
...
@@ -447,30 +451,35 @@ EOD;
if
(
!
empty
(
$pppoecfg
[
'dns1'
]))
{
$mpdconf
.=
" set ipcp dns "
.
$pppoecfg
[
'dns1'
];
if
(
!
empty
(
$pppoecfg
[
'dns2'
]))
if
(
!
empty
(
$pppoecfg
[
'dns2'
]))
{
$mpdconf
.=
" "
.
$pppoecfg
[
'dns2'
];
}
$mpdconf
.=
"
\n
"
;
}
elseif
(
isset
(
$config
[
'dnsmasq'
][
'enable'
]))
{
}
elseif
(
isset
(
$config
[
'dnsmasq'
][
'enable'
]))
{
$mpdconf
.=
" set ipcp dns "
.
get_interface_ip
(
"lan"
);
if
(
$syscfg
[
'dnsserver'
][
0
])
if
(
$syscfg
[
'dnsserver'
][
0
])
{
$mpdconf
.=
" "
.
$syscfg
[
'dnsserver'
][
0
];
}
$mpdconf
.=
"
\n
"
;
}
elseif
(
isset
(
$config
[
'unbound'
][
'enable'
]))
{
}
elseif
(
isset
(
$config
[
'unbound'
][
'enable'
]))
{
$mpdconf
.=
" set ipcp dns "
.
get_interface_ip
(
"lan"
);
if
(
$syscfg
[
'dnsserver'
][
0
])
if
(
$syscfg
[
'dnsserver'
][
0
])
{
$mpdconf
.=
" "
.
$syscfg
[
'dnsserver'
][
0
];
}
$mpdconf
.=
"
\n
"
;
}
elseif
(
is_array
(
$syscfg
[
'dnsserver'
])
&&
(
$syscfg
[
'dnsserver'
][
0
]))
{
$mpdconf
.=
" set ipcp dns "
.
join
(
" "
,
$syscfg
[
'dnsserver'
])
.
"
\n
"
;
}
if
(
isset
(
$pppoecfg
[
'radius'
][
'server'
][
'enable'
]))
{
if
(
isset
(
$pppoecfg
[
'radius'
][
'server'
][
'enable'
]))
{
$radiusport
=
""
;
$radiusacctport
=
""
;
if
(
isset
(
$pppoecfg
[
'radius'
][
'server'
][
'port'
]))
if
(
isset
(
$pppoecfg
[
'radius'
][
'server'
][
'port'
]))
{
$radiusport
=
$pppoecfg
[
'radius'
][
'server'
][
'port'
];
if
(
isset
(
$pppoecfg
[
'radius'
][
'server'
][
'acctport'
]))
}
if
(
isset
(
$pppoecfg
[
'radius'
][
'server'
][
'acctport'
]))
{
$radiusacctport
=
$pppoecfg
[
'radius'
][
'server'
][
'acctport'
];
}
$mpdconf
.=<<<
EOD
set
radius
server
{
$pppoecfg
[
'radius'
][
'server'
][
'ip'
]}
"
{
$pppoecfg
[
'radius'
][
'server'
][
'secret'
]
}
"
{
$radiusport
}
{
$radiusacctport
}
set
radius
retries
3
...
...
@@ -479,7 +488,7 @@ EOD;
EOD
;
if
(
isset
(
$pppoecfg
[
'radius'
][
'accounting'
]))
{
if
(
isset
(
$pppoecfg
[
'radius'
][
'accounting'
]))
{
$mpdconf
.=<<<
EOD
set
auth
enable
radius
-
acct
...
...
@@ -529,7 +538,7 @@ EOD;
if
(
!
empty
(
$pppoecfg
[
'username'
]))
{
$item
=
explode
(
" "
,
$pppoecfg
[
'username'
]);
foreach
(
$item
as
$userdata
)
{
foreach
(
$item
as
$userdata
)
{
$data
=
explode
(
":"
,
$userdata
);
$mpdsecret
.=
"
{
$data
[
0
]
}
\"
"
.
base64_decode
(
$data
[
1
])
.
"
\"
{
$data
[
2
]
}
\n
"
;
}
...
...
@@ -580,11 +589,12 @@ function vpn_l2tp_configure()
switch
(
isset
(
$l2tpcfg
[
'mode'
])
?
$l2tpcfg
[
'mode'
]
:
null
)
{
case
'server'
:
if
(
$l2tpcfg
[
'paporchap'
]
==
"chap"
)
case
'server'
:
if
(
$l2tpcfg
[
'paporchap'
]
==
"chap"
)
{
$paporchap
=
"set link enable chap"
;
else
}
else
{
$paporchap
=
"set link enable pap"
;
}
/* write mpd.conf */
$fd
=
fopen
(
"/var/etc/l2tp-vpn/mpd.conf"
,
"w"
);
...
...
@@ -606,7 +616,7 @@ EOD;
$clientip
=
long2ip32
(
ip2long
(
$l2tpcfg
[
'remoteip'
])
+
$i
);
if
(
isset
(
$l2tpcfg
[
'radius'
][
'radiusissueips'
])
&&
isset
(
$l2tpcfg
[
'radius'
][
'enable'
]))
{
if
(
isset
(
$l2tpcfg
[
'radius'
][
'radiusissueips'
])
&&
isset
(
$l2tpcfg
[
'radius'
][
'enable'
]))
{
$isssue_ip_type
=
"set ipcp ranges
{
$l2tpcfg
[
'localip'
]
}
/32 0.0.0.0/0"
;
}
else
{
$isssue_ip_type
=
"set ipcp ranges
{
$l2tpcfg
[
'localip'
]
}
/32
{
$clientip
}
/32"
;
...
...
@@ -647,24 +657,27 @@ EOD;
}
if
(
is_ipaddr
(
$l2tpcfg
[
'dns1'
]))
{
$mpdconf
.=
" set ipcp dns "
.
$l2tpcfg
[
'dns1'
];
if
(
is_ipaddr
(
$l2tpcfg
[
'dns2'
]))
if
(
is_ipaddr
(
$l2tpcfg
[
'dns2'
]))
{
$mpdconf
.=
" "
.
$l2tpcfg
[
'dns2'
];
}
$mpdconf
.=
"
\n
"
;
}
elseif
(
isset
(
$config
[
'dnsmasq'
][
'enable'
]))
{
}
elseif
(
isset
(
$config
[
'dnsmasq'
][
'enable'
]))
{
$mpdconf
.=
" set ipcp dns "
.
get_interface_ip
(
"lan"
);
if
(
$syscfg
[
'dnsserver'
][
0
])
if
(
$syscfg
[
'dnsserver'
][
0
])
{
$mpdconf
.=
" "
.
$syscfg
[
'dnsserver'
][
0
];
}
$mpdconf
.=
"
\n
"
;
}
elseif
(
isset
(
$config
[
'unbound'
][
'enable'
]))
{
}
elseif
(
isset
(
$config
[
'unbound'
][
'enable'
]))
{
$mpdconf
.=
" set ipcp dns "
.
get_interface_ip
(
"lan"
);
if
(
$syscfg
[
'dnsserver'
][
0
])
if
(
$syscfg
[
'dnsserver'
][
0
])
{
$mpdconf
.=
" "
.
$syscfg
[
'dnsserver'
][
0
];
}
$mpdconf
.=
"
\n
"
;
}
elseif
(
is_array
(
$syscfg
[
'dnsserver'
])
&&
(
$syscfg
[
'dnsserver'
][
0
]))
{
$mpdconf
.=
" set ipcp dns "
.
join
(
" "
,
$syscfg
[
'dnsserver'
])
.
"
\n
"
;
}
if
(
isset
(
$l2tpcfg
[
'radius'
][
'enable'
]))
{
if
(
isset
(
$l2tpcfg
[
'radius'
][
'enable'
]))
{
$mpdconf
.=<<<
EOD
set
radius
server
{
$l2tpcfg
[
'radius'
][
'server'
]}
"
{
$l2tpcfg
[
'radius'
][
'secret'
]
}
"
set
radius
retries
3
...
...
@@ -673,7 +686,7 @@ EOD;
EOD
;
if
(
isset
(
$l2tpcfg
[
'radius'
][
'accounting'
]))
{
if
(
isset
(
$l2tpcfg
[
'radius'
][
'accounting'
]))
{
$mpdconf
.=<<<
EOD
set
auth
enable
radius
-
acct
...
...
@@ -703,9 +716,10 @@ l2tp{$i}:
set
l2tp
disable
originate
EOD
;
if
(
!
empty
(
$l2tpcfg
[
'secret'
]))
if
(
!
empty
(
$l2tpcfg
[
'secret'
]))
{
$mpdlinks
.=
"set l2tp secret
{
$l2tpcfg
[
'secret'
]
}
\n
"
;
}
}
fwrite
(
$fd
,
$mpdlinks
);
fclose
(
$fd
);
...
...
@@ -721,9 +735,10 @@ EOD;
$mpdsecret
=
"
\n\n
"
;
if
(
is_array
(
$l2tpcfg
[
'user'
]))
{
foreach
(
$l2tpcfg
[
'user'
]
as
$user
)
foreach
(
$l2tpcfg
[
'user'
]
as
$user
)
{
$mpdsecret
.=
"
{
$user
[
'name'
]
}
\"
{
$user
[
'password'
]
}
\"
{
$user
[
'ip'
]
}
\n
"
;
}
}
fwrite
(
$fd
,
$mpdsecret
);
fclose
(
$fd
);
...
...
@@ -736,7 +751,7 @@ EOD;
break
;
case
'redir'
:
case
'redir'
:
break
;
}
...
...
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