server: add pprof endpoint
This adds a pprof endpoint to all SourceHut APIs. It picks an
OS-assigned port on localhost to run it on and prints this port to
stdout. This ensures a unique port is selected even if several APIs are
running on a single host.
Allow unix scheme for redis url
Recently, the logic for creating redis client
has been changed and mistakenly unix scheme
has been removed from supported schemes.
errors: add ERR_UNSUPPORTED
server: enable request logging only in debug mode
To improve the signal:noise ratio in the production logs.
errors: new module for common GQL errors
This package provides a means of creating GraphQL-aware errors and
a location for common error codes.
email/worker: catch some PGP error earlier
The writer returned by pgpmail.Encryption() will have the keyring
parsed, but it only tries to determine the encryption key once it is
being written to. Hence, certain errors will only occur later on, when
it is too late to fall back to unencrypted email.
Catch these errors earlier by checking if a valid encryption key is
found.
redis: avoid building UniversalOptions for standard mode
This makes it support all options that go-redis recognizes in ParseURL,
by constructing a standard client directly instead of building
UniversalOptions ourselves.
auth: fix middleware tests
They got broken with 6eae2199 because the tests cannot use
`config.LoadConfig`, so the list of internal IP nets never gets
populated.
server/email: print correct var on type assertion failure
webhooks: fix filter for internal auth
Export webhooks public key via api-meta.json
webhooks: implement internal webhook users
AUTH_INTERNAL requests previously could not register webhooks. This
commit adds the necessary changes to allow for this.
all: pass errors to panic, not strings
GraphQL's recovery middleware can't handle strings so it just logs a
very not useful <nil>
webhooks: add User-Agent to outgoing requests
client: add User-Agent to outgoing requests
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>
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>
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>