mirror of
https://github.com/openziti/zrok.git
synced 2025-01-05 13:38:53 +01:00
better URL validation (#83)
This commit is contained in:
parent
98b7f81aa8
commit
56a0b255af
@ -16,6 +16,7 @@ import (
|
|||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"strings"
|
"strings"
|
||||||
@ -48,6 +49,17 @@ func newHttpBackendCommand() *httpBackendCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *httpBackendCommand) run(_ *cobra.Command, args []string) {
|
func (self *httpBackendCommand) run(_ *cobra.Command, args []string) {
|
||||||
|
targetEndpoint, err := url.Parse(args[0])
|
||||||
|
if err != nil {
|
||||||
|
if !panicInstead {
|
||||||
|
showError("invalid target endpoint URL", err)
|
||||||
|
}
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
if targetEndpoint.Scheme == "" {
|
||||||
|
targetEndpoint.Scheme = "https"
|
||||||
|
}
|
||||||
|
|
||||||
if !self.quiet {
|
if !self.quiet {
|
||||||
if err := ui.Init(); err != nil {
|
if err := ui.Init(); err != nil {
|
||||||
if !panicInstead {
|
if !panicInstead {
|
||||||
@ -77,7 +89,7 @@ func (self *httpBackendCommand) run(_ *cobra.Command, args []string) {
|
|||||||
}
|
}
|
||||||
cfg := &backend.Config{
|
cfg := &backend.Config{
|
||||||
IdentityPath: zif,
|
IdentityPath: zif,
|
||||||
EndpointAddress: args[0],
|
EndpointAddress: targetEndpoint.String(),
|
||||||
}
|
}
|
||||||
|
|
||||||
zrok, err := zrokdir.ZrokClient(env.ApiEndpoint)
|
zrok, err := zrokdir.ZrokClient(env.ApiEndpoint)
|
||||||
|
Loading…
Reference in New Issue
Block a user