Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweaks upgrade - Networks Menu & NTP (#807) #828

Merged
merged 28 commits into from
May 19, 2023

Conversation

Aemiii91
Copy link
Member

No description provided.

XK9274 added 15 commits May 2, 2023 14:04
Tweaks changes:

# This PR adds the following features to Tweaks.

Network:
		- > HTTP Server
		- > SSH (Menu structure built but hidden due to issues with OpenSSH starting the root script on connection and crashing MainUI, this will be added when dropbear comes available)
		- > FTP (bftpd)
		- > Telnet
		- > WiFi Hotspot

Emulated time skip moved to new submenu header under System, new System menu structure:

System:
		- > Startup...
		- > Date and time...
			- > Set auto from network
			- > Select timezone
			- > Emulated time skip
		- > Save and exit when battery <4%
		- > Vibration intensity

# Global known issues:
- Main gets a bit sluggish when all services are running (especially opening/closing tweaks)

## HTTP Server
- Adds the filebrowser menu option already included in onion

# Known issues
- Binds to wlan0 IP address so does not function over hotspot without manual changes

## SSH
- Adds an SSH menu option
- Needs dropbear in .tmp_update/bin

# Known issues
- none yet encountered.

## FTP
- Adds the filebrowser menu option already included in onion (bftpd)

# Known issues
- Using filezilla as your client needs a slight change or bin files are corrupt on transfer (transfer -> transfer type -> binary)

## Telnet
- Adds telnet option (native telnet client)
- Runs with telnet -l sh

# Known issues
- It's telnet

## Personal hotspot:
Personal hotspot
- Adds a personal hotspot option under the Networks top level menu.
- Modified runtime.sh
- Modified tweaks source files
- Added bins / libs
- Generates logs in .tmp_update/logs/ that are cleared by runtime.sh in clear_logs
- Creates a hotspot on wlan1 to be used for any other network features (If the network feature has been built to bind against 0.0.0.0 and NOT the wlan0 address). Currently telnet and bftpd work across the hotspot however filebrowser binds against wlan0 so does not.
- Running on wlan1 gives us the benefit of having both wlan0 and wlan1 running over the same chip. (dual network)
- Starts/stops based on toggle position (persistent across boots)
- No bridging across wlan0 and wlan1

# hostapd config - this is the hotspot config
# For basic users:
- The SSID will be MiyooMiniAP
- The key will be the serial number without the preceeding 0's and no spaces. (example if the serial number is: 000028887D694890 the key will be 28887D694890) unless they've changed it in the file, in which case it'll be left alone.

For advanced users:
- SSID/Key can be configured in .tmp_update/config/hostapd.conf
- Minimum characters for key is 8

# dnsmasq config - this is the dhcp server config
For basic users:
- Gateway IP (The MMP address): 192.168.100.100
- DHCP range: 192.168.100.101-192.168.100.200 /24

For advanced users:
- IP and range can be configured in .tmp_update/config/dnsmasq.conf

# Known issues
I've found by disconnecting/re-connecting a fair few times windows sometimes does not want to connect, forgetting the network then retrying has resolved it.

# Files changed/added at install/run
new libs to .tmp_update/lib
libnl-3.so.200
libnl-genl-3.so.200

new bin files to .tmp_update/bin
dnsmasq
hostapd

new config files to .tmp_update/config
dnsmasq.conf
hostapd.conf
dhcp.leases (file generated by runtime.sh if not created by dnsmasq)

new logfiles generated in /.tmp_update/logs but cleared by runtime.sh
dnsmasq.log (generated by running)

## NTP:

NTP
- Adds an NTP menu option (enable/disable) in System -> Date and time (only shows on MMP)
- Adds a TZ select (UTC+1/UTC+2 etc)
- Modified runtime.sh
- Modified tweaks source files

# Known issues
Doesn't sync across all shells as $TZ doesn't get set by export (can be verified by the /logs/ file or by opening the clock app)
Some themes are missing the minus symbol so it will show UTC  0100 instead of UTC-0100
NTPD is backwards, UTC-1 becomes UTC+1? worked around
File times may still be incorrect, not sure why.

# Files changed/added at install/run
tweaks
runtime.sh

## Example log file:

This log is a cycle of systemboot->disabled all->enabled all->disabled wifi->enabled wifi->enabled all

```FTP: Starting bftpd
Dropbear: Starting dropbear
Filebrowser: Checking for an IP address and trying to start
Hotspot: Key not default, not editing
Hotspot: Started with gateway of: 192.168.100.100, subnet of: 255.255.255.0
Filebrowser: Starting filebrowser with 192.168.1.215
NTP: Starting NTP with TZ of UTC-1
NTP1: TZ set to UTC-1, Time set to: Tue May  2 13:48:25 UTC 2023 and merged to hwclock, which shows: Tue May  2 13:48:26 2023  0.000000 seconds
FTP: Killed
Dropbear: Killed
Telnet: Killed
Filebrowser: Killed
Hotspot: Killed
NTP: Killed by request
FTP: Starting bftpd
Dropbear: Starting dropbear
Telnet: Starting telnet
Filebrowser: Checking for an IP address and trying to start
Filebrowser: Starting filebrowser with 192.168.1.215
Hotspot: Key not default, not editing
Hotspot: Started with gateway of: 192.168.100.100, subnet of: 255.255.255.0
NTP: Starting NTP with TZ of UTC-1
NTP1: TZ set to UTC-1, Time set to: Tue May  2 13:49:15 UTC 2023 and merged to hwclock, which shows: Tue May  2 13:49:16 2023  0.000000 seconds
Hotspot: Wifi is turned off, disabling the toggle for hotspot and killing the process
NTP: Wifi is turned off, disabling the toggle for NTP and killing the process
FTP: Killed
Dropbear: Killed
Telnet: Killed
Filebrowser: Killed
FTP: Wifi is turned off, disabling the toggle for FTP and killing the process
Dropbear: Wifi is turned off, disabling the toggle for dropbear and killing the process
Telnet: Wifi is turned off, disabling the toggle for Telnet and killing the process
Filebrowser: Checking for an IP address and trying to start
Filebrowser: Wifi is turned off, disabling the toggle for HTTP FS and killing the process
Hotspot: Wifi is turned off, disabling the toggle for hotspot and killing the process
FTP: Wifi is turned off, disabling the toggle for FTP and killing the process
Dropbear: Wifi is turned off, disabling the toggle for dropbear and killing the process
Telnet: Wifi is turned off, disabling the toggle for Telnet and killing the process
Filebrowser: Checking for an IP address and trying to start
Filebrowser: Wifi is turned off, disabling the toggle for HTTP FS and killing the process
Hotspot: Wifi is turned off, disabling the toggle for hotspot and killing the process
NTP: Wifi is turned off, disabling the toggle for NTP and killing the process
FTP: Starting bftpd
Dropbear: Starting dropbear
Telnet: Starting telnet
Filebrowser: Checking for an IP address and trying to start
Hotspot: Key not default, not editing
Hotspot: Started with gateway of: 192.168.100.100, subnet of: 255.255.255.0
NTP: Starting NTP with TZ of UTC-1
NTP1: TZ set to UTC-1, Time set to: Tue May  2 13:51:06 UTC 2023 and merged to hwclock, which shows: Tue May  2 13:51:07 2023  0.000000 seconds
Filebrowser: Starting filebrowser with 192.168.1.215```
as per conversation with kebab, gateway being set is causing problems currently so have removed it. The ip address that gets set on wlan1 will now be the DHCP scope -1 (example, 192.168.100.101 first usable address, wlan1 will be set to 192.168.100.100)
- Hotspot now bound to wlan0
- Reproduced steps to get hotspot icon and added to runtime.sh
- Changed filebrowser startup to bind to 0.0.0.0 so we don't need to check/chase IP addresses.
- Tidied comments.
- Commented out check_networking()
- Updated echo's to the logfile with time and date for NTP.
- Moved the starting of the hotspot to a function that's called through check_hotspotstate as we need to chase the startup, cuts down on duped lines
Retroarch will only send a netplay discovery broadcast if there's (any) default via set
Re_add this func. or search crashes on boot, remove the kill from filebrowser
The original hotspot icon is too big for the GUI imo, have rescaled to 35x35 which seems to fit better
Commit description updated w/ new features.

Hotspot is always disabled at boot.

If Wifi is off and hotspot is started, Wifi will be brought up and the label for Wifi will be turned on in main (if you go into wifi though it will kill hotspot until the next state change)

All network services are disabled if wifi is disabled at the first state change (in and out of app) (before it was the second)

Fixed a hang relating to NTP and hotspot

Fixed some processes making Main sluggish relating to wifi

Standard wifi connection reliably comes back up when hotspot is disabled

NTP will now be disabled when hotspot is enabled (pointless having both on taking up resources)
- Moved filebrowser branding out of the check_httpserver (Happens once on startup now)
- Moved the check for if Main has taken wlan0 before the hotspot could get it (if switched on)
- Removed the kill for dnsmasq and hostapd in start_hotspot, if they're already running there's not really any need to kill them and restart (if there's hotspot issues they can bounce through tweaks)
- Added check_networking to logs
On initial testing killing dnsmasq and hostapd didn't seem necessary however after leaving running it appears hostapd becomes unstable without this kill (hotspot icon comes on, spotty connection and poor pings)

Reply from 192.168.100.100: bytes=32 time=92ms TTL=64
Reply from 192.168.100.100: bytes=32 time=17ms TTL=64
Request timed out.
Reply from 192.168.100.100: bytes=32 time=38ms TTL=64
Reply from 192.168.100.100: bytes=32 time=29ms TTL=64
Request timed out.
Request timed out.
Request timed out.
Reply from 192.168.100.100: bytes=32 time=19ms TTL=64
Request timed out.
Request timed out.
Request timed out.
Reply from 192.168.100.100: bytes=32 time=20ms TTL=64
Request timed out.
Request timed out.
Reply from 192.168.100.100: bytes=32 time=39ms TTL=64
Reply from 192.168.100.100: bytes=32 time=12ms TTL=64
Reply from 192.168.100.100: bytes=32 time=15ms TTL=64
Reply from 192.168.100.100: bytes=32 time=2ms TTL=64
Request timed out.
Removed a reference that appears in logs falsely specifying the MMP has been set as the gateway
Set password back to default, add OnionOS branding to hotspot name
@Aemiii91 Aemiii91 self-assigned this May 15, 2023
Aemiii91 and others added 13 commits May 15, 2023 19:52
update_networking.sh changes:
Added `check_hotspotstate` to main loop.
Added a check in `check_wifi` to test hotspot state.

Info: When WiFi is started at the same time as the hotspot, wpa_supplicant is quicker to grab wlan0 which results in hotspot failing to come up

Added dropbear to .tmp_update/bin from this PR:#790 to restore SSH functionality and break the SSHState loop pending review of PR.
- update_networking now sourced in runtime.sh
- check_hotspotstate now called in runtime loop
- check_hotspotstate and start_hotspot merged with old/new config to provide recovery after main relaunch.
- start wifi on hotspot launch removed, needs reworking for new layout
- serialnumber WPA code commented out following conversation with schmurtz, see chat. password now `onionos!` (warn: has to be 8 chars!)
- some NTP code moved to a func. as duplicated
- please note hotspot is still killed sometimes when mainui relaunches (during a 'longer' loading screen).

Steps to test full cycle:

- Turn on hotspot
- Observe hotspot icon appears, hotspot shows in other devices & is connectable (10-20 seconds wait)
- Open search with x (or app) - close app
- Observe MainUI relaunch
- Observe hotspot drops but recovers
- Turn hotspot off, observe wifi recovers
- Turn hotspot on
- Turn hotspot off
- Observe all hostapd/dnsmasq processes dead.
Removed sleep from NTP - not needed anymore.
Removed backgrounded task.
@Aemiii91 Aemiii91 marked this pull request as ready for review May 19, 2023 20:57
@Aemiii91 Aemiii91 merged commit 5482dd0 into dev-V4.2-beta May 19, 2023
@Aemiii91 Aemiii91 deleted the dev-V4.2-beta-networking branch May 19, 2023 20:58
@Aemiii91 Aemiii91 added the enhancement New or improved feature label Oct 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New or improved feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants