mirror of
https://github.com/openwrt/packages.git
synced 2025-12-21 21:24:31 +04:00
xl2tpd: add support to set own hostname in proto handler
This is needed if the peer only allows certain hostnames to connect. Signed-off-by: Martin Schiller <ms@dev.tdt.de>
This commit is contained in:
committed by
Florian Eckert
parent
728e9e1073
commit
b9cd720d28
@@ -17,6 +17,7 @@ proto_l2tp_init_config() {
|
|||||||
proto_config_add_int "mtu"
|
proto_config_add_int "mtu"
|
||||||
proto_config_add_int "checkup_interval"
|
proto_config_add_int "checkup_interval"
|
||||||
proto_config_add_string "server"
|
proto_config_add_string "server"
|
||||||
|
proto_config_add_string "hostname"
|
||||||
available=1
|
available=1
|
||||||
no_device=1
|
no_device=1
|
||||||
no_proto_task=1
|
no_proto_task=1
|
||||||
@@ -26,9 +27,9 @@ proto_l2tp_init_config() {
|
|||||||
proto_l2tp_setup() {
|
proto_l2tp_setup() {
|
||||||
local interface="$1"
|
local interface="$1"
|
||||||
local optfile="/tmp/l2tp/options.${interface}"
|
local optfile="/tmp/l2tp/options.${interface}"
|
||||||
local ip serv_addr server host
|
local ip serv_addr server host hostname
|
||||||
|
|
||||||
json_get_var server server
|
json_get_vars server hostname
|
||||||
host="${server%:*}"
|
host="${server%:*}"
|
||||||
for ip in $(resolveip -t 5 "$host"); do
|
for ip in $(resolveip -t 5 "$host"); do
|
||||||
( proto_add_host_dependency "$interface" "$ip" )
|
( proto_add_host_dependency "$interface" "$ip" )
|
||||||
@@ -41,6 +42,8 @@ proto_l2tp_setup() {
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hostname="${hostname:+hostname=$hostname}"
|
||||||
|
|
||||||
# Start and wait for xl2tpd
|
# Start and wait for xl2tpd
|
||||||
if [ ! -p /var/run/xl2tpd/l2tp-control -o -z "$(pidof xl2tpd)" ]; then
|
if [ ! -p /var/run/xl2tpd/l2tp-control -o -z "$(pidof xl2tpd)" ]; then
|
||||||
/etc/init.d/xl2tpd restart
|
/etc/init.d/xl2tpd restart
|
||||||
@@ -88,7 +91,7 @@ $mtu
|
|||||||
$pppd_options
|
$pppd_options
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
xl2tpd-control add-lac l2tp-${interface} pppoptfile=${optfile} lns=${server} || {
|
xl2tpd-control add-lac l2tp-${interface} pppoptfile=${optfile} lns=${server} ${hostname} || {
|
||||||
echo "xl2tpd-control: Add l2tp-$interface failed" >&2
|
echo "xl2tpd-control: Add l2tp-$interface failed" >&2
|
||||||
proto_setup_failed "$interface"
|
proto_setup_failed "$interface"
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
Reference in New Issue
Block a user