From a78e1d24bf271c18750b612ad42b5a075efe2417 Mon Sep 17 00:00:00 2001 From: Anton Kuznetcov Date: Sun, 9 Nov 2025 14:02:35 +0600 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=B2=20=D0=B2=D0=B5=D1=82=D0=BA?= =?UTF-8?q?=D0=B5=20main?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfiles/OllamaServer/Dockerfile | 2 ++ VERSION.txt | 2 +- deploy/VERSION.txt | 2 +- kustomize/configmap.yaml | 2 +- kustomize/deployment.yaml | 4 ++-- kustomize/kustomization.yaml | 4 ++-- serve/auth.go | 19 +++++++++++----- serve/csrf.go | 34 +++++++++++++++++++++++++---- serve/templates/execute.css.go | 3 ++- 9 files changed, 55 insertions(+), 17 deletions(-) diff --git a/Dockerfiles/OllamaServer/Dockerfile b/Dockerfiles/OllamaServer/Dockerfile index 34c7949..ef331cd 100644 --- a/Dockerfiles/OllamaServer/Dockerfile +++ b/Dockerfiles/OllamaServer/Dockerfile @@ -60,6 +60,8 @@ RUN chown -R ollama:ollama /app/data 2>/dev/null || \ (chown -R 1000:1000 /app/data 2>/dev/null || true) # Настройки по умолчанию +ENV TZ='Asia/Omsk' +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone ENV LCG_PROVIDER=ollama ENV LCG_HOST=http://127.0.0.1:11434/ ENV LCG_MODEL=qwen2.5-coder:1.5b diff --git a/VERSION.txt b/VERSION.txt index b1e69f3..4b9ce42 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -v.2.0.17 +v.2.0.18 diff --git a/deploy/VERSION.txt b/deploy/VERSION.txt index b1e69f3..4b9ce42 100644 --- a/deploy/VERSION.txt +++ b/deploy/VERSION.txt @@ -1 +1 @@ -v.2.0.17 +v.2.0.18 diff --git a/kustomize/configmap.yaml b/kustomize/configmap.yaml index 0d3e564..d31eec5 100644 --- a/kustomize/configmap.yaml +++ b/kustomize/configmap.yaml @@ -5,7 +5,7 @@ metadata: namespace: lcg data: # Основные настройки - LCG_VERSION: "v.2.0.17" + LCG_VERSION: "v.2.0.18" LCG_BASE_PATH: "/lcg" LCG_SERVER_HOST: "0.0.0.0" LCG_SERVER_PORT: "8080" diff --git a/kustomize/deployment.yaml b/kustomize/deployment.yaml index 81d4d38..f77384f 100644 --- a/kustomize/deployment.yaml +++ b/kustomize/deployment.yaml @@ -5,7 +5,7 @@ metadata: namespace: lcg labels: app: lcg - version: v.2.0.17 + version: v.2.0.18 spec: replicas: 1 selector: @@ -18,7 +18,7 @@ spec: spec: containers: - name: lcg - image: kuznetcovay/lcg:v.2.0.17 + image: kuznetcovay/lcg:v.2.0.18 imagePullPolicy: Always ports: - containerPort: 8080 diff --git a/kustomize/kustomization.yaml b/kustomize/kustomization.yaml index 624aacc..491bd7b 100644 --- a/kustomize/kustomization.yaml +++ b/kustomize/kustomization.yaml @@ -15,11 +15,11 @@ resources: # Common labels # commonLabels: # app: lcg -# version: v.2.0.17 +# version: v.2.0.18 # managed-by: kustomize # Images # images: # - name: lcg # newName: kuznetcovay/lcg -# newTag: v.2.0.17 +# newTag: v.2.0.18 diff --git a/serve/auth.go b/serve/auth.go index c21577e..cc107cc 100644 --- a/serve/auth.go +++ b/serve/auth.go @@ -127,7 +127,6 @@ func getTokenFromCookie(r *http.Request) (string, error) { func setAuthCookie(w http.ResponseWriter, token string) { cookie := &http.Cookie{ Name: "auth_token", - Domain: config.AppConfig.Server.Domain, Value: token, Path: config.AppConfig.Server.CookiePath, HttpOnly: true, @@ -136,9 +135,16 @@ func setAuthCookie(w http.ResponseWriter, token string) { MaxAge: config.AppConfig.Server.CookieTTLHours * 60 * 60, } - // Добавляем домен если указан + // Устанавливаем Domain только если это не IP адрес и не 0.0.0.0 + // При доступе по IP адресу не устанавливаем Domain, иначе cookie не будет работать if config.AppConfig.Server.Domain != "" { - cookie.Domain = config.AppConfig.Server.Domain + domain := config.AppConfig.Server.Domain + // Проверяем, не является ли домен IP адресом или 0.0.0.0 + if !isIPAddress(domain) && domain != "0.0.0.0" && domain != "::" && domain != "::1" { + cookie.Domain = domain + } + // Если domain пустой, 0.0.0.0 или IP адрес - не устанавливаем Domain + // Браузер автоматически применит cookie к текущему хосту } http.SetCookie(w, cookie) @@ -156,9 +162,12 @@ func clearAuthCookie(w http.ResponseWriter) { MaxAge: -1, // Удаляем cookie } - // Добавляем домен если указан + // Устанавливаем Domain только если это не IP адрес if config.AppConfig.Server.Domain != "" { - cookie.Domain = config.AppConfig.Server.Domain + domain := config.AppConfig.Server.Domain + if !isIPAddress(domain) && domain != "0.0.0.0" && domain != "::" && domain != "::1" { + cookie.Domain = domain + } } http.SetCookie(w, cookie) diff --git a/serve/csrf.go b/serve/csrf.go index a42e6b4..7d73ac2 100644 --- a/serve/csrf.go +++ b/serve/csrf.go @@ -8,6 +8,8 @@ import ( "fmt" "net/http" "os" + "strconv" + "strings" "time" "github.com/direct-dev-ru/linux-command-gpt/config" @@ -172,9 +174,16 @@ func setCSRFCookie(w http.ResponseWriter, token string) { MaxAge: CSRFTokenLifetimeSeconds, // Минимум 12 часов в секундах } - // Добавляем домен если указан + // Устанавливаем Domain только если это не IP адрес и не 0.0.0.0 + // При доступе по IP адресу не устанавливаем Domain, иначе cookie не будет работать if config.AppConfig.Server.Domain != "" { - cookie.Domain = config.AppConfig.Server.Domain + domain := config.AppConfig.Server.Domain + // Проверяем, не является ли домен IP адресом или 0.0.0.0 + if !isIPAddress(domain) && domain != "0.0.0.0" && domain != "::" && domain != "::1" { + cookie.Domain = domain + } + // Если domain пустой, 0.0.0.0 или IP адрес - не устанавливаем Domain + // Браузер автоматически применит cookie к текущему хосту } http.SetCookie(w, cookie) @@ -192,9 +201,12 @@ func СlearCSRFCookie(w http.ResponseWriter) { MaxAge: -1, } - // Добавляем домен если указан + // Устанавливаем Domain только если это не IP адрес if config.AppConfig.Server.Domain != "" { - cookie.Domain = config.AppConfig.Server.Domain + domain := config.AppConfig.Server.Domain + if !isIPAddress(domain) && domain != "0.0.0.0" && domain != "::" && domain != "::1" { + cookie.Domain = domain + } } http.SetCookie(w, cookie) @@ -270,3 +282,17 @@ func InitCSRFManager() error { func GetCSRFManager() *CSRFManager { return csrfManager } + +// isIPAddress проверяет, является ли строка IPv4 адресом +func isIPAddress(s string) bool { + parts := strings.Split(s, ".") + if len(parts) != 4 { + return false + } + for _, part := range parts { + if num, err := strconv.Atoi(part); err != nil || num < 0 || num > 255 { + return false + } + } + return true +} diff --git a/serve/templates/execute.css.go b/serve/templates/execute.css.go index a9d35cc..c24adb5 100644 --- a/serve/templates/execute.css.go +++ b/serve/templates/execute.css.go @@ -72,8 +72,9 @@ var ExecutePageCSSTemplate = template.Must(template.New("execute_css").Parse(` text-align: center; } .header h1 { + margin: 0; font-size: 2.5em; - margin-bottom: 10px; + font-weight: 300; } .header p { opacity: 0.9;