Moode Forum
Self Hosting Connectivity Check on MoodeOS - Printable Version

+- Moode Forum (https://moodeaudio.org/forum)
+-- Forum: moOde audio player (https://moodeaudio.org/forum/forumdisplay.php?fid=3)
+--- Forum: Support (https://moodeaudio.org/forum/forumdisplay.php?fid=7)
+--- Thread: Self Hosting Connectivity Check on MoodeOS (/showthread.php?tid=5446)



Self Hosting Connectivity Check on MoodeOS - psychofaktory - 03-20-2023

Hello,

ok, this one is a bit special Blush


I'm using two of my Moode installations on portable music boxes with no internet.
The boxes are headless and for controlling I use the access point feature, connect my android 13 smartphone with its wifi and use the BubbleUPnP app for controling.

Unfortunately, Android checks the connectivity of the Moode WLAN when connecting.
Specifically, the system tries to reach the address https://connectivitycheck.gstatic.com/generate_204.
If this address cannot be reached via the WLAN, the mobile network is used despite the WLAN connection.
In this case, a connection to Moode via the WLAN is no longer possible.
So far, I always had to deactivate the mobile data in this scenario before I could control Moode.

Now I want to adjust Moode so that my smartphone "thinks" it has Internet connectivity when it is connected to its WLAN.
I have also found nice instructions for this:
https://malv.in/posts/2018-11-08-self-hosting-the-wifi-connectivity-check-for-android.html
https://foxdogstudios.com/blog/making-phones-believe-the-wifi-has-internet

However, I don't know how to implement this in Moode.
Can someone help me to make the right adjustments here?


I have set up entries for dnsmasq and in the hosts file already. so dns requests to connectivitycheck.gstatic.com redirects to localhost.
But I don't know how adapt the webserver.


Code:
sudo nano /etc/dnsmasq.d/connectivitycheck.gstatic.com
    address=/connectivitycheck.gstatic.com/127.0.0.1

Code:
sudo nano /etc/hosts
    127.0.0.1               connectivitycheck.gstatic.com



RE: Self Hosting Connectivity Check on MoodeOS - TheOldPresbyope - 03-21-2023

@psychofaktory 

You've already done the heavy lifting by installing dnsmasq and configuring it and the hosts file.

nginx is used by moOde to serve its webUI, you should need only adjust it to support the new virtual hosts. To do this the nginx "way", create a file in /etc/nginx/sites-available with a suggestive name such as walled-garden.conf with contents similar to what is shown in your second hyperlinked reference, i.e.


Code:
# =====================================================================
# = android walled garden hack                                        =
# =====================================================================

server {
   server_name
       clients3.google.com
       clients.l.google.com
       connectivitycheck.android.com
       connectivitycheck.gstatic.com
       play.googleapis.com
       ;
   listen 80;

   location /generate_204 {
       return 204;
   }
}


Obviously you need include only the domains you've added via dnsmasq. I suspect just connectivitycheck.gstatic.com may be sufficient.

The file should have the same permissions as the files already in the directory.

Now, in the parallel /etc/nginx/sites-enabled directory, create a symlink to the file you just created (see the existing /etc/nginx/sites-enabled/moode-http.conf symlink as an example.

Finally, restart the nginx service. you should be good to go (and let me know either way).


As an aside, it's true that Android contains code to check for Internet connectivity but various handset vendors treat the results differently.

For example, my Google Pixel 6a phone (also Android 13) will say of my moOde AP "This network has no internet access. Stay connected?" I can choose yes (and choose to tell it to remember I said so) and then the moOde webUI is fully performant on the phone.

Regards,
Kent


RE: Self Hosting Connectivity Check on MoodeOS - psychofaktory - 03-21-2023

(03-21-2023, 06:08 PM)TheOldPresbyope Wrote: @psychofaktory 

You've already done the heavy lifting by installing dnsmasq and configuring it and the hosts file.

nginx is used by moOde to serve its webUI, you should need only adjust it to support the new virtual hosts. To do this the nginx "way", create a file in /etc/nginx/sites-available with a suggestive name such as walled-garden.conf with contents similar to what is shown in your second hyperlinked reference, i.e.


Code:
# =====================================================================
# = android walled garden hack                                        =
# =====================================================================

server {
   server_name
       clients3.google.com
       clients.l.google.com
       connectivitycheck.android.com
       connectivitycheck.gstatic.com
       play.googleapis.com
       ;
   listen 80;

   location /generate_204 {
       return 204;
   }
}


Obviously you need include only the domains you've added via dnsmasq. I suspect just connectivitycheck.gstatic.com may be sufficient.

The file should have the same permissions as the files already in the directory.

Now, in the parallel /etc/nginx/sites-enabled directory, create a symlink to the file you just created (see the existing /etc/nginx/sites-enabled/moode-http.conf symlink as an example.

Finally, restart the nginx service. you should be good to go (and let me know either way).
Thanks for your help Kent!

I have followed the steps as described and just tested the connection.
When trying to connect to the access point, I am now prompted to log into the network.
I am then redirected to a captive portal "connectivitycheck.gstatic.com". There I can choose "do not connect to the network" or "connect to the network as is".
If I choose the latter option here, I am fully connected to the network and Internet availability via the network is also displayed.

However, I was already connected without the newly created site "walled-garden.conf" and the creation of the symlink.

What I wanted to achieve is that the connection is established automatically without the need for a manual login.


(03-21-2023, 06:08 PM)TheOldPresbyope Wrote: As an aside, it's true that Android contains code to check for Internet connectivity but various handset vendors treat the results differently.

For example, my Google Pixel 6a phone (also Android 13) will say of my moOde AP "This network has no internet access. Stay connected?" I can choose yes (and choose to tell it to remember I said so) and then the moOde webUI is fully performant on the phone.
I know this function and it is also supported by my smartphone.

If I select "Stay connected" here, I can also access the web interface.
But what does not work is UPnP in this state.
Here Android wants a "full" network connection.