Merge pull request #19 from outis1one/claude/fix-extension-connectivity-QNhcq
Fix web admin stop and device status detection
This commit is contained in:
@@ -3756,18 +3756,28 @@ def check_auth(headers):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def get_registered_endpoints():
|
def get_registered_endpoints():
|
||||||
"""Get list of registered endpoints from Asterisk"""
|
"""Get list of registered endpoints from Asterisk - matches bash script logic"""
|
||||||
try:
|
try:
|
||||||
|
# Get full endpoint details which shows Contact lines with Avail status
|
||||||
result = subprocess.run(
|
result = subprocess.run(
|
||||||
['asterisk', '-rx', 'pjsip show endpoints'],
|
['asterisk', '-rx', 'pjsip show endpoints'],
|
||||||
capture_output=True, text=True, timeout=5
|
capture_output=True, text=True, timeout=10
|
||||||
)
|
)
|
||||||
endpoints = {}
|
endpoints = {}
|
||||||
|
current_endpoint = None
|
||||||
|
|
||||||
for line in result.stdout.split('\n'):
|
for line in result.stdout.split('\n'):
|
||||||
match = re.match(r'\s*(\d{3})/\S+\s+(\S+)\s+', line)
|
# Match endpoint header line: " Endpoint: 101/101"
|
||||||
if match:
|
endpoint_match = re.match(r'\s*Endpoint:\s+(\d+)/', line)
|
||||||
ext, state = match.groups()
|
if endpoint_match:
|
||||||
endpoints[ext] = 'online' if 'Avail' in state else 'offline'
|
current_endpoint = endpoint_match.group(1)
|
||||||
|
endpoints[current_endpoint] = 'offline' # Default to offline
|
||||||
|
|
||||||
|
# Match contact line with Avail status: " Contact: 101/sip:... Avail"
|
||||||
|
if current_endpoint and 'Contact:' in line:
|
||||||
|
if 'Avail' in line or 'NonQual' in line:
|
||||||
|
endpoints[current_endpoint] = 'online'
|
||||||
|
|
||||||
return endpoints
|
return endpoints
|
||||||
except:
|
except:
|
||||||
return {}
|
return {}
|
||||||
@@ -4692,8 +4702,15 @@ web_admin_menu() {
|
|||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
2)
|
2)
|
||||||
systemctl stop easy-asterisk-webadmin
|
systemctl stop easy-asterisk-webadmin 2>/dev/null
|
||||||
systemctl disable easy-asterisk-webadmin 2>/dev/null
|
systemctl disable easy-asterisk-webadmin 2>/dev/null
|
||||||
|
# Kill any remaining processes
|
||||||
|
pkill -f "easy-asterisk-webadmin" 2>/dev/null || true
|
||||||
|
sleep 1
|
||||||
|
# Force kill if still running
|
||||||
|
pkill -9 -f "easy-asterisk-webadmin" 2>/dev/null || true
|
||||||
|
# Release the port if still held
|
||||||
|
fuser -k "${WEB_ADMIN_PORT}/tcp" 2>/dev/null || true
|
||||||
print_success "Web Admin stopped"
|
print_success "Web Admin stopped"
|
||||||
;;
|
;;
|
||||||
3)
|
3)
|
||||||
|
|||||||
Reference in New Issue
Block a user