Commit Graph

92 Commits

Author SHA1 Message Date
Hemna 491644ece6 Added new Config object.
The config object now has builtin dot notation getter with default

config.get("some.path.here", default="Not found")
2021-10-04 15:37:14 -04:00
Hemna a6ed7b894b Fixed email plugin's use of globals
The email plugin was still using globals for tracking
the check_email_delay as well as the config.  This
patch creates a new singleton thread safe mechanism for
check_email_delay with the EmailInfo class.
2021-10-04 11:36:13 -04:00
Hemna 23e3876e7b Refactor utils usage
This patch separates out the config from the utils.py
utils.py has grown into a catchall for everything and this
patch is the start of that cleanup.
2021-09-16 17:08:30 -04:00
Hemna 8ada789d4d Fixed a problem with the AVWX plugin not working
the regex for the plugin was not matching correctly
2021-09-02 11:06:25 -04:00
Hemna 558710d348 Remove some noisy trace in email plugin
This removes the trace decorators from the email login
functions.  They have been stable for a while now.
2021-09-02 10:03:43 -04:00
Hemna 0f6df5fc05 Fixed email validation
This patch adjusts the py3-email-validation usage.  Since we
upgraded to 1.0.2, the signature has changed.  This patch adjusts
the signature usage so it works again.
2021-09-02 09:43:33 -04:00
Hemna ec92b07e31 Silence some log noise
Removed an email thread log at the start of the loop.
Also bumped the Keepalivethread time to 60 seconds
2021-08-25 08:25:36 -04:00
Hemna 61967b5fe8 Removed TXThread
Since all outbound messages have a send() method that starts
a separate there, there really is no reason for the transmit queue
thread at all.  All it did was get a message from the queue and then
call send on it, which would start another thread.  This removes that
intermediate TXThread.   When you want to send a message just call
send() on the message object.
2021-08-24 15:22:50 -04:00
Hemna 8b5f21eece Rebase from master and run gray
This patch is a rebase of master after the introduction
of switching from black to gray code formatting.
2021-08-23 14:08:14 -04:00
Hemna 86777d838c Added threads functions to APRSDPluginBase
This patch updates the APRSDPluginBase class to include
standard methods for allowing plugins to create, start, stop
threads that the plugin might need/use.  Also update the aprsd-dev
to correctly start the threads and stop them for testing plugin
functionality.
Also added more unit tests and fake objects for unit tests.
2021-08-23 13:44:58 -04:00
Hemna 5f4cf89733 Refactor Message processing and MORE
This patch refactors how the recieved message processing happens.
We now handle all incoming packets the same.  Removed the notification
thread to handle the watchlist packets.  This is now done with a
unified plugins architecture that allows different capabilities
via the new plugin structure.  All packets sent to us will be
sent through all of the plugins.  It's the plugins job to decide what to
do with that packet or ignore it.

Email is no longer a special case for the most part.  All email
functions have been migrated to the EmailPlugin, including starting the
EmailThread, which works in the background to check for new emails and
send those to the registered callsign.   The EmailPlugin now starts the
EmailThread itself.

All plugins are now build on the new APRSDPluginBase which has a common
set of features.  The APRSDPluginBase calls self.setup() upon creation,
which allows all plugins to do whatever they want for initiali startup.
The EmailPlugin uses setup() to start the EmailThread if email is
enabled.
2021-08-23 13:43:53 -04:00
Hemna e175f77347 Use Gray instead of Black for code formatting.
The Black code formatter sucks with respect to function
declarations with a lot of params.  Completely unreadable.
2021-08-23 13:32:09 -04:00
Hemna f1f8aed8c4 Fixed LOG.debug issue in weather plugin 2021-08-19 19:07:45 -04:00
Hemna ed4995b6eb Fixed time plugin 2021-07-29 20:17:58 -04:00
Hemna 2fceba10e1 Reworked the notification threads and admin ui.
This patch updates the notification thread to send all packets
through the notification plugins.   The plugins themselves need to
do smart filter to not reply to every packet.  This allows for
more interesting plugins.

Also fixed an issue with the messages tab in the admin ui, not
showing all of the recieved packets.   The messages tab now also
sees all the packets that aprsd recieves.
2021-07-17 14:30:29 -04:00
Hemna 1a1fcba1c4 Add new watchlist feature
This patch adds a new optional feature called Watch list.
Aprsd will filter IN all aprs packets from a list of callsigns.
APRSD will keep track of the last time a callsign has been seen.
When the configured timeout value has been reached, the next time
a callsign is seen, APRSD will send the next packet from that callsign
through the new notification plugins list.

