From 239ac4cdf9f14e3fba8320d73843199fc4f1ef1b Mon Sep 17 00:00:00 2001 From: Dwi Siswanto Date: Wed, 12 Jul 2023 18:55:05 +0700 Subject: [PATCH] feat(tunnel): move up the validation --- pkg/tunnel/tunnel.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/tunnel/tunnel.go b/pkg/tunnel/tunnel.go index 70e5d0f..94e5a89 100644 --- a/pkg/tunnel/tunnel.go +++ b/pkg/tunnel/tunnel.go @@ -18,6 +18,10 @@ type Tunnel struct { } func NewTunnel(port int, dest, cfgPath, optFormat string) (*Tunnel, error) { + if dest == "" { + return nil, common.ErrDestAddressEmpty + } + dest = "http://" + dest destURL, err := url.Parse(dest) if err != nil { @@ -26,10 +30,6 @@ func NewTunnel(port int, dest, cfgPath, optFormat string) (*Tunnel, error) { var opt teler.Options - if dest == "" { - return nil, common.ErrDestAddressEmpty - } - tun := &Tunnel{} tun.ReverseProxy = httputil.NewSingleHostReverseProxy(destURL)