Skip to content

Commit

Permalink
chore(runner): refactor tunnel generator
Browse files Browse the repository at this point in the history
Signed-off-by: Dwi Siswanto <[email protected]>
  • Loading branch information
dwisiswant0 committed Oct 25, 2023
1 parent 75a17af commit bd714b1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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
}
Expand Down
9 changes: 9 additions & 0 deletions internal/runner/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
}

0 comments on commit bd714b1

Please sign in to comment.