Hi Julián,

This functionality already (mostly) exists. My patch, which switched something 
to use host-record instead, did not remove the existing functionality. 
Specifically there's this configuration structure:

config 'domain'
        option 'name' 'typhoon'
        option 'ip'   '192.168.1.140'

This is parsed with the following function in the current dnsmasq.init:

dhcp_domain_add() {
        local cfg="$1"
        local ip name names record

        config_get names "$cfg" name "$2"
        [ -n "$names" ] || return 0

        config_get ip "$cfg" ip "$3"
        [ -n "$ip" ] || return 0

        for name in $names; do
                record="${record:+$record/}$name"
        done

        xappend "--address=/$record/$ip"
}

Which ultimately adds, per the last line there:

--address=/typhoon/192.168.1.140

…to /tmp/etc/dnsmasq.conf.

Your patch seems to be nearly identical except you are adding the domain to the 
end. I'm not sure I see the need to have a nearly identical function to append 
the domain to the end. Wouldn't it be easier to define it as such:

config 'domain'
        option 'name' 'typhoon.domain.name'
        option 'ip'   '192.168.1.140'

That would accomplish the same thing using existing functionality.

Regarding the wildcards, are you really looking to resolve, in keeping with the 
above example:

*.typhoon.domain.name  --> 192.168.1.140

So, essentially, everything possible, that ends in typhoon.domain.name to 
192.168.1.140? Keep in mind that using --address does not get you the proper 
reverse DNS records, only A records are created.

Adam


On Jul 16, 2013, at 4:47 PM, Julián Landerreche <mani...@gmail.com> wrote:

> The goal of this change is to allow the dynamic creation 
> of an "--address" option for each host in the local network.
> 
> This opens up the possibility of fitting a common request among users
> (particularly web-developers). That request is:to resolve DNS 
> request for wildcard subdomains for local domains.[2][3]
> This plays nice with serving virtual hosts from different machines 
> on LAN, allowing to easily test on different devices . [3]
> 
> [1] dnsmasq: use host-record instead of address
> https://dev.openwrt.org/changeset/36943
> 
> [2] dnsmasq + wildcard + address
> https://www.google.com/search?q=dnsmasq+wildcard+address
> 
> [3] Feature request: dynamically add an "address=/hostname/ip" line
> for each hostname (on generated /tmp/etc/dnsmasq.conf)
> https://dev.openwrt.org/ticket/12722
> 
> Signed-off-by: Julián Landerreche <openwrt at julianlanderreche.com.ar>
> ---
>  package/network/services/dnsmasq/files/dnsmasq.init |   19 
> +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/package/network/services/dnsmasq/files/dnsmasq.init 
> b/package/network/services/dnsmasq/files/dnsmasq.init
> index 630c07d..8c43e48 100644
> --- a/package/network/services/dnsmasq/files/dnsmasq.init
> +++ b/package/network/services/dnsmasq/files/dnsmasq.init
> @@ -408,6 +408,24 @@ dhcp_domain_add() {
>       xappend "--address=/$record/$ip"
>  }
>  
> +dhcp_address_add() {
> +     local cfg="$1"
> +     local ip name names record
> +
> +     config_get names "$cfg" name "$2"
> +     [ -n "$names" ] || return 0
> +
> +     config_get ip "$cfg" ip "$3"
> +     [ -n "$ip" ] || return 0
> +
> +     for name in $names; do
> +             fqdn="$name${DOMAIN:+.$DOMAIN}"
> +             record="${record:+$record/}$name/$fqdn"
> +     done
> +
> +     xappend "--address=/$record/$ip"
> +}
> +
>  dhcp_srv_add() {
>       local cfg="$1"
>  
> @@ -512,6 +530,7 @@ start() {
>       config_foreach dhcp_subscrid_add subscrid
>       config_foreach dhcp_domain_add domain
>       config_foreach dhcp_hostrecord_add hostrecord
> +     config_foreach dhcp_address_add host
>  
>       # add own hostname
>       [ $ADD_LOCAL_HOSTNAME -eq 1 ] && [ -n "$lanaddr" ] && {
> -- 
> 
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel

Reply via email to