diff --git a/internal/runner/runner.go b/internal/runner/runner.go index ad48094..6d6ca0d 100644 --- a/internal/runner/runner.go +++ b/internal/runner/runner.go @@ -16,7 +16,6 @@ import ( "github.com/kitabisa/teler-proxy/common" "github.com/kitabisa/teler-proxy/internal/cron" "github.com/kitabisa/teler-proxy/internal/writer" - "github.com/kitabisa/teler-proxy/pkg/tunnel" "github.com/kitabisa/teler-waf" "github.com/kitabisa/teler-waf/threat" ) @@ -56,8 +55,9 @@ func New(opt *common.Options) error { } dest := buildDest(opt.Destination) + writer := writer.New() - tun, err := tunnel.NewTunnel(opt.Port, dest, opt.Config.Path, opt.Config.Format, writer.New()) + tun, err := run.createTunnel(dest, writer) if err != nil { return err } diff --git a/internal/runner/utils.go b/internal/runner/utils.go index 43071b9..6e51839 100644 --- a/internal/runner/utils.go +++ b/internal/runner/utils.go @@ -2,11 +2,14 @@ package runner import ( "fmt" + "io" "net" "strings" "time" "net/url" + + "github.com/kitabisa/teler-proxy/pkg/tunnel" ) func parseURL(dest string) (*url.URL, error) { @@ -67,3 +70,9 @@ func (r *Runner) shouldCron() bool { return false } + +func (r *Runner) createTunnel(dest string, writer io.Writer) (*tunnel.Tunnel, error) { + opt := r.Options + + return tunnel.NewTunnel(opt.Port, dest, opt.Config.Path, opt.Config.Format, writer) +}