mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-06 13:25:51 +01:00
add warning for terminal ssl
This commit is contained in:
@@ -209,6 +209,13 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
{% if accessed_via_ip %}
|
||||
<div class="alert alert-danger ssh-access-warning">
|
||||
<strong>Notice:</strong> You are accessing CyberPanel via an <b>IP address</b>.<br>
|
||||
The Web Terminal will not work when accessed via IP. Please issue a <b>hostname SSL</b> and access the panel using your hostname (with valid SSL) to enable the terminal.<br>
|
||||
<a href="{{ ssl_issue_link }}" target="_blank" class="btn btn-warning" style="margin-top:10px;">Issue Hostname SSL</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if is_selfsigned_ssl %}
|
||||
<div class="alert alert-warning ssh-access-warning">
|
||||
<strong>Warning:</strong> Your server is using a <b>self-signed SSL certificate</b> for the web terminal.<br>
|
||||
|
||||
@@ -142,6 +142,14 @@
|
||||
|
||||
{% if not error %}
|
||||
|
||||
{% if accessed_via_ip %}
|
||||
<div class="alert alert-danger ssh-access-warning">
|
||||
<strong>Notice:</strong> You are accessing CyberPanel via an <b>IP address</b>.<br>
|
||||
The Web Terminal will not work when accessed via IP. Please issue a <b>hostname SSL</b> and access the panel using your hostname (with valid SSL) to enable the terminal.<br>
|
||||
<a href="{{ ssl_issue_link }}" target="_blank" class="btn btn-warning" style="margin-top:10px;">Issue Hostname SSL</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div style="display:flex;justify-content:flex-end;gap:18px;margin-bottom:18px;align-items:center;">
|
||||
<!-- Open Terminal Button -->
|
||||
<button ng-click="openWebTerminal()" type="button" class="btn btn-success"
|
||||
|
||||
@@ -43,6 +43,7 @@ from plogical.cronUtil import CronUtil
|
||||
from .StagingSetup import StagingSetup
|
||||
import validators
|
||||
from django.http import JsonResponse
|
||||
import ipaddress
|
||||
|
||||
|
||||
class WebsiteManager:
|
||||
@@ -3111,6 +3112,23 @@ Require valid-user
|
||||
Data['is_selfsigned_ssl'] = bool(is_selfsigned)
|
||||
Data['ssl_issue_link'] = ssl_issue_link
|
||||
|
||||
|
||||
# Detect if accessed via IP
|
||||
from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter
|
||||
accessed_via_ip = False
|
||||
try:
|
||||
host = request.get_host().split(':')[0] # Remove port if present
|
||||
try:
|
||||
ipaddress.ip_address(host)
|
||||
accessed_via_ip = True
|
||||
except ValueError:
|
||||
accessed_via_ip = False
|
||||
except Exception as e:
|
||||
accessed_via_ip = False
|
||||
CyberCPLogFileWriter.writeToFile(f"Error detecting accessed_via_ip: {str(e)}")
|
||||
|
||||
Data['accessed_via_ip'] = bool(accessed_via_ip)
|
||||
|
||||
proc = httpProc(request, 'websiteFunctions/website.html', Data)
|
||||
return proc.render()
|
||||
else:
|
||||
@@ -5096,8 +5114,21 @@ StrictHostKeyChecking no
|
||||
is_selfsigned = True # If cert missing or unreadable, treat as self-signed
|
||||
CyberCPLogFileWriter.writeToFile(f"is_selfsigned: {is_selfsigned}. Error: {str(e)}")
|
||||
|
||||
# Detect if accessed via IP
|
||||
accessed_via_ip = False
|
||||
try:
|
||||
host = request.get_host().split(':')[0] # Remove port if present
|
||||
try:
|
||||
ipaddress.ip_address(host)
|
||||
accessed_via_ip = True
|
||||
except ValueError:
|
||||
accessed_via_ip = False
|
||||
except Exception as e:
|
||||
accessed_via_ip = False
|
||||
CyberCPLogFileWriter.writeToFile(f"Error detecting accessed_via_ip: {str(e)}")
|
||||
|
||||
proc = httpProc(request, 'websiteFunctions/sshAccess.html',
|
||||
{'domainName': self.domain, 'externalApp': externalApp, 'has_addons': has_addons, 'is_selfsigned_ssl': is_selfsigned, 'ssl_issue_link': ssl_issue_link})
|
||||
{'domainName': self.domain, 'externalApp': externalApp, 'has_addons': has_addons, 'is_selfsigned_ssl': is_selfsigned, 'ssl_issue_link': ssl_issue_link, 'accessed_via_ip': accessed_via_ip})
|
||||
return proc.render()
|
||||
|
||||
def saveSSHAccessChanges(self, userID=None, data=None):
|
||||
|
||||
Reference in New Issue
Block a user