loblab / noip-renew

Auto renew (confirm) noip.com free hosts
Apache License 2.0
423 stars 134 forks source link

new button label for expiration #90

Open neothematrix opened 2 years ago

neothematrix commented 2 years ago

it seems the website changed once again, I raised #89 to adapt the script, I hope you'll find it useful

mitzone commented 2 years ago

Confirm it's working. Thanks for posting this to the public!

kodavn commented 2 years ago

It worked and didn't work again. Here is my log [2021/11/09 16:15:00] - Debug level: 2 [2021/11/09 16:15:00] - Opening https://www.noip.com/login... [2021/11/09 16:15:09] - Logging in... [2021/11/09 16:15:21] - Opening https://my.noip.com/dynamic-dns... [2021/11/09 16:15:28] - 11111111111.org expires in 0 days [2021/11/09 16:15:28] - Updating 11111111111.org.org [2021/11/09 16:15:32] - 88888888888.org expires in 0 days [2021/11/09 16:15:32] - Updating 88888888888.org [2021/11/09 16:15:34] - Message: element click intercepted: Element is not clickable at point (1079, 379). Other element would receive the click:

(Session info: headless chrome=92.0.4515.98)

It seeem : host_remaining_days = host.find_element_by_xpath(".//a[@class='no-link-style']").get_attribute("title") didn't work

mitzone commented 2 years ago

yup..same here. looks like no-ip changed something again.

neothematrix commented 2 years ago

yep, definitely another change, I committed the fix to the already existing PR #89 if you want to patch your scripts and test it btw, @loblab any plan to merge some of these PR? I volunteer to do it if you authorize me, otherwise I think it might be a good idea to fork and keep another repo up to date.

kodavn commented 2 years ago

yep, definitely another change, I committed the fix to the already existing PR #89 if you want to patch your scripts and test it btw, @loblab any plan to merge some of these PR? I volunteer to do it if you authorize me, otherwise I think it might be a good idea to fork and keep another repo up to date.

Hi neothematrix. It worked. Thank you.

neothematrix commented 2 years ago

I pushed another small change to #89 because the if/exception logic didn't work if you have more than one host to confirm with different expiration days, it should work better now.

Angel0ffDeath commented 2 years ago

@neothematrix I installed this script today and of course it doesn't work... Deprecated command warnings, changed URLs, etc. It is difficult to track all changes since last update from the author and to incorporate all your fixes... Can you post or give a link to fully working python script. Or maybe make a branch with fully operational version...

Here is some output from:

[2021/11/21 14:13:04] - Debug level: 2 [2021/11/21 14:13:04] - Opening https://www.noip.com/login... [2021/11/21 14:13:15] - Logging in... /usr/local/bin/noip-renew.py:73: DeprecationWarning: find_elementby commands are deprecated. Please use find_element() instead ele_usr = self.browser.find_element_by_name("username") /usr/local/bin/noip-renew.py:74: DeprecationWarning: find_elementby commands are deprecated. Please use find_element() instead ele_pwd = self.browser.find_element_by_name("password") /usr/local/bin/noip-renew.py:77: DeprecationWarning: find_elementby* commands are deprecated. Please use find_element() instead self.browser.find_element_by_name("Login").click() [2021/11/21 14:13:16] - Message: element not interactable (Session info: headless chrome=92.0.4515.98)

neothematrix commented 2 years ago

hello @Angel0ffDeath , I pushed and synced all the changes I use on my forked repo: https://github.com/neothematrix/noip-renew feel free to use it, just keep in mind I commented out with "#NOCRON" all the part of code that belongs to the crontab automatic configuration as I don't use them because I run it inside a docker container, you can just uncomment them but I didn't test if that part is working. Feel free to contribute and let me know if it works!

Angel0ffDeath commented 2 years ago

@neothematrix - Thanks. Your code - it is good and working. It took me a while until I find out you don't decode base64 coded password (if you install everything via setup.sh password is coded), but now everything is ok.

