Skip to content

Commit 639367b

Browse files
committed
release: v1.5.0 - updated optimizer logic and docs
1 parent afa1ef4 commit 639367b

5 files changed

Lines changed: 441 additions & 88 deletions

File tree

AI_DEV.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
2+
#!/bin/bash
3+
4+
# 1. Define Version and Release Info
5+
DOC_VERSION="v1.0.0-docs"
6+
RELEASE_TITLE="📚 Protocol Update: AI Development Guidelines"
7+
RELEASE_NOTES="
8+
## 🚀 Official AI Development Guidelines
9+
10+
We have established a standardized protocol for AI-assisted development to ensure code quality, security, and stability.
11+
12+
### 📄 New File: \`AI_DEV_GUIDELINES.md\`
13+
This document contains the **System Prompts** (English & Persian) that must be used when generating code for this repository.
14+
15+
### ✨ Key Standards Enforced:
16+
* **Immutability:** Preventing regressions in existing code.
17+
* **Minimal Dependencies:** Prioritizing native Bash solutions.
18+
* **Security:** Mandatory audits for every code snippet.
19+
* **Dual Language:** Support for both English and Persian workflows.
20+
"
21+
22+
# 2. Stage and Commit the new file
23+
echo ">> Staging AI_DEV_GUIDELINES.md..."
24+
git add AI_DEV_GUIDELINES.md
25+
git commit -m "docs: add comprehensive AI development guidelines (En/Fa)"
26+
27+
# 3. Create a Git Tag
28+
echo ">> Creating Tag $DOC_VERSION..."
29+
git tag -a "$DOC_VERSION" -m "Release $DOC_VERSION: Added AI Guidelines"
30+
31+
# 4. Push Changes and Tags to GitHub
32+
echo ">> Pushing to Origin..."
33+
git push origin main
34+
git push origin "$DOC_VERSION"
35+
36+
# 5. Create GitHub Release (Requires GitHub CLI 'gh')
37+
if command -v gh &> /dev/null; then
38+
echo ">> Creating GitHub Release automatically..."
39+
gh release create "$DOC_VERSION" \
40+
--title "$RELEASE_TITLE" \
41+
--notes "$RELEASE_NOTES"
42+
echo "✅ Release created successfully on GitHub!"
43+
else
44+
echo "⚠️ GitHub CLI (gh) not found."
45+
echo ">> Please manually create a release on GitHub for tag: $DOC_VERSION"
46+
echo ">> Use the Release Notes provided in the script above."
47+
fi

README.md

Lines changed: 54 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,59 @@
1-
Conduit Console ManagerConduit Console is a robust, terminal-based management dashboard for the Psiphon Conduit volunteer proxy node.This tool provides a native "Console" experience for server administrators, offering real-time status reports, action logs, and easier management of the Conduit service without needing complex manual commands.
2-
(Screenshots coming soon)
1+
# Conduit Console & Optimizer Tools
2+
> **Repository:** [https://github.com/babakskr/Conduit-console](https://github.com/babakskr/Conduit-console)
3+
> **Maintainer:** Babak Sorkhpour
4+
> **Latest Version:** 1.5.0
35
4-
✨ FeaturesNative Dashboard:
5-
A clean, text-based user interface (TUI) for monitoring your node.
6-
Action Reports: Detailed logs of node activities and interventions.
7-
Status Totals: Real-time aggregation of connection stats and bandwidth usage.Lightweight: Written purely in Shell, requiring minimal dependencies.
8-
Version Control: Built-in update checks and version tracking (currently v0.1.1).
9-
🚀 InstallationYou can install Conduit-console by cloning the repository directly to your server:
10-
# 1. Update your package list
6+
## 🛠 Project Tools Overview
117

12-
sudo apt update && sudo apt install git -y
8+
| Tool File | Description | Usage |
9+
| :--- | :--- | :--- |
10+
| `conduit-optimizer.sh` | Performance tuner for Docker & Native instances. Adjusts CPU/IO Priority. | `sudo ./conduit-optimizer.sh -h` |
11+
| `AI_DEV_GUIDELINES.md` | Protocol and System Prompts for AI-assisted development (En/Fa). | Reference Doc |
12+
| `git_op.sh` | Automated Release Manager & README Generator. | `./git_op.sh` |
1313

14-
# 2. Clone the repository
15-
git clone [https://github.com/babakskr/Conduit-console.git](https://github.com/babakskr/Conduit-console.git)
14+
## 🚀 How to Use: Conduit Optimizer
1615

17-
# 3. Enter the directory and make it executable
16+
The optimizer intelligently adjusts the Linux Priority (PRI) of your running Conduit processes to prevent lag.
17+
18+
### Installation
19+
```bash
20+
git clone https://github.com/babakskr/Conduit-console.git
1821
cd Conduit-console
19-
chmod +x conduit-console.sh
20-
21-
# 4. Run the console
22-
./conduit-console.sh
23-
📖 UsageOnce installed, simply run the script to enter the main dashboard:
24-
./conduit-console.sh
25-
From the menu, you can access:Start/Stop the Conduit service.View Live Logs.Check Total Status (Connections/Bandwidth).Generate Action Reports.🤝 Credits & AcknowledgementsThis project is an independent management tool built upon the shoulders of giants. Special thanks to the core developers and the open-source community:ssmirr/conduit: The core Conduit server implementation. This project wraps the functionality provided by ssmirr's incredible work.SamNet-dev/conduit-manager: Inspiration for the management structure and automation flows.
26-
⚖️ LicenseThis project is licensed under the MIT License. See the LICENSE file for details.Disclaimer: This tool is not officially affiliated with Psiphon Inc.
27-
It is a community-driven manager for the volunteer Conduit network.
22+
chmod +x conduit-optimizer.sh
23+
```
24+
25+
### Basic Usage (Default Mode)
26+
Automatically sets **Docker to PRI 10** (High) and **Native to PRI 15** (Medium-High).
27+
```bash
28+
sudo ./conduit-optimizer.sh
29+
```
30+
31+
### Custom Usage (CLI Arguments)
32+
You can manually set the target Priority (Range 5-20).
33+
*Lower value = Higher Priority in manual input? No, we follow Linux PRI logic:*
34+
* **10**: Very High Priority (Nice -10)
35+
* **20**: Normal Priority (Nice 0)
36+
37+
```bash
38+
# Example: Set Docker to PRI 10 and Native to PRI 18 (almost normal)
39+
sudo ./conduit-optimizer.sh -dock 10 -srv 18
40+
41+
# Example: Skip Docker, only optimize Service to PRI 5 (Maximum Power)
42+
sudo ./conduit-optimizer.sh -dock 0 -srv 5
43+
44+
# Get Help
45+
./conduit-optimizer.sh -h
46+
```
47+
48+
## 📜 Latest Release Notes (1.5.0)
49+
## ?? Release v1.5.0: CLI & Custom Priorities
50+
#
51+
**Key Changes:**
52+
* **New CLI Args:** Added `-dock` and `-srv` to set custom target priorities manually.
53+
* **Logic Update:** Inputs now map to Linux PRI column (Target 10 = Nice -10).
54+
* **Verbose Mode:** Added `-v` for detailed output logging.
55+
* **Help Menu:** Added `-h` for quick usage guide.
56+
* **Safety Range:** Inputs restricted to 5-20 (0 to skip).
57+
58+
---
59+
*Auto-generated by git_op.sh*

conduit-optimizer.sh

Lines changed: 155 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,38 @@
11
#!/bin/bash
22
# ==============================================================================
33
# Project: Conduit-console | Module: Performance Optimizer
4+
# Repo: https://github.com/babakskr/Conduit-console.git
45
# Author: Babak Sorkhpour (Assisted by Gemini Pro)
56
# License: MIT
6-
# Version: 1.4.0
7-
# Description: Improved Docker detection (Image & Name) + Execution Fixes.
7+
# Version: 1.5.0
88
# ==============================================================================
99

10-
# --- Configuration ---
11-
PRIORITY_NATIVE_NICE=-5
12-
PRIORITY_DOCKER_NICE=-10 # Higher priority for Docker
13-
TARGET_IONICE_CLASS=2
10+
# --- RELEASE NOTES (Auto-parsed by git_op.sh) ---
11+
# <release_notes>
12+
# ## ?? Release v1.5.0: CLI & Custom Priorities
13+
#
14+
# **Key Changes:**
15+
# * **New CLI Args:** Added `-dock` and `-srv` to set custom target priorities manually.
16+
# * **Logic Update:** Inputs now map to Linux PRI column (Target 10 = Nice -10).
17+
# * **Verbose Mode:** Added `-v` for detailed output logging.
18+
# * **Help Menu:** Added `-h` for quick usage guide.
19+
# * **Safety Range:** Inputs restricted to 5-20 (0 to skip).
20+
# </release_notes>
21+
22+
# --- DEFAULTS ---
23+
# Default Target PRI (Linux Priority Column):
24+
# 10 = High Priority (Nice -10) -> For Docker
25+
# 15 = Medium-High Priority (Nice -5) -> For Native Services
26+
DEFAULT_DOCKER_PRI=10
27+
DEFAULT_NATIVE_PRI=15
28+
29+
# Inputs (Initialized with Defaults)
30+
INPUT_DOCKER_PRI=$DEFAULT_DOCKER_PRI
31+
INPUT_NATIVE_PRI=$DEFAULT_NATIVE_PRI
32+
VERBOSE=0
33+
34+
# --- CONFIG ---
35+
TARGET_IONICE_CLASS=2
1436
TARGET_IONICE_LEVEL=0
1537

1638
# Colors
@@ -20,89 +42,156 @@ YELLOW='\033[1;33m'
2042
RED='\033[0;31m'
2143
NC='\033[0m'
2244

23-
# --- Root Check ---
45+
# --- FUNCTIONS ---
46+
47+
show_help() {
48+
echo -e "${BLUE}Conduit Performance Optimizer v1.5.0${NC}"
49+
echo -e "Repo: https://github.com/babakskr/Conduit-console.git"
50+
echo ""
51+
echo "Usage: sudo $0 [OPTIONS]"
52+
echo ""
53+
echo "Options:"
54+
echo " -h Show this help message"
55+
echo " -v Verbose mode (show detailed logs)"
56+
echo " -dock <val> Set Target Priority for Docker (Range: 5-20, Default: 10, 0: Skip)"
57+
echo " -srv <val> Set Target Priority for Native Services (Range: 5-20, Default: 15, 0: Skip)"
58+
echo ""
59+
echo "Concept:"
60+
echo " Value matches Linux 'PRI' column."
61+
echo " 10 = Very High (Nice -10)"
62+
echo " 15 = High (Nice -5)"
63+
echo " 20 = Normal (Nice 0)"
64+
echo ""
65+
}
66+
67+
log_verbose() {
68+
if [[ $VERBOSE -eq 1 ]]; then
69+
echo -e "$1"
70+
fi
71+
}
72+
73+
validate_input() {
74+
local val=$1
75+
local name=$2
76+
if [[ "$val" -eq 0 ]]; then
77+
return 0 # 0 means skip
78+
fi
79+
if [[ "$val" -lt 5 || "$val" -gt 20 ]]; then
80+
echo -e "${RED}[ERROR] $name priority must be between 5 and 20 (or 0 to skip).${NC}"
81+
exit 1
82+
fi
83+
}
84+
85+
calc_nice() {
86+
# Formula: Nice = Target_PRI - 20
87+
# Example: Input 10 -> 10 - 20 = -10 (Nice)
88+
echo $(( $1 - 20 ))
89+
}
90+
91+
# --- CLI PARSING ---
92+
while getopts "hvd:s:" opt; do
93+
case ${opt} in
94+
h ) show_help; exit 0 ;;
95+
v ) VERBOSE=1 ;;
96+
d ) INPUT_DOCKER_PRI=$OPTARG ;;
97+
s ) INPUT_NATIVE_PRI=$OPTARG ;;
98+
\? ) show_help; exit 1 ;;
99+
esac
100+
done
101+
102+
# --- ROOT CHECK ---
24103
if [[ $EUID -ne 0 ]]; then
25104
echo -e "${RED}[ERROR] Root privileges required.${NC}"
26105
exit 1
27106
fi
28107

