aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ipc
Commit message (Collapse)AuthorAgeFilesLines
* commands: pass raw command line down to template evaluationRobin Jarry2023-10-282-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | Some commands need to invoke others and/or run shell commands. For this, we need the raw command line as entered by the user. Pass it down the call chain just before it is split to invoke the command Execute method. Remove unit tests for the template expand() test which does have any added value now that it is performed on a single string without any quote juggling. Update all code to handle a single string instead of a list of arguments. Introduce a new dependency on git.sr.ht/~rjarry/go-opt to deal with shell splitting. This is in preparation for using opt.ArgsToStruct to parse arguments for all aerc commands. There should be no functional change after this patch. Signed-off-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Koni Marti <koni.marti@gmail.com> Tested-by: Moritz Poldrack <moritz@poldrack.dev> Tested-by: Inwit <inwit@sindominio.net>
* xdg: get rid of deprecated dependenciesRobin Jarry2023-08-272-6/+4
| | | | | | | | | | | github.com/mitchellh/go-homedir has not received any update since 2019. The last release of github.com/kyoh86/xdg was in 2020 and it has been marked as deprecated by its author. Replace these with internal functions. Signed-off-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Moritz Poldrack <moritz@poldrack.dev>
* ipc: stay silent if command succeededMoritz Poldrack2023-03-071-3/+1
| | | | | | | | It would be nicer if aerc behaved the same way most other tools behave in that no news is good news. Signed-off-by: Moritz Poldrack <git@moritz.sh> Acked-by: Robin Jarry <robin@jarry.cc>
* ipc: allow triggering internal commands via IPCMoritz Poldrack2023-03-072-0/+15
| | | | | | | | | | | | | | | | | | | | | In order to make automation easier, it's useful to be able to send commands to aerc via IPC. This can be done by calling the aerc binary followed by a colon and the command to run. For example: aerc :read && aerc :remark && aerc :archive month Security to ensure no malicious commands are run is deferred to the user. By default the socket is only writable by the user. This is considered sufficient as the potential harm an attacker gaining write-access to a user's session can cause is significantly greater than "can delete some emails". To ensure users with an according threat model, it is possible to disable command IPC. mailto-handling is unaffected even though it works over IPC as it is absolutely non-destructive. Signed-off-by: Moritz Poldrack <git@moritz.sh> Acked-by: Robin Jarry <robin@jarry.cc>
* ipc: use an interface instead of a function listMoritz Poldrack2023-03-072-7/+13
| | | | | | | | | Currently, every function has to be mapped to the according handler with our god-object. To make adding new handlers require less changes, change this mapping into an interface that is satisfied by *widgets.Aerc Signed-off-by: Moritz Poldrack <git@moritz.sh> Signed-off-by: Robin Jarry <robin@jarry.cc>
* ipc: change protocol to JSONMoritz Poldrack2023-03-073-28/+105
| | | | | | | | | | | | | | | | | | | | | | In overhauling the IPC, it has become necessary to switch to a more extendable message format, to ensure more complex commands can be sent. Messages have the following basic structure and must not contain linebreaks, as these are used to delimit separate messages from one another. {"arguments": ["mailto:moritz@poldrack.dev"]} The responses have the following structure: {"error": "epic fail"} If the IPC request was successful, "error" will be empty. {"error": ""} Signed-off-by: Moritz Poldrack <git@moritz.sh> Signed-off-by: Robin Jarry <robin@jarry.cc>
* socket: refactor existing codeMoritz Poldrack2023-03-073-146/+147
| | | | | | | | | | | | | There are several //TODO comments in the socket package, these should be fixed before expanding it. Put send logic into it's own file and rename receiver code. Fix the rather inelegant error handling when shutting down the server. Make sure to close sockets. Signed-off-by: Moritz Poldrack <git@moritz.sh> Signed-off-by: Robin Jarry <robin@jarry.cc>
* socket: extract functionality into ipc packageMoritz Poldrack2023-03-071-0/+146
The current model of files dumped into lib does not follow the general advice not to have "util" classes. Naming the package "lib" does not change that it is a random assortments of functions that have some utility. Extracts socket functionality into it's own package. Signed-off-by: Moritz Poldrack <git@moritz.sh> Acked-by: Robin Jarry <robin@jarry.cc>