mirror of
https://github.com/openziti/zrok.git
synced 2025-01-03 12:39:07 +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/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
"net/url"
|
||||
"os"
|
||||
"os/signal"
|
||||
"strings"
|
||||
@ -48,6 +49,17 @@ func newHttpBackendCommand() *httpBackendCommand {
|
||||
}
|
||||
|
||||
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 err := ui.Init(); err != nil {
|
||||
if !panicInstead {
|
||||
@ -77,7 +89,7 @@ func (self *httpBackendCommand) run(_ *cobra.Command, args []string) {
|
||||
}
|
||||
cfg := &backend.Config{
|
||||
IdentityPath: zif,
|
||||
EndpointAddress: args[0],
|
||||
EndpointAddress: targetEndpoint.String(),
|
||||
}
|
||||
|
||||
zrok, err := zrokdir.ZrokClient(env.ApiEndpoint)
|
||||
|
Loading…
Reference in New Issue
Block a user