update: redirect user to not found tunnel page
All checks were successful
Docker Build and Push / build-and-push (push) Successful in 3m52s

This commit is contained in:
2025-09-08 09:59:41 +07:00
parent 334655b116
commit 0999196ee9
3 changed files with 13 additions and 3 deletions

View File

@ -155,7 +155,11 @@ func Handler(conn net.Conn) {
sshSession, ok := session.Clients[slug] sshSession, ok := session.Clients[slug]
if !ok { if !ok {
conn.Write([]byte("HTTP/1.1 400 Bad Request\r\n\r\n")) conn.Write([]byte("HTTP/1.1 301 Moved Permanently\r\n" +
fmt.Sprintf("Location: https://%s/tunnel-not-found?slug=%s\r\n", utils.Getenv("domain"), slug) +
"Content-Length: 0\r\n" +
"Connection: close\r\n" +
"\r\n"))
conn.Close() conn.Close()
return return
} }

View File

@ -4,6 +4,7 @@ import (
"bufio" "bufio"
"crypto/tls" "crypto/tls"
"errors" "errors"
"fmt"
"log" "log"
"net" "net"
"net/http" "net/http"
@ -101,7 +102,11 @@ func HandlerTLS(conn net.Conn) {
sshSession, ok := session.Clients[slug] sshSession, ok := session.Clients[slug]
if !ok { if !ok {
conn.Write([]byte("HTTP/1.1 400 Bad Request\r\n\r\n")) conn.Write([]byte("HTTP/1.1 301 Moved Permanently\r\n" +
fmt.Sprintf("Location: https://%s/tunnel-not-found?slug=%s\r\n", utils.Getenv("domain"), slug) +
"Content-Length: 0\r\n" +
"Connection: close\r\n" +
"\r\n"))
conn.Close() conn.Close()
return return
} }

View File

@ -1,13 +1,14 @@
package utils package utils
import ( import (
"github.com/joho/godotenv"
"log" "log"
"math/rand" "math/rand"
"os" "os"
"strings" "strings"
"sync" "sync"
"time" "time"
"github.com/joho/godotenv"
) )
type Env struct { type Env struct {