The new BaseNotifyPlugin is the default core APRSD notify based plugin.
When it gets a packet it will construct a reply message to be sent
to the configured alert callsign to alert them that the seen callsign
is now on the APRS network.

This basically acts as a notification that your watched callsign list is
available on APRS.

The new configuration options:
aprsd:
    watch_list:
        # The callsign to send a message to once a watch list callsign
        # is now seen on APRS-IS
        alert_callsign: NOCALL
        # The time in seconds to wait for notification.
        # The default is 12 hours.
        alert_time_seconds: 43200
        # The list of callsigns to watch for
        callsigns:
          - WB4BOR
          - KFART
        # Enable/disable this feature
        enabled: false
        # The list of notify based plugins to load for
        # processing a new seen packet from a callsign.
        enabled_plugins:
        - aprsd.plugins.notify.BaseNotifyPlugin

This patch also adds a new section in the Admin UI for showing the
watch list and the age of the last seen packet for each callsing since
APRSD startup.
2021-07-16 08:31:38 -04:00
Hemna 7b019d24f0 Updated stats output for KeepAlive thread
Also added the aprsd uptime to the VersionPlugin
2021-04-02 18:54:00 -04:00
Hemna e6cafeb3d2 Added plugin live reload and StockPlugin
This patch adds 2 items.  First it adds the new StockPlugin,
which fetches stock quotes from yahoo finance rest API using
the yfinance python module.

2nd, the web interface contains a new url /plugins, which allows
aprsd to reload all of it's plugins from disk.  This is useful for
development where the dev is editing an existing plugin and wants to
run the edited plugin without restarting aprsd itself.  The /plugins
url requires admin login credentials.

TODO: would be nice to live reload the aprsd.yml config file, so plugin
reloading can start new plugins defined in aprsd.yml between /plugins
being reloaded.
2021-02-18 16:31:52 -05:00
Hemna af48c43eb2 Added tracing facility
You can enable debug tracing iff loglevel == DEBUG AND
config file has aprsd:trace:True
2021-01-29 10:07:49 -05:00
Craig Lamparter 57d768e010 duplicate email messages from RF would generate usage response 2021-01-26 09:18:43 -08:00
Hemna 0d18e54969 Fixed an issue with LocationPlugin
When calling LocationPlugin with a callsign outside of the US,
the forecast.weather gov wasn't raising an exception.  A valid json
dict was coming back, but it didn't have location data we were
expecting.
2021-01-22 16:32:49 -05:00
Hemna 5c949343ec Added Flask web thread and stats collection
This patch adds the stats object to collect statistics of
the running server.  This also optionally adds the ability
to run a flask web service on a port to use as a keepalive
healthcheck.
2021-01-21 20:58:47 -05:00
Hemna 982f24c5f5 Allow email to be disabled.
The config file defaults to email being off now.  This requires
the user to set the email settings anyway, so the default is off.
2021-01-21 13:50:19 -05:00
Hemna ce5b09233c Reworked the config file and options
This patch reorganizes the config file layout and options
to make more logical sense as well as make it more readable.

This breaks backwards compatibility.
2021-01-21 13:32:19 -05:00
Hemna a35cb04ca7 Updated documentation and config output
This patch reformats the sample-config output for more
informative comments for the 3 external services:
openweathermap
opencagedata
avwx-api
2021-01-21 10:05:49 -05:00
Hemna fefb626c97 Fixed extracting lat/lon
This patch fixes an issue when aprs.fi returns a non error, but
doesn't have any real entries as the response
2021-01-20 19:51:59 -05:00
Hemna 2349024539 Added openweathermap weather plugin
This patch adds the openweathermap weather plugin.
Also adds a new config option to set the overall
units setting from imperial (default) to metric.

to change it add the following to the ~/.config/aprsd/aprsd.yaml

...
aprsd:
  units: metric
2021-01-20 16:12:17 -05:00
Hemna fc3a747aa4 Added new time plugins
This patch adds 2 new time plugins to allow admins to use their
opencagedata APIkey or openweathermap API key to fetch the timezone
from the lat/lon GPS coordinates for the callsign requesting the time.

This will enable fetching the time local to the ham radio's last beacon,
and not time local to the aprsd server instance running.  If the
location is not found, then the timezone will default to UTC.

The 2 new plugins are
- aprsd.plugins.time.TimeOpenCageDataPlugin
   Fetches timezone from lat/lon using the opencagedata api that can be
   found here:  https://opencagedata.com/dashboard#api-keys

   This requires a new ~/.config/aprsd/aprsd.yml entry to specify the
   api key.
   opencagedata:
       apiKey: <the api key hash here>

- aprsd.plugins.time.TimeOWMPlugin
   Fetches the timezone from lat/lon using the openweathermap api
   that can be found here:  https://home.openweathermap.org/api_keys

   This requires a new ~/.config/aprsd/aprsd.yml entry to specify the
   api key.
   openweathermap:
       apiKey: <the api key hash here>
2021-01-20 10:19:49 -05:00
Hemna 9f38fd179e Fixed TimePlugin timezone issue
The existing time plugin had a hard coded PDT for pacific timezone,
when it wasn't.   This patch adds some real timezone conversion from
utc to the tz of the running aprsd server.   This will eventually allow
us to use either the tz of the running aprsd and/or the tz of the
calling callsign if we can just get the tz string from the location
beacon of the caller's callsign.
2021-01-19 11:26:07 -05:00
Craig Lamparter ca05676c98 remove fortune white space 2021-01-17 08:02:45 -08:00
Craig Lamparter 83f42dd7b7 Merge branch 'master' of https://github.com/craigerl/aprsd 2021-01-17 07:57:10 -08:00
Craig Lamparter 7de2820caa change query char from ? to ! 2021-01-17 07:55:59 -08:00
Hemna cc8fd178ce Added aprsd-dev plugin test cli and WxPlugin
This patch adds a new CLI app called aprsd-dev.  arpsd-dev is
used specifically for developing plugins.  It allows you to run a
plugin directly without the need to run aprsd server.

This patch also adds the Weather Metar plugin called WxPlugin.
You can use it to fetch METAR from the nearest station for a callsign
or from a known METAR station id.  Call WxPlugin with a message of
'wx' for closest metar station or 'wx KAUN' for metar at KAUN wx station
2021-01-15 22:30:34 -05:00
Hemna d81bfd6fd5 Enabled some emailthread messages and added timestamp
This patch re-enables some log.debug messages for email, to ensure
we can see emailthread is running correctly.  Also adds a timestamp
to the query pending messages, so radios don't think it's a duplicate
message.
2021-01-15 11:12:43 -05:00
Craig Lamparter 0b5c9dacf0 fix query command syntax ?, ?3, ?d(elete), ?a(ll) 2021-01-14 11:21:26 -08:00
Hemna 4ca5c29d49 Fixed latitude reporting in locationPlugin
The latitude was always 0, because it was the
altitude.
2021-01-14 14:02:43 -05:00
Hemna bdeaf6348a Added new config for aprs.fi API Key
This patch adds the new required aprs.fi api key.  This key is used
by 2 of the core plugins, locationPlugin and weatherPlugin.

You must set the apiKey in the config, or aprsd won't start.
2021-01-12 09:51:36 -05:00
Hemna 7ab26135c2 Fixed fortune plugin failures
On alpine containers the fortune options aren't all available
and we were silently failing.  Updated the fortune plugin to capture
shell failures.
2021-01-11 14:14:16 -05:00
Craig Lamparter d9141dc2d0 update query plugin to resend last N messages. syntax: ?rN 2021-01-11 09:13:37 -08:00
Craig Lamparter 0aa7fe7a14 change query character syntax, don't reply that we're resending stuff 2021-01-10 14:44:40 -08:00
Craig Lamparter e7f2ebf17e switch command characters for query plugin 2021-01-09 15:50:04 -08:00
Hemna d5a34b4d11 refactor Plugin objects to plugins directory
This patch moves all of the plugins out of plugin.py
into their own separate plugins/<plugin>.py file.  This
makes it easier to maintain each plugin.

NOTE:  You will have to update your ~/.config/aprsd/aprsd.yml

to change the python location path for each plugin enabled.

For example:
OLD:
  enabled_plugins:
   - aprsd.plugin.EmailPlugin

TO NEW
  enabled_plugins:
   - aprsd.plugins.email.EmailPlugin
2021-01-09 10:00:37 -05:00