Skip to content

Conversation

moisespsena
Copy link

Add registered clients feature. See README.md for more details.

@mmatczuk
Copy link
Owner

Hi @moisespsena,
could you please elaborate on what this patch set does what is the motivation.
Overall it's a massive PR, I do not follow all the decisions such as moving cmd to cli could you give more insight to that too.

@moisespsena
Copy link
Author

moisespsena commented Oct 17, 2018

Hi @mmatczuk,

  1. My motivation was a need to have multiple data collectors behind a router and that could be accessed externally. As these collectors are sent to various places on different projects, and because they have no control over these collectors, the need arose to release the tunnel only to registered collectors.

  2. I moved cmd to cli to allow exposes "tunnel" and "tunneld" to be embedded.

Example for embed tunnel in your code.

package main

import "github.com/mmatczuk/go-http-tunnel/cli/tunnel"

func tunnelClient() {
	options, err := tunnel.ParseArgs(false, "mycmd", "start-all")
	if err != nil {
		panic(err)
	}
	tunnel.MainConfigOptions(&tunnel.ClientConfig{
		ServerAddr: "domain.com:2000",
		Tunnels: map[string]*tunnel.Tunnel{
			"main": {
				Protocol:   "tcp",
				LocalAddr:  "localhost:5000",
				RemoteAddr: "domain.com:5000",
			},
		},
	}, options)
}

func main() {
	go tunnelClient()

	// ... my system code
}

Example for embed tunneld in your code.

package main

import "github.com/mmatczuk/go-http-tunnel/cli/tunneld"

func main() {
	go tunneld.MainArgs("mycmd", "-log-level", "3", "-httpAddr", ":19000", "-httpsAddr", ":19001")

	// ... my system code
}

DefaultBackoffMultiplier = 1.5
DefaultBackoffMaxInterval = 60 * time.Second
DefaultBackoffMaxTime = 15 * time.Minute
ConfigFileSTDIN = "-"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like it's not part of "Default backoff configuration."

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only stdin file path reference.


func Main() {
MainArgs(os.Args[1:]...)
MainArgs(os.Args...)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Author

@moisespsena moisespsena Nov 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the old version, the ParseArgs function uses the os.Args[0], for command name, now, uses the first passed argument.

args = args[1:]
if hasConfig {
config = cli.String("config", "tunnel.yaml", "Path to tunnel configuration file")
config = cli.String("config", "tunnel.yaml",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about Path to tunnel configuration file, for reading from STDIN use '-'.?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used as an example the "cat" command: cat -

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants