Commit Graph

87 Commits

Author SHA1 Message Date
Hemna 34d2c31d90 Added log config for flask and lnav config file
This patch adds the aprsd-lnav.json formatting file.
This is useful when you want to tail the logfile with the lnav
log tailing app.

http://lnav.org/

To install the aprsd-lnav.json formatter
1) install lnav
2) lnav -i aprsd-lnav.json
3) lnav -C  -- just to test it out

The next time you launch aprsd do it with this
aprsd server --loglevel DEBUG | lnav

This patch also updates the logging output from the flask
web service to 1) disable flask web url logging and 2)
use the same output format as the rest of the app.
2021-03-31 11:07:39 -04:00
Hemna 0a038dae44 Added log format and dateformat to config file
This patch moves the default log format string and date format string
to the config file, so users can format the logs as they see fit.
The default log format also includes the file and line number that
posted the log entry.

The new entries in the config are here:
aprsd:
  logformat: "String here"
  dateformat: "string here"
2021-02-25 13:32:50 -05:00
Hemna db2b537317 Added memory tracing in keeplive 2021-01-29 11:02:21 -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
Hemna 030b02551f Enable debug logging for smtp and imap
Add the new config options for
aprsd:
  email:
    imap:
      debug: True

    smtp:
      debug: True
2021-01-25 16:16:08 -05:00
Hemna aa290692ab Added flask messages web UI and basic auth
This patch fixes the CTRL-C signal_handler.
This patch also adds the new Messages WEB UI page
as well as the save url, which are both behind an
http basic auth.

The flask web service now has users in the config file
aprsd:
  web:
    users:
      admin: <password>
2021-01-25 11:24:39 -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 7486770bdc Fixed main server client initialization
This fixes the usage of the singleton client class which
houses/creates the aprslib client.  We were getting multiple
logins, now we get one.
2021-01-14 15:44:07 -05:00
Hemna 72fa550250 Removed flask code 2021-01-14 14:36:36 -05:00
Hemna 0aa905ebba Changed default log level to INFO
Also adjusted some of the logging for main, messaging and threads
to be more sane
2021-01-14 14:32:59 -05:00
Craig Lamparter 7e3b95fd01 get rid of some debug noise from tracker and email delay 2021-01-14 10:51:00 -08:00
Hemna cdde9c290b Added the ability to add comments to the config file
This patch adds a new add_config_comments() function in utils.py
that allows you to insert a comment string in a raw_yaml string
that's already been created from the yaml.dump() call.
2021-01-14 12:38:30 -05:00
Hemna 54072a2103 Added --raw format for sending messages
aprsd send-message --raw "RAW APRS MESSAGE HERE"
2021-01-12 14:50:49 -05:00
Hemna f022a3e421 Fixed --quiet option
This patch fixes the --quiet option for both send-message
and server commands.   Don't write anything to STDOUT.
2021-01-12 11:26:12 -05:00
Hemna 90c4c6c59d Added send-message login checking and --no-ack
This patch adds the login failure checking for the
send-message command as well as a new command line option
--no-ack.   The new option enables sending the message directly
to aprs-is servers and then exiting immediately.  It doesn't wait
for an ack to come back.
2021-01-12 11:18:17 -05:00
Hemna 3dd23fa2ad Added a fix for failed logins to APRS-IS
This patch adds a check for a failed login to ARPS due to
LoginError.  This accounts for bad accounts or username/password
failures.  aprsd server will exit immediately upon failed login now.
2021-01-12 09:31:04 -05:00
Hemna 231c15b1af Lots of fixes 2021-01-08 20:58:18 -05:00
Hemna 75f610d971 Added pre-commit hooks
This patch adds pre-commit hook support to ensure
code passes basic checks prior to allowing a commit.
2021-01-06 17:54:50 -05:00
Hemna 2659a0b3b9 Added support to save/load MsgTrack on exit/start
This patch added saving of the MsgTrack list of messages at aprsd exit.
The will be loaded at startup unless you pass in the --flush option.
2020-12-30 07:41:34 -05:00
Hemna 2e90c0bdbb Creation of MsgTrack object and other stuff
This patch adds the new MsgTrack object replacing the
global ack_dict.  the ack_dict was not thread safe.
the new MsgTrack is a singleton object that keeps track of
all outbound TextMessage objects.  When a TextMessage.send() is called
it is added to the MsgTrack object, and when an ack is received for that
message, the message is removed from the MsgTrack object.

TODO:  Add an automatic mechanism for saving the messages in MsgTrack
so that when CTRL-C is called to exit aprsd server, then the MsgTrack
state is saved to storage.   When aprsd server is started up again, add
the option to try and reload state of MsgTrack.

This patch also reworked the email thread into an APRSDThread object
that can exit gracefully with CTRL-C.

NOTE: Don't call sleep() with a long time (greater than 5 seconds), as
it causes a delay in exiting aprsd until the last sleep() finishes.
Since aprsd has so many threads now for processing incoming messages and
outgoing messages, we need to coordinate all thread operations so that
they don't block the exiting of the app.
2020-12-29 10:40:38 -05:00
Hemna f65707cb8c reworked threading
This patch reworks the threading code for processing
messages.   This patch also extends the aprslib IS class
to allow us to stop processing the consumer packets when
someone hits CTRL-C correctly.  Alloing the app to exit.
2020-12-24 13:40:59 -05:00
Hemna 9768003c2a Reworked messaging lib
This patch updates the messaging lib to use Message Objects
for each message type (text, ack) that know how to send
themselves with the same interface.
2020-12-23 13:12:04 -05:00
Hemna 1d898ea20f Refactored the main process_packet method
This patch refactored the process_packet method
and adjusted the logic for determining if we got
a message to filter on.  We now look at the format
to make a determination.  Also isolated the processing
of message packets, ack packets and mic-e packets into
their own functions.
2020-12-21 11:59:58 -05:00
Hemna b2609548f2 Added fix for an unknown packet type
If we get a packet that doesn't have a message in it, nor an ack,
we don't know what to do with it, so log it and then stop processing it.
2020-12-20 20:28:56 -05:00
Hemna d3ee1b78bc Fixed issue when RX ack
This patch ensures that after we get an ACK, then proessing of the ack
message is complete and we don't try and send the ack through plugin
filtering.

Created send_ack_direct for the send-message command.

Also added logic to the send-message command to ensure we wait for an
ack from the command sent to APRSD and we also wait for a response
message and send an ack to that response before we exit.
2020-12-20 16:35:23 -05:00
Hemna 3261710bf8 Fixed send-message with email command and others
This patch fixes a minor issue with the new send-message command
You now should use nargs to send the email command because it includes
a - as the start.  click assumed that any -<foo>  looks ike an argument.
So call aprsd with

aprsd send-command <callsign> -- -wb sendmap

This patch also adds -h as a help option for aprsd to make it simpler to
type.

This patch adds the VersionPlugin so you can remotely request the
version of aprsd that's running.
2020-12-20 12:21:30 -05:00
Hemna fa51f8fdf2 Big patch
This commit adds the new send-message command for sending messages.
This also redoes the logging of sent/rx'd packets to a single method
which is syncrhonized, so we don't get intermixed log messages for
packets.

Also adds email address validation during startup, and
optionally disables the validation via a command line switch.  without
email validation for production running aprsd, emails sent can turn up
garbage and cause issues when those emails are received by aprsd
message processing as invalid content.
2020-12-19 16:35:53 -05:00
Hemna 08c73a17d1 Major refactor
This branch refactors the majority of main.py out into individual
modules to compartmentalize the code.  Migrated all email related
features unti email.py, sending of messages into messaging.py

Also refactored all of the socket code to use aprslib for all APRS-IS
communication as well as message/packet processing.

Moved the email command into it's own Plugin.
2020-12-18 16:21:35 -05:00
Hemna 96bae795a5 Fix unknown characterset emails
Some emails that had an unknown character set.  when that happens
we can't decode the body of the message properly, so the default body
string was being used, and was attempting to be decoded.  Only byte
strings can be decoded, so the default string is now labeled as a byte
encoding.
2020-12-15 17:59:17 -05:00
Hemna 8a6273867c Updated loggin timestamp to include []
Added timestamp inside of [] for easier parsing
2020-12-15 11:10:46 -05:00
Hemna 2873e35f14 Fixed the usage string after plugins introduced
This patch fixes the Usage string for a call message
that isn't matched by any plugin.

Plugin object now must impleent a 'command_name' attribute
that is the usage string for that plugin.
2020-12-13 21:51:39 -05:00
Hemna d09a66006b Created plugin.py for Command Plugins
This patch adds the new APRSD Command Plugin architecture.
All Comand plugins must implement the same object API, which includes
plugin object is subclass of APRSDPluginBase
version attribute
command_regex attribute
command method

When an APRS command is detected, then the regex is run against
the command.  If the command_regex matches, then the plugin's
command() method will be called.   If the command() method returns
a string, then that string is sent as a reply to the APRS caller.

A new aprs.yml config section is added to support selecting
which plugins to enable.

If you want all plugins enabled, then omit "enabled_plugins" entirely
from the aprs section of the config.

To load custom plugins:
1) create a directory with an __init__.py file
2) Add a plugin.py file that contains your plugin

Look at the exmaples directory for an example plugin.
2020-12-13 20:57:30 -05:00
Hemna 00d99bc2c4 Refactor networking and commands
This patch refactors the socket management
to use select, as well as refactor all of the
commands into a COMMAND_ENVELOPE dictionary.

This patch also adds the Dockerfile and
docker-compose.yml files
2020-12-11 19:29:18 -05:00
Craig Lamparter 43509ea9e6 get rid of some debug statements 2020-12-11 10:23:14 -08:00
Craig Lamparter bb1a2ee61a yet another unicode problem, in resend_email fixed 2020-12-11 09:49:26 -08:00
Craig Lamparter d3bb44feec reset default email check delay to 60, fix a few comments 2020-12-11 06:53:38 -08:00
Hemna 53b8f21535 Update tox environment to fix formatting python errors
This patch includes lots of changes to tox environment for
automatically detecting pep8 failures, which can cause python2 vs
python3 failures after install.

The following tox commands have been added
tox -efmt-check  - This checks the python syntax and formatting
tox -efmt        - Automatically fixes python syntax formatting that
                   fmt-check complains about.
tox -etype-check - check on types
tox -elint       - flake8 run

This patch also changes where the default config file is located.
The new location is ~/.config/aprsd/aprsd.yml

You can now also specify a custom config file on the command line
with the -c or --config option as well.
2020-12-11 08:47:56 -05:00
Craig Lamparter 2bebd83449 fixed fortune. yet another unicode issue, tested in py3 and py2 2020-12-10 15:54:38 -08:00
Craig Lamparter c5517a7cb5 lose some logging statements 2020-12-10 15:29:29 -08:00
Craig Lamparter 86bf42802c completely off urllib now, tested locate/weather in py2 and py3 2020-12-10 15:15:19 -08:00
Craig Lamparter b38f561b84 add urllib import back until i replace all calls with requests 2020-12-10 12:19:40 -08:00
Craig Lamparter ad0f96d1aa cleaned up weather code after switch to requests ... from urllib. works on py2 and py3 2020-12-10 10:21:31 -08:00
Craig Lamparter 00432cf5bb switch from urlib to requests for weather, tested in py3 and py2. still need to update locate, and all other http calls 2020-12-10 10:11:35 -08:00
Craig Lamparter 4b09fad876 imap tags are unicode in py3. .decode tags 2020-12-10 09:10:59 -08:00
Hemna 50fb090557 Initial conversion to click 2020-12-09 09:47:37 -05:00
craigerl b553987350 Reconnect on socket timeout 2020-12-09 09:40:23 -05:00
Craig Lamparter 735cb3a557 clean up code around closed_socket and reconnect 2020-12-09 09:34:34 -05:00
Hemna 51832ea75e Fixed all pep8 errors and some py3 errors
This introduced the six lib which can translate common
py2 vs py3 incompatibilities.
https://six.readthedocs.io/
2020-12-09 09:31:36 -05:00