@@ -4,17 +4,30 @@ import SwiftyPing
44struct SettingsView : View {
55 @AppStorage ( " serverHost " ) private var serverHost : String = " localhost:8080 "
66 @AppStorage ( " videoFormat " ) private var videoFormat : String = " mp4 "
7+ @AppStorage ( " verifyCertificate " ) private var verifyCertificate : Bool = true
78 @State private var displayText : String = " Ready. "
89
910 var body : some View {
1011 VStack ( alignment: . center) {
11- Text ( " AllSpark Network " )
12+ Text ( " Client Settings " )
1213 . font ( . largeTitle)
1314 . padding ( . top, 20 )
1415
1516 Spacer ( )
1617
17- Text ( " Upload Server Host " )
18+ Text ( " Video Format " )
19+ . font ( . headline)
20+ . padding ( . top, 20 )
21+
22+ Picker ( " Video Format " , selection: $videoFormat) {
23+ Text ( " MP4 (Default) " ) . tag ( " mp4 " )
24+ Text ( " MOV " ) . tag ( " mov " )
25+ }
26+ . pickerStyle ( . segmented)
27+ . frame ( maxWidth: 300 )
28+ . padding ( )
29+
30+ Text ( " Server Host " )
1831 . font ( . headline)
1932 . padding ( . top, 10 )
2033
@@ -27,17 +40,9 @@ struct SettingsView: View {
2740 . autocapitalization ( . none)
2841 . textInputAutocapitalization ( . never)
2942
30- Text ( " Video Format " )
31- . font ( . headline)
32- . padding ( . top, 20 )
33-
34- Picker ( " Video Format " , selection: $videoFormat) {
35- Text ( " MP4 (Default) " ) . tag ( " mp4 " )
36- Text ( " MOV " ) . tag ( " mov " )
37- }
38- . pickerStyle ( . segmented)
39- . frame ( maxWidth: 300 )
40- . padding ( )
43+ Toggle ( " Verify SSL Certificate " , isOn: $verifyCertificate)
44+ . frame ( maxWidth: 300 )
45+ . padding ( )
4146
4247 Button ( action: {
4348 displayText = " pinging \( serverHost) ... "
@@ -96,7 +101,17 @@ struct SettingsView: View {
96101 return
97102 }
98103
99- let task = URLSession . shared. dataTask ( with: url) { data, response, error in
104+ let config = URLSessionConfiguration . default
105+ config. waitsForConnectivity = true
106+
107+ if !verifyCertificate {
108+ config. urlCredentialStorage = nil
109+ config. requestCachePolicy = . reloadIgnoringLocalCacheData
110+ }
111+
112+ let delegate = CertificateVerificationDelegate ( verifyCertificate: verifyCertificate)
113+ let session = URLSession ( configuration: config, delegate: delegate, delegateQueue: nil )
114+ let task = session. dataTask ( with: url) { data, response, error in
100115 DispatchQueue . main. async {
101116 if let error = error {
102117 displayText = " HTTP Connection Failed \n Error: \( error. localizedDescription) "
0 commit comments