shiori/internal/webserver
Tomi lla dde1b44e77
fix(log): record user real ip from headers (#603)
* fix(real_ip): get user real ip from headers of request

* fix(real_ip): compatible with those header with multiple IP values separated by commas

* test(real_ip): add benchmark for IPv4 and IPv6 private address check

* fix(real_ip): check empty, then remove leading and tailing comma char, finally locate first IP field

* test(real_ip): move checker logic into utils and add more unit test cases

* test(real_ip): write unit tests covering all code branches of the `util-ip` module

* refactor(real_ip): use one-line `testify.assert.Panics` to capture intended panic in test case

* chore(real_ip): add module private variable `UserRealIpHeaderCandidates`

put those headers together, make it easy to manage in one place

* doc(real_ip): write docstring for each function in the `utils-ip` module

* chore(real_ip): choose more concrete and unambiguous name for test helper function

It is to avoid polluting the module name-space with too general names.

* chore(naming): change function names according to code style

* refactor(real_ip): simplify the code indicated by 'gosimple' and `golangci`

* chore(naming): rename the `utils-ip` file to `utils_ip` to match with the rest of the file structure

---------

Co-authored-by: Felipe Martin <812088+fmartingr@users.noreply.github.com>
2023-06-11 21:25:23 +02:00
..
assets-dev.go Initial new web interfaces 2019-05-27 17:01:53 +07:00
assets-prod.go replace assets generation with embed (#423) 2022-05-26 19:36:23 +02:00
handler-api-ext.go fix: browser ext cannot archive and update bookmark. (#560) 2023-02-05 10:58:00 +01:00
handler-api.go use UTC for cookie expiry date in backend (#566) 2023-02-05 10:56:34 +01:00
handler-ui.go refactor:pass ctx to db layer, return err instead of recover panic (#450) 2022-09-30 12:19:36 +02:00
handler.go fix(api-ext): use same save logic as the api (#518) 2022-10-15 14:16:12 +02:00
server.go fix(log): record user real ip from headers (#603) 2023-06-11 21:25:23 +02:00
utils.go refactor:pass ctx to db layer, return err instead of recover panic (#450) 2022-09-30 12:19:36 +02:00
utils_ip.go fix(log): record user real ip from headers (#603) 2023-06-11 21:25:23 +02:00
utils_ip_test.go fix(log): record user real ip from headers (#603) 2023-06-11 21:25:23 +02:00