Merge branch 'main' into module/wifi
C++ / fmt (pull_request) Successful in 7s
JS/TS / fmt (pull_request) Successful in 14s
JS/TS / lint (pull_request) Successful in 20s
Python / fmt (pull_request) Successful in 28s
Python / lint (pull_request) Successful in 29s
Python / test (pull_request) Successful in 59s
Rust / fmt (pull_request) Successful in 57s
C++ / build (pull_request) Successful in 3m47s
Rust / build (pull_request) Successful in 2m10s
Python / buildcheck (pull_request) Successful in 2m51s
Rust / clippy (pull_request) Successful in 1m32s
C++ / clang-tidy (pull_request) Successful in 5m9s
C++ / fmt (pull_request) Successful in 7s
JS/TS / fmt (pull_request) Successful in 14s
JS/TS / lint (pull_request) Successful in 20s
Python / fmt (pull_request) Successful in 28s
Python / lint (pull_request) Successful in 29s
Python / test (pull_request) Successful in 59s
Rust / fmt (pull_request) Successful in 57s
C++ / build (pull_request) Successful in 3m47s
Rust / build (pull_request) Successful in 2m10s
Python / buildcheck (pull_request) Successful in 2m51s
Rust / clippy (pull_request) Successful in 1m32s
C++ / clang-tidy (pull_request) Successful in 5m9s
This commit is contained in:
+1
-1
@@ -15,4 +15,4 @@ dist/
|
||||
**/target/
|
||||
**/test-plugins/
|
||||
**/Charts/
|
||||
**/network-dev/
|
||||
network-dev/
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
import QtQuick
|
||||
import QtQuick.Shapes
|
||||
import qs.Config
|
||||
import qs.Components
|
||||
|
||||
Item {
|
||||
id: root
|
||||
|
||||
readonly property real designHeight: 80.419373
|
||||
readonly property real designWidth: 98.057144
|
||||
|
||||
implicitHeight: designHeight
|
||||
implicitWidth: designWidth
|
||||
|
||||
Shape {
|
||||
id: shape
|
||||
|
||||
anchors.centerIn: parent
|
||||
height: root.designHeight
|
||||
preferredRendererType: Shape.CurveRenderer
|
||||
scale: Math.min(root.implicitHeight / height, root.implicitWidth / width)
|
||||
width: root.designWidth
|
||||
|
||||
ShapePath {
|
||||
strokeColor: "transparent"
|
||||
|
||||
fillGradient: LinearGradient {
|
||||
x1: 0
|
||||
x2: shape.width
|
||||
y1: 0
|
||||
y2: shape.height
|
||||
|
||||
GradientStop {
|
||||
color: DynamicColors.palette.m3primary
|
||||
position: 0.0
|
||||
}
|
||||
|
||||
GradientStop {
|
||||
color: DynamicColors.palette.m3tertiary
|
||||
position: 1.0
|
||||
}
|
||||
}
|
||||
|
||||
PathSvg {
|
||||
path: "m 51.981821,0.026059 c -1.39501,-0.04986 -2.77607,-0.02697 -4.1305,0.05839 -9.029544,0.569111 -16.873893,3.910515 -19.747638,6.917924 -4.597996,4.811856 -9.516732,6.095236 -9.516732,6.095236 -4.063345,1.817811 -10.372493,1.390096 -10.372493,1.390096 -1.283162,6.736594 -5.560032,10.051544 -7.377844,12.724804 -1.817812,2.67325 -0.106971,4.38371 -0.106971,4.38371 7.805897,9.40985 5.132504,15.93288 5.132504,15.93288 3.421763,5.13265 5.132503,8.87491 5.132503,8.87491 0.855441,17.21575 24.059513,19.14095 24.059513,19.14095 8.019764,4.38413 21.813738,6.09496 33.041398,3.95635 11.22766,-2.1386 22.13426,-8.66133 25.44909,-12.40389 3.31484,-3.74255 4.70506,-4.70528 4.4912,-7.80625 -0.21386,-3.10098 -8.34057,-6.73654 -8.34057,-6.73654 4.70492,-26.73253 -10.5857,-43.627569 -25.12819,-49.829514 -4.09007,-1.744297 -8.40025,-2.549484 -12.58527,-2.69906 z m 0.0522,6.437333 c 2.11073,-0.04742 4.33196,0.144541 6.65179,0.645956 18.55865,4.011316 31.22355,22.883281 24.70082,47.477201 0,0 0.42763,1.06939 6.62957,4.38423 0,0 -6.09519,11.86918 -29.40596,14.97015 0,0 -16.039134,2.13849 -27.908379,-8.55452 0,0 -4.491338,2.24573 -10.372493,0.53485 0,0 6.094988,-3.3149 4.063317,-8.44755 -2.031672,-5.13264 -10.051071,-6.84383 -11.441162,-7.69927 -1.390091,-0.85544 -2.673221,-2.24534 -2.673221,-2.24534 0,0 8.12664,-1.49702 9.516731,-8.23361 1.390092,-6.7366 -2.994298,-11.01376 -4.812109,-12.29692 -1.817812,-1.28317 -3.421899,-2.5665 -4.491199,-4.59816 0,0 6.415801,-1.069 9.623702,-3.31453 0,0 2.566413,-0.42817 2.994133,9.83712 0,0 3.40241,0.98386 2.780192,-10.05106 0,0 9.369134,-12.076644 24.144268,-12.408547 z m 1.44952,11.296987 c -7.539424,-0.42396 -14.807124,3.94504 -19.819474,11.69747 -8.019756,12.40389 -4.597866,33.04123 15.505004,39.45703 20.10286,6.41581 34.21755,-8.76794 34.21755,-8.76794 0,0 -6.20221,-5.34688 -7.5923,-16.14682 -1.39009,-10.79994 -8.87492,-19.99568 -8.87492,-19.99568 -4.29057,-4.00988 -8.91222,-5.98969 -13.43587,-6.24406 z m 0.43874,3.91759 c 5.90958,0.2395 10.57783,4.70548 11.60704,7.352 1.49702,3.84948 2.88726,10.26522 -3.74241,13.58005 1e-5,-1.81781 1.06895,-2.13837 -0.96273,-4.91856 1.81781,-1.17623 2.99392,-3.10096 1.06918,-5.45342 -1.71088,0.53465 -0.85529,1.38993 -3.7424,-0.42788 -2.88711,-1.81781 -0.85514,-3.10083 -3.31453,-5.1325 0,0 -1.06951,-0.42772 -1.92495,0 -0.85544,0.42772 0.96245,2.88717 -2.56625,4.27726 -3.528694,1.39009 -2.673344,-0.21375 -2.994134,-2.45928 0,0 -4.49095,4.27695 -1.06919,10.37197 3.421764,6.09501 9.730474,-0.10662 7.805734,-1.92443 -1.92474,-1.81782 -2.13858,-2.1386 -4.06332,-1.39009 0,0 0.21415,-3.7426 4.91908,-1.49707 4.70492,2.24553 3.84939,13.90048 -5.77432,12.61732 -9.623714,-1.28316 -13.366163,-15.07666 -3.849384,-22.13405 2.973994,-2.20543 5.916404,-2.97018 8.602584,-2.86132 z m -44.322368,1.76475 c 0.177759,-0.002 0.290475,0.19502 0.325562,0.66869 0.21386,2.88712 7.806121,5.98809 7.485331,12.40389 -0.32079,6.41581 -6.309176,5.77433 -6.309176,5.77433 0.962372,-5.34651 -7.591784,-13.36663 -7.591784,-13.36663 2.592219,-0.26816 5.184343,-5.46781 6.090067,-5.48028 z m 60.847968,11.36158 c 0,0 3.10099,17.10864 5.56039,18.81952 0,0 -4.7046,-3.20747 -7.37785,-1.60352 -2.67325,1.60395 -2.67322,5.23955 -2.67322,6.84351 0,0 -3.31509,-4.27761 -7.5923,-2.4598 -4.2772,1.81781 -11.013604,-2.13842 -11.869044,-5.02553 0,0 9.623444,2.45961 14.435294,-3.52847 0,0 8.98208,-0.85568 9.51673,-13.04571 z"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -44,6 +44,14 @@ PageBase {
|
||||
spacing: Appearance.spacing.small
|
||||
width: parent.width - Appearance.padding.largeIncreased * 2
|
||||
|
||||
Logo {
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
Layout.preferredHeight: implicitHeight
|
||||
Layout.preferredWidth: implicitWidth
|
||||
implicitHeight: designHeight * 2
|
||||
implicitWidth: designWidth * 2
|
||||
}
|
||||
|
||||
CustomText {
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
Layout.topMargin: Appearance.spacing.small
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<div align="center">
|
||||
<img src="/images/shell.png" alt="ZShell screenshot">
|
||||
<img src="./assets/logo.svg" alt="ZShell logo" width="480">
|
||||
</div>
|
||||
|
||||
# ZShell
|
||||
@@ -8,6 +8,10 @@ ZShell is a Hyprland-focused desktop shell built with Quickshell + Qt6/QML.
|
||||
|
||||
It includes a configurable top bar, launcher, notifications daemon + sidebar, wallpaper and dynamic color pipeline, lock screen, OSD widgets, dashboard, dock, desktop icons, and a separate greetd-compatible greeter.
|
||||
|
||||
<div align="center">
|
||||
<img src="/images/shell.png" alt="ZShell screenshot">
|
||||
</div>
|
||||
|
||||
## Highlights
|
||||
|
||||
- Multi-window shell layout driven by `Drawers/Windows.qml` and panel/interactions wrappers
|
||||
@@ -218,14 +222,14 @@ Action-driven flows (`>` prefix by default) include calculator, wallpaper picker
|
||||
|
||||
### `shell` — daemon management
|
||||
|
||||
| Command | Description |
|
||||
|---------|-------------|
|
||||
| `start` | Start the shell daemon (pass `--no-daemon` to run in foreground) |
|
||||
| `kill` | Kill the running shell daemon |
|
||||
| `restart` | Kill then restart the daemon |
|
||||
| `lock` | Lock the session via IPC |
|
||||
| `show` | Show the shell window via IPC |
|
||||
| `log` | Print daemon logs |
|
||||
| Command | Description |
|
||||
| --------- | ---------------------------------------------------------------- |
|
||||
| `start` | Start the shell daemon (pass `--no-daemon` to run in foreground) |
|
||||
| `kill` | Kill the running shell daemon |
|
||||
| `restart` | Kill then restart the daemon |
|
||||
| `lock` | Lock the session via IPC |
|
||||
| `show` | Show the shell window via IPC |
|
||||
| `log` | Print daemon logs |
|
||||
|
||||
### `scheme` — color scheme generation
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 32 KiB |
@@ -0,0 +1,68 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
width="370.60901"
|
||||
height="370.60901"
|
||||
viewBox="0 0 98.056968 98.056968"
|
||||
version="1.1"
|
||||
id="svg1"
|
||||
xml:space="preserve"
|
||||
inkscape:export-filename="logo.svg"
|
||||
inkscape:export-xdpi="96"
|
||||
inkscape:export-ydpi="96"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"><sodipodi:namedview
|
||||
id="namedview1"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#000000"
|
||||
borderopacity="0.25"
|
||||
inkscape:showpageshadow="2"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pagecheckerboard="0"
|
||||
inkscape:deskcolor="#d1d1d1"
|
||||
inkscape:document-units="px"
|
||||
showborder="false"><inkscape:page
|
||||
x="0"
|
||||
y="0"
|
||||
width="98.056969"
|
||||
height="98.056969"
|
||||
id="page2"
|
||||
margin="0"
|
||||
bleed="0" /></sodipodi:namedview><defs
|
||||
id="defs1"><style
|
||||
id="theme-style">
|
||||
.grad-stop-1 { stop-color: #9898ff; stop-opacity: 1; }
|
||||
.grad-stop-2 { stop-color: #ff9ac3; stop-opacity: 1; }
|
||||
@media (prefers-color-scheme: light) {
|
||||
.grad-stop-1 { stop-color: #000080; stop-opacity: 1; }
|
||||
.grad-stop-2 { stop-color: #800037; stop-opacity: 1; }
|
||||
}
|
||||
</style><linearGradient
|
||||
id="linearGradient7"
|
||||
inkscape:collect="always"><stop
|
||||
class="grad-stop-1"
|
||||
offset="0.00635612"
|
||||
id="stop7" /><stop
|
||||
class="grad-stop-2"
|
||||
offset="1"
|
||||
id="stop8" /></linearGradient><linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient7"
|
||||
id="linearGradient8"
|
||||
x1="52.200813"
|
||||
y1="75.440575"
|
||||
x2="150.25795"
|
||||
y2="155.85995"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="translate(-8.4478442e-5,8.8187943)" /></defs><g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
transform="translate(-52.200813,-75.440577)"><path
|
||||
id="path2"
|
||||
style="fill:url(#linearGradient8);stroke-width:0.264583"
|
||||
d="m 104.18255,84.28543 c -1.39501,-0.04986 -2.77607,-0.02697 -4.1305,0.05839 -9.029544,0.569111 -16.873893,3.910515 -19.747638,6.917924 -4.597996,4.811856 -9.516732,6.095236 -9.516732,6.095236 -4.063345,1.817811 -10.372493,1.390096 -10.372493,1.390096 -1.283162,6.736594 -5.560032,10.051544 -7.377844,12.724804 -1.817812,2.67325 -0.106971,4.38371 -0.106971,4.38371 7.805897,9.40985 5.132504,15.93288 5.132504,15.93288 3.421763,5.13265 5.132503,8.87491 5.132503,8.87491 0.855441,17.21575 24.059513,19.14095 24.059513,19.14095 8.019764,4.38413 21.813738,6.09496 33.041398,3.95635 11.22766,-2.1386 22.13426,-8.66133 25.44909,-12.40389 3.31484,-3.74255 4.70506,-4.70528 4.4912,-7.80625 -0.21386,-3.10098 -8.34057,-6.73654 -8.34057,-6.73654 4.70492,-26.73253 -10.5857,-43.627569 -25.12819,-49.829514 -4.09007,-1.744297 -8.40025,-2.549484 -12.58527,-2.69906 z m 0.0522,6.437333 c 2.11073,-0.04742 4.33196,0.144541 6.65179,0.645956 18.55865,4.011316 31.22355,22.883281 24.70082,47.477201 0,0 0.42763,1.06939 6.62957,4.38423 0,0 -6.09519,11.86918 -29.40596,14.97015 0,0 -16.039134,2.13849 -27.908379,-8.55452 0,0 -4.491338,2.24573 -10.372493,0.53485 0,0 6.094988,-3.3149 4.063317,-8.44755 -2.031672,-5.13264 -10.051071,-6.84383 -11.441162,-7.69927 -1.390091,-0.85544 -2.673221,-2.24534 -2.673221,-2.24534 0,0 8.12664,-1.49702 9.516731,-8.23361 1.390092,-6.7366 -2.994298,-11.01376 -4.812109,-12.29692 -1.817812,-1.28317 -3.421899,-2.5665 -4.491199,-4.59816 0,0 6.415801,-1.069 9.623702,-3.31453 0,0 2.566413,-0.42817 2.994133,9.83712 0,0 3.40241,0.98386 2.780192,-10.05106 0,0 9.369134,-12.076644 24.144268,-12.408547 z m 1.44952,11.296987 c -7.539424,-0.42396 -14.807124,3.94504 -19.819474,11.69747 -8.019756,12.40389 -4.597866,33.04123 15.505004,39.45703 20.10286,6.41581 34.21755,-8.76794 34.21755,-8.76794 0,0 -6.20221,-5.34688 -7.5923,-16.14682 -1.39009,-10.79994 -8.87492,-19.99568 -8.87492,-19.99568 -4.29057,-4.00988 -8.91222,-5.98969 -13.43587,-6.24406 z m 0.43874,3.91759 c 5.90958,0.2395 10.57783,4.70548 11.60704,7.352 1.49702,3.84948 2.88726,10.26522 -3.74241,13.58005 1e-5,-1.81781 1.06895,-2.13837 -0.96273,-4.91856 1.81781,-1.17623 2.99392,-3.10096 1.06918,-5.45342 -1.71088,0.53465 -0.85529,1.38993 -3.7424,-0.42788 -2.88711,-1.81781 -0.85514,-3.10083 -3.31453,-5.1325 0,0 -1.06951,-0.42772 -1.92495,0 -0.85544,0.42772 0.96245,2.88717 -2.56625,4.27726 -3.528694,1.39009 -2.673344,-0.21375 -2.994134,-2.45928 0,0 -4.49095,4.27695 -1.06919,10.37197 3.421764,6.09501 9.730474,-0.10662 7.805734,-1.92443 -1.92474,-1.81782 -2.13858,-2.1386 -4.06332,-1.39009 0,0 0.21415,-3.7426 4.91908,-1.49707 4.70492,2.24553 3.84939,13.90048 -5.77432,12.61732 -9.623714,-1.28316 -13.366163,-15.07666 -3.849384,-22.13405 2.973994,-2.20543 5.916404,-2.97018 8.602584,-2.86132 z m -44.322368,1.76475 c 0.177759,-0.002 0.290475,0.19502 0.325562,0.66869 0.21386,2.88712 7.806121,5.98809 7.485331,12.40389 -0.32079,6.41581 -6.309176,5.77433 -6.309176,5.77433 0.962372,-5.34651 -7.591784,-13.36663 -7.591784,-13.36663 2.592219,-0.26816 5.184343,-5.46781 6.090067,-5.48028 z m 60.847968,11.36158 c 0,0 3.10099,17.10864 5.56039,18.81952 0,0 -4.7046,-3.20747 -7.37785,-1.60352 -2.67325,1.60395 -2.67322,5.23955 -2.67322,6.84351 0,0 -3.31509,-4.27761 -7.5923,-2.4598 -4.2772,1.81781 -11.013604,-2.13842 -11.869044,-5.02553 0,0 9.623444,2.45961 14.435294,-3.52847 0,0 8.98208,-0.85568 9.51673,-13.04571 z" /></g></svg>
|
||||
|
After Width: | Height: | Size: 5.5 KiB |
@@ -1,445 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# =============================================================================
|
||||
|
||||
# wifi-sim.sh — Virtual WiFi environment for development & testing
|
||||
|
||||
#
|
||||
|
||||
# Creates 3 dummy networks using mac80211_hwsim + hostapd + dnsmasq:
|
||||
|
||||
# - FreeWifi (open, strong signal, ch 1)
|
||||
|
||||
# - OfficeNetwork (open, medium signal, ch 6)
|
||||
|
||||
# - HomeNetwork (WPA2, weak signal, ch 11)
|
||||
|
||||
#
|
||||
|
||||
# Usage:
|
||||
|
||||
# sudo ./wifi-sim.sh start
|
||||
|
||||
# sudo ./wifi-sim.sh stop
|
||||
|
||||
# sudo ./wifi-sim.sh status
|
||||
|
||||
# =============================================================================
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# --- User configuration ------------------------------------------------------
|
||||
|
||||
SSID_STRONG="FreeWifi" # Open network, strong signal
|
||||
SSID_MEDIUM="OfficeNetwork" # Open network, medium signal
|
||||
SSID_SECURE="HomeNetwork" # WPA2 network, weak signal
|
||||
WIFI_PASSWORD="testpassword123"
|
||||
|
||||
# TX power levels in mBm (millibel-milliwatts). Higher = stronger signal.
|
||||
|
||||
# These affect the RSSI reported to scanning clients.
|
||||
|
||||
TXPOWER_STRONG=3000 # 30 dBm
|
||||
TXPOWER_MEDIUM=1500 # 15 dBm
|
||||
TXPOWER_WEAK=100 # 1 dBm
|
||||
|
||||
# Per-network IP plan for DHCP.
|
||||
|
||||
AP1_IP="10.10.1.1"
|
||||
AP1_RANGE_START="10.10.1.50"
|
||||
AP1_RANGE_END="10.10.1.150"
|
||||
|
||||
AP2_IP="10.10.2.1"
|
||||
AP2_RANGE_START="10.10.2.50"
|
||||
AP2_RANGE_END="10.10.2.150"
|
||||
|
||||
AP3_IP="10.10.3.1"
|
||||
AP3_RANGE_START="10.10.3.50"
|
||||
AP3_RANGE_END="10.10.3.150"
|
||||
|
||||
RUN_DIR="/tmp/wifi-sim"
|
||||
|
||||
# --- Helpers -----------------------------------------------------------------
|
||||
|
||||
die() {
|
||||
echo "ERROR: $*" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
info() {
|
||||
echo "[*] $*"
|
||||
}
|
||||
|
||||
ok() {
|
||||
echo "[+] $*"
|
||||
}
|
||||
|
||||
require_cmds() {
|
||||
local missing=()
|
||||
for cmd in "$@"; do
|
||||
command -v "$cmd" &>/dev/null || missing+=("$cmd")
|
||||
done
|
||||
if [[ ${#missing[@]} -gt 0 ]]; then
|
||||
die "Missing required tools: ${missing[*]}
|
||||
Install with: sudo apt install hostapd dnsmasq wpasupplicant iw"
|
||||
fi
|
||||
}
|
||||
|
||||
get_phy_for_iface() {
|
||||
iw dev "$1" info | awk '/wiphy/{print "phy"$2}'
|
||||
}
|
||||
|
||||
start_dnsmasq() {
|
||||
local name="$1"
|
||||
local iface="$2"
|
||||
local gw_ip="$3"
|
||||
local dhcp_start="$4"
|
||||
local dhcp_end="$5"
|
||||
|
||||
dnsmasq \
|
||||
--interface="$iface" \
|
||||
--bind-interfaces \
|
||||
--except-interface=lo \
|
||||
--port=0 \
|
||||
--no-resolv \
|
||||
--no-hosts \
|
||||
--dhcp-authoritative \
|
||||
--dhcp-range="${dhcp_start},${dhcp_end},255.255.255.0,12h" \
|
||||
--dhcp-option=3,"$gw_ip" \
|
||||
--dhcp-option=6,"$gw_ip" \
|
||||
--pid-file="$RUN_DIR/${name}.dnsmasq.pid" \
|
||||
--dhcp-leasefile="$RUN_DIR/${name}.leases" \
|
||||
>"$RUN_DIR/${name}.dnsmasq.log" 2>&1 ||
|
||||
{
|
||||
cat "$RUN_DIR/${name}.dnsmasq.log"
|
||||
die "dnsmasq failed for $name. See log above."
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
stop_pidfile() {
|
||||
local pidfile="$1"
|
||||
local label="$2"
|
||||
|
||||
if [[ -f "$pidfile" ]]; then
|
||||
local pid
|
||||
pid="$(cat "$pidfile")"
|
||||
if kill "$pid" 2>/dev/null; then
|
||||
info "Stopped $label (PID $pid)"
|
||||
fi
|
||||
rm -f "$pidfile"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
remove_iface_addr() {
|
||||
local iface="$1"
|
||||
local cidr="$2"
|
||||
ip addr del "$cidr" dev "$iface" 2>/dev/null || true
|
||||
}
|
||||
|
||||
# --- Start -------------------------------------------------------------------
|
||||
|
||||
cmd_start() {
|
||||
[[ $EUID -ne 0 ]] && die "Please run as root: sudo $0 start"
|
||||
require_cmds hostapd dnsmasq iw ip
|
||||
|
||||
if [[ -d "$RUN_DIR" && -f "$RUN_DIR/interfaces" ]]; then
|
||||
die "wifi-sim appears to already be running. Run 'sudo $0 stop' first."
|
||||
fi
|
||||
mkdir -p "$RUN_DIR"
|
||||
|
||||
# Snapshot existing wlan interfaces so we can identify the new ones
|
||||
info "Snapshotting existing interfaces..."
|
||||
BEFORE=($(iw dev 2>/dev/null | awk '/Interface/{print $2}' | grep -v '^hwsim' || true))
|
||||
|
||||
# Load the kernel module with 4 radios (3 APs + 1 client)
|
||||
info "Loading mac80211_hwsim (4 radios)..."
|
||||
if lsmod | grep -q mac80211_hwsim; then
|
||||
die "mac80211_hwsim is already loaded. Run 'sudo $0 stop' or 'sudo rmmod mac80211_hwsim' first."
|
||||
fi
|
||||
modprobe mac80211_hwsim radios=4
|
||||
sleep 1
|
||||
|
||||
# Find the interfaces created by our modprobe
|
||||
AFTER=($(iw dev 2>/dev/null | awk '/Interface/{print $2}' | grep -v '^hwsim'))
|
||||
NEW_IFACES=()
|
||||
for iface in "${AFTER[@]}"; do
|
||||
[[ ! " ${BEFORE[*]:-} " =~ " $iface " ]] && NEW_IFACES+=("$iface")
|
||||
done
|
||||
|
||||
if [[ ${#NEW_IFACES[@]} -lt 4 ]]; then
|
||||
rmmod mac80211_hwsim 2>/dev/null || true
|
||||
die "Expected 4 new wlan interfaces, found ${#NEW_IFACES[@]}. Check 'dmesg' for errors."
|
||||
fi
|
||||
|
||||
AP1="${NEW_IFACES[0]}" # Will host SSID_STRONG
|
||||
AP2="${NEW_IFACES[1]}" # Will host SSID_MEDIUM
|
||||
AP3="${NEW_IFACES[2]}" # Will host SSID_SECURE
|
||||
CLIENT="${NEW_IFACES[3]}" # Client-side interface for your code to use
|
||||
|
||||
info "Interfaces assigned: AP1=$AP1 AP2=$AP2 AP3=$AP3 Client=$CLIENT"
|
||||
echo "$AP1 $AP2 $AP3 $CLIENT" >"$RUN_DIR/interfaces"
|
||||
|
||||
# Prevent NetworkManager from fighting us over the AP interfaces.
|
||||
# Leave the client managed so your app can use NetworkManager normally.
|
||||
if command -v nmcli &>/dev/null && nmcli general status &>/dev/null 2>&1; then
|
||||
info "Marking AP interfaces as unmanaged in NetworkManager..."
|
||||
for iface in "$AP1" "$AP2" "$AP3"; do
|
||||
nmcli device set "$iface" managed no 2>/dev/null || true
|
||||
done
|
||||
|
||||
nmcli device set "$CLIENT" managed yes 2>/dev/null || true
|
||||
fi
|
||||
|
||||
# Set TX power on each physical radio to simulate signal strength differences.
|
||||
# mac80211_hwsim factors TX power into the RSSI reported to scanning clients.
|
||||
info "Setting TX power levels for signal strength simulation..."
|
||||
PHY1=$(get_phy_for_iface "$AP1")
|
||||
PHY2=$(get_phy_for_iface "$AP2")
|
||||
PHY3=$(get_phy_for_iface "$AP3")
|
||||
|
||||
iw phy "$PHY1" set txpower fixed "$TXPOWER_STRONG"
|
||||
iw phy "$PHY2" set txpower fixed "$TXPOWER_MEDIUM"
|
||||
iw phy "$PHY3" set txpower fixed "$TXPOWER_WEAK"
|
||||
|
||||
# --- hostapd config: AP1 (open, strong, channel 1) -----------------------
|
||||
cat >"$RUN_DIR/ap1.conf" <<EOF
|
||||
|
||||
interface=$AP1
|
||||
driver=nl80211
|
||||
ssid=$SSID_STRONG
|
||||
hw_mode=g
|
||||
channel=1
|
||||
auth_algs=1
|
||||
wmm_enabled=0
|
||||
ignore_broadcast_ssid=0
|
||||
EOF
|
||||
|
||||
# --- hostapd config: AP2 (open, medium, channel 6) -----------------------
|
||||
cat >"$RUN_DIR/ap2.conf" <<EOF
|
||||
|
||||
interface=$AP2
|
||||
driver=nl80211
|
||||
ssid=$SSID_MEDIUM
|
||||
hw_mode=g
|
||||
channel=6
|
||||
auth_algs=1
|
||||
wmm_enabled=0
|
||||
ignore_broadcast_ssid=0
|
||||
EOF
|
||||
|
||||
# --- hostapd config: AP3 (WPA2, weak, channel 11) ------------------------
|
||||
cat >"$RUN_DIR/ap3.conf" <<EOF
|
||||
|
||||
interface=$AP3
|
||||
driver=nl80211
|
||||
ssid=$SSID_SECURE
|
||||
hw_mode=g
|
||||
channel=11
|
||||
auth_algs=1
|
||||
wpa=2
|
||||
wpa_passphrase=$WIFI_PASSWORD
|
||||
wpa_key_mgmt=WPA-PSK
|
||||
rsn_pairwise=CCMP
|
||||
wmm_enabled=0
|
||||
ignore_broadcast_ssid=0
|
||||
EOF
|
||||
|
||||
# Start a hostapd instance for each AP
|
||||
info "Starting hostapd instances..."
|
||||
hostapd -B -P "$RUN_DIR/ap1.pid" "$RUN_DIR/ap1.conf" \
|
||||
>"$RUN_DIR/ap1.log" 2>&1 ||
|
||||
{
|
||||
cat "$RUN_DIR/ap1.log"
|
||||
die "hostapd failed for AP1. See log above."
|
||||
}
|
||||
|
||||
hostapd -B -P "$RUN_DIR/ap2.pid" "$RUN_DIR/ap2.conf" \
|
||||
>"$RUN_DIR/ap2.log" 2>&1 ||
|
||||
{
|
||||
cat "$RUN_DIR/ap2.log"
|
||||
die "hostapd failed for AP2. See log above."
|
||||
}
|
||||
|
||||
hostapd -B -P "$RUN_DIR/ap3.pid" "$RUN_DIR/ap3.conf" \
|
||||
>"$RUN_DIR/ap3.log" 2>&1 ||
|
||||
{
|
||||
cat "$RUN_DIR/ap3.log"
|
||||
die "hostapd failed for AP3. See log above."
|
||||
}
|
||||
|
||||
# Give each AP a gateway IP and start DHCP on each one.
|
||||
info "Configuring AP addresses and DHCP servers..."
|
||||
ip link set "$AP1" up
|
||||
ip link set "$AP2" up
|
||||
ip link set "$AP3" up
|
||||
|
||||
ip addr add "$AP1_IP/24" dev "$AP1"
|
||||
ip addr add "$AP2_IP/24" dev "$AP2"
|
||||
ip addr add "$AP3_IP/24" dev "$AP3"
|
||||
|
||||
start_dnsmasq "ap1" "$AP1" "$AP1_IP" "$AP1_RANGE_START" "$AP1_RANGE_END"
|
||||
start_dnsmasq "ap2" "$AP2" "$AP2_IP" "$AP2_RANGE_START" "$AP2_RANGE_END"
|
||||
start_dnsmasq "ap3" "$AP3" "$AP3_IP" "$AP3_RANGE_START" "$AP3_RANGE_END"
|
||||
|
||||
# Bring up the client interface so it's ready to scan/connect
|
||||
ip link set "$CLIENT" up
|
||||
|
||||
# --- Summary -------------------------------------------------------------
|
||||
ok "Virtual WiFi environment is up!"
|
||||
echo ""
|
||||
echo " Networks:"
|
||||
echo " ┌──────────────────┬──────────┬────────┬─────────────┐"
|
||||
echo " │ SSID │ Security │ Signal │ Interface │"
|
||||
echo " ├──────────────────┼──────────┼────────┼─────────────┤"
|
||||
printf " │ %-16s │ %-8s │ %-6s │ %-11s │\n" "$SSID_STRONG" "Open" "Strong" "$AP1"
|
||||
printf " │ %-16s │ %-8s │ %-6s │ %-11s │\n" "$SSID_MEDIUM" "Open" "Medium" "$AP2"
|
||||
printf " │ %-16s │ %-8s │ %-6s │ %-11s │\n" "$SSID_SECURE" "WPA2" "Weak" "$AP3"
|
||||
echo " └──────────────────┴──────────┴────────┴─────────────┘"
|
||||
echo ""
|
||||
echo " WPA2 password : $WIFI_PASSWORD"
|
||||
echo " Client iface : $CLIENT (use this in your code)"
|
||||
echo ""
|
||||
echo " Gateway IPs / DHCP:"
|
||||
echo " $SSID_STRONG -> $AP1_IP/24"
|
||||
echo " $SSID_MEDIUM -> $AP2_IP/24"
|
||||
echo " $SSID_SECURE -> $AP3_IP/24"
|
||||
echo ""
|
||||
echo " Useful commands:"
|
||||
echo " Scan for networks : sudo iw dev $CLIENT scan | grep -E 'SSID|signal'"
|
||||
echo " Connect (open) : sudo iw dev $CLIENT connect \"$SSID_STRONG\""
|
||||
echo " Connect (WPA2) : sudo nmcli device wifi connect \"$SSID_SECURE\" password \"$WIFI_PASSWORD\" ifname \"$CLIENT\""
|
||||
echo " Stop simulation : sudo $0 stop"
|
||||
echo ""
|
||||
echo " Logs: $RUN_DIR/ap{1,2,3}.log and $RUN_DIR/ap{1,2,3}.dnsmasq.log"
|
||||
|
||||
}
|
||||
|
||||
# --- Stop --------------------------------------------------------------------
|
||||
|
||||
cmd_stop() {
|
||||
[[ $EUID -ne 0 ]] && die "Please run as root: sudo $0 stop"
|
||||
|
||||
info "Stopping virtual WiFi environment..."
|
||||
local had_something=false
|
||||
|
||||
# Stop dnsmasq instances first.
|
||||
for ap in ap1 ap2 ap3; do
|
||||
PID_FILE="$RUN_DIR/$ap.dnsmasq.pid"
|
||||
if [[ -f "$PID_FILE" ]]; then
|
||||
PID=$(cat "$PID_FILE")
|
||||
if kill "$PID" 2>/dev/null; then
|
||||
info "Stopped dnsmasq for $ap (PID $PID)"
|
||||
fi
|
||||
rm -f "$PID_FILE"
|
||||
had_something=true
|
||||
fi
|
||||
done
|
||||
|
||||
# Kill hostapd processes via PID files
|
||||
for ap in ap1 ap2 ap3; do
|
||||
PID_FILE="$RUN_DIR/$ap.pid"
|
||||
if [[ -f "$PID_FILE" ]]; then
|
||||
PID=$(cat "$PID_FILE")
|
||||
if kill "$PID" 2>/dev/null; then
|
||||
info "Stopped hostapd for $ap (PID $PID)"
|
||||
fi
|
||||
rm -f "$PID_FILE"
|
||||
had_something=true
|
||||
fi
|
||||
done
|
||||
|
||||
# Restore addresses if we still know the interface names.
|
||||
if [[ -f "$RUN_DIR/interfaces" ]]; then
|
||||
read -r AP1 AP2 AP3 CLIENT <"$RUN_DIR/interfaces"
|
||||
|
||||
remove_iface_addr "$AP1" "$AP1_IP/24"
|
||||
remove_iface_addr "$AP2" "$AP2_IP/24"
|
||||
remove_iface_addr "$AP3" "$AP3_IP/24"
|
||||
|
||||
if command -v nmcli &>/dev/null; then
|
||||
for iface in "$AP1" "$AP2" "$AP3" "$CLIENT"; do
|
||||
nmcli device set "$iface" managed yes 2>/dev/null || true
|
||||
done
|
||||
fi
|
||||
fi
|
||||
|
||||
# Unload the kernel module (also destroys all virtual interfaces)
|
||||
if lsmod | grep -q mac80211_hwsim; then
|
||||
info "Unloading mac80211_hwsim..."
|
||||
rmmod mac80211_hwsim && had_something=true
|
||||
fi
|
||||
|
||||
# Clean up runtime directory
|
||||
rm -rf "$RUN_DIR"
|
||||
|
||||
if $had_something; then
|
||||
ok "Virtual WiFi environment stopped."
|
||||
else
|
||||
echo "Nothing was running."
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
# --- Status ------------------------------------------------------------------
|
||||
|
||||
cmd_status() {
|
||||
if [[ ! -f "$RUN_DIR/interfaces" ]]; then
|
||||
echo "wifi-sim is not running."
|
||||
return
|
||||
fi
|
||||
|
||||
read -r AP1 AP2 AP3 CLIENT <"$RUN_DIR/interfaces"
|
||||
echo "wifi-sim is running."
|
||||
echo ""
|
||||
echo " Interfaces:"
|
||||
for iface in "$AP1" "$AP2" "$AP3" "$CLIENT"; do
|
||||
STATE=$(ip link show "$iface" 2>/dev/null | awk '/state/{print $9}' || echo "unknown")
|
||||
CHANNEL=$(iw dev "$iface" info 2>/dev/null | awk '/channel/{print $2}' || echo "?")
|
||||
printf " %-10s state=%-4s channel=%s\n" "$iface" "$STATE" "$CHANNEL"
|
||||
done
|
||||
echo ""
|
||||
echo " Processes:"
|
||||
for ap in ap1 ap2 ap3; do
|
||||
PID_FILE="$RUN_DIR/$ap.pid"
|
||||
if [[ -f "$PID_FILE" ]]; then
|
||||
PID=$(cat "$PID_FILE")
|
||||
if kill -0 "$PID" 2>/dev/null; then
|
||||
echo " hostapd ($ap) PID=$PID running"
|
||||
else
|
||||
echo " hostapd ($ap) PID=$PID DEAD (check $RUN_DIR/$ap.log)"
|
||||
fi
|
||||
fi
|
||||
|
||||
DNSMASQ_PID_FILE="$RUN_DIR/$ap.dnsmasq.pid"
|
||||
if [[ -f "$DNSMASQ_PID_FILE" ]]; then
|
||||
PID=$(cat "$DNSMASQ_PID_FILE")
|
||||
if kill -0 "$PID" 2>/dev/null; then
|
||||
echo " dnsmasq ($ap) PID=$PID running"
|
||||
else
|
||||
echo " dnsmasq ($ap) PID=$PID DEAD (check $RUN_DIR/$ap.dnsmasq.log)"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# --- Entry point -------------------------------------------------------------
|
||||
|
||||
case "${1:-help}" in
|
||||
start) cmd_start ;;
|
||||
stop) cmd_stop ;;
|
||||
status) cmd_status ;;
|
||||
*)
|
||||
echo "Usage: sudo $0 {start|stop|status}"
|
||||
echo ""
|
||||
echo " start Load mac80211_hwsim and bring up 3 virtual APs with DHCP"
|
||||
echo " stop Tear down all virtual interfaces and unload module"
|
||||
echo " status Show current state of interfaces and processes"
|
||||
echo ""
|
||||
echo "Networks created on start:"
|
||||
printf " %-16s open, strong signal\n" "$SSID_STRONG"
|
||||
printf " %-16s open, medium signal\n" "$SSID_MEDIUM"
|
||||
printf " %-16s WPA2, weak signal (password: $WIFI_PASSWORD)\n" "$SSID_SECURE"
|
||||
;;
|
||||
esac
|
||||
Reference in New Issue
Block a user