Commit graph

18 commits

Author SHA1 Message Date
tfwiii
697c3310a0 publicip - Bug Fix - IP address changes wer being missed if an interface was present but did not have an IPv4 address associated with it. Added exception handling to mitigate this. 2022-10-12 13:52:55 +07:00
tfwiii
cace02909e Bug fix improvements to publicip and util.location
Fixed publicip bug arising from last PR review
Simplified ip change detection code
Added pause after location.reset() call to allow completion before query
util.location - change order of information providers as default was not returning geo coords
2022-10-08 10:42:12 +07:00
tfwiii
605b749e22 Removed debugging prints 2022-10-06 14:21:43 +07:00
tfwiii
61fe7f6d3e Handled fail where core.location does not provide values for latitude and longitude. Added handling for coordinates N, S, E, W. 2022-10-06 13:49:37 +07:00
tobi-wan-kenobi
1983408e58 [util] fix location timeouts 2022-08-31 19:12:05 +02:00
tobi-wan-kenobi
0f74b690ca [modules/publicip] add nicer logging 2022-08-31 19:09:04 +02:00
tfwiii
7ee9645437 Added secondary check for potential changes in public IP and a small bug fix arising from reliance on util.location
Added a second check for indications of possible change of public IP address since netifaces does not properly handle all Linux routing tables (ref: http://linux-ip.net/html/routing-tables.html) which can lead to changes being missed if only looking at defauilt route. Consequently an additional check for changes to the network interface names/numbers was added to further help in identifying potentially notable changes. Note that netifaces is no longer being maintained so the underlying issue with its handling of gateways is unlikely to be resolved (https://github.com/al45tair/netifaces). An alternative would be to use direct calls to the OS like 'ip route list table all' (note the difference to 'ip route list all') but this might lead to unpredicatble results between distributions/flavours so probably best to stick with a library for now. all') but this might lead to unpredicatble results between distributions/flavours so probably best to stick with a library for now.

Introduced time.sleep(2) following calls to util.location.reset() since it can take util.location a while to update following a call to .reset() which can cause calls to .location_info() to return unpredicatable/unuseful results.
2022-08-30 02:01:25 +07:00
tobi-wan-kenobi
7a47e9e13d [module/publicip] handle netifaces errors
make sure the monitoring thread doesn't terminate when there are
netifaces errors.

see #909
2022-08-06 09:17:49 +02:00
tobi-wan-kenobi
a7dba79664 [modules/publicip] add default route monitor
(re)add a separate thread that monitors the default route and updates
the module immediately, if the default route changes.

fixes #909
2022-08-05 14:30:50 +02:00
tobi-wan-kenobi
a78403d3e8 [publicip] fix tests and bugs 2022-07-29 14:00:28 +02:00
Tom Watson
2fa7931783 Fixed runaway thread creation (faulty indenting) 2022-07-12 00:19:19 +07:00
Tom Watson
284662a0ba Ran publicip.py through black 2022-07-07 18:38:43 +07:00
Tom Watson
9a6e61173f Updated publicip to automatically update on detecting a change to default route 2022-07-07 18:08:20 +07:00
Tom Watson
a97a7fe507 Updates addressing PR comments
Added location_info() to util/location API to return a dict of all location information. Updated modules/contrib/publicip to use that API. Changed modules/contrib/publicip refresh period back to 60 minutes. Changed /util/location API from 'country_name' back to 'name'
2022-07-06 19:37:29 +07:00
Tom Watson
6f137c4927 Update following PR review
Moved to format string handling of parameters. Minor refactoring.
2022-07-06 17:51:19 +07:00
Tom Watson
218bfa2235 Updated contrib/publicip module and util/location
Added another API endpoint, Added options to display country name, country code, city name and lat/long coordinates, attempt to handle failure to fetch info from API endpoints cleanly
2022-07-06 01:05:25 +07:00
tobi-wan-kenobi
3aadab5628 [modules/publicip] handle missing public ip more gracefully
If location does not throw, but reports an empty public IP, return
"n/a".

Since this caused a bug, also add a test for it.

fixes #853
2022-02-14 14:58:01 +01:00
tobi-wan-kenobi
320827d577 [core] restructure to allow PIP packaging
OK - so I have to admit I *hate* the fact that PIP seems to require a
subdirectory named like the library.

But since the PIP package is something really nifty to have (thanks to
@tony again!!!), I updated the codebase to hopefully conform with what
PIP expects. Testruns so far look promising...
2020-05-09 21:22:00 +02:00
Renamed from modules/contrib/publicip.py (Browse further)