diff --git a/rvpn/server/listener_generic.go b/rvpn/server/listener_generic.go index ad56bdc..0f68e52 100644 --- a/rvpn/server/listener_generic.go +++ b/rvpn/server/listener_generic.go @@ -18,6 +18,7 @@ import ( "github.com/gorilla/websocket" "git.daplie.com/Daplie/go-rvpn-server/rvpn/packer" + "git.daplie.com/Daplie/go-rvpn-server/rvpn/sni" ) type contextKey string @@ -160,7 +161,7 @@ func handleConnection(ctx context.Context, wConn *WedgeConn) { wssHostName := ctx.Value(ctxWssHostName).(string) adminHostName := ctx.Value(ctxAdminHostName).(string) - sniHostName, err := getHello(peek) + sniHostName, err := sni.GetHostname(peek) if err != nil { loginfo.Println(err) return diff --git a/rvpn/server/tls_get_hello.go b/rvpn/sni/tls_get_hostname.go similarity index 91% rename from rvpn/server/tls_get_hello.go rename to rvpn/sni/tls_get_hostname.go index 8aa78c4..606fdf7 100644 --- a/rvpn/server/tls_get_hello.go +++ b/rvpn/sni/tls_get_hostname.go @@ -1,10 +1,11 @@ -package server +package sni import ( "errors" ) -func getHello(b []byte) (string, error) { +// GetHostname uses SNI to determine the intended target of a new TLS connection. +func GetHostname(b []byte) (string, error) { rest := b[5:] current := 0 handshakeType := rest[0]