75 Commits

Author SHA1 Message Date
perennial 352ab0ce90 wip: rm PIXIVFE_TZ and replace with pixivfe-TZ cookie 2024-12-05 10:56:50 +11:00
perennial badc7ad82f import "time/tzdata" 2024-12-05 09:29:06 +11:00
perennial 905b0379ef add PIXIVFE_TZ env var 2024-12-05 09:22:49 +11:00
perennial 780ea8c339 cache-control tests 2024-12-04 12:27:57 +11:00
VnPower 434170d176 Change hyperlinks according to the ownership change 2024-12-02 20:55:07 +07:00
perennial 52fdb0fd51 tag search by popular, experimental
update frontend for popular search

add PIXIVFE_POPULAR_SEARCH_ENABLED option
2024-10-25 21:42:27 +11:00
VnPower 8c11db54be Bump version to v2.10 2024-10-22 19:44:43 +07:00
perennial c8e58640d8 set default config as constants 2024-10-21 15:56:07 +11:00
perennial 7095acd437 rm go-retryablehttp 2024-10-21 15:05:46 +11:00
perennial af3506efe4 add PIXIVFE_CACHE_ENABLED 2024-10-16 21:58:20 +11:00
perennial cec9ca0ff1 docs: update caching section 2024-10-16 15:01:55 +11:00
perennial 31dc0d660d add support for ShortTTL 2024-10-16 02:25:03 +11:00
perennial 1e38499e40 drop default CacheSize to 100 2024-10-16 02:04:36 +11:00
perennial 913f72d462 implement caching configuration 2024-10-16 01:31:16 +11:00
perennial 5a8ce89d74 check for when both Host and UnixSocket are set 2024-10-15 19:59:00 +11:00
perennial b6965679ba dont panic when no port is set 2024-10-15 19:48:28 +11:00
perennial 7f1a319e09 fix spurious error when s.ProxyServer_staging == BuiltinProxyUrl 2024-10-15 19:40:29 +11:00
perennial 2077556172 actually validate custom image server before setting it 2024-10-15 19:27:31 +11:00
perennial ba76469422 logging configuration 2024-10-13 15:26:34 +11:00
iacore 2f4e95d002 Capture error strings for i18n 2024-10-05 15:19:22 +00:00
iacore 7cb6ac50c6 simplify proxy checker 2024-10-04 16:04:08 +00:00
perennial b3b8d5117c revert to net/url in config.go 2024-09-29 20:10:38 +10:00
iacore 5f8b659b49 use urlx.Parse 2024-09-28 23:12:00 +00:00
perennial 32739f7dad Add test case for LoadConfig 2024-09-25 17:20:19 +10:00
perennial 10250205f0 Add test case for parseRevision 2024-09-25 17:20:19 +10:00
perennial c03355d939 Create unit tests for validateURL 2024-09-25 17:20:19 +10:00
perennial 5d4cae7505 Require both scheme and host in validateURL
Prevents random strings like "hrpuohreoghpaeuog" from being
considered valid.
2024-09-25 17:20:19 +10:00
perennial 64761db5c1 Remove duplicate log message on startup 2024-09-25 17:20:19 +10:00
iacore 079993e801 Use proper rate limiter
Rename package handlers to middleware, since most are middleware

router.go is not middleware. can be moved out to router/router.go
2024-09-25 05:05:04 +00:00
perennial c3bb477132 Rename token management environment variables
This commit clarifies the purpose of certain environment variables
by explicitly associating them with token management. The variables
PIXIVFE_MAX_RETRIES, PIXIVFE_BASE_TIMEOUT, and PIXIVFE_MAX_BACKOFF_TIME
are now prefixed with "TOKEN_" to better distinguish them from API-level
settings.

The ServerConfig struct, configuration loading, logging,
and documentation have been updated accordingly.
2024-09-24 19:32:14 +10:00
perennial ae031dbd8b Add option to disable image proxy checker
This commit introduces a new configuration option to disable the image proxy
checker. A new environment variable PIXIVFE_PROXY_CHECK_ENABLED and
corresponding ServerConfig field are added. The main.go file is updated
to conditionally initialise the proxy checker based on this setting.

Documentation is also updated to explain the new configuration options.
2024-09-24 19:08:40 +10:00
perennial 7473aa14bd Run gofmt 2024-09-23 22:35:35 +10:00
perennial 7fcec3ff75 Add unit tests for user_agent_list 2024-09-23 22:35:20 +10:00
perennial d1534682e2 Implement random User-Agent selection
This commit introduces a mechanism for randomly selecting User-Agents
from a predefined list to be used for requests to the Pixiv API.

References to setting a custom User-Agent via the PIXIVFE_USERAGENT
environment variable have been removed as it is no longer used.
2024-09-23 22:30:26 +10:00
perennial 7a9216a165 Add "dirty" flag to revision for uncommitted changes 2024-09-22 21:09:02 +10:00
perennial 6f7ff6fe47 Improve error handling and add fallbacks for config
This commit improves the error handling in the configuration loading
process, specifically for URL validations.

It replaces panic calls with proper error returns and adds
fallback mechanisms for invalid proxy server and repo URLs.

Warning logs are now used for these configuration issues.
2024-09-22 20:57:29 +10:00
perennial 8a2f817ae6 Add configurable repository URL
This commit introduces a new PIXIVFE_REPO_URL configuration option,
allowing users to specify a custom repository URL.

The about page now uses this configurable URL, and the configuration
loading process has been updated to validate and handle the new option.

Documentation has been updated to reflect these changes.
2024-09-22 20:57:29 +10:00
perennial d977ae7d62 Improve version and revision info handling
Modify the REVISION variable to include both commit date and hash.
Update config package to parse and store revision components separately.
Modify about page and routes to display more detailed revision information.
2024-09-22 20:57:28 +10:00
VnPower 7af2e9a500 Merge pull request 'Display revision on about page' (#104) from jackyzy823/PixivFE:about-revision into v2
Reviewed-on: https://codeberg.org/VnPower/PixivFE/pulls/104
2024-09-21 14:40:33 +00:00
perennial 6a6fb803a4 Remove redundant responseSaveLocation variable
Replace local responseSaveLocation variable in audit_init.go
with direct references to config.GlobalConfig.ResponseSaveLocation.
2024-09-20 18:09:34 +10:00
perennial b480df0e7f Add configurable response save location
Introduce a new ResponseSaveLocation config option to flexibly store
API responses during development. Move InDevelopment flag to a
dedicated "Development options" section in the config struct.
Update audit package to use the new configurable save location instead
of a hardcoded path.
2024-09-20 16:09:41 +10:00
perennial 3d6f5ace8c fix type bug 2024-09-19 16:41:52 +10:00
perennial bc19f485a2 Add separate API request level backoff mechanism
Implement new backoff settings for API requests, distinct from token
management backoff.

Update config, core request handling, and documentation to reflect the
new API request backoff mechanism. Refactor TokenManager to use the
manager's baseTimeout instead of individual token timeouts.
2024-09-19 16:27:22 +10:00
perennial 54314d465c Implement token management and request retry system
Introduce a new TokenManager to handle token rotation, status
tracking, and automatic retries with exponential backoff for API
requests. This change aims to improve the reliability API
interactions by intelligently managing tokens and gracefully
handling request failures.

Update API request functions to utilise the new TokenManager. This
commit also adds configuration options for max retries, base timeout,
and max backoff time to fine-tune the retry behavior.
2024-09-18 14:49:18 +10:00
jackyzy823 f53e1c3e4d Display revision on about page 2024-09-18 00:22:55 +08:00
VnPower 08f43dfbcf Bump version 2024-09-17 21:33:37 +07:00
perennial c72bc08f02 run make fmt 2024-09-17 15:55:11 +10:00
VnPower c5b3805aa6 Add token validation 2024-09-16 19:10:55 +07:00
perennial 1aca710908 change wording 2024-09-14 18:06:20 +10:00
perennial ecbeaeec67 round-robin LB as default case 2024-09-14 14:41:51 +10:00