aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/ipc/handler.go6
-rw-r--r--lib/ipc/receive.go46
2 files changed, 6 insertions, 46 deletions
diff --git a/lib/ipc/handler.go b/lib/ipc/handler.go
index 10f42753..9ed81be0 100644
--- a/lib/ipc/handler.go
+++ b/lib/ipc/handler.go
@@ -1,9 +1,5 @@
package ipc
-import "net/url"
-
type Handler interface {
- Mailto(addr *url.URL) error
- Mbox(source string) error
- Command(cmdline string) error
+ Command(args []string) error
}
diff --git a/lib/ipc/receive.go b/lib/ipc/receive.go
index 4f6258ad..ff837d0f 100644
--- a/lib/ipc/receive.go
+++ b/lib/ipc/receive.go
@@ -5,14 +5,10 @@ import (
"context"
"errors"
"net"
- "net/url"
"os"
- "strings"
"sync/atomic"
"time"
- "git.sr.ht/~rjarry/go-opt"
-
"git.sr.ht/~rjarry/aerc/config"
"git.sr.ht/~rjarry/aerc/lib/log"
"git.sr.ht/~rjarry/aerc/lib/xdg"
@@ -101,44 +97,12 @@ func (as *AercServer) Serve() {
}
func (as *AercServer) handleMessage(req *Request) *Response {
- if len(req.Arguments) == 0 {
- return &Response{} // send noop success message, i.e. ping
+ if config.General.DisableIPC {
+ return &Response{Error: "command rejected: IPC is disabled"}
}
- var err error
- switch {
- case strings.HasPrefix(req.Arguments[0], "mailto:"):
- mailto, err := url.Parse(req.Arguments[0])
- if err != nil {
- return &Response{Error: err.Error()}
- }
- err = as.handler.Mailto(mailto)
- if err != nil {
- return &Response{
- Error: err.Error(),
- }
- }
- case strings.HasPrefix(req.Arguments[0], "mbox:"):
- err = as.handler.Mbox(req.Arguments[0])
- if err != nil {
- return &Response{Error: err.Error()}
- }
- case strings.HasPrefix(req.Arguments[0], ":"):
- if config.General.DisableIPC {
- return &Response{
- Error: "command rejected: IPC is disabled",
- }
- }
- cmdline := req.Arguments[0]
- if len(req.Arguments) > 1 {
- cmdline = opt.QuoteArgs(req.Arguments...).String()
- }
- err = as.handler.Command(cmdline)
- if err != nil {
- return &Response{Error: err.Error()}
- }
-
- default:
- return &Response{Error: "command not understood"}
+ err := as.handler.Command(req.Arguments)
+ if err != nil {
+ return &Response{Error: err.Error()}
}
return &Response{}
}