21 Commits

Author SHA1 Message Date
8b7d8d0cc6 Assume no User-Agent is Kindle
All checks were successful
continuous-integration/drone/push Build is passing
2025-01-26 22:52:07 +01:00
f41910d9f4 Use ASCII7 file names to support Kobo web browser
Some checks failed
continuous-integration/drone/push Build is failing
2025-01-24 17:23:24 +01:00
Evan Buss
0f0540549d feat: request deduplication / debouncing
Kobo eReaders have a buggy browser that makes 2 requests for
the same HTTP resource when you click a link.

This change ensures that requests within a certain time frame
from the same IP, for the same path  / query params will only
be executed a single time.

We record the http request response and replay it for the second
request. If we get 2 simultaneous requests, we use the
sync/singleflight library to ensure only the first request is actually
processed. The second waits for the shared result of the first.

This probably adds latency since some requests are blocked while
we determine if we already have a cache entry, but for a simple
service like this I don't think it matters.
2024-08-18 18:37:42 +00:00
Evan Buss
33ab199b21 fix: panic when auth not specified 2024-08-11 20:20:41 +00:00
Evan Buss
9da7ea1bbc feat: environment configuration
Environment variables can now be used to configure any
config property including the feeds list.

This makes it easier to use in environments without access
to config files like GCR. Some may prefer not to have a separate
config file as well.

Also added build metadata to the docker image and binaries.
2024-08-11 18:47:46 +00:00
Evan Buss
041d8d5e22 fix: only try to split host/port for RemoteAddr 2024-08-10 21:52:53 +00:00
Evan Buss
6c41117af1 feat: automatic redirect if single configured feed 2024-08-10 21:36:52 +00:00
Evan Buss
e21a648506 feat: "local only" automatic authentication
Often you want to expose your library publicly, which requires
authentication to prevent unknown users from seeing your
content.

In my case, I also expose the library on a local domain using a local DNS server which doesn't have these security issues.

This change adds a `local_only` option to the feed auth
config which will only supply the provided username/password
when the request comes from a private IP address.

Omitting `local_only` or setting to false will keep the current
logic of sending the credentials no matter the origin of the
request.
2024-08-10 21:34:23 +00:00
Evan Buss
ccc6217014 feat: structured logging improvements
This change adds a child logger with request information to the
http request context. Also improved the log format for clarity.

- Unescaped the query string
- Use JSON log format when not in dev mode.
- Added request ip to the request child logger.
- The child logger is passed to the converter so we can associate
  any errors with a specific request / file.
- Add book file name as a logger attribute
- Add user agent header as a logger attribute
- Log the "X-Forwarded-For" header, falling back to RemoteAddr
2024-08-10 20:03:34 +00:00
Evan Buss
be78d83bd6 fix: single conversion at a time
See the notes for a full explanation, but basically
Kobo is making simultaneous requests and the
files were conflicting because there were 2 being
downloaded / converted at the same time which
resulted in unreliable behavior.

The solution is to protect the conversion
section to allow a single conversion to complete
before allowing the next one to start.
2024-07-14 19:56:00 +00:00
Evan Buss
56cb81bbb4 fix: return after handleError 2024-07-13 20:52:29 +00:00
Evan Buss
3d4af0bd61 refactor: cleanup
naming and other things
2024-07-13 19:37:57 +00:00
Evan Buss
349e86f0b1 feat: server-side feed credentials
If a feed requires credentials, OPDS Proxy can transparently
set them server side by reading the feed configuration.

This is useful in scenarios where the server operator sets up their
own authentication in front of OPDS Proxy and doesn't want to
have users remember separate credentials for each of the configured
feeds.
2024-07-13 18:24:10 +00:00
Evan Buss
28d3a7d761 feat: secure cookie keys config
If keys aren't specified they will be generated. The downside
of this is that the keys will change every server restart
which will invalidate previously generated cookies.

If the keys are specified in the config.yml, they are
used between restarts and all previously generated
cookies remain valid.
2024-07-13 18:01:19 +00:00
Evan Buss
9094e780d0 feat: search 2024-07-13 17:16:38 +00:00
Evan Buss
4f3948943a feat: cookie authentication
use encrypted cookies to authenticate
basic auth feeds. most eReader browsers
don't support basic auth
2024-07-13 01:55:48 +00:00
Evan Buss
f4408abeae refactor: dry conversion code 2024-07-12 19:36:08 +00:00
Evan Buss
b683d0c9b6 feat: set up configuration
A YAML file is used to set the available feeds.
The CLI args can set the port and the path to the YAML file.
2024-07-12 15:10:48 +00:00
Evan Buss
c00f6a9750 chore: rename project
No longer "Kobo" specific
2024-07-10 01:27:49 +00:00
Evan Buss
85c497f70c feat: kepub conversions
Working *.epub to *.kepub.epub file conversions when
using a Kobo reader. Updated docker file to include
`kepubify` to convert to kepub. If not available the
file is just sent without conversion.
2024-07-08 22:20:25 -04:00
Evan Buss
7e066fafee refactor 2024-07-06 17:59:54 -04:00