refactor: restructure project architecture
All checks were successful
renovate / renovate (push) Successful in 45s
Docker Build and Push / build-and-push-branches (push) Successful in 5m54s
Docker Build and Push / build-and-push-tags (push) Successful in 6m21s

This commit is contained in:
2025-12-31 15:49:37 +07:00
parent 878664e0ac
commit acd02aadd3
13 changed files with 89 additions and 77 deletions

View File

@@ -11,8 +11,8 @@ import (
"regexp"
"strings"
"time"
"tunnel_pls/internal/config"
"tunnel_pls/session"
"tunnel_pls/utils"
"golang.org/x/crypto/ssh"
)
@@ -231,12 +231,12 @@ func (cw *customWriter) AddInteraction(interaction Interaction) {
var redirectTLS = false
func NewHTTPServer() error {
httpPort := utils.Getenv("HTTP_PORT", "8080")
httpPort := config.Getenv("HTTP_PORT", "8080")
listener, err := net.Listen("tcp", ":"+httpPort)
if err != nil {
return errors.New("Error listening: " + err.Error())
}
if utils.Getenv("TLS_ENABLED", "false") == "true" && utils.Getenv("TLS_REDIRECT", "false") == "true" {
if config.Getenv("TLS_ENABLED", "false") == "true" && config.Getenv("TLS_REDIRECT", "false") == "true" {
redirectTLS = true
}
go func() {
@@ -288,7 +288,7 @@ func Handler(conn net.Conn) {
if redirectTLS {
_, err = conn.Write([]byte("HTTP/1.1 301 Moved Permanently\r\n" +
fmt.Sprintf("Location: https://%s.%s/\r\n", slug, utils.Getenv("DOMAIN", "localhost")) +
fmt.Sprintf("Location: https://%s.%s/\r\n", slug, config.Getenv("DOMAIN", "localhost")) +
"Content-Length: 0\r\n" +
"Connection: close\r\n" +
"\r\n"))