There still were some deprecation messages from selenium, but it is easy to remove them:

from selenium.webdriver.common.by import By

And everywhere in the code self.browser.find_element_by_xpath("xpath") should be changed by: self.browser.find_element(By.XPATH, "xpath")

The same is valid also for .find_elements_by_xpath function - the same change

As for the cronjob - it was scheduled correctly, but script name was not correct. In noip-renew-skd.sh from your fork this row: INSTEXE=$INSTDIR/noip-renew-$USER

should be changed to: INSTEXE=$INSTDIR/noip-renew-$USER.sh

and the script name will be correct in the cronjob.

Log in button - on no-ip login page after you type the password if you press Enter it pushes log in button. So probably after sending the password it is good to be tested with ele_pwd.send_keys(Keys.ENTER); Keys should be imported from selenium.webdriver.common.keys; Didn't tested that, but if it works this will spare future changes when they change again Log In button. Will test it these days when have more time. The only thing which remains is: We know when to run the script (either cronjob, home automatic system, etc). How we deal if script executes, but due to some changes on no-ip web page, the script doesnt renew hosts??? There should be some feedback from the script. It is not serious to check all png files if everything is ok. I think exit code is good choice (maybe like 3 merged bytes - each byte responsible for 1 host). What's your opinion? PS: The last question is because I dont find any logs in log folder

benyjr commented 2 years ago

I've also noticed that the "Active" label indicates that the hostname will expire in 37 days instead of the actual 30 days which causes the script to renew the domain 7 days after it has already expired.

Angel0ffDeath commented 2 years ago

@benyjr - here everything is ok for now. The script takes from noip web site the days to expiration and substracts 6 days, i.e. cronjob will be scheduled for 0:30 after 31 days. I can say this is ok or not after 31 days. However I preffer if there is a feedback from the script and everybody to decide how this feedback will be used. Personally I preffer to run everything from my home automation server (Im usin fhem) and not as cronjob...Nevertheless - thanks for your comment - will monitor it. (I think you are correct because the correct calculation occurs AFTER succesfull update (next run of the script), and not while updating Hosts. Moreover I have only 1 host and cannot test it for 3 hosts) PS: Im using the script of neothematrix (link from above - few comments above). Im not using the script of loblab (original for this site). Also up to now I used a trigger in fhem, which sends me a message on Telegram to renew Noip. Last week I received a renewal message, but when logged to noip, it stated Expires after 9 days.... so no Confirm button. Up to now I always added 29 days to my trigger and since 1 year everything was ok (except manual confirmation). So it seems noip confirmation policy have been changed - you have an extra 7 days (I cannot confirm that - only thinking)... And of course I dont know hiw long this will continue. There was a daemon which do that (you can search), but of course now it doesnt work - no support/development. The code of tje daemon service checked everything every 48 hours. Probably this is the best solution. However feedback is neccessary - personally I dont want to check each month wether everything is ok or not - I should be informed only if something is wrong....)

benyjr commented 2 years ago

@Angel0ffDeath, I agree, I first started using loblab's script and noticed that it is quite out of date. After manually debugging it myself, I discovered neothematrix's code and will be using that going forward and will contribute towards neothematrix's code instead of loblab's.

Angel0ffDeath commented 2 years ago

@neothematrix @benyjr Then letsmove to neothe matirx fork, it seems loblab will not make any update (31 issues opened, neothematrix volunteered to commit all changes, but obviously, no authorization...).... Personally I will not visit this repo anymore. Will write directly issues... and hopefully solutions directly to neo's repo

Angel0ffDeath commented 2 years ago

@neothematrix i think you can close this issue since everything alteady solved... Unfortunatelly not by author, but from you, but if you close it 'only 30 issues will remain'. I will really move to your fork :-) . Thanks for the nice work neo :-)

benyjr commented 2 years ago

@Angel0ffDeath I'm ok with this. I'd prefer to use a more actively developed code base.

