~bigbes/core-go

server/email: print correct var on type assertion failure
c3d11991 — Drew DeVault 1 year, 6 months ago
webhooks: fix filter for internal auth
e4b0261f — Drew DeVault 1 year, 6 months ago
Export webhooks public key via api-meta.json
d3f7b91a — Drew DeVault 1 year, 6 months ago
webhooks: implement internal webhook users

AUTH_INTERNAL requests previously could not register webhooks. This
commit adds the necessary changes to allow for this.
465a6f71 — Drew DeVault 1 year, 6 months ago
all: pass errors to panic, not strings

GraphQL's recovery middleware can't handle strings so it just logs a
very not useful <nil>
fea51c61 — Drew DeVault 1 year, 6 months ago
webhooks: add User-Agent to outgoing requests
bf509aee — Drew DeVault 1 year, 6 months ago
client: add User-Agent to outgoing requests
aa1834b6 — Robin Jarry 1 year, 7 months ago
email: fix mime version header position

Prevent the MIME-Version header from being inserted on the first part.

Link: https://github.com/emersion/go-pgpmail/pull/15
Signed-off-by: Robin Jarry <robin@jarry.cc>
c05af16c — Robin Jarry 1 year, 7 months ago
email: fix partial bodies

Depending on the email and buffer size, cleartext.Close() and
body.Close() may happen *after* buf.Bytes() is called; producing
incomplete emails, interrupted in the middle of the body.

Make sure to close both *before* getting the buffer contents.

Fixes: db4d67a2a6fb ("email: fix empty emails sent on retries")
Signed-off-by: Robin Jarry <robin@jarry.cc>
78a07dca — Robin Jarry 1 year, 7 months ago
email: fix malformed emails

go-message 0.18.2 contains a new implementation of the message line
wrapping algorithm. Without it, messages sometimes contain random line
breaks in the middle of the body.

Update to the latest tag.

Signed-off-by: Robin Jarry <robin@jarry.cc>
db4d67a2 — Robin Jarry 1 year, 7 months ago
email: fix empty emails sent on retries

io.Reader objects can only be consumed once. On retry, re-reading from
them will return 0 bytes all the time.

Change NewTask to take in a bytes array instead of a reader. Create
a new reader on each retry.

Also remove SendRaw which has an inherent issue related to retry as
well. message.Entity is virtually a reader that can only be consumed
once.

Update EnqueueRaw to take a bytes array directly and have it call
NewTask() like EnqueueStd does.

Fixes: 78cfc5d87a7d ("email: allow sending raw emails")
Signed-off-by: Robin Jarry <robin@jarry.cc>
6eae2199 — Drew DeVault 1 year, 7 months ago
auth: use config.IsInternalIP
deb699c9 — Robin Jarry 1 year, 7 months ago
config: add global internal-ipnet setting

Add support for a general [sr.ht]internal-ipnet list of networks that
can be considered OK for internal operations.

The default is loopback addresses (127.0.0.0/8 and ::1/128) and private
routable unicast addresses (192.168.0.0/16, 10.0.0.0/8 and fc00::/7)

Since parsing IP networks and addresses can be costly, store the result
of [sr.ht]internal-ipnet into a global list of net.IPNet and
a convenience IsInternalIP() function to be called by services.

Signed-off-by: Robin Jarry <robin@jarry.cc>
0ad8eb8e — Drew DeVault 1 year, 7 months ago
server: add @admin directive implementation

This will be used at least by meta.sr.ht in the near future.
17315205 — Robin Jarry 1 year, 8 months ago
config: factorize integer parsing

Add a new GetInt() function to parse an integer value from a parsed
ini.File. Use that function instead of duplicated code.

Signed-off-by: Robin Jarry <robin@jarry.cc>
eeb0384a — Robin Jarry 1 year, 8 months ago
mod: use latest version for dowork

The latest version contains fixes against potential races.

Link: https://git.sr.ht/~sircmpwn/dowork/commit/d4703ef2dbb3
Link: https://git.sr.ht/~sircmpwn/dowork/commit/2b00aa42322c
Signed-off-by: Robin Jarry <robin@jarry.cc>
78cfc5d8 — Robin Jarry 1 year, 8 months ago
email: allow sending raw emails

The current email.Enqueue() function only allows sending messages with
the server's default settings.

In order to support sending any arbitrary message, we need to expose
a lower level API taking a raw message.Entity pointer. This new API will
be reused in a future reimplementation of the lists.sr.ht ingress agent
to forward messages to subscribers.

Add email.EnqueueRaw() that calls email.SendRaw(). Retry sending 10
times in the case of failure.

Signed-off-by: Robin Jarry <robin@jarry.cc>
bbcb2a10 — Robin Jarry 1 year, 8 months ago
email: keep smtp client connection alive

Instead of connecting and disconnecting each and every time we need to
send an email, keep the SMTP connection alive attached to a context
variable.

Before sending an email, check if the connection is still valid and
reconnect if it is not.

Signed-off-by: Robin Jarry <robin@jarry.cc>
7457c44b — Robin Jarry 1 year, 8 months ago
treewide: update to new multi worker dowork api

The work.Queue() implementation has changed and now allows scheduling
tasks from multiple goroutines in parallel. Also, it requires a new
argument for limiting the queue buffer size in order to apply back
pressure.

Define new configuration variables to allow tuning the queue sizes and
number of workers per service:

  [mail]
  # Maximum size of the outgoing email queue (default 512).
  egress-queue-size = 512

  [$service_name]
  # Number of parallel workers per queue (default 1).
  # There are multiple queues (for egress email, webhooks, etc.).
  # This setting is applied on a per-queue basis.
  queue-workers = 1

  [webhooks]
  # Maximum size of the webhooks queue (default 512).
  queue-size = 512

Use these new settings to configure the queues and workers accordingly.

Fix unit tests as well.

Link: https://git.sr.ht/~sircmpwn/dowork/commit/95719cfc0118
Signed-off-by: Robin Jarry <robin@jarry.cc>
562662dc — Robin Jarry 1 year, 8 months ago
graphql: add support for multipart file uploads

Inspire from the python implementation in core.sr.ht.

Link: https://git.sr.ht/~sircmpwn/core.sr.ht/tree/7bcbc8ba8f4e/item/srht/graphql/client.py
Signed-off-by: Robin Jarry <robin@jarry.cc>
Next