YunoHost-Apps / hotspot_ynh

Wifi Hotspot app for YunoHost
GNU Affero General Public License v3.0
40 stars 19 forks source link

Remove multi SSID feature #100

Open hidrarga opened 11 months ago

hidrarga commented 11 months ago

During the YunoCamp with @alexAubin, we were wondering if we should keep the multi SSID feature (i.e. having more than one Wifi hotspot). This feature makes the code really complex for what I guess is a pretty rare use case. In general, people have a single SSID and that's it…

What are your thoughts about this? Should we keep this feature?

Thatoo commented 11 months ago

On the contrary, I'd like to be able to assign one SSID per device which is unfortunately not the case today.

hidrarga commented 11 months ago

I think a solution would be to have one instance of this app per SSID or device. This would make the code simplier, but this requires a big refactoring…

hidrarga commented 10 months ago

I made the PR #107 for one hotspot app per device, but with a single SSID per device. It still needs some testing though ^^

I think we could add an option to enable a guest hotspot, because it seems to be the common usage for multiple SSID.

Thatoo commented 10 months ago

I'll test it this week-end. Is there anything you want me to do in particular during my test?

hidrarga commented 10 months ago

Thanks! I tried with two antenna, the only issue I met is that the first hotspot is down after installing the second hotspot, because usb devices are being reloaded during install. So I have to manually restart the hotspot for now.

I didn't test internet connection from the wifi hotspot yet, so you can do that :) You could also test if everything is ok when we stop one hotspot, but keep the other active, etc. because there some firewall rules that are common to all hotspot. Normally I made sure the firewall rules arern't removed if at least one hotspot is still running.

Thatoo commented 10 months ago

I deleted my original hotspot app. I installed a first time buy ssh and command line this version https://github.com/YunoHost-Apps/hotspot_ynh/tree/remove_multissid , then I installed a second one throught GUI. Both installation were ok. Hotspot1 was configured with wlan0, the internal wifi of Rpi4 Hotspot2 wasn't configured with anything and I should set it up with wlan1. It failed : https://paste.yunohost.org/raw/sonewewila . Then I realised that I didn't have internet on the Hotspot1 because of DNS issue. The DNS was 10.0.242.1. I set up DNS to some others and got internet. I did setup also for htospot2 and it change the error to https://paste.yunohost.org/raw/etecohujus . I could not start hotspot2, even if I stop hotspot1.

Thatoo commented 10 months ago

I removed hotspot2 and I switched hotspot1 to use wlan1 (the usb device). Internet was working. I installed hotspot2 again to set it with wlan0 then. What is weird is that at install it doesn't ask me which device to choose (only after installation). Impossible to connect to hotspost1 (wlan1) anymore. Hotspot2 has no internet. Reloading hotspot1 doesn't do anything and if I try to go in the settings and save the congig, it says "No wifi antenna has been detected! If you use a wifi USB dongle and that this one is not listed here, try to unplug and replug it, then reload this page.". I set dns to hotspot2 (wlan1) and got internet. I unplugged and replugged the usb device (wlan1) and I went back to hotspot1 to see this error :

wlan1: AP-STA-DISCONNECTED b8:81:98:27:95:34
wlan1: INTERFACE-DISABLED
wlan1: interface state ENABLED->DISABLED
wlan1: AP-DISABLED
wlan1: CTRL-EVENT-TERMINATING
nl80211: deinit ifname=wlan1 disabled_11b_rates=0
Stopping LSB: Advanced IEEE 802.11 management daemon...
hostapd@hotspot.service: Succeeded.
Stopped LSB: Advanced IEEE 802.11 management daemon.
hostapd@hotspot.service: Consumed 1.485s CPU time.

I tried to save the settings and it loaded and internet was working.

So now, I have indeed two SSID wifi woring both on each device and I have internet connecting to either both of them.

Thatoo commented 10 months ago

I can't say why it has not work at first and why it has not work the second time neither why it has worked the third time but it can work at the end.

hidrarga commented 9 months ago

Sorry, I was quite busy these past weeks…

Hotspot2 wasn't configured with anything and I should set it up with wlan1. It failed : https://paste.yunohost.org/raw/sonewewila .

Hm that's strange :/ I'll try to reproduce the bug on my board.

Then I realised that I didn't have internet on the Hotspot1 because of DNS issue. The DNS was 10.0.242.1. I set up DNS to some others and got internet.

Yes, that's the expected DNS for hotspot1, it will use the DNS from your board. If you don't have internet with that, maybe something else went wrong…

I did setup also for htospot2 and it change the error to https://paste.yunohost.org/raw/etecohujus . I could not start hotspot2, even if I stop hotspot1.

Probably related to your first error, because hotspot2 couldn't be configured?

What is weird is that at install it doesn't ask me which device to choose (only after installation).

Yes, the hotspot app tries to detect the wireless device and pick one during install. I kept the behavior that was there before my changes. We could change that, but I don't think it's a real problem?

Impossible to connect to hotspost1 (wlan1) anymore. Hotspot2 has no internet.

Yeah, when we install the second hotspot, the script tries to reload the usb devices, but then the first hotspot doesn't work anymore. I didn't find a clean way to solve this bug yet.

hidrarga commented 9 months ago

Could you try again with the latest version @Thatoo ? Normally I fixed the DNS issues, so it should work with the default DNS resolver.

I noticed that both wifi networks aren't isolated though… For instance, one can ping a device connected to the second wifi from the first wifi.

I'm not sure I'm being very clear, but for instance:

It's clearly a firewall rule that is missing, but I don't know enough about firewall to solve that right away…

Thatoo commented 9 months ago

I'll try asap

Thatoo commented 9 months ago

Update to version 2.0.2~ynh1 ok. But I had to unplug and plug again the external antenna of hotspot 2 (wlan1). About DNS, if I remove DNS (to let yunohost use the default DNS resolver), I get an error :

image

even if I switch "Advanced settings" to no :

image

Thatoo commented 9 months ago

Saving the config is infinite, it remain at the state "Starting hotspot service if needed". By ssh, I can see that the service has been started,

configuration: unknown
description: Creates a Wi-Fi access point
last_state_change: 2023-10-08 12:59:34
start_on_boot: enabled
status: running

but

:~ $ sudo ps -ef | grep $(cat /var/run/moulinette_yunohost.lock)
root       607     1  1 12:33 ?        00:00:24 /usr/bin/python3 /usr/bin/yunohost-api
root     28363   607  0 12:57 ?        00:00:00 sh -c /bin/bash -x "./config" apply 7>&1
adminis+ 31821 30198  0 13:01 pts/1    00:00:00 grep --color=auto 607

and on the webgui, it remain at ""Starting hotspot service if needed"." so I have to kill 28363 to be able to regain control over yunohost. Otherwise, it works.

alexAubin commented 9 months ago

on the webgui, it remain at ""Starting hotspot service if needed"." so I have to kill 28363 to be able to regain control over yunohost. Otherwise, it works.

My bad, that bit should be fixed by the first commit in : https://github.com/YunoHost-Apps/hotspot_ynh/pull/114

hidrarga commented 9 months ago

But I had to unplug and plug again the external antenna of hotspot 2 (wlan1).

Yes, as I was saying I still need to fix that bit… :( It's a bit complex because it seems the app needs to refresh the list of available usb devices (I don't know why exactly), and the current way is to disable / enable existing devices… which makes the other hotspots to crash...

About DNS, if I remove DNS (to let yunohost use the default DNS resolver), I get an error :

Indeed, it should set back the default values (10.0.242.1 in your case). I'll fix that this week when i have some time :)