update: redirect user to not found tunnel page
All checks were successful
Docker Build and Push / build-and-push (push) Successful in 3m52s
All checks were successful
Docker Build and Push / build-and-push (push) Successful in 3m52s
This commit is contained in:
@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user