Issues with HASH in listener files

  • Hello everyboy,


    I tried to create some listener files which allow to modify the named config based on domains but I got stuck when passing over the array. Perhaps someone may help to fix this - the final listener will be provided to the community.


    This is where I am stuck - I created a listener which adds a general list of mx-entries to all domains (see here) but when I try to make this per Domain the array is not working (complete code is attached).


    So this works:

    Code
    1. my %additionalMailservers = ( 'mx50' => '50' );# All dns mail-serversmy %mailserverList = %additionalMailservers;if(%mailserverList) { my @formattedEntries = (); push @formattedEntries, '; custom MX DNS entries BEGIN'; # add out-of-zone mail-servers while (my ($name, $priority) = each(%mailserverList)) { push @formattedEntries, '@ IN MX ' . $priority . ' ' . $name; }....


    But this does not work:


    So, perhaps anyone knows how to solve this. Thanks in advance.


    Regards Jörg

    Files

    (Ubuntu 16.04, i-MSCP 1.5.1, php-Fpm, Plugins: ClamAV, CronJobs, InstantSSH, LetsEncrypt, Mailgraph, Monitorix, OpenDKIM, PhpSwitcher, PolicydSPF, Postscreen, RecaptchaPMA, RoundcubePlugins, ServerDefaultPage, SpamAssassin, YubiKeyAuth)

  • @UncleJ


    Hello,


    First, you should not talk about associative array here... In Perl we say: HASH.



    I can provide a fixed version but first I need to know if the per domain MX entries take precedence over the global entries or if both, the global entries and the per domain entries much be merged together and added in the zone file.

    badge.php?id=1239063037&bid=2518&key=1747635596&format=png&z=547451206

  • @Nuxwin


    Hello,


    okay, I will try to remember that.


    The entries should be merged. So in case that there are globally defined mx-entries and per Domain defined ones, both should be added. This should help to cover all possible combinations then (only global, only local, some global for all and special per domain, a.s.o.). In case both contain the same key (is it also a key when talking about a HASH?) the value should be taken from domain specification.


    Thanks in adavance for your fix - it will also help for some other files I have nearly finished ;)


    Regards Jörg

    (Ubuntu 16.04, i-MSCP 1.5.1, php-Fpm, Plugins: ClamAV, CronJobs, InstantSSH, LetsEncrypt, Mailgraph, Monitorix, OpenDKIM, PhpSwitcher, PolicydSPF, Postscreen, RecaptchaPMA, RoundcubePlugins, ServerDefaultPage, SpamAssassin, YubiKeyAuth)

  • @UncleJ


    Here the fixed version.



    See also here (the same but with better indentation: http://pastebin.com/CaVdgnP5



    Here, two cases are covered: Global and per domain MX entries merged together, or only global MX entries (if any)

    badge.php?id=1239063037&bid=2518&key=1747635596&format=png&z=547451206

  • Edited my previous post in which I posted wrong fixed version... Please look again.

    badge.php?id=1239063037&bid=2518&key=1747635596&format=png&z=547451206

  • badge.php?id=1239063037&bid=2518&key=1747635596&format=png&z=547451206