mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Merge pull request #1383 from YunoHost/enh-dns-resolver
Hotspot with local services and router port unforwarded
This commit is contained in:
commit
fdaf37c9fd
4 changed files with 29 additions and 12 deletions
|
@ -14,9 +14,8 @@ do_pre_regen() {
|
||||||
etcdefault_dir="${pending_dir}/etc/default"
|
etcdefault_dir="${pending_dir}/etc/default"
|
||||||
mkdir -p "$etcdefault_dir"
|
mkdir -p "$etcdefault_dir"
|
||||||
|
|
||||||
# add general conf files
|
# add default conf files
|
||||||
cp plain/etcdefault ${pending_dir}/etc/default/dnsmasq
|
cp plain/etcdefault ${pending_dir}/etc/default/dnsmasq
|
||||||
cp plain/dnsmasq.conf ${pending_dir}/etc/dnsmasq.conf
|
|
||||||
|
|
||||||
# add resolver file
|
# add resolver file
|
||||||
cat plain/resolv.dnsmasq.conf | grep "^nameserver" | shuf >${pending_dir}/etc/resolv.dnsmasq.conf
|
cat plain/resolv.dnsmasq.conf | grep "^nameserver" | shuf >${pending_dir}/etc/resolv.dnsmasq.conf
|
||||||
|
@ -26,11 +25,22 @@ do_pre_regen() {
|
||||||
ynh_validate_ip4 "$ipv4" || ipv4='127.0.0.1'
|
ynh_validate_ip4 "$ipv4" || ipv4='127.0.0.1'
|
||||||
ipv6=$(curl -s -6 https://ip6.yunohost.org 2>/dev/null || true)
|
ipv6=$(curl -s -6 https://ip6.yunohost.org 2>/dev/null || true)
|
||||||
ynh_validate_ip6 "$ipv6" || ipv6=''
|
ynh_validate_ip6 "$ipv6" || ipv6=''
|
||||||
|
interfaces="$(ls -m /sys/class/net | sed s/,//g)"
|
||||||
|
wireless_interfaces="lo"
|
||||||
|
for dev in $(ls /sys/class/net); do
|
||||||
|
if [ -d "/sys/class/net/$dev/wireless" ]; then
|
||||||
|
wireless_interfaces+=" $dev"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
export ipv4
|
# General configuration
|
||||||
export ipv6
|
export wireless_interfaces
|
||||||
|
ynh_render_template "dnsmasq.conf.tpl" "${pending_dir}/etc/dnsmasq.conf"
|
||||||
|
|
||||||
# add domain conf files
|
# add domain conf files
|
||||||
|
export interfaces
|
||||||
|
export ipv4
|
||||||
|
export ipv6
|
||||||
for domain in $YNH_DOMAINS; do
|
for domain in $YNH_DOMAINS; do
|
||||||
[[ ! $domain =~ \.local$ ]] || continue
|
[[ ! $domain =~ \.local$ ]] || continue
|
||||||
export domain
|
export domain
|
||||||
|
|
10
data/templates/dnsmasq/dnsmasq.conf.tpl
Normal file
10
data/templates/dnsmasq/dnsmasq.conf.tpl
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
domain-needed
|
||||||
|
expand-hosts
|
||||||
|
localise-queries
|
||||||
|
|
||||||
|
{% set interfaces = wireless_interfaces.strip().split(' ') %}
|
||||||
|
{% for interface in interfaces %}
|
||||||
|
interface={{ interface }}
|
||||||
|
{% endfor %}
|
||||||
|
resolv-file=/etc/resolv.dnsmasq.conf
|
||||||
|
cache-size=256
|
|
@ -1,5 +1,8 @@
|
||||||
host-record={{ domain }},{{ ipv4 }}
|
{% set interfaces_list = interfaces.split(' ') %}
|
||||||
host-record=xmpp-upload.{{ domain }},{{ ipv4 }}
|
{% for interface in interfaces_list %}
|
||||||
|
interface-name={{ domain }},{{ interface }}
|
||||||
|
interface-name=xmpp-upload.{{ domain }},{{ interface }}
|
||||||
|
{% endfor %}
|
||||||
{% if ipv6 %}
|
{% if ipv6 %}
|
||||||
host-record={{ domain }},{{ ipv6 }}
|
host-record={{ domain }},{{ ipv6 }}
|
||||||
host-record=xmpp-upload.{{ domain }},{{ ipv6 }}
|
host-record=xmpp-upload.{{ domain }},{{ ipv6 }}
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
domain-needed
|
|
||||||
expand-hosts
|
|
||||||
|
|
||||||
listen-address=127.0.0.1
|
|
||||||
resolv-file=/etc/resolv.dnsmasq.conf
|
|
||||||
cache-size=256
|
|
Loading…
Add table
Reference in a new issue