-
Notifications
You must be signed in to change notification settings - Fork 309
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add registered clients feature #86
base: master
Are you sure you want to change the base?
Conversation
Hi @moisespsena, |
Hi @mmatczuk,
Example for embed 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 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
} |
@@ -21,6 +22,7 @@ const ( | |||
DefaultBackoffMultiplier = 1.5 | |||
DefaultBackoffMaxInterval = 60 * time.Second | |||
DefaultBackoffMaxTime = 15 * time.Minute | |||
ConfigFileSTDIN = "-" |
There was a problem hiding this comment.
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."
There was a problem hiding this comment.
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.
@@ -24,7 +24,7 @@ import ( | |||
) | |||
|
|||
func Main() { | |||
MainArgs(os.Args[1:]...) | |||
MainArgs(os.Args...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
There was a problem hiding this comment.
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.
@@ -91,7 +91,8 @@ func ParseArgs(hasConfig bool, args ...string) (*options, error) { | |||
cli := flag.NewFlagSet(args[0], flag.ExitOnError) | |||
args = args[1:] | |||
if hasConfig { | |||
config = cli.String("config", "tunnel.yaml", "Path to tunnel configuration file") | |||
config = cli.String("config", "tunnel.yaml", |
There was a problem hiding this comment.
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 '-'.
?
There was a problem hiding this comment.
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 -
Add registered clients feature. See README.md for more details.