81 Commits

Author SHA1 Message Date
yusing
4ec352f1f6 refactor(homepage/icon): check service health before fetching icons and add retry logic
The icon fetching logic now checks if the target service is healthy before
attempting to fetch icons. If the health monitor reports an unhealthy status,
the function returns HTTP 503 Service Unavailable instead of proceeding.

Additionally, the icon cache lookup now includes infinite retry logic with a
15-second backoff interval, improving resilience during transient service
outages. Previously, failed lookups would not be retried.

The `route` interface was extended with a `HealthMonitor()` method to support
the health check functionality.
2026-01-09 21:48:35 +08:00
yusing
df530245bd fix(homepage/icon): set icons provider on init (introduced in 74f97a6621) 2026-01-09 21:41:32 +08:00
yusing
74f97a6621 refactor(homepage): reorganize icons into dedicated package structure
Split the monolithic `internal/homepage` icons functionality into a structured package hierarchy:

- `internal/homepage/icons/` - Core types (URL, Key, Meta, Provider, Source, Variant)
- `internal/homepage/icons/fetch/` - Icon fetching logic (content.go, fetch.go, route.go)
- `internal/homepage/icons/list/` - Icon listing and search (list_icons.go, list_icons_test.go)

Moved icon-related code from `internal/homepage/`:
- `icon_url.go` → `icons/url.go` (+ url_test.go)
- `content.go` → `icons/fetch/content.go`
- `route.go` → `icons/fetch/route.go`
- `list_icons.go` → `icons/list/list_icons.go` (+ list_icons_test.go)

Updated all consumers to use the new package structure:
- `cmd/main.go`
- `internal/api/v1/favicon.go`
- `internal/api/v1/icons.go`
- `internal/idlewatcher/handle_http.go`
- `internal/route/route.go`
2026-01-09 12:06:54 +08:00
yusing
4275cdae38 docs: enhance package README documentation 2026-01-09 10:27:55 +08:00
yusing
e9d7edef12 docs: add per package README for implementation details (AI generated with human review) 2026-01-08 23:39:19 +08:00
yusing
89a4ca767d fix(homepage): improve alphabetical sorting by normalizing item names (#181)
- Updated the sorting function to use Title case for item names to ensure consistent alphabetical ordering.
2026-01-01 12:31:36 +08:00
yusing
93af695e95 refactor(list_icons): interning app category names to save memory 2025-12-20 20:43:21 +08:00
yusing
c143593284 fix(icons): add handling for dark icons for walkxcode 2025-12-15 15:42:59 +08:00
yusing
31bf889d4a refactor(favicon): enhance FindIcon function to support icon variants
- Updated FindIcon to accept an additional variant parameter for improved icon fetching.
- Adjusted FavIcon and GetFavIconFromAlias functions to utilize the new variant handling logic.
2025-12-15 14:54:05 +08:00
yusing
baa7e72ad6 refactor(icon): improve handling in WithVariant 2025-12-15 14:42:31 +08:00
yusing
d319ee99ad fix(favicon): correct icon cache key in FindIcon method 2025-12-15 14:31:16 +08:00
yusing
ab58559afc refactor(icon): add variant handling for absolute/relative icons in WithVariant method 2025-12-15 14:30:31 +08:00
yusing
a0c589c546 feat(favicon): add variant support for favicons
- Introduced a new Variant field in GetFavIconRequest to specify icon variants (light/dark).
- Updated GetFavIconFromAlias function to handle the variant when fetching favicons.
- Added WithVariant method in IconURL to manage icon variants effectively.
2025-12-15 12:28:03 +08:00
yusing
3b2ae5dbd6 refactor: move some utility functions to goutils and update references 2025-12-04 12:17:33 +08:00
yusing
6f75bb7593 refactor(api): replace apitypes module and fix swagger generation 2025-10-26 01:05:18 +08:00
yusing
f8716d990e perf(pool): split bytes pool into tiered sized and unsized pools
- Remove BytesPoolWithMemory; split into UnsizedBytesPool and 11-tier SizedBytesPool
- Track buffer capacities with xsync Map to prevent capacity leaks
- Improve buffer reuse: split large buffers and put remainders back in pool
- Optimize small buffers to use unsized pool
- Expand test coverage and benchmarks for various allocation sizes
2025-10-18 17:38:01 +08:00
yusing
e13b18621d fix(favicon): add status code in error message 2025-10-15 00:11:38 +08:00
yusing
848f26aa86 test(list-icon): fix tests regarding previous changes 2025-10-11 19:05:49 +08:00
yusing
ac8ad149b8 fix(icons): list icon logic 2025-10-11 13:07:50 +08:00
yusing
b23c3f1c3b refactor(icons): replace mutex-based cache with atomic synk.Value
- Remove sync.RWMutex and Cache struct in favor of atomic Value
  - Implement background goroutine for periodic icon updates
  - Add backward compatibility for old cache format
  - Improve concurrent access to icon cache
  - Simplify ListAvailableIcons()
2025-10-10 23:21:30 +08:00
yusing
5acc4c3894 fix(homepage): logic error in ListAvailableIcons, ensure the cache is ready in GetHomepageMeta 2025-10-10 09:27:23 +08:00
yusing
a150f1a628 refactor(config): reduce references to config.GetInstance() 2025-10-07 21:49:00 +08:00
yusing
6051f75145 refactor(favicon): improve cache and error handling 2025-10-05 20:37:27 +08:00
yusing
f411e17d80 feat(json): improve JSON performance with bytedance/sonic 2025-09-29 17:43:34 +08:00
yusing
2a05c6a630 refactor: move websocket package and some http utils to seperate repo 2025-09-27 14:16:42 +08:00
yusing
6776f20332 refactor: move task, error and testing utils to separte repo; apply gofumpt 2025-09-27 13:41:50 +08:00
yusing
22bcf1201b refactor: move some io, http and string utils to separate repo 2025-09-27 12:46:41 +08:00
yusing
d406b940d9 style: fix some golangci-lint warnings 2025-09-26 23:45:59 +08:00
yusing
f9affba9fc refactor(modules): replace github.com/yusing/go-proxy with github.com/yusing/godoxy 2025-09-22 16:44:59 +08:00
yusing
2c290a3916 feat(homepage): enhance homepage functionality with new item click tracking, sort methods and category management
- Added ItemClick endpoint to increment item click counts.
- Refactored Categories function to dynamically generate categories based on available items.
- Introduced sorting methods for homepage items and categories.
- Updated item configuration to include visibility, favorite status, and sort orders.
- Improved handling of item URLs and added support for websocket connections in item retrieval.
2025-09-13 23:52:54 +08:00
yusing
a9847b6f81 refactor(homepage): improve icon search functionality and add case-insensitive string matching 2025-09-13 22:22:23 +08:00
yusing
a057f0e956 fix(homepage): incorrect url
- fixed url being overridden
- fixed sub-subdomain being stripped
- fixed empty url for routes with FQDN aliases
2025-08-19 21:01:04 +08:00
yusing
35b0dcb418 chore(todo): remove completed TODOs 2025-08-17 17:10:21 +08:00
yusing
353f818b41 fix(icons): update selfhstIcons URL to point to the raw GitHub content 2025-08-17 16:39:11 +08:00
yusing
90efa36193 refactor(api): better type safety, split homepage override apis, fixed favicon api docs 2025-08-16 19:57:14 +08:00
yusing
35a3e3fef6 refactor(api): restructured API for type safety, maintainability and docs generation
- These changes makes the API incombatible with previous versions
- Added new types for error handling, success responses, and health checks.
- Updated health check logic to utilize the new types for better clarity and structure.
- Refactored existing handlers to improve response consistency and error handling.
- Updated Makefile to include a new target for generating API types from Swagger.
- Updated "new agent" API to respond an encrypted cert pair
2025-08-16 13:04:05 +08:00
yusing
47910774dd fix(homepage): missing homepage.url option 2025-07-13 15:47:26 +08:00
yusing
72dc783e23 fix(icons): update selfh.st icon json url 2025-07-01 02:14:27 +08:00
yusing
421aaecba4 refactor: rename net/types to nettypes 2025-06-08 17:59:48 +08:00
Yuzerion
4a8bd48ad5 fix: optimize memory usage, fix agent and code refactor (#118)
* refactor: simplify io code and make utils module independent

* fix(docker): agent and socket-proxy docker event flushing with modified reverse proxy handler

* refactor: remove unused code

* refactor: remove the use of logging module in most code

* refactor: streamline domain mismatch check in certState function

* tweak: use ecdsa p-256 for autocert

* fix(tests): update health check tests for invalid host and add case for port in host

* feat(acme): custom acme directory

* refactor: code refactor and improved context and error handling

* tweak: optimize memory usage under load

* fix(oidc): restore old user matching behavior

* docs: add ChatGPT assistant to README

---------

Co-authored-by: yusing <yusing@6uo.me>
2025-05-25 09:45:57 +08:00
yusing
53acf75c04 fix(homepage): item not hiding after config override 2025-05-10 18:14:10 +08:00
yusing
cf30fe6cfc feat(homepage): custom app sort order 2025-05-10 17:36:51 +08:00
yusing
c05059765d style: coed cleanup and fix styling 2025-05-10 10:46:31 +08:00
yusing
b8c0961de3 test: fix failed tests after code changes 2025-05-05 20:05:47 +08:00
yusing
8ef8015a7f feat: improved icon and category lookup mechanism 2025-05-04 09:37:15 +08:00
yusing
98e90d7a0b refactor: improve error handling and response formatting in API 2025-05-03 17:41:10 +08:00
yusing
28d9a72908 fix: icon not exists error on loading icon cache 2025-05-02 05:19:16 +08:00
yusing
cd4c843025 feat: light/dark variant icons and selfh.st tag as default category
- code refactor
- reduce memory usage
2025-05-02 03:38:50 +08:00
yusing
8da63daf02 refactor: simplify and remove duplicated code for icon caching 2025-04-28 11:22:49 +08:00
yusing
8363dfe257 fix: json marshal/unmarshal 2025-04-25 08:25:37 +08:00