neothematrix commented 2 years ago

thanks for your support guys, I'll leave the comment open in case someone else lands here, so they can have a pointer to another fork. I don't mean to steal @loblab's work at all, so if they come back and reply I'll be willing to push all changes here. Nevertheless, I'll update my fork README to reflect that I've forked from here and I'll try to keep my fork up to date.

Sopor commented 2 years ago

Can someone upload a complete working script instead of patching existing script?

It is hard to follow all the issues and add every patch from each of them.

I even tried @neothematrix fork and it won't work either. I still get a exception.png in the log directory :(

You can see here that all my domains will expire in 7 days: image

neothematrix commented 2 years ago

@Sopor my fork should work properly, I suggest you open an issue on my fork after making sure you're using all the code from my fork and including also the debug log so we can understand if there are other issues

Sopor commented 2 years ago

@neorhematrix How should i open an issue on your fork? You seems to have disable it :)

I don't know what is going on, but i ran it again and now it was working except from the the cron job. It is set to run tomorrow at 00:30.

The hard part is that i now need to wait 25 days again to try to find out why it wasn't working the first time i ran it... The only different was that the second time i ran it without the log path and i ran it from a prompt instead from the cron job. My goal is to use it as it was meant, to run it as a cron job 7 days before it expires.

Update: It seems that the cron job fails because of the path to the log files. If i run it without the path it works.

And as someone already have mention, the script thinks that the next expire day will be in expires in 37 days

kodavn commented 2 years ago

Hi @Sopor Noip.com has changed their confirmation process: https://www.noip.com/support/knowledgebase/why-is-my-hostname-missing-or-deleted-what-do-i-do/

neothematrix commented 2 years ago

@neorhematrix How should i open an issue on your fork? You seems to have disable it :)

good point, I didn't realize the Issue feature was disabled, probably it's the default for forked repos! I now enabled it, thanks!

neothematrix commented 2 years ago

Hi @Sopor Noip.com has changed their confirmation process: https://www.noip.com/support/knowledgebase/why-is-my-hostname-missing-or-deleted-what-do-i-do/

Does this mean the crontab setup code should also be reviewed? I don't use it at the moment so I can't test it

peterchs commented 2 years ago

Hi @Sopor Noip.com has changed their confirmation process: https://www.noip.com/support/knowledgebase/why-is-my-hostname-missing-or-deleted-what-do-i-do/

Does this mean the crontab setup code should also be reviewed? I don't use it at the moment so I can't test it

Yes, I had a look. Looks like the tooltip that is extracted gives the days to confirm where previously it gave the days to expire and set a crontab 6 days before. Using that logic on the confirm date would mean at the crontab-ed run the host would not be ready for confirming explaining the failures.

I'd expect the crontab setting would be fixed by changing the calculation to +1 instead of -6. Certainly adding debugs with that the crontab date it calculates for my hosts would be right, 1 day into the 'confirmation' period, like it did before.

i.e. changing https://github.com/loblab/noip-renew/blob/9640063294708bfd1a28111a5fc214dcdfa05af9/noip-renew.py#L104

to nr = min(next_renewal) + 1

Although i dont use the auto crontab and no hosts to confirm at the moment.

neothematrix commented 2 years ago

mm maybe: nr = min(next_renewal) - 13 because if right after updating it, the tooltip says "37", we need to confirm it 7 days earlier than before, hence 37 - (6+7) = 24 that is 6 days before the 30 days, that is when the confirm button will appear. I reckon it could be -14 instead, but we probably risk running the crontab a few minutes or hours before the 7 days trigger. I guess the only option is to test it, I can commit this change to my fork and let someone who uses auto-cron test it

peterchs commented 2 years ago

Actually its probably bit more complicated than that as I'd expect that tooltip sometimes shows the days to confirm and sometimes shows the days to expire now.

Probably best way to do it would be keep the original min(next_renewal) - 6 logic, and update get_host_expiration_days method so that it will handle both 'days to confirm' and 'days to expire' and correct/normalise the days to confirm to days to expire by adding 7 days.

peterchs commented 2 years ago

If its extracting 37 is days to expire, -13 days will be in the middle of the 'active' period and you wont be able to confirm?

benyjr commented 2 years ago

There is no problem if the domain gets renewed early. What we want to avoid is the domain getting renewed after 30 days and causing the domain to break.

benyjr commented 2 years ago

We could alternatively add logic to the script where if there is >30 days remaining, we could force the days remaining to be =30. Though thus might break other parts of the code which are already compensating for the 7 extra days.

neothematrix commented 2 years ago

ummm ok I'm officially confused I thought despite the label, you're still supposed to confirm every 30 days, with the renew button becoming active after 23 days, but it really looks like the button will become active after 30 days now, so your logic @peteakalad checks out. The get_host_expiration_days method already handles the different labels in my fork so it's probably the correct place to fix this, I'll see if I can fix it will take some days to test it :-D

peterchs commented 2 years ago

I think changing the method as follows will normalise the extraction so it always returns days to expiry like the original code was expecting. To be clear keep the nr = min(next_renewal) - 6 logic with this. With added debugs this seems to be calculating the correct date for my hosts to be confirmed next.

  @staticmethod
    def get_host_expiration_days(host, iteration):
        try:
            host_remaining_days = host.find_element_by_xpath(".//a[contains(@class,'no-link-style')]")
        except:
            return 0
        if host_remaining_days.get_attribute("data-original-title") is not None:
            regex_match = re.search("\\d+", host_remaining_days.get_attribute("data-original-title"))
            isConfirm = 'Confirm' in host_remaining_days.get_attribute("data-original-title")
        else:
            regex_match = re.search("\\d+", host_remaining_days.text)
            isConfirm = 'Confirm' in host_remaining_days.text
        if regex_match is None:
            raise Exception("Expiration days label does not match the expected pattern in iteration: {iteration}")
        expiration_days = int(regex_match.group(0))
        if isConfirm:
            expiration_days = expiration_days + 7
        return expiration_days
Sopor commented 2 years ago

How do you guys run it? If i look in the crontab it runs like this: /usr/local/bin/noip-renew-myusername.sh /var/log/noip-renew/myusername but that will make it fail. Same thing if i run that manually in a terminal, but if i run it like this from a terminal: /usr/local/bin/noip-renew-myusername.sh i can see the whole login process and it won't fail.

The crontab is created by the script so it should work. I don't even get a log file. It is 0 byte :(

neothematrix commented 2 years ago

do you have permission to write to that /var/log/noip-renew/myusername file? you can try running it with: sh -x /usr/local/bin/noip-renew-myusername.sh /var/log/noip-renew/myusername to see if you get some error that allows you to understand the issue

benyjr commented 2 years ago

ummm ok I'm officially confused I thought despite the >label, you're still supposed to confirm every 30 days, with >the renew button becoming active after 23 days, but it >really looks like the button will become active after 30

You can renew any time within the 30-day period. Once it's renewed, the 30 day deadline gets pushed out to 30 days past the renewal date. Theoretically, you can renew every day, but that would probably cause noip to make a major change to their website.

peterchs commented 2 years ago

You can’t renew everyday the button is disabled.

You can renew from 7 days before expiry.

Have a look at: https://www.noip.com/support/knowledgebase/why-is-my-hostname-missing-or-deleted-what-do-i-do/

And also manually try and renew when all your hosts are confirmed you’ll find the button disabled.

Sopor commented 2 years ago

do you have permission to write to that /var/log/noip-renew/myusername file? you can try running it with: sh -x /usr/local/bin/noip-renew-myusername.sh /var/log/noip-renew/myusername to see if you get some error that allows you to understand the issue

I have permissions to write to it because it will create a exception.png picture in the directory.

benyjr commented 2 years ago

I have permission to write to /var/log/noip-renew/myusername but when I run: /usr/local/bin/noip-renew-myusername.sh /var/log/noip-renew/myusername It does not complete and my crontab does not get updated. I only get the exception.png However if i just run: /usr/local/bin/noip-renew-myusername.sh Then everything completes properly and I get all the successful pngs.

I suspect it has something to do with ">> $USERNAME.log" because it is the only difference between lines 10 and 13 because if I run: cd /var/log/noip-renew/myusername && /usr/local/bin/noip-renew-myusername.sh Everything completes properly. Something about the logfile is messing up the process.

peterchs commented 2 years ago

I think the logging adds enough delay for the page loads to work. Without the logging it runs too quick and fails.

Try adding time.sleep(2) after self.login()

benyjr commented 2 years ago

I don't think that will help.

Writing $USERNAME.log is causing the script to fail.

benyjr commented 2 years ago

'cd /var/log/noip-renew/myusername && /usr/local/bin/noip-renew-myusername.sh

skips writing $USERNAME.log, saves all the pngs and the script completes successfully.

peterchs commented 2 years ago

Outputting logs due to the different log level is delaying execution allowing selenium sufficient to time to load the page. That lack of delay when the logging is off is the real cause.

Have a look in the shell script the log level parameter is changing dependent on whether you pass the log path. Level 2 is debug logging, level 0 is none.

benyjr commented 2 years ago

You're right. Changing the 0 to 2 in line 13 of noip-renew-myusername.sh seems to fix the problem.

benyjr commented 2 years ago

I'll propose a change.

peterchs commented 2 years ago

Adding delay(s) will work too if someone doesn’t want all the debug logging.

Although the time.sleeps (or depending on logging for timings) are bad practice it should really be waiting for an explicit condition (element present or something) before proceeding. Bit of rework to add that in but it would be more robust.

benyjr commented 2 years ago

There is still the issue that nothing is actually being written to $USERNAME.log.

peterchs commented 2 years ago

Seems to still write out log “Confirmed hosts: 0” for me with logging level 0/off and a delay added.

benyjr commented 2 years ago

I'm not getting anything in the log file and I don't know why.

peterchs commented 2 years ago

Did you add the delay I mentioned? Without it I expect you’ll get an exception.png of the page after login rather than the hosts page, and no log. The exception logging needs improved it should still properly log exceptions at log level 0.

benyjr commented 2 years ago

I only tested it with changing log level to 2 with logging. That is the change I proposed.

kodavn commented 2 years ago

Hi everyone, here is my "noip-renew-skd.sh". It'll run 2 days/time at 6AM. I can check the .log file by using "cat /var/log/noip-renew/pi/noip-renew.log" command.

cd /usr/local/bin/ sudo nano noip-renew-skd.sh

paste below code then Ctrl+O and Ctrl+X

!/bin/bash

USER=pi SUDO=sudo LOGDIR=/var/log/noip-renew/$USER INSTDIR=/usr/local/bin INSTEXE=$INSTDIR/noip-renew-$USER CRONJOB="0 6 /2 $INSTEXE.sh > $LOGDIR/noip-renew.log" NEWCJOB="0 6 /2 $INSTEXE.sh > $LOGDIR/noip-renew.log" $SUDO crontab -u $USER -l | grep -v '/noip-renew*' | $SUDO crontab -u $USER - if [[ $3 = "True" ]]; then ($SUDO crontab -u $USER -l; echo "$NEWCJOB") | $SUDO crontab -u $USER - else ($SUDO crontab -u $USER -l; echo "$CRONJOB") | $SUDO crontab -u $USER - fi

exit 0

neothematrix commented 2 years ago

hi all! I think we're making a bit of a mess here, we're discussing all sort of bugs and changes inside an issue that has nothing to do, this won't help future people landing here. let's separate the issues opening them on my fork and we can work with all of them in a ordered manner, what do you think? I see @benyjr has already sent a few PR to address some of these issues: https://github.com/neothematrix/noip-renew/issues