seud0nym / tch-gui-unhide

Modify Telstra-branded Technicolor devices to access hidden features
GNU General Public License v3.0
119 stars 15 forks source link

agh-setup, status check not long enough and not importing static leases #191

Closed frankyman88 closed 4 months ago

frankyman88 commented 4 months ago

Just setting up the Adguard Home addon on DJA0231 running firmware 20.3.c.0501-MR22.1-RA, and ran into some troubles initially where it thought it wasn't installed similar to this issue: https://github.com/seud0nym/tch-gui-unhide/issues/187. However, I then checked and it was actually installed but the script didn't seem to wait long enough. I changed line 908 in agh-setup (the status check section) from sleep 1s to sleep 10s and it works, after about 5s. All installs fine and seems to control both DNS and DHCP.

However, it's not importing my static leases at all (I have about 16). The script reports like this [AdGuard-Home-Setup] Loading static leases... but then nothing between that and the next line: [AdGuard-Home-Setup] Downloading utility script: agh-change-password to /root/AdGuardHome

I've copied an example device from my "uci show dhcp":

dhcp.B2CC147236DCE0C8026D7FFC08FD96FB=host
dhcp.B2CC147236DCE0C8026D7FFC08FD96FB.dns='1'
dhcp.B2CC147236DCE0C8026D7FFC08FD96FB.name='Xiaomi-plug'
dhcp.B2CC147236DCE0C8026D7FFC08FD96FB.mac='40:31:3c:ce:6d:10'
dhcp.B2CC147236DCE0C8026D7FFC08FD96FB.ip='192.168.0.191'

Not sure if the format or something has changed and script is unable to read the host and relevant data properly? I tried to troubleshoot the syntax in line 916: for host in $(uci show dhcp | grep '@host.*=host$' | cut -d= -f1); do But I can't figure it out. Hoping someone else might have some ideas :) Thanks!

seud0nym commented 4 months ago

Hi.

Thanks for the bug report.

I couldn't reproduce the status check wait time issue. The wait time is actually currently 5 seconds (it is in a loop that tries 5 times, waiting 1 second between each check). I have increased it to 15 retries, but left the intervals at 1s.

I did reproduce the bug that causes static leases to fail to load. There are actually 2 different issues.

You can load your static leases without re-running the setup by pasting the following into an SSH session. You will need to set the USERNAME and PASSWORD correctly first, obviously.

USERNAME="root"
PASSWORD="agh-admin"
GATEWAY="$(uci -q get network.lan.ipaddr)"
for host in $(uci show dhcp | grep '=host$' | cut -d= -f1); do
  SLEASE_MAC="$(uci -q get $host.mac)"
  SLEASE_IP="$(uci -q get $host.ip)"
  SLEASE_NAME="$(uci -q get $host.name)"
  if [ -n "$SLEASE_IP" -a -n "$SLEASE_MAC" -a -n "$SLEASE_NAME" ]; then
    echo -e "Loading static lease for $SLEASE_IP ($SLEASE_MAC - $SLEASE_NAME)"
    curl -u $USERNAME:$PASSWORD -X POST -H 'Content-Type: application/json' --data "{ \"mac\":\"$SLEASE_MAC\", \"ip\":\"$SLEASE_IP\", \"hostname\":\"$SLEASE_NAME\" }" http://${GATEWAY}:8008/control/dhcp/add_static_lease
  else
    echo -e "SKIPPED loading static lease - missing parameter (MAC=$SLEASE_MAC: IP=$SLEASE_IP HOST NAME=$SLEASE_NAME)"
  fi
done
frankyman88 commented 4 months ago

Thanks for your prompt reply! I just manually imported a few of them last night for testing today. Today I found that it was crashing my router (pretty sure running out of RAM despite only sitting at average %65 usage prior to install of agh), so I have uninstalled and planning to revert to my previous setup of adguard home run on my proxmox host. I will give it a go again on my spare DJA0230 when i get it back (loaned out temporarily)

However, I noticed after uninstall that the Local Network Card -> Interfaces no longer gives drop down option for IPv4 DNS server selections, it is just hard locked to 192.168.0.1 (the gateway IP). image

I tried running tch-gui-unhide again with an ipv4-DNS-Servers in the folder, but doesn't seem to have changed anything. Is there an easy way to restore that functionality without having to do a factory reset or similar? Thanks again for your help :)

seud0nym commented 4 months ago

For what it is worth, I don't run AdGuard on my router. I run it in a Proxmox instance.

The agh-setup script automatically enables DNS Hijacking, unless you use the -xi option. You will have to disable hijacking in the DNS card, and then you will be able to edit the DHCP DNS servers.

frankyman88 commented 4 months ago

Yeah I guess it is a decent option if you were a basic home user without any other standalone servers. That fixed it! Thanks again :D