Skip to content

Commit

Permalink
more notes
Browse files Browse the repository at this point in the history
  • Loading branch information
nickzelei committed Oct 1, 2024
1 parent 4c52262 commit ad60fbc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/sshtunnel/dialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type SSHDialer struct {
clientmu *sync.RWMutex
}

func NewDialer(addr string, cfg *ssh.ClientConfig) *SSHDialer {
func NewLazyDialer(addr string, cfg *ssh.ClientConfig) *SSHDialer {

Check failure on line 29 in internal/sshtunnel/dialer.go

View workflow job for this annotation

GitHub Actions / golang-lint

unnecessary leading newline (whitespace)

return &SSHDialer{addr: addr, cfg: cfg, clientmu: &sync.RWMutex{}}
}
Expand Down
20 changes: 20 additions & 0 deletions internal/sshtunnel/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ type NetProxy struct {
dailer Dialer
}

// Create a new proxy that when started will bind to the source endpoint
func NewProxy(
source *Endpoint,
destination *Endpoint,
Expand All @@ -18,6 +19,25 @@ func NewProxy(
}
}

// The proxy binds to localhost on a random port
func NewHostProxy(
destination *Endpoint,
dialer Dialer,
) *NetProxy {
return &NetProxy{
source: &Endpoint{host: "localhost", port: 0},
destination: destination,
dailer: dialer,
}
}

// I think this thing was supposed to act as a traditional proxy.
// It takes in a source, destination, and a tunnel dialer.
// When the proxy is started, it will start a TCP server
// and forward incoming traffic to the destination
// I think the source is useful if you want to bind to a specific local port
// Port 0 is the special case that allows you to bind to any port

func (n *NetProxy) GetSourceValues() (host string, port int) {
return n.source.GetValues()
}

0 comments on commit ad60fbc

Please sign in to comment.