Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
147 changes: 34 additions & 113 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,42 +260,48 @@ This will:
Afterwards, Mattermost should be reachable at `http://<device-ip>/` (port 80) and proxied to `127.0.0.1:8065`.
For HTTPS, add your TLS server block or use Certbot.

### Modular TUI Menu System
### Optional: Flask Web UI Dashboard

The interactive Terminal User Interface (TUI) menu provides comprehensive system management through a modular architecture designed for maintainability and extensibility:
Azazel-Pi now includes a Flask-based Web UI backend and dashboard assets in `azazel_web/`.

```bash
# Launch the TUI menu
python3 -m azctl.cli menu
# local run (dev)
python3 azazel_web/app.py

# With specific interface configuration
python3 -m azctl.cli menu --lan-if ${AZAZEL_LAN_IF:-wlan0} --wan-if ${AZAZEL_WAN_IF:-wlan1}
# systemd run (installed host)
sudo systemctl enable --now azazel-web.service
```

**Modular Architecture:**

Azazel-Pi's menu system employs a modular design with functional separation for improved maintainability:

``` text
azctl/menu/
├── core.py # Main framework
├── types.py # Data type definitions
├── defense.py # Defense control module
├── services.py # Service management module
├── network.py # Network information module
├── wifi.py # WiFi management module
├── monitoring.py # Log monitoring module
├── system.py # System information module
└── emergency.py # Emergency operations module
Default bind is `127.0.0.1:8084`. Change with:

```bash
export AZAZEL_WEB_HOST=0.0.0.0
export AZAZEL_WEB_PORT=8084
python3 azazel_web/app.py
```

**Key Features:**
### Unified Textual TUI (Azazel-Zero Port)

- **Modular Design**: Function-specific modules for enhanced maintainability
- **Rich UI**: Color-coded panels, tables, and progress bars
- **Safety-First**: Multi-stage confirmation for dangerous operations
- **Extensible**: Easy addition of new functionality through module system
- **Real-time Monitoring**: Live status displays with automatic updates
The old `azctl/menu` modular TUI has been removed and replaced with the Azazel-Zero style unified Textual TUI.

```bash
# Launch unified TUI menu
python3 -m azctl.cli menu

# With specific interface configuration (optional)
python3 -m azctl.cli menu --lan-if ${AZAZEL_LAN_IF:-wlan0} --wan-if ${AZAZEL_WAN_IF:-wlan1}
```

- Runtime implementation: `azctl/tui_zero.py` + `azctl/tui_zero_textual.py`
- Dependency: `textual`
- Key controls:
- `u`: Refresh
- `a`: Stage-Open (`portal`)
- `r`: Re-Probe (`shield`)
- `c`: Contain (`lockdown`)
- `m`: Toggle menu
- `l`: Toggle details
- `q`: Quit

## Usage

Expand Down Expand Up @@ -330,10 +336,8 @@ echo '{"mode": "lockdown"}' | azctl events --config -

#### Interactive TUI Menu

The modular TUI menu provides comprehensive system management:

```bash
# Launch modular TUI menu. If --wan-if is omitted, azctl will consult the
# Launch unified Textual TUI. If --wan-if is omitted, azctl will consult the
# WAN manager to select the active WAN interface. To override selection use
# the CLI flags or environment variables described below.
python3 -m azctl.cli menu
Expand All @@ -345,89 +349,6 @@ python3 -m azctl.cli menu --lan-if ${AZAZEL_LAN_IF:-wlan0} --wan-if ${AZAZEL_WAN
python3 -m azctl.cli menu --lan-if ${AZAZEL_LAN_IF:-wlan0}
```

**Menu Features:**

1. **Defense Control** (`defense.py`)
- Current defense mode display (Portal/Shield/Lockdown)
- Manual mode switching (emergency overrides)
- Decision history and score trends
- Real-time threat score monitoring

2. **Service Management** (`services.py`)
- Azazel core service control (azctl-unified, suricata, opencanary, vector)
- Service status overview
- Real-time log file viewing
- Service restart and health checks

3. **Network Information** (`network.py`)
- WiFi management integration
- Interface status and IP configuration
- Active profiles and QoS settings
- Network traffic statistics

4. **WiFi Management** (`wifi.py`)
- Nearby WiFi network scanning
- WPA/WPA2 network connection
- Saved network management
- Connection status and signal strength

5. **Log Monitoring** (`monitoring.py`)
- Suricata alert real-time monitoring
- OpenCanary honeypot events
- System logs and daemon logs
- Security event summaries

6. **System Information** (`system.py`)
- CPU, memory, disk usage
- Network interface statistics
- System temperature monitoring
- Process list and resource usage

7. **Emergency Operations** (`emergency.py`)
- Emergency lockdown (immediate network isolation)
- Complete network configuration reset
- System status report generation
- Factory reset (requires confirmation)

**Technical Features:**

- **Modular Design**: Each function implemented as independent module
- **Rich UI**: Color-coded panels, tables, progress bars
- **Error Handling**: Robust error processing and recovery
- **Security-Focused**: Multi-stage confirmation for dangerous operations
- **Extensible**: Easy addition of new functionality

**Safety Features:**

- Confirmation dialogs for dangerous operations
- Automatic root permission verification
- Automatic operation logging
- Error handling and automatic recovery procedures
- Emergency operations require multiple confirmations

**Keyboard Navigation:**

- `Number keys`: Select menu items
- `r`: Refresh screen
- `b`: Return to previous menu
- `q`: Exit
- `Ctrl+C`: Safe interruption anytime

**Safety Features:**

- Confirmation dialogs for dangerous operations
- Root permission validation for privileged actions
- Automatic operation logging
- Error handling and recovery procedures

**Navigation:**

- `Number keys`: Select menu items
- `r`: Refresh screen
- `b`: Back to previous menu
- `q`: Quit
- `Ctrl+C`: Interrupt at any time

### Configuration Workflow

1. **Edit Core Configuration**: Modify `/etc/azazel/azazel.yaml` to adjust delay values, bandwidth controls, and lockdown allowlists (template at `configs/network/azazel.yaml`).
Expand Down
159 changes: 44 additions & 115 deletions README_ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,9 @@ sudo systemctl enable --now azazel-epd.service

完全なE-Paper設定手順については、[`docs/ja/EPD_SETUP.md`](docs/ja/EPD_SETUP.md) を参照してください。

### モジュラーTUIメニューシステム
### Unified Textual TUI(Azazel-Zero移植)

インタラクティブなターミナルユーザーインターフェース(TUI)メニューは、保守性と拡張性を考慮したモジュラーアーキテクチャを通じて包括的なシステム管理を提供します:
旧 `azctl/menu` ベースのモジュラーTUIは廃止し、Azazel-Zero由来の unified Textual TUI へ統一しました。

```bash
# TUIメニューを起動
Expand All @@ -209,29 +209,21 @@ python3 -m azctl.cli menu
python3 -m azctl.cli menu --lan-if ${AZAZEL_LAN_IF:-wlan0}
```

**モジュラーアーキテクチャ:**
実装ファイル:

Azazel-Piのメニューシステムは、保守性向上のために機能分離を採用したモジュラー設計を採用しています:

```
azctl/menu/
├── core.py # メインフレームワーク
├── types.py # データ型定義
├── defense.py # 防御制御モジュール
├── services.py # サービス管理モジュール
├── network.py # ネットワーク情報モジュール
├── wifi.py # WiFi管理モジュール
├── monitoring.py # ログ監視モジュール
├── system.py # システム情報モジュール
└── emergency.py # 緊急操作モジュール
```text
azctl/tui_zero.py
azctl/tui_zero_textual.py
```

**主要機能:**
- **モジュラー設計**: 保守性向上のための機能別モジュール
- **Rich UI**: 色分けされたパネル、表、プログレスバー
- **安全性優先**: 危険な操作には多段階確認
- **拡張可能**: モジュールシステムを通じた新機能の簡単な追加
- **リアルタイム監視**: 自動更新付きライブステータス表示
主要キー:
- `u`: Refresh
- `a`: Stage-Open(portal)
- `r`: Re-Probe(shield)
- `c`: Contain(lockdown)
- `m`: メニュー開閉
- `l`: 詳細表示
- `q`: 終了

### オプション: Nginx を介して Mattermost を公開

Expand All @@ -249,6 +241,26 @@ sudo scripts/setup_nginx_mattermost.sh
適用後は `http://<デバイスIP>/`(80番)で Mattermost に到達できます(裏側は `127.0.0.1:8065` へプロキシ)。
HTTPS を利用する場合は、TLS 用の server ブロックを追加するか Certbot を利用してください。

### オプション: Flask WebUI ダッシュボード

`azazel_web/` に Flask ベースの WebUI バックエンドとダッシュボード資産が含まれます。

```bash
# ローカル起動(開発用)
python3 azazel_web/app.py

# systemd 起動(インストール環境)
sudo systemctl enable --now azazel-web.service
```

デフォルトのバインドは `127.0.0.1:8084` です。変更する場合:

```bash
export AZAZEL_WEB_HOST=0.0.0.0
export AZAZEL_WEB_PORT=8084
python3 azazel_web/app.py
```

## 使用方法

### コマンドラインインターフェース
Expand Down Expand Up @@ -280,18 +292,14 @@ echo '{"mode": "lockdown"}' | azctl events --config -

#### インタラクティブTUIメニュー

モジュラーTUIメニューは包括的なシステム管理を提供します:

```bash
# モジュラーTUIメニューを起動
# Unified Textual TUIを起動
python3 -m azctl.cli menu

# カスタムインターフェースを指定
python3 -m azctl.cli menu --lan-if ${AZAZEL_LAN_IF:-wlan0} --wan-if ${AZAZEL_WAN_IF:-wlan1}
```

**メニュー機能:**

1. **コア設定の編集**: `/etc/azazel/azazel.yaml` を修正して遅延値、帯域制御、ロックダウン許可リストを調整(テンプレートは `configs/network/azazel.yaml`)。
- 既定では `wlan0` を内部LAN(AP)、`wlan1` と `eth0` を外部(WAN/アップリンク)として扱います。`configs/network/azazel.yaml` の `interfaces.external` に `["eth0", "wlan1"]` を定義済みです(必要に応じて変更可能)。
注: `--wan-if` を指定しない場合、WAN 管理コンポーネントがランタイムで最適な WAN インターフェイスを選択します。明示的に指定したい場合は `AZAZEL_WAN_IF` / `AZAZEL_LAN_IF` を環境変数で設定してください。
Expand All @@ -312,97 +320,18 @@ python3 -m azctl.cli menu --lan-if ${AZAZEL_LAN_IF:-wlan0} --wan-if ${AZAZEL_WAN

モード遷移は、タイムスタンプ、スコア、トリガーイベントとともに `/var/log/azazel/decisions.log` に記録されます。

### インタラクティブTUIメニュー

Azazel-Piは完全にモジュール化された包括的なターミナルベースのメニューインターフェースを提供します:

```bash
# TUIメニューを起動
python3 -m azctl.cli menu

# または特定のインターフェースを指定
python3 -m azctl.cli menu --lan-if wlan0 --wan-if wlan1
```

**モジュラーメニューシステム:**

Azazel-Piのメニューシステムは、保守性と拡張性を向上させるために機能別に分離されたモジュラーアーキテクチャを採用しています:

```
azctl/menu/
├── core.py # メインフレームワーク
├── types.py # データ型定義
├── defense.py # 防御制御モジュール
├── services.py # サービス管理モジュール
├── network.py # ネットワーク情報モジュール
├── wifi.py # WiFi管理モジュール
├── monitoring.py # ログ監視モジュール
├── system.py # システム情報モジュール
└── emergency.py # 緊急操作モジュール
```
### インタラクティブTUIメニュー(統合版)

**メニュー機能:**

1. **防御制御** (`defense.py`)
- 現在の防御モード表示(Portal/Shield/Lockdown)
- 手動モード切り替え(緊急時オーバーライド)
- 決定履歴とスコア変動の確認
- リアルタイム脅威スコア監視

2. **サービス管理** (`services.py`)
- Azazelコアサービスの制御(azctl, suricata, opencanary, vector)
- サービス状態の一覧表示
- ログファイルのリアルタイム表示
- サービス再起動とヘルスチェック

3. **ネットワーク情報** (`network.py`)
- WiFi管理機能の統合
- インターフェース状態とIP設定
- アクティブプロファイルとQoS設定
- ネットワークトラフィック統計

4. **WiFi管理** (`wifi.py`)
- 近隣WiFiネットワークのスキャン
- WPA/WPA2ネットワークへの接続
- 保存済みネットワークの管理
- 接続状態とシグナル強度表示

5. **ログ監視** (`monitoring.py`)
- Suricataアラートのリアルタイム監視
- OpenCanaryハニーポットイベント
- システムログとデーモンログ
- セキュリティイベントの要約

6. **システム情報** (`system.py`)
- CPU、メモリ、ディスク使用率
- ネットワークインターフェース統計
- システム温度監視
- プロセス一覧とリソース使用状況

7. **緊急操作** (`emergency.py`)
- 緊急ロックダウン(即座にネットワーク封鎖)
- ネットワーク設定の完全リセット
- システム状態レポート生成
- ファクトリーリセット(要確認)

**技術的特徴:**
- **モジュラー設計**: 各機能が独立したモジュールで実装
- **Rich UI**: 色分けされたパネル、表、プログレスバー
- **エラーハンドリング**: 堅牢なエラー処理と回復機能
- **セキュリティ重視**: 危険な操作には多段階確認
- **拡張可能**: 新機能を簡単に追加可能な構造

**安全機能:**
- 危険な操作には確認ダイアログを表示
- root権限が必要な操作の自動検証
- 操作ログの自動記録
- エラーハンドリングと自動回復手順
- 緊急操作には複数回確認が必要
`python3 -m azctl.cli menu` は、`azctl/tui_zero.py` と `azctl/tui_zero_textual.py` を用いた統合TUIを起動します。
旧 `azctl/menu` 実装は削除済みです。

**キーボードナビゲーション:**
- `数字キー`: メニュー項目を選択
- `r`: 画面を更新
- `b`: 前のメニューに戻る
- `u`: 画面を更新
- `a`: Stage-Open(portal)
- `r`: Re-Probe(shield)
- `c`: Contain(lockdown)
- `m`: メニュー開閉
- `l`: 詳細表示
- `q`: 終了
- `Ctrl+C`: いつでも安全に中断可能

Expand Down
Loading