summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjwijenbergh <jeroenwijenbergh@protonmail.com>2023-10-11 16:22:49 +0200
committerjwijenbergh <jeroenwijenbergh@protonmail.com>2023-10-11 16:22:49 +0200
commit9fa291f1a8c5d5f833d9ed754254eb947864dc87 (patch)
tree4f7a43642ea72010e0d9bbd40fa450e6af5a4359
parent373b1fc58ecfdac53d0cd4a3011ac522bdfd3e85 (diff)
Exports + Server + Python: Expose dns_search_domains
See: https://git.sr.ht/~fkooman/vpn-user-portal/commit/f22c736c28fafec19f44f0b70d2b372be93b0f8b Needed for Linux client
-rw-r--r--exports/server.h3
-rw-r--r--exports/servers.go4
-rw-r--r--internal/server/profile.go1
-rw-r--r--wrappers/python/eduvpn_common/server.py8
-rw-r--r--wrappers/python/eduvpn_common/types.py2
5 files changed, 16 insertions, 2 deletions
diff --git a/exports/server.h b/exports/server.h
index 4bc8a16..f2af70b 100644
--- a/exports/server.h
+++ b/exports/server.h
@@ -5,8 +5,9 @@
typedef struct serverProfile {
const char* id;
const char* display_name;
- //const char* proto_list;
int default_gateway;
+ const char** dns_search_domains;
+ size_t total_dns_search_domains;
} serverProfile;
// The struct for all server profiles
diff --git a/exports/servers.go b/exports/servers.go
index 73b8b6c..d96d73e 100644
--- a/exports/servers.go
+++ b/exports/servers.go
@@ -27,6 +27,9 @@ func getCPtrProfile(profile *server.Profile) *C.serverProfile {
} else {
cProfile.default_gateway = C.int(0)
}
+ cProfile.total_dns_search_domains, cProfile.dns_search_domains = getCPtrListStrings(
+ profile.DNSSearchDomains,
+ )
return cProfile
}
@@ -71,6 +74,7 @@ func FreeProfiles(profiles *C.serverProfiles) {
for i := C.size_t(0); i < profiles.total_profiles; i++ {
C.free(unsafe.Pointer(profilesSlice[i].id))
C.free(unsafe.Pointer(profilesSlice[i].display_name))
+ freeCListStrings(profilesSlice[i].dns_search_domains, profilesSlice[i].total_dns_search_domains)
C.free(unsafe.Pointer(profilesSlice[i]))
}
// Free the inner profiles struct
diff --git a/internal/server/profile.go b/internal/server/profile.go
index d981421..7de944f 100644
--- a/internal/server/profile.go
+++ b/internal/server/profile.go
@@ -5,6 +5,7 @@ type Profile struct {
DisplayName string `json:"display_name"`
VPNProtoList []string `json:"vpn_proto_list"`
DefaultGateway bool `json:"default_gateway"`
+ DNSSearchDomains []string `json:"dns_search_domain_list"`
}
type ProfileListInfo struct {
diff --git a/wrappers/python/eduvpn_common/server.py b/wrappers/python/eduvpn_common/server.py
index cd3ad15..1ed0752 100644
--- a/wrappers/python/eduvpn_common/server.py
+++ b/wrappers/python/eduvpn_common/server.py
@@ -18,12 +18,14 @@ class Profile:
:param: identifier: str: The identifier (id) of the profile
:param: display_name: str: The display name of the profile
:param: default_gateway: str: Whether or not this profile should have the default gateway set
+ :param: search_domains: List[str]: The list of DNS search domains
"""
- def __init__(self, identifier: str, display_name: str, default_gateway: bool):
+ def __init__(self, identifier: str, display_name: str, default_gateway: bool, dns_search_domains: List[str]):
self.identifier = identifier
self.display_name = display_name
self.default_gateway = default_gateway
+ self.dns_search_domains = dns_search_domains
def __str__(self):
return self.display_name
@@ -241,11 +243,15 @@ def get_profiles(ptr) -> Optional[Profiles]:
if not _profiles.profiles[i]:
continue
profile = _profiles.profiles[i].contents
+ dns_search_domains = []
+ for j in range(profile.total_dns_search_domains):
+ dns_search_domains.append(profile.dns_search_domains[j].decode("utf-8"))
profiles.append(
Profile(
profile.identifier.decode("utf-8"),
profile.display_name.decode("utf-8"),
profile.default_gateway == 1,
+ dns_search_domains,
)
)
return Profiles(profiles, current_profile)
diff --git a/wrappers/python/eduvpn_common/types.py b/wrappers/python/eduvpn_common/types.py
index 32a7a00..ecb036c 100644
--- a/wrappers/python/eduvpn_common/types.py
+++ b/wrappers/python/eduvpn_common/types.py
@@ -133,6 +133,8 @@ class cServerProfile(Structure):
("identifier", c_char_p),
("display_name", c_char_p),
("default_gateway", c_int),
+ ("dns_search_domains", POINTER(c_char_p)),
+ ("total_dns_search_domains", c_size_t),
]