summaryrefslogtreecommitdiff
path: root/internal/server
diff options
context:
space:
mode:
Diffstat (limited to 'internal/server')
-rw-r--r--internal/server/custom/custom.go14
1 files changed, 10 insertions, 4 deletions
diff --git a/internal/server/custom/custom.go b/internal/server/custom/custom.go
index 14a72a5..d4a0508 100644
--- a/internal/server/custom/custom.go
+++ b/internal/server/custom/custom.go
@@ -2,11 +2,13 @@ package custom
import (
"context"
+ "net/url"
"github.com/eduvpn/eduvpn-common/internal/server/api"
"github.com/eduvpn/eduvpn-common/internal/server/base"
"github.com/eduvpn/eduvpn-common/internal/server/institute"
"github.com/eduvpn/eduvpn-common/types/server"
+ "github.com/go-errors/errors"
)
type (
@@ -14,10 +16,14 @@ type (
Servers = institute.Servers
)
-func New(ctx context.Context, url string) (*Server, error) {
+func New(ctx context.Context, u string) (*Server, error) {
+ pu, err := url.Parse(u)
+ if err != nil {
+ return nil, errors.WrapPrefix(err, "failed to parse custom server URL", 0)
+ }
b := base.Base{
- URL: url,
- DisplayName: map[string]string{"en": url},
+ URL: u,
+ DisplayName: map[string]string{"en": pu.Hostname()},
Type: server.TypeCustom,
}
if err := api.Endpoints(ctx, &b); err != nil {
@@ -26,6 +32,6 @@ func New(ctx context.Context, url string) (*Server, error) {
API := b.Endpoints.API.V3
s := &Server{Basic: b}
- s.Auth.Init(url, API.Authorization, API.Token)
+ s.Auth.Init(u, API.Authorization, API.Token)
return s, nil
}