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