Commit Graph

599 Commits

Author SHA1 Message Date
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 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 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 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
Hemna ac4c3d6562 Extend APRS.IS object to change login string
This patch copies the aprslib.inet IS object's _send_login()
method so we can change the login app identification string.
2021-01-11 13:08:30 -05:00
Craig Lamparter d9141dc2d0 update query plugin to resend last N messages. syntax: ?rN 2021-01-11 09:13:37 -08:00
Hemna 1ce2a56140 Updated MsgTrack restart_delayed
This patch updates the restart_delayed method to accept the count of
messages to restart as well as the most_recent flag that sorts the
messages based on most recent first.  If you want the oldest first,
then pass in False
2021-01-11 11:03:41 -05:00
Hemna a385d171bd 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-11 08:28:08 -05:00
Craig Lamparter 0aa7fe7a14 change query character syntax, don't reply that we're resending stuff 2021-01-10 14:44:40 -08:00
Hemna e6dee3a5b0 Disable MX record validation
This patch disables the MX record checking for
email address shortcuts.  verizon is a shit
smtp host that won't let you check emails as
existing/valid.  Email validation still is checked
against RFC based regex for email address as
well as blacklist checking.

TODO(hemna): make this optionally enabled
by config file.
2021-01-10 13:22:23 -05:00
Craig Lamparter e7f2ebf17e switch command characters for query plugin 2021-01-09 15:50:04 -08:00
Hemna 1763e94f93 Fix broken test 2021-01-09 18:44:36 -05:00
Craig Lamparter 45dd3f0205 undo git disaster 2021-01-09 15:39:37 -08:00
Craig Lamparter a33462327a swap Query command characters a bit 2021-01-09 14:02:16 -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
Hemna 231c15b1af Lots of fixes 2021-01-08 20:58:18 -05:00
Hemna 4c0150dd97 Added more pre-commit hook tests
also added pre-commit job for tox.
2021-01-08 20:57:58 -05:00
Hemna 9f4cc27a11 Fixed email shortcut lookup
This patch fixes the email.get_email_from_shortcut.  It ensures that
if the lookup isn't found in the shortcut list, it simply returns
the original value.  This patch also adds a unit test to specifically
test this function to always return the correct value.
2021-01-08 19:35:16 -05:00
Hemna dbc891f738 Cleaned out old ack_dict
This patch removes remnants of ack_dict from the code.
The new mechanism is the MsgTrack object queue.
2021-01-08 15:11:27 -05:00
Craig Lamparter 1697395e84 add null reply for send_email 2021-01-08 11:02:57 -08:00
Hemna e83ee31310 Fixed failures caused by last commit
This patch fixes test failures caused by last commit.
2021-01-08 10:57:34 -05:00
Craig Lamparter 99c5867162 don't tell radio emails were sent, ack is enuf 2021-01-07 16:22:45 -08: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 af0d4491c3 Added QueryPlugin resend all delayed msgs or Flush
This patch also updates the QueryPlugin to allow the configured user
to immediately resend all Delayed messages!

