From 3701c3f4bbc795e5f6bcf6a1d1717aab713b395d Mon Sep 17 00:00:00 2001 From: Eugene Burkov Date: Wed, 17 Mar 2021 13:51:26 +0300 Subject: [PATCH] Pull request: 2835 fix mobileconfig Merge in DNS/adguard-home from 2835-fix-mobileconfig to master Updates #2835. Squashed commit of the following: commit 83a6fd08d4429db9e532c2788689ca542d5ddb9b Author: Eugene Burkov Date: Wed Mar 17 13:37:14 2021 +0300 all: imp changes' log commit 3dabf0251b8b539509a097ac100d1b2948596668 Author: Eugene Burkov Date: Wed Mar 17 13:31:36 2021 +0300 all: imp naming, log changes commit c87032fdc7c61618768843a06fcf7c3db1cea593 Author: Eugene Burkov Date: Wed Mar 17 13:22:19 2021 +0300 home: fix mobileconfig response --- CHANGELOG.md | 5 +++++ internal/home/mobileconfig.go | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index db9a0b48..266e09c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,10 +31,15 @@ and this project adheres to - Go 1.14 support. +### Fixed + +- Invalid filenames in the `mobileconfig` API responses ([#2835]). + [#2385]: https://github.com/AdguardTeam/AdGuardHome/issues/2385 [#2412]: https://github.com/AdguardTeam/AdGuardHome/issues/2412 [#2498]: https://github.com/AdguardTeam/AdGuardHome/issues/2498 [#2533]: https://github.com/AdguardTeam/AdGuardHome/issues/2533 +[#2835]: https://github.com/AdguardTeam/AdGuardHome/issues/2835 diff --git a/internal/home/mobileconfig.go b/internal/home/mobileconfig.go index 9ea3e7f5..beb50b22 100644 --- a/internal/home/mobileconfig.go +++ b/internal/home/mobileconfig.go @@ -152,6 +152,18 @@ func handleMobileConfig(w http.ResponseWriter, r *http.Request, dnsp string) { w.Header().Set("Content-Type", "application/xml") + const ( + dohContDisp = `attachment; filename=doh.mobileconfig` + dotContDisp = `attachment; filename=dot.mobileconfig` + ) + + contDisp := dohContDisp + if dnsp == dnsProtoTLS { + contDisp = dotContDisp + } + + w.Header().Set("Content-Disposition", contDisp) + _, _ = w.Write(mobileconfig) }