Улучшение фронта

This commit is contained in:
2026-02-08 06:12:19 +07:00
parent caf52afcdf
commit a3cdf02d48
34 changed files with 487 additions and 641 deletions

View File

@@ -39,7 +39,6 @@ func StartHTTPS() {
serverName := chi.ServerName
if serverName == "" {
tools.Logs_file(1, "HTTPS", "⚠️ Подключение без SNI (возможно по IP)", "logs_https.log", false)
} else if cert, ok := certMap[serverName]; ok {
// Найден точный сертификат для домена
@@ -59,7 +58,6 @@ func StartHTTPS() {
}
if fallbackCert != nil {
tools.Logs_file(1, "HTTPS", "⚠️ Используем fallback-сертификат", "logs_https.log", false)
return fallbackCert, nil
}

View File

@@ -377,7 +377,6 @@ func PHPHandler(w http.ResponseWriter, r *http.Request, host string, originalURI
return
}
tools.Logs_file(0, "PHP", fmt.Sprintf("✅ FastCGI обработал: %s (порт %d)", phpPath, port), "logs_php.log", false)
}
// Streaming чтение FastCGI ответа с поддержкой SSE и chunked transfer

View File

@@ -28,16 +28,9 @@ func isWebSocketRequest(r *http.Request) bool {
// Проксирует WebSocket соединение
func handleWebSocketProxy(w http.ResponseWriter, r *http.Request, proxyConfig config.Proxy_Service) bool {
// Определяем протокол для локального соединения
protocol := "ws"
networkProtocol := "tcp"
if proxyConfig.ServiceHTTPSuse {
protocol = "wss"
}
targetAddr := proxyConfig.LocalAddress + ":" + proxyConfig.LocalPort
tools.Logs_file(0, "WS-PROXY", "🔌 WebSocket: "+r.RemoteAddr+" → "+protocol+"://"+targetAddr+r.URL.Path, "logs_proxy.log", false)
// Захватываем клиентское соединение через Hijacker
hijacker, ok := w.(http.Hijacker)
@@ -135,7 +128,6 @@ func handleWebSocketProxy(w http.ResponseWriter, r *http.Request, proxyConfig co
return true
}
tools.Logs_file(0, "WS-PROXY", "✅ WebSocket установлен: "+r.Host+r.URL.Path, "logs_proxy.log", false)
// Двунаправленное проксирование данных
done := make(chan struct{}, 2)
@@ -171,7 +163,6 @@ func handleWebSocketProxy(w http.ResponseWriter, r *http.Request, proxyConfig co
// Ждём завершения одного из направлений
<-done
tools.Logs_file(0, "WS-PROXY", "🔌 WebSocket закрыт: "+r.Host+r.URL.Path, "logs_proxy.log", false)
return true
}

View File

@@ -388,32 +388,32 @@ func checkRules(rules []VAccessRule, requestPath string, r *http.Request, checkF
if errorPage == "" {
errorPage = "404"
}
tools.Logs_file(1, logPrefix, "🚫 Доступ запрещён для "+getClientIP(r)+" к "+requestPath, logFile, false)
return false, errorPage
tools.Logs_file(1, logPrefix, "🚫 Доступ запрещён для "+getClientIP(r)+" к "+r.Host+requestPath, logFile, false)
return false, errorPage
}
// Все условия Allow выполнены - разрешаем доступ
return true, ""
case "Disable":
// Disable правило: запрещаем если ЛЮБОЕ условие выполнено
shouldBlock := true
// Для расширений файлов (только если проверка включена)
if checkFileExtensions && len(rule.TypeFile) > 0 && !fileMatches {
shouldBlock = false
}
// Для IP адресов
if len(rule.IPList) > 0 && !ipMatches {
shouldBlock = false
}
if shouldBlock {
errorPage := rule.UrlError
if errorPage == "" {
errorPage = "404"
}
// Все условия Allow выполнены - разрешаем доступ
return true, ""
case "Disable":
// Disable правило: запрещаем если ЛЮБОЕ условие выполнено
shouldBlock := true
// Для расширений файлов (только если проверка включена)
if checkFileExtensions && len(rule.TypeFile) > 0 && !fileMatches {
shouldBlock = false
}
// Для IP адресов
if len(rule.IPList) > 0 && !ipMatches {
shouldBlock = false
}
if shouldBlock {
errorPage := rule.UrlError
if errorPage == "" {
errorPage = "404"
}
tools.Logs_file(1, logPrefix, "🚫 Доступ запрещён для "+getClientIP(r)+" к "+requestPath, logFile, false)
tools.Logs_file(1, logPrefix, "🚫 Доступ запрещён для "+getClientIP(r)+" к "+r.Host+requestPath, logFile, false)
return false, errorPage
}