add tcp as supported protocol
This commit is contained in:
parent
dd521aba29
commit
3c9b700a52
|
@ -115,7 +115,7 @@ func Commands() []*cli.Command {
|
|||
{
|
||||
Name: "ssh",
|
||||
Action: ssh,
|
||||
Aliases: []string{"rdp"},
|
||||
Aliases: []string{"rdp", "tcp"},
|
||||
Usage: "",
|
||||
ArgsUsage: "",
|
||||
Description: `The ssh subcommand sends data over a proxy to the Cloudflare edge.`,
|
||||
|
|
|
@ -622,10 +622,19 @@ func hostnameFromURI(uri string) string {
|
|||
return addPortIfMissing(u, 22)
|
||||
case "rdp":
|
||||
return addPortIfMissing(u, 3389)
|
||||
case "tcp":
|
||||
return errorIfPortMissing(u)
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func errorIfPortMissing(uri *url.URL) string {
|
||||
if uri.Port() == "" {
|
||||
return "Port must be speficied for"
|
||||
}
|
||||
return uri.Host
|
||||
}
|
||||
|
||||
func addPortIfMissing(uri *url.URL, port int) string {
|
||||
if uri.Port() != "" {
|
||||
return uri.Host
|
||||
|
|
|
@ -12,6 +12,7 @@ func TestHostnameFromURI(t *testing.T) {
|
|||
assert.Equal(t, "awesome.warptunnels.horse:2222", hostnameFromURI("ssh://awesome.warptunnels.horse:2222"))
|
||||
assert.Equal(t, "localhost:3389", hostnameFromURI("rdp://localhost"))
|
||||
assert.Equal(t, "localhost:3390", hostnameFromURI("rdp://localhost:3390"))
|
||||
assert.Equal(t, "localhost:3306", hostnameFromURI("tcp://localhost:3306"))
|
||||
assert.Equal(t, "", hostnameFromURI("trash"))
|
||||
assert.Equal(t, "", hostnameFromURI("https://awesomesauce.com"))
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ import (
|
|||
const defaultScheme = "http"
|
||||
|
||||
var (
|
||||
supportedProtocols = []string{"http", "https", "rdp"}
|
||||
supportedProtocols = []string{"http", "https", "rdp", "tcp"}
|
||||
validationTimeout = time.Duration(30 * time.Second)
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue