From 76e709193614b3668d3c31a078e667473af20369 Mon Sep 17 00:00:00 2001 From: jwijenbergh Date: Mon, 15 May 2023 11:52:20 +0200 Subject: Initial i18n implementation --- internal/server/server.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'internal/server') diff --git a/internal/server/server.go b/internal/server/server.go index c34158a..45d6ccd 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -77,7 +77,7 @@ func CurrentProfile(srv Server) (*profile.Profile, error) { return nil, errors.Errorf("profile not found: " + pID) } -func ValidProfiles(srv Server, wireguardSupport bool) (*[]profile.Profile, error) { +func ValidProfiles(srv Server, wireguardSupport bool) (*profile.Info, error) { // No error wrapping here otherwise we wrap it too much b, err := srv.Base() if err != nil { @@ -87,7 +87,12 @@ func ValidProfiles(srv Server, wireguardSupport bool) (*[]profile.Profile, error if len(ps) == 0 { return nil, errors.Errorf("no profiles found with supported protocols") } - return &ps, nil + return &profile.Info{ + Current: b.Profiles.Current, + Info: profile.ListInfo{ + ProfileList: ps, + }, + }, nil } func Profile(srv Server, id string) error { @@ -190,6 +195,7 @@ func HasValidProfile(ctx context.Context, srv Server, wireguardSupport bool) (bo } } + // there are multiple profiles and no selection has been made if len(b.Profiles.Info.ProfileList) != 1 && b.Profiles.Current == "" { return false, nil } -- cgit v1.2.3