This patch updates the QueryPlugin to allow the configured user
to immediately Flush/delete all messages!
2020-12-30 09:12:38 -05:00
Hemna 28f3daf6d0 Added QueryPlugin
Query Plugin looks for ^/?.* and currently only responds with
the list of pending messages in the MsgTrack queue.
2020-12-30 08:15:49 -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 18b269a39d Ensure fortune is installed
This patch uses python3's shutil to find the path
to fortune app, which can be very different depending on
the host OS that aprsd is running on.
2020-12-20 19:04:33 -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 63079a817d Don't use the dirname for the plugin path search 2020-12-15 09:30:10 -05:00
Hemna 1385f5ee27 Reworked Plugin loading
This patch reworked the loading of plugins.  Python2 is dead.
Previously was using the imp module to easily load the plugins from
a separate directory, which is a bit of a pita.  Found a python3 lib
that takes care of the difference between py3.3, 3.4 and 3.5+ module
loading called "thesmuggler"
2020-12-15 07:50:10 -05:00
Hemna eba093b62a Fixed an issue with weather plugin
Weather plugin had an invalid call to rstrip()
2020-12-14 14:18:12 -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
craigerl b552f9611f fix check_email_thread to do proper threading, take delay as arg 2020-12-09 09:27:44 -05:00
Craig Lamparter f69f9a2027 found another .decode that didn't include errors='ignore' 2020-12-08 17:07:23 -08:00
Craig Lamparter 90fcb9973b some failed attempts at getting the first txt or html from a multipart message, currently sends the last 2020-12-08 15:31:56 -08:00
Craig Lamparter 3c16149e71 fix parse_email unicode probs by using body.decode(errors='ignore').. again 2020-12-08 15:01:07 -08:00
Craig Lamparter 44228c63b3 fix parse_email unicode probs by using body.decode(errors='ignore') 2020-12-08 14:59:28 -08:00
Craig Lamparter 371a7a08ac clean up code around closed_socket and reconnect 2020-12-08 09:27:24 -08:00
Craig Lamparter e6995c3605 socket timeout 5 minutes 2020-12-07 10:08:21 -08:00
Craig Lamparter 4b67df2907 Detect closed socket, reconnect, with a bit more grace 2020-12-06 12:01:32 -08:00
Craig Lamparter b8f37fac6e can detect closed socket and reconnect now 2020-12-06 11:54:11 -08:00
craigerl 3d7e3a4e54 more debugging messages trying to find rare tight loop in main 2020-12-06 08:59:33 -08:00
craigerl a4faa7614c main loop went into tight loop, more debug prints 2020-12-05 19:23:17 -08:00
craigerl b597228719 main loop went into tight loop, added debug print before every continue 2020-12-05 18:59:58 -08:00
craigerl 3ae7a056b6 George Carlin profanity filter 2020-12-05 12:50:08 -08:00
craigerl cf73add2db added decaying email check timer which resets with activity 2020-12-05 11:30:31 -08:00
Walter A. Boring IV a3813eaf3a
Merge branch 'master' into py3 2020-12-04 16:48:28 -05:00
Hemna 4084ddfe31 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-04 16:46:34 -05:00
Hemna 06a63f541e 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-04 16:43:30 -05:00
craigerl ecd0e8f95e Reconnect on socket timeout 2020-12-04 16:43:12 -05:00
craigerl 5e96706f7a socket reconnect on timeout testing 2020-12-04 16:42:45 -05:00
craigerl 32e146d105 socket timeout of 300 instead of 60 2020-12-04 13:37:29 -08:00
craigerl 766acbb777 Reconnect on socket timeout 2020-12-04 09:43:11 -08:00
craigerl 712d66c389 socket reconnect on timeout testing 2020-12-04 07:21:37 -08:00
Hemna 0c40689743 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-04 09:07:32 -05:00
craigerl e171e16854 fix check_email_thread to do proper threading, take delay as arg 2020-12-03 14:48:27 -08:00
craigerl abc63791f1 fix bugs after beautification and yaml config additions. Convert to sockets. case insensitive commands 2020-12-02 12:25:39 -08:00
craigerl 78add91f3c fix INBOX 2020-12-02 09:42:23 -08:00
Walter A. Boring IV d1a50c6559 Added tox support
This patch adds support for tox.  Tox is used to run various
python compliance tests.  This enables pep8 tests, as well as python2
and python3 compatibility as well as coverage and documentation
building.
2019-05-15 20:12:59 +00:00
Walter A. Boring IV da153b64f6 Fixed SMTP settings
This patch reads the SMTP settings from the config.yml now.
Also added a logfile entry to the aprs: section of the config.yml
so the logfile can be placed anywhere.
2018-11-29 14:19:52 -05:00
Walter A. Boring IV bd47a2bdea Created fake_aprs.py
Moved the config parsing to utils, so it's shared with
main.py (aprs) and fake_aprs.py
2018-11-29 13:20:53 -05:00
Walter A. Boring IV 7abc47098b select inbox if gmail server 2018-11-29 10:01:30 -05:00
Walter A. Boring IV a9eb1714c2 removed ASS 2018-11-29 09:33:24 -05:00
Walter A. Boring IV 89d038e93d Added a try block around imap login 2018-11-29 09:30:51 -05:00
Walter A. Boring IV 81d01c3bc6 Added port and fixed telnet user
This patch adds the port to the aprs: section of the config.yml
as well as fixes a possible issue with the user telnet auth command
where the user is a string and the port is an int.  python can't
concatonate a string with an int.
2018-11-29 09:20:15 -05:00
Walter A. Boring IV ce7a30aa78 Require ~/.aprsd/config.yml
This patch completes the migration to using a config.yml file.
~/.aprsd/config.yml is now required and all options for callsign,
imap, aprs user, passwords are in the config.  If there is no existing
~/.aprsd/config.yml file, then the app will output a sample config
and exit.

This patch also adds a global logging facility that allows logging all
commands to aprsd.log as well as stdout.  You can disable logging to
stdout by adding --quiet on the command line.  You can specify the log
level with --loglevel INFO.  By default the log level is DEBUG.

This patch also updates some formatting issues and small refactoring
to ensure that the logging facility and config is read prior to starting
any network connections and/or services.
2018-11-29 08:22:41 -05:00
Walter A. Boring IV 8d1d2933e8 added test to ensure shortcuts in config.yml
This patch adds a simple test to ensure that 'shortcuts' is part of
the config.yml
2018-11-21 15:25:31 -08:00
Walter A. Boring IV e3964c5426 added exit if missing config file 2018-11-21 15:23:06 -08:00
Walter A. Boring IV 5717504f11 Added reading of a config file
This patch adds support to read a ~/.aprsd/config.yml file.
If one doesn't exist, it puts out an example yaml string to stdout
that can be copied into a file and edited.

Since this patch adds a new external requirement (pyyaml) you need
to re-install the app for dev with
pip install -e .
2018-11-21 15:20:11 -08:00
Walter A. Boring IV ecd797d91e First stab at migrating this to a pytpi repo
This patch does some refactoring of the code and the directory
structure to conform to the needs of a pypi project.
The python code now lives in the aprsd directory so it acts like a real
python package that can be installed/included/used.
The aprsd.py is now aprds/main.py

This patch also adds support for using pbr, which enables a consistent
bin install that you can then call as 'aprsd' from the command line.

To use this as a developer you should create a virtualenv
virtualenv .venv
source .venv/bin/activate
pip install -e .

now you can edit the aprds/main.py and then test it by immediately
running aprsd from the command line.

The -e option for pip allows you to install the package as an editable
package in the .venv, so you can hack on it and not need to re-install
every time you make a change.
2018-11-21 13:56:29 -08:00