jcorporation / myMPD

myMPD is a standalone and mobile friendly web mpd client with a tiny footprint and advanced features.
https://jcorporation.github.io/myMPD/
GNU General Public License v3.0
412 stars 63 forks source link

IPv4-mapped address broken? #1066

Closed comburent closed 11 months ago

comburent commented 1 year ago

myMPD version: 11.0.0

Describe the bug

myMPD no longer responds on http://127.0.0.1 when bound to http://[::].

To Reproduce

Steps to reproduce the behavior:

  1. Launch myMPD.
  2. Run wget http://[::1] -O - | zcat | cut -c-70.
    
    $ wget http://[::1] -O - | zcat | cut -c-70
    --2023-07-18 21:11:14--  http://[::1]/
    Connecting to [::1]:80... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 16672 (16K) [text/html]
    Saving to: ‘STDOUT’

2023-07-18 21:11:14 (1.09 GB/s) - written to stdout [16672/16672]

<!DOCTYPE html><!--myMPD (c) 2018-2023 Juergen Mang mail@jcgames.de


3. Run `wget http://127.0.0.1 -O - | zcat | cut -c-70`.

$ wget http://127.0.0.1 -O - | zcat | cut -c-70 --2023-07-18 21:12:02-- http://127.0.0.1/ Connecting to 127.0.0.1:80... failed: Connection refused.

gzip: stdin: unexpected end of file


4. Run `wget http://localhost -O - | zcat | cut -c-70`.

$ wget http://localhost -O - | zcat | cut -c-70 --2023-07-18 21:13:15-- http://localhost/ Resolving localhost (localhost)... 127.0.0.1 Connecting to localhost (localhost)|127.0.0.1|:80... failed: Connection refused.

gzip: stdin: unexpected end of file


**Expected behavior**

Both `127.0.0.1` and `[::1]` can be connected to.

**Server platform:**
 - OS: Guix
 - OS version 772eaa69f31457aa19ca4dc4ce755c791d722054
 - Platform: x86_64
 - MPD version: N/A

**Debug logs (please attach if it can be useful)**

- myMPD log:

2023-07-18 20:45:57 NOTICE mympd Cache dir: "/var/cache/mympd" 2023-07-18 20:45:57 NOTICE mympd Work dir: "/var/lib/mympd" 2023-07-18 20:45:57 NOTICE mympd Config dir: "/var/lib/mympd/config" 2023-07-18 20:45:57 NOTICE mympd Setting loglevel to NOTICE 2023-07-18 20:45:57 NOTICE mympd Starting myMPD 11.0.0 2023-07-18 20:45:57 WARN mympd No valid nameserver found 2023-07-18 20:45:57 NOTICE mympd Listening on http://[::]:80 2023-07-18 20:45:57 NOTICE mympd "Serving files from "%s"": /gnu/store/2yisgplz600a7vsmbkfl0ap0xrki4cbh-mympd-11.0.0/var/empty 2023-07-18 20:45:57 NOTICE mympd Dropping privileges to user "mympd" 2023-07-18 20:45:57 NOTICE mympd Empty dir: "/var/lib/mympd/empty" created 2023-07-18 20:45:57 NOTICE mympd Pics dir: "/var/lib/mympd/pics" created 2023-07-18 20:45:57 NOTICE mympd Backgrounds dir: "/var/lib/mympd/pics/backgrounds" created 2023-07-18 20:45:57 NOTICE mympd Thumbnails dir: "/var/lib/mympd/pics/thumbs" created 2023-07-18 20:45:57 NOTICE mympd Scripts dir: "/var/lib/mympd/scripts" created 2023-07-18 20:45:57 NOTICE mympd Smartpls dir: "/var/lib/mympd/smartpls" created 2023-07-18 20:45:57 NOTICE mympd State dir: "/var/lib/mympd/state" created 2023-07-18 20:45:57 NOTICE mympd Default partition dir: "/var/lib/mympd/state/default" created 2023-07-18 20:45:57 NOTICE mympd Tags cache dir: "/var/lib/mympd/tags" created 2023-07-18 20:45:57 NOTICE mympd Webradio dir: "/var/lib/mympd/webradios" created 2023-07-18 20:45:57 NOTICE mympd Covercache dir: "/var/cache/mympd/covercache" created 2023-07-18 20:45:57 NOTICE mympd Webradiodb cache dir: "/var/cache/mympd/webradiodb" created 2023-07-18 20:45:57 NOTICE mympd Starting mympd api thread 2023-07-18 20:45:57 NOTICE mympd Starting webserver thread 2023-07-18 20:45:57 NOTICE mympd myMPD is ready 2023-07-18 20:45:57 NOTICE mympdapi Starting myMPD autoconfiguration 2023-07-18 20:45:57 NOTICE mympdapi Reading environment 2023-07-18 20:45:57 WARN mympdapi MPD autoconfiguration failed 2023-07-18 20:45:57 NOTICE mympdapi Setting mpd host to "localhost" 2023-07-18 20:45:57 NOTICE mympdapi Setting mpd port to "6600" 2023-07-18 20:45:57 NOTICE mympdapi Reading global states 2023-07-18 20:45:57 NOTICE mympdapi "default": Reading partition states from directory "/var/lib/mympd/state/default" 2023-07-18 20:45:57 NOTICE mympdapi "default": Connecting to "localhost:6600" 2023-07-18 20:45:57 ERROR mympdapi "default": Connection: Connection refused …


- Additional info:

root@komputilo ~# ss -tunlp Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
udp UNCONN 0 0 0.0.0.0:68 0.0.0.0: users:(("dhclient",pid=104,fd=7))
tcp LISTEN 0 3 [::]:80 [::]:
users:(("mympd",pid=102,fd=4))


**Configuration (please attach if it can be useful)**

- myMPD config

/var/lib/mympd# find ./config -type l | xargs tail -n +1 ==> ./config/ssl_port <== 443 ==> ./config/ssl <== false ==> ./config/scriptacl <== +127.0.0.1 ==> ./config/lualibs <== all ==> ./config/loglevel <== 5 ==> ./config/http_port <== 80 ==> ./config/http_host <== [::] ==> ./config/http <== true ==> ./config/covercache_keep_days <== 31


- Relevant [kernel sysctl](https://www.kernel.org/doc/html/latest/networking/ip-sysctl.html#proc-sys-net-ipv6-variables)

root@komputilo ~# cat /proc/sys/net/ipv6/bindv6only 0



**Additional context**

This wasn't the case for `10.2.6`.
jcorporation commented 1 year ago

I was not aware of that this worked before. IPv6 support is only roughly tested.

In my environment this does not work in any version. I tested with 11.0.0, 10.3.3 and 10.2.6.

jcorporation commented 1 year ago

I check this with the mongoose developers: https://github.com/cesanta/mongoose/discussions/2305

If this behavior is intended, I can add the option to define multiple listening addresses.

comburent commented 1 year ago

I was not aware of that this worked before. IPv6 support is only roughly tested.

In my environment this does not work in any version. I tested with 11.0.0, 10.3.3 and 10.2.6.

Did a test with mympd 10.3.3, same config:

root@komputilo ~# wget http://127.0.0.1 -O - | zcat | cut -c-70
--2023-07-19 02:55:24--  http://127.0.0.1/
Connecting to 127.0.0.1:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 15914 (16K) [text/html]
Saving to: ‘STDOUT’

-                   100%[===================>]  15.54K  --.-KB/s    in 0s      

2023-07-19 02:55:24 (947 MB/s) - written to stdout [15914/15914]

<!DOCTYPE html><!--myMPD (c) 2018-2023 Juergen Mang <mail@jcgames.de> 
root@komputilo ~# wget http://[::1] -O - | zcat | cut -c-70
--2023-07-19 02:55:32--  http://[::1]/
Connecting to [::1]:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 15914 (16K) [text/html]
Saving to: ‘STDOUT’

-                   100%[===================>]  15.54K  --.-KB/s    in 0s      

2023-07-19 02:55:32 (1.02 GB/s) - written to stdout [15914/15914]

<!DOCTYPE html><!--myMPD (c) 2018-2023 Juergen Mang <mail@jcgames.de> 
root@komputilo ~# 
jcorporation commented 1 year ago

My fault, i configured [::1] by mistake, with [::] it works in older versions. This is a mongoose bug.

jcorporation commented 1 year ago

It seems it was an intended behavior change of mongoose since version 7.10.

jcorporation commented 1 year ago

I fixed this meanwhile in my fork of mongoose. I leave this issue open, until the mongoose developers have decided how to deal with this.

comburent commented 1 year ago

Hi Jürgen,

On 2023-09-16 23:48, Jürgen Mang wrote:

Closed #1066 https://github.com/jcorporation/myMPD/issues/1066 as completed.

Did upstream reach any conclusion regarding this?

-- Cheers, Bruno.

jcorporation commented 1 year ago

Today there was an update from the mongoose developers.

jcorporation commented 11 months ago

There is now a compile time option to change the behavior. I wait for next mongoose release, that I can remove my quick fix and adapt the build options accordingly.