From f94e73b1ecd674771f1e1f4ea4417ae138f76934 Mon Sep 17 00:00:00 2001
From: Bolke de Bruin <bolke@xs4all.nl>
Date: Fri, 26 Aug 2022 10:06:43 +0200
Subject: [PATCH] Fix some issues with gateway addresses

---
 cmd/rdpgw/api/web.go  |   4 ++--
 cmd/rdpgw/main.go     |   2 +-
 dev/docker/Dockerfile |   3 +++
 dev/docker/tmp.tar    | Bin 0 -> 10240 bytes
 4 files changed, 6 insertions(+), 3 deletions(-)
 create mode 100644 dev/docker/tmp.tar

diff --git a/cmd/rdpgw/api/web.go b/cmd/rdpgw/api/web.go
index b1da3ab..d02f5c3 100644
--- a/cmd/rdpgw/api/web.go
+++ b/cmd/rdpgw/api/web.go
@@ -44,7 +44,7 @@ type Config struct {
 	stateStore           *cache.Cache
 	Hosts                []string
 	HostSelection        string
-	GatewayAddress       string
+	GatewayAddress       *url.URL
 	UsernameTemplate     string
 	NetworkAutoDetect    int
 	BandwidthAutoDetect  int
@@ -276,7 +276,7 @@ func (c *Config) HandleDownload(w http.ResponseWriter, r *http.Request) {
 	w.Header().Set("Content-Disposition", "attachment; filename="+fn)
 	w.Header().Set("Content-Type", "application/x-rdp")
 	data := "full address:s:" + host + "\r\n" +
-		"gatewayhostname:s:" + c.GatewayAddress + "\r\n" +
+		"gatewayhostname:s:" + c.GatewayAddress.Host + "\r\n" +
 		"gatewaycredentialssource:i:5\r\n" +
 		"gatewayusagemethod:i:1\r\n" +
 		"gatewayprofileusagemethod:i:1\r\n" +
diff --git a/cmd/rdpgw/main.go b/cmd/rdpgw/main.go
index c6cdbf0..9850f5c 100644
--- a/cmd/rdpgw/main.go
+++ b/cmd/rdpgw/main.go
@@ -88,7 +88,7 @@ func main() {
 			url.Scheme = "https"
 		}
 		url.Path = "callback"
-		api.GatewayAddress = url.String()
+		api.GatewayAddress = url
 
 		oauthConfig := oauth2.Config{
 			ClientID:     conf.OpenId.ClientId,
diff --git a/dev/docker/Dockerfile b/dev/docker/Dockerfile
index 7497cb8..336b379 100644
--- a/dev/docker/Dockerfile
+++ b/dev/docker/Dockerfile
@@ -30,6 +30,9 @@ RUN git clone https://github.com/bolkedebruin/rdpgw.git /app && \
 
 FROM scratch
 
+# make tempdir in case filestore is used
+ADD tmp.tar /
+
 COPY --from=builder /opt/rdpgw /opt/rdpgw
 COPY --from=builder /etc/passwd /etc/passwd
 COPY --from=builder /etc/ssl/certs /etc/ssl/certs
diff --git a/dev/docker/tmp.tar b/dev/docker/tmp.tar
new file mode 100644
index 0000000000000000000000000000000000000000..ee83747f6d085188eba2d5164c43f22b52571059
GIT binary patch
literal 10240
zcmeIuI}XAy3;@s^B{#rnXmTD7P!*MMf1o2nS?Kn>ShD4h-dOIJbaF&Q>Ak0S{=|3Q
zYo(TJv^KRmrzlZdPkBE1uYLXVF>YJVX<OHEbnjRHXjYE^0RjXF5FkK+009C72oNAZ
ffB*pk1PBlyK!5-N0t5&UAV7cs0RjXF{8``yO283G

literal 0
HcmV?d00001

-- 
GitLab