mirror of
https://github.com/openziti/zrok.git
synced 2024-11-29 03:24:15 +01:00
parsing tweaks (#211)
This commit is contained in:
parent
a30645171a
commit
8244910842
@ -5,6 +5,7 @@ import (
|
|||||||
"github.com/go-openapi/runtime"
|
"github.com/go-openapi/runtime"
|
||||||
httptransport "github.com/go-openapi/runtime/client"
|
httptransport "github.com/go-openapi/runtime/client"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"math"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
@ -22,13 +23,13 @@ func mustGetAdminAuth() runtime.ClientAuthInfoWriter {
|
|||||||
func parseUrl(in string) (string, error) {
|
func parseUrl(in string) (string, error) {
|
||||||
// parse port-only urls
|
// parse port-only urls
|
||||||
if iv, err := strconv.ParseInt(in, 10, 0); err == nil {
|
if iv, err := strconv.ParseInt(in, 10, 0); err == nil {
|
||||||
if iv > 0 && iv < 65536 {
|
if iv > 0 && iv <= math.MaxUint16 {
|
||||||
if iv == 443 {
|
if iv == 443 {
|
||||||
return fmt.Sprintf("https://127.0.0.1:%d", iv), nil
|
return fmt.Sprintf("https://127.0.0.1:%d", iv), nil
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("http://127.0.0.1:%d", iv), nil
|
return fmt.Sprintf("http://127.0.0.1:%d", iv), nil
|
||||||
}
|
}
|
||||||
return "", errors.Errorf("ports must be between 1 and 65536; %d is not", iv)
|
return "", errors.Errorf("ports must be between 1 and %d; %d is not", math.MaxUint16, iv)
|
||||||
}
|
}
|
||||||
|
|
||||||
// make sure either https:// or http:// was specified
|
// make sure either https:// or http:// was specified
|
||||||
|
Loading…
Reference in New Issue
Block a user