29-
echo -e "${GREEN}Starting Conduit Optimizer v1.4.0${NC}"
108+
# --- VALIDATION ---
109+
validate_input "$INPUT_DOCKER_PRI" "Docker"
110+
validate_input "$INPUT_NATIVE_PRI" "Native Service"
111+
112+
echo -e "${GREEN}Starting Conduit Optimizer v1.5.0${NC}"
30113
echo -e "Author: Babak Sorkhpour"
31114
echo "---------------------------------------------------"
115+
if [[ $INPUT_NATIVE_PRI -gt 0 ]]; then
116+
echo -e "Target Native PRI : ${YELLOW}$INPUT_NATIVE_PRI${NC} (Nice $(calc_nice $INPUT_NATIVE_PRI))"
117+
else
118+
echo -e "Target Native PRI : ${YELLOW}SKIPPING${NC}"
119+
fi
120+
if [[ $INPUT_DOCKER_PRI -gt 0 ]]; then
121+
echo -e "Target Docker PRI : ${RED}$INPUT_DOCKER_PRI${NC} (Nice $(calc_nice $INPUT_DOCKER_PRI))"
122+
else
123+
echo -e "Target Docker PRI : ${YELLOW}SKIPPING${NC}"
124+
fi
125+
echo "---------------------------------------------------"
32126

33-
# Track PIDs to prevent double optimization (Native vs Docker overlap)
127+
# Track PIDs
34128
declare -A PROCESSED_PIDS
129+
TOTAL_SUCCESS=0
35130

36131
# ==============================================================================
37-
# SECTION 1: DOCKER OPTIMIZATION (Priority 1)
38-
# We run this FIRST to ensure Docker processes get the higher priority (-10)
39-
# even if they are also detected by the native scanner later.
132+
# PHASE 1: DOCKER
40133
# ==============================================================================
41-
echo -e "${BLUE}>> Phase 1: Scanning Docker Containers (Image & Name)...${NC}"
42-
43-
if command -v docker &>/dev/null; then
44-
# Search for containers where Image OR Name contains "conduit"
45-
# format: ID | Image | Names
46-
DOCKER_CANDIDATES=$(docker ps --format "{{.ID}} {{.Image}} {{.Names}}" | grep -i "conduit")
47-
48-
if [[ -n "$DOCKER_CANDIDATES" ]]; then
49-
# Read line by line
50-
while read -r LINE; do
51-
CID=$(echo "$LINE" | awk '{print $1}')
52-
C_INFO=$(echo "$LINE" | awk '{$1=""; print $0}') # Rest of the string
53-
54-
# Get Host PID
55-
CPID=$(docker inspect --format '{{.State.Pid}}' "$CID" 2>/dev/null)
56-
57-
if [[ -n "$CPID" && "$CPID" -gt 0 ]]; then
58-
renice -n "$PRIORITY_DOCKER_NICE" -p "$CPID" &>/dev/null
59-
ionice -c "$TARGET_IONICE_CLASS" -n "$TARGET_IONICE_LEVEL" -p "$CPID" &>/dev/null
60-
61-
PROCESSED_PIDS[$CPID]=1
62-
echo -e " [Docker] Container $CID ($C_INFO)"
63-
echo -e " PID: $CPID -> Nice $PRIORITY_DOCKER_NICE: ${GREEN}OK${NC}"
64-
fi
65-
done <<< "$DOCKER_CANDIDATES"
66-
else
67-
echo -e " ${YELLOW}No active containers matching 'conduit' found.${NC}"
68-
echo -e " (Debug: Ensure 'docker ps' shows running containers)"
134+
if [[ $INPUT_DOCKER_PRI -gt 0 ]]; then
135+
log_verbose "${BLUE}>> Phase 1: Scanning Docker Containers...${NC}"
136+
137+
TARGET_NICE=$(calc_nice $INPUT_DOCKER_PRI)
138+
139+
if command -v docker &>/dev/null; then
140+
DOCKER_CANDIDATES=$(docker ps --format "{{.ID}} {{.Image}} {{.Names}}" | grep -i "conduit")
141+
142+
if [[ -n "$DOCKER_CANDIDATES" ]]; then
143+
while read -r LINE; do
144+
CID=$(echo "$LINE" | awk '{print $1}')
145+
C_INFO=$(echo "$LINE" | awk '{$1=""; print $0}')
146+
CPID=$(docker inspect --format '{{.State.Pid}}' "$CID" 2>/dev/null)
147+
148+
if [[ -n "$CPID" && "$CPID" -gt 0 ]]; then
149+
renice -n "$TARGET_NICE" -p "$CPID" &>/dev/null
150+
ionice -c "$TARGET_IONICE_CLASS" -n "$TARGET_IONICE_LEVEL" -p "$CPID" &>/dev/null
151+
152+
PROCESSED_PIDS[$CPID]=1
153+
echo -e " [Docker] Container $CID -> PRI $INPUT_DOCKER_PRI: ${GREEN}OK${NC}"
154+
log_verbose " (Info: $C_INFO)"
155+
((TOTAL_SUCCESS++))
156+
fi
157+
done <<< "$DOCKER_CANDIDATES"
158+
else
159+
log_verbose " No active Docker containers found."
160+
fi
69161
fi
70-
else
71-
echo -e " Docker not installed or not in PATH."
72162
fi
73163

74164
# ==============================================================================
75-
# SECTION 2: NATIVE OPTIMIZATION (Priority 2)
165+
# PHASE 2: NATIVE
76166
# ==============================================================================
77-
echo -e "${BLUE}>> Phase 2: Scanning Native Processes...${NC}"
78-
79-
NATIVE_PIDS=$(pgrep -f "/opt/conduit.*/conduit")
167+
if [[ $INPUT_NATIVE_PRI -gt 0 ]]; then
168+
log_verbose "${BLUE}>> Phase 2: Scanning Native Processes...${NC}"
169+
170+
TARGET_NICE=$(calc_nice $INPUT_NATIVE_PRI)
171+
NATIVE_PIDS=$(pgrep -f "/opt/conduit.*/conduit")
80172

81-
if [[ -n "$NATIVE_PIDS" ]]; then
82-
for PID in $NATIVE_PIDS; do
83-
# Skip if already optimized as Docker
84-
if [[ ${PROCESSED_PIDS[$PID]} ]]; then
85-
continue
86-
fi
173+
if [[ -n "$NATIVE_PIDS" ]]; then
174+
for PID in $NATIVE_PIDS; do
175+
if [[ ${PROCESSED_PIDS[$PID]} ]]; then continue; fi
87176

88-
renice -n "$PRIORITY_NATIVE_NICE" -p "$PID" &>/dev/null
89-
ionice -c "$TARGET_IONICE_CLASS" -n "$TARGET_IONICE_LEVEL" -p "$PID" &>/dev/null
90-
91-
echo -e " [Native] PID: $PID -> Nice $PRIORITY_NATIVE_NICE: ${GREEN}OK${NC}"
92-
PROCESSED_PIDS[$PID]=1
93-
done
94-
else
95-
echo -e " No native processes found."
177+
renice -n "$TARGET_NICE" -p "$PID" &>/dev/null
178+
ionice -c "$TARGET_IONICE_CLASS" -n "$TARGET_IONICE_LEVEL" -p "$PID" &>/dev/null
179+
180+
echo -e " [Native] PID: $PID -> PRI $INPUT_NATIVE_PRI: ${GREEN}OK${NC}"
181+
PROCESSED_PIDS[$PID]=1
182+
((TOTAL_SUCCESS++))
183+
done
184+
else
185+
log_verbose " No native processes found."
186+
fi
96187
fi
97188

98189
# ==============================================================================
99-
# SECTION 3: VERIFICATION
190+
# PHASE 3: VERIFICATION
100191
# ==============================================================================
101192
echo "---------------------------------------------------"
102-
echo -e "${YELLOW}>> Phase 3: Final Verification${NC}"
103-
COUNT=${#PROCESSED_PIDS[@]}
104-
if [[ $COUNT -gt 0 ]]; then
105-
echo -e "${GREEN}>> SUCCESS: Optimized $COUNT processes.${NC}"
193+
if [[ $TOTAL_SUCCESS -gt 0 ]]; then
194+
echo -e "${GREEN}>> SUCCESS: Optimized $TOTAL_SUCCESS processes.${NC}"
106195
else
107-
echo -e "${RED}>> WARNING: No processes were optimized.${NC}"
196+
echo -e "${YELLOW}>> DONE: No eligible processes found or operations skipped.${NC}"
108197
fi

0 commit comments

Comments
 (0)