Web based family history software

lightbulb Idea small code change to handle IPv6 LLA

More
2 months 4 days ago #116601 by D4N5
unable to access a local install of webtrees from another device on LAN
(apart from assigning a static IPv4 address via a DHCP reservation)

example: myhost.local:8080/webtrees/

current behavior:

Error: Typed static property Fisharebest\Webtrees\I18N::$translator must not be accessed before initialization in /opt/homebrew/var/www/webtrees/app/I18N.php:343
Stack trace:
#0 /opt/homebrew/var/www/webtrees/app/Validator.php(382): Fisharebest\Webtrees\I18N::translate('The parameter \xE2...', 'client-ip')
#1 /opt/homebrew/var/www/webtrees/app/Http/Middleware/BadBotBlocker.php(1530): Fisharebest\Webtrees\Validator->string('client-ip')
#2 /opt/homebrew/var/www/webtrees/app/Http/Dispatcher.php(76): Fisharebest\Webtrees\Http\Middleware\BadBotBlocker->process(Object(Nyholm\Psr7\ServerRequest), Object(Psr\Http\Server\RequestHandlerInterface@anonymous))
#3 /opt/homebrew/var/www/webtrees/app/Http/Middleware/CompressResponse.php(56): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(Nyholm\Psr7\ServerRequest))
#4 /opt/homebrew/var/www/webtrees/app/Http/Dispatcher.php(76): Fisharebest\Webtrees\Http\Middleware\CompressResponse->process(Object(Nyholm\Psr7\ServerRequest), Object(Psr\Http\Server\RequestHandlerInterface@anonymous))
#5 /opt/homebrew/var/www/webtrees/app/Http/Middleware/ContentLength.php(31): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(Nyholm\Psr7\ServerRequest))
#6 /opt/homebrew/var/www/webtrees/app/Http/Dispatcher.php(76): Fisharebest\Webtrees\Http\Middleware\ContentLength->process(Object(Nyholm\Psr7\ServerRequest), Object(Psr\Http\Server\RequestHandlerInterface@anonymous))
#7 /opt/homebrew/var/www/webtrees/vendor/middlewares/client-ip/src/ClientIp.php(68): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(Nyholm\Psr7\ServerRequest))
#8 /opt/homebrew/var/www/webtrees/app/Http/Middleware/ClientIp.php(38): Middlewares\ClientIp->process(Object(Nyholm\Psr7\ServerRequest), Object(Psr\Http\Server\RequestHandlerInterface@anonymous))
#9 /opt/homebrew/var/www/webtrees/app/Http/Dispatcher.php(76): Fisharebest\Webtrees\Http\Middleware\ClientIp->process(Object(Nyholm\Psr7\ServerRequest), Object(Psr\Http\Server\RequestHandlerInterface@anonymous))
#10 /opt/homebrew/var/www/webtrees/app/Http/Middleware/PublicFiles.php(59): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(Nyholm\Psr7\ServerRequest))
#11 /opt/homebrew/var/www/webtrees/app/Http/Dispatcher.php(76): Fisharebest\Webtrees\Http\Middleware\PublicFiles->process(Object(Nyholm\Psr7\ServerRequest), Object(Psr\Http\Server\RequestHandlerInterface@anonymous))
#12 /opt/homebrew/var/www/webtrees/app/Http/Middleware/HandleExceptions.php(81): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(Nyholm\Psr7\ServerRequest))
#13 /opt/homebrew/var/www/webtrees/app/Http/Dispatcher.php(76): Fisharebest\Webtrees\Http\Middleware\HandleExceptions->process(Object(Nyholm\Psr7\ServerRequest), Object(Psr\Http\Server\RequestHandlerInterface@anonymous))
#14 /opt/homebrew/var/www/webtrees/app/Http/Middleware/SecurityHeaders.php(40): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(Nyholm\Psr7\ServerRequest))
#15 /opt/homebrew/var/www/webtrees/app/Http/Dispatcher.php(76): Fisharebest\Webtrees\Http\Middleware\SecurityHeaders->process(Object(Nyholm\Psr7\ServerRequest), Object(Psr\Http\Server\RequestHandlerInterface@anonymous))
#16 /opt/homebrew/var/www/webtrees/app/Http/Middleware/BaseUrl.php(64): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(Nyholm\Psr7\ServerRequest))
#17 /opt/homebrew/var/www/webtrees/app/Http/Dispatcher.php(76): Fisharebest\Webtrees\Http\Middleware\BaseUrl->process(Object(Nyholm\Psr7\ServerRequest), Object(Psr\Http\Server\RequestHandlerInterface@anonymous))
#18 /opt/homebrew/var/www/webtrees/app/Http/Middleware/ReadConfigIni.php(59): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(Nyholm\Psr7\ServerRequest))
#19 /opt/homebrew/var/www/webtrees/app/Http/Dispatcher.php(76): Fisharebest\Webtrees\Http\Middleware\ReadConfigIni->process(Object(Nyholm\Psr7\ServerRequest), Object(Psr\Http\Server\RequestHandlerInterface@anonymous))
#20 /opt/homebrew/var/www/webtrees/app/Http/Middleware/EmitResponse.php(52): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(Nyholm\Psr7\ServerRequest))
#21 /opt/homebrew/var/www/webtrees/app/Http/Dispatcher.php(76): Fisharebest\Webtrees\Http\Middleware\EmitResponse->process(Object(Nyholm\Psr7\ServerRequest), Object(Psr\Http\Server\RequestHandlerInterface@anonymous))
#22 /opt/homebrew/var/www/webtrees/app/Http/Middleware/ErrorHandler.php(38): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(Nyholm\Psr7\ServerRequest))
#23 /opt/homebrew/var/www/webtrees/app/Http/Dispatcher.php(76): Fisharebest\Webtrees\Http\Middleware\ErrorHandler->process(Object(Nyholm\Psr7\ServerRequest), Object(Psr\Http\Server\RequestHandlerInterface@anonymous))
#24 /opt/homebrew/var/www/webtrees/app/Http/Dispatcher.php(47): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(Nyholm\Psr7\ServerRequest))
#25 /opt/homebrew/var/www/webtrees/app/Webtrees.php(276): Fisharebest\Webtrees\Http\Dispatcher::dispatch(Array, Object(Nyholm\Psr7\ServerRequest))
#26 /opt/homebrew/var/www/webtrees/app/Webtrees.php(249): Fisharebest\Webtrees\Webtrees->httpRequest()
#27 /opt/homebrew/var/www/webtrees/index.php(24): Fisharebest\Webtrees\Webtrees->run('apache2handler')
#28 {main}

Root Cause:
IPv6 Link-local address (LLA) Scope ID
format:
[REMOTE_ADDR] => fe80::[interface-identifier]%[interface]
link-local addresses are not globally routable, operating systems use a Scope ID (typically the interface name) appended with a % character
before $ip is validated in vendor/middlewares/client-ip/src/ClientIp.php,
and $address is asserted in app/Http/Middleware/BadBotBlocker.php;
the $ip can be stripped of the scope ID via

$ip = strtok($ip, '%'); /* strip IPv6 scope ID */

As this is may be beneficial to others, I'd like to ask to have this modification added to the codebase

Please Log in or Create an account to join the conversation.

More
2 months 3 days ago #116602 by RickM
Replied by RickM on topic small code change to handle IPv6 LLA

unable to access a local install of webtrees from another device on LAN
(apart from assigning a static IPv4 address via a DHCP reservation)

example: myhost.local:8080/webtrees/


Root Cause:
IPv6 Link-local address (LLA) Scope ID
format:
[REMOTE_ADDR] => fe80::[interface-identifier]%[interface]
link-local addresses are not globally routable, operating systems use a Scope ID (typically the interface name) appended with a % character
before $ip is validated in vendor/middlewares/client-ip/src/ClientIp.php,
and $address is asserted in app/Http/Middleware/BadBotBlocker.php;
the $ip can be stripped of the scope ID via

$ip = strtok($ip, '%'); /* strip IPv6 scope ID */

As this is may be beneficial to others, I'd like to ask to have this modification added to the codebase
 
I am not going to pretend to fully understand what you have said and suggested.. And whilst IPv6 has been about for a while now, I have to admit knowing very little about such.. 

However, if indeed this is a fix for such is the issue and will have no impact on IPv4 things then grand IDEA and go for it..

@D4N5 you may want to create an 'issue' or PR on WebTrees GitHub page to get this into core code..
 

Rick M
Tauranga
Nu Tirani - New Zealand

Malkins in Nu Tirani - New Zealand
Webtrees v2.2.6
wt-malkins.alineofmalkins.com

Hosted by HostArmada on Litespeed Server using PHP v8.4.12

Offline: WebTrees v2.2.6
Laragon v8.6.1, PHP v8.5.2

Please Log in or Create an account to join the conversation.

  • bertkoor
  • bertkoor's Avatar
  • Offline
  • Platinum Member
  • Platinum Member
  • Greetings from Utrecht, Holland
More
2 months 3 days ago - 2 months 3 days ago #116604 by bertkoor
Replied by bertkoor on topic small code change to handle IPv6 LLA
Some thoughts:
  • If there's a bug in vendor/middlewares/client-ip/src/ClientIp.php, then we should not compensate for it ourselves, but it should be reported downstream:
    github.com/middlewares/client-ip
  • I'm not so sure the strtok function does what's needed here, since that returns an array of strings, not a single string. Since our Validator requires the value to be a string (and not an array) I don't see how this helps.
  • Stripping off "%{interface}" is taken care of in the next statement , when Factory::parseAddressString is called:
  • github.com/mlocati/ip-lib/blob/main/src/Address/IPv6.php#L154
  • webtrees wants to have a base_url variable filled in /data/config.ini.php. If it's not on localhost and not the ip address of the machine it runs on, then what have you put in there?
  • The error you had could be caused by other things, here is a previous analysis: www.webtrees.net/index.php/forum/webtree...orking-kinda?start=0
  • The premature usage of I18N is unfortunate. I'll make a PR to correct that.

stamboom.BertKoor.nl runs on webtrees v2.2.6
Last edit: 2 months 3 days ago by bertkoor.

Please Log in or Create an account to join the conversation.

More
2 months 3 days ago #116605 by D4N5
Replied by D4N5 on topic small code change to handle IPv6 LLA
Thanks for the info. I'll spend some time later today, dig a little deeper into the mlocati IPv6.php, and provide an update.

Please Log in or Create an account to join the conversation.

  • bertkoor
  • bertkoor's Avatar
  • Offline
  • Platinum Member
  • Platinum Member
  • Greetings from Utrecht, Holland
More
2 months 3 days ago #116606 by bertkoor
Replied by bertkoor on topic small code change to handle IPv6 LLA
Could you try the changes proposed in this PR, please?
github.com/fisharebest/webtrees/pull/5393/changes

stamboom.BertKoor.nl runs on webtrees v2.2.6

Please Log in or Create an account to join the conversation.

More
2 months 3 days ago #116607 by D4N5
Replied by D4N5 on topic small code change to handle IPv6 LLA
Hi Bert,
I can confirm that the changes in PR address the "$translator must not be accessed before initialization".

Response:
Fisharebest\Webtrees\Http\Exceptions\HttpBadRequestException: The parameter “client-ip” is missing. in /opt/homebrew/var/www/webtrees/app/Validator.php:428
Stack trace:
#0 /opt/homebrew/var/www/webtrees/app/Validator.php(382): Fisharebest\Webtrees\Validator->newBadRequestException('client-ip')
#1 /opt/homebrew/var/www/webtrees/app/Http/Middleware/BadBotBlocker.php(1530): Fisharebest\Webtrees\Validator->string('client-ip')
#2 /opt/homebrew/var/www/webtrees/app/Http/Dispatcher.php(76): Fisharebest\Webtrees\Http\Middleware\BadBotBlocker->process(Object(Nyholm\Psr7\ServerRequest), Object(Psr\Http\Server\RequestHandlerInterface@anonymous))
#3 /opt/homebrew/var/www/webtrees/app/Http/Middleware/CompressResponse.php(56): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(Nyholm\Psr7\ServerRequest))
#4 /opt/homebrew/var/www/webtrees/app/Http/Dispatcher.php(76): Fisharebest\Webtrees\Http\Middleware\CompressResponse->process(Object(Nyholm\Psr7\ServerRequest), Object(Psr\Http\Server\RequestHandlerInterface@anonymous))
#5 /opt/homebrew/var/www/webtrees/app/Http/Middleware/ContentLength.php(31): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(Nyholm\Psr7\ServerRequest))
#6 /opt/homebrew/var/www/webtrees/app/Http/Dispatcher.php(76): Fisharebest\Webtrees\Http\Middleware\ContentLength->process(Object(Nyholm\Psr7\ServerRequest), Object(Psr\Http\Server\RequestHandlerInterface@anonymous))
#7 /opt/homebrew/var/www/webtrees/vendor/middlewares/client-ip/src/ClientIp.php(68): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(Nyholm\Psr7\ServerRequest))
#8 /opt/homebrew/var/www/webtrees/app/Http/Middleware/ClientIp.php(38): Middlewares\ClientIp->process(Object(Nyholm\Psr7\ServerRequest), Object(Psr\Http\Server\RequestHandlerInterface@anonymous))
#9 /opt/homebrew/var/www/webtrees/app/Http/Dispatcher.php(76): Fisharebest\Webtrees\Http\Middleware\ClientIp->process(Object(Nyholm\Psr7\ServerRequest), Object(Psr\Http\Server\RequestHandlerInterface@anonymous))
#10 /opt/homebrew/var/www/webtrees/app/Http/Middleware/PublicFiles.php(59): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(Nyholm\Psr7\ServerRequest))
#11 /opt/homebrew/var/www/webtrees/app/Http/Dispatcher.php(76): Fisharebest\Webtrees\Http\Middleware\PublicFiles->process(Object(Nyholm\Psr7\ServerRequest), Object(Psr\Http\Server\RequestHandlerInterface@anonymous))
#12 /opt/homebrew/var/www/webtrees/app/Http/Middleware/HandleExceptions.php(82): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(Nyholm\Psr7\ServerRequest))
#13 /opt/homebrew/var/www/webtrees/app/Http/Dispatcher.php(76): Fisharebest\Webtrees\Http\Middleware\HandleExceptions->process(Object(Nyholm\Psr7\ServerRequest), Object(Psr\Http\Server\RequestHandlerInterface@anonymous))
#14 /opt/homebrew/var/www/webtrees/app/Http/Middleware/SecurityHeaders.php(40): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(Nyholm\Psr7\ServerRequest))
#15 /opt/homebrew/var/www/webtrees/app/Http/Dispatcher.php(76): Fisharebest\Webtrees\Http\Middleware\SecurityHeaders->process(Object(Nyholm\Psr7\ServerRequest), Object(Psr\Http\Server\RequestHandlerInterface@anonymous))
#16 /opt/homebrew/var/www/webtrees/app/Http/Middleware/BaseUrl.php(64): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(Nyholm\Psr7\ServerRequest))
#17 /opt/homebrew/var/www/webtrees/app/Http/Dispatcher.php(76): Fisharebest\Webtrees\Http\Middleware\BaseUrl->process(Object(Nyholm\Psr7\ServerRequest), Object(Psr\Http\Server\RequestHandlerInterface@anonymous))
#18 /opt/homebrew/var/www/webtrees/app/Http/Middleware/ReadConfigIni.php(59): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(Nyholm\Psr7\ServerRequest))
#19 /opt/homebrew/var/www/webtrees/app/Http/Dispatcher.php(76): Fisharebest\Webtrees\Http\Middleware\ReadConfigIni->process(Object(Nyholm\Psr7\ServerRequest), Object(Psr\Http\Server\RequestHandlerInterface@anonymous))
#20 /opt/homebrew/var/www/webtrees/app/Http/Middleware/EmitResponse.php(52): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(Nyholm\Psr7\ServerRequest))
#21 /opt/homebrew/var/www/webtrees/app/Http/Dispatcher.php(76): Fisharebest\Webtrees\Http\Middleware\EmitResponse->process(Object(Nyholm\Psr7\ServerRequest), Object(Psr\Http\Server\RequestHandlerInterface@anonymous))
#22 /opt/homebrew/var/www/webtrees/app/Http/Middleware/ErrorHandler.php(38): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(Nyholm\Psr7\ServerRequest))
#23 /opt/homebrew/var/www/webtrees/app/Http/Dispatcher.php(76): Fisharebest\Webtrees\Http\Middleware\ErrorHandler->process(Object(Nyholm\Psr7\ServerRequest), Object(Psr\Http\Server\RequestHandlerInterface@anonymous))
#24 /opt/homebrew/var/www/webtrees/app/Http/Dispatcher.php(47): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(Nyholm\Psr7\ServerRequest))
#25 /opt/homebrew/var/www/webtrees/app/Webtrees.php(276): Fisharebest\Webtrees\Http\Dispatcher::dispatch(Array, Object(Nyholm\Psr7\ServerRequest))
#26 /opt/homebrew/var/www/webtrees/app/Webtrees.php(249): Fisharebest\Webtrees\Webtrees->httpRequest()
#27 /opt/homebrew/var/www/webtrees/index.php(24): Fisharebest\Webtrees\Webtrees->run('apache2handler')
#28 {main}

Please Log in or Create an account to join the conversation.

  • bertkoor
  • bertkoor's Avatar
  • Offline
  • Platinum Member
  • Platinum Member
  • Greetings from Utrecht, Holland
More
2 months 3 days ago #116608 by bertkoor
Replied by bertkoor on topic small code change to handle IPv6 LLA
right, thank you !!

stamboom.BertKoor.nl runs on webtrees v2.2.6

Please Log in or Create an account to join the conversation.

Powered by Kunena Forum