AndreBL/ip6neigh

Log messages report newlines in "old"

Opened this issue · 3 comments

EDIT: somehow I must've hit enter before typing this out?

After the latest ip6neigh update, I've noticed that the logging shows weird newlines in the old-name parts of messages:

Thu Feb  1 11:55:24 PST 2024 Unknown host qbittorrent
qbittorrent now has got a proper name. Replacing all entries.
Thu Feb  1 11:55:24 PST 2024 Renamed host: qbittorrent
qbittorrent to qbittorrent
Thu Feb  1 11:55:26 PST 2024 Unknown host EAP670
EAP670 now has got a proper name. Replacing all entries.
Thu Feb  1 11:55:26 PST 2024 Renamed host: EAP670
EAP670 to EAP670

Please provide more information (copy of the log, description of what is incorrect, etc)

Somehow I must've sent this before I finished typing it. My guess is that the grep is getting confused by the /tmp/hosts/ip6neigh.bak file that keeps getting automatically created.

In ip6neigh-svc.sh:

        #Must save changes to another temp file and then move it over the main file.
        Change name in-place with SED
        sed -i.bak "s/ ${oldname}/ ${newname}/g" "$HOSTS_FILE"

        #Deletes the old cached entry if dynamic.
        # Delete with SED
        sed -i.bak "/0. ${oldname}$/d" "$CACHE_FILE"
        ```

I did a bit more investigating, by making the get_name function in ip6neigh-svc.sh print the match, and yes, with that .bak file, I see two lines for the same hostname.

Seems like the simplest fix is to remove the .bak from calls to sed -i.bak.

Is it possible that these bogus renames ("hostname\nhostname" to "hostname") are causing my extra dnsmasq restarts?