feat: close connection if no tunneling request is specified
All checks were successful
Docker Build and Push / build-and-push (push) Successful in 7m18s

This commit is contained in:
2025-10-20 12:28:52 +00:00
parent 659b2b82ec
commit e02b7ed937
7 changed files with 82 additions and 66 deletions

View File

@ -63,7 +63,7 @@ var allowedCors = make(map[string]bool)
var isAllowedAllCors = false
func init() {
corsList := utils.Getenv("cors_list")
corsList := utils.Getenv("CORS_LIST")
if corsList == "*" {
isAllowedAllCors = true
} else {
@ -86,11 +86,11 @@ func NewHTTPServer() error {
}
}
listener, err := net.Listen("tcp", ":80")
listener, err := net.Listen("tcp", fmt.Sprintf(":%s", utils.Getenv("HTTP_PORT")))
if err != nil {
return errors.New("Error listening: " + err.Error())
}
if utils.Getenv("tls_enabled") == "true" && utils.Getenv("tls_redirect") == "true" {
if utils.Getenv("TLS_ENABLED") == "true" && utils.Getenv("TLS_ENABLED") == "true" {
redirectTLS = true
}
go func() {
@ -129,7 +129,7 @@ func Handler(conn net.Conn) {
if redirectTLS {
conn.Write([]byte("HTTP/1.1 301 Moved Permanently\r\n" +
fmt.Sprintf("Location: https://%s.%s/\r\n", slug, utils.Getenv("domain")) +
fmt.Sprintf("Location: https://%s.%s/\r\n", slug, utils.Getenv("DOMAIN")) +
"Content-Length: 0\r\n" +
"Connection: close\r\n" +
"\r\n"))