File tree 3 files changed +68
-42
lines changed 3 files changed +68
-42
lines changed Original file line number Diff line number Diff line change @@ -45,22 +45,22 @@ public class Config
45
45
/// </summary>
46
46
public string ServerAddress { get ; set ; } = "https://ssp.nbki.ru/qbch/" ;
47
47
48
+ /// <summary>
49
+ /// Проверять отпечаток сервера
50
+ /// (имеет смысл при указанном ServerThumbprint).
51
+ /// </summary>
52
+ public bool ValidateThumbprint { get ; set ; } = false ;
53
+
48
54
/// <summary>
49
55
/// Отпечаток сертификата сервера ServerAddress
50
56
/// (имеет смысл при включении ValidateThumbprint).
51
57
/// </summary>
52
- public string ? ServerThumbprint { get ; set ; } = "18042E6D06AE9F05B639DF511A8583FEDE72784D" ;
58
+ public string ServerThumbprint { get ; set ; } = string . Empty ;
53
59
54
60
/// <summary>
55
61
/// Проверять валидность сертификатов для подключения.
56
62
/// </summary>
57
63
public bool ValidateTls { get ; set ; } = true ;
58
-
59
- /// <summary>
60
- /// Проверять отпечаток сервера
61
- /// (имеет смысл при указанном ServerThumbprint).
62
- /// </summary>
63
- public bool ValidateThumbprint { get ; set ; } = true ;
64
64
65
65
/// <summary>
66
66
/// Показывать дамп сертификата сервера при подключении.
@@ -76,7 +76,7 @@ public class Config
76
76
/// Адрес и порт сервера прокси
77
77
/// (имеет смысл при включении UseProxy).
78
78
/// </summary>
79
- public string ? ProxyAddress { get ; set ; } = "http://192.168.2.1:3128" ;
79
+ public string ProxyAddress { get ; set ; } = "http://192.168.2.1:3128" ;
80
80
81
81
/// <summary>
82
82
/// Подписывать файлы при отправке или же они уже подписаны
Original file line number Diff line number Diff line change
1
+ #region License
2
+ /*
3
+ Copyright 2022-2024 Dmitrii Evdokimov
4
+ Open source software
5
+
6
+ Licensed under the Apache License, Version 2.0 (the "License");
7
+ you may not use this file except in compliance with the License.
8
+ You may obtain a copy of the License at
9
+
10
+ http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+ Unless required by applicable law or agreed to in writing, software
13
+ distributed under the License is distributed on an "AS IS" BASIS,
14
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ See the License for the specific language governing permissions and
16
+ limitations under the License.
17
+ */
18
+ #endregion
19
+
20
+ using System . Text . Json ;
21
+
22
+ namespace Api5704 ;
23
+
24
+ public static class ConfigManager
25
+ {
26
+ private static JsonSerializerOptions GetJsonOptions ( )
27
+ {
28
+ return new ( )
29
+ {
30
+ WriteIndented = true
31
+ } ;
32
+ }
33
+
34
+ public static Config Read ( )
35
+ {
36
+ try
37
+ {
38
+ string appsettings = Path . ChangeExtension ( Environment . ProcessPath ! , ".config.json" ) ;
39
+
40
+ if ( File . Exists ( appsettings ) )
41
+ {
42
+ using var read = File . OpenRead ( appsettings ) ;
43
+ return JsonSerializer . Deserialize < Config > ( read ) ! ;
44
+ }
45
+
46
+ using var write = File . OpenWrite ( appsettings ) ;
47
+ JsonSerializer . Serialize ( write , new Config ( ) , GetJsonOptions ( ) ) ;
48
+
49
+ Console . WriteLine ( @$ "Создан новый файл настроек ""{ appsettings } "" - откорректируйте его.") ;
50
+ throw new Exception ( ) ;
51
+ }
52
+ catch
53
+ {
54
+ Environment . Exit ( 2 ) ;
55
+ }
56
+
57
+ return new ( ) ;
58
+ }
59
+ }
Original file line number Diff line number Diff line change @@ -25,18 +25,13 @@ namespace Api5704;
25
25
26
26
internal class Program
27
27
{
28
- public static Config Config { get ; private set ; } = new ( ) ;
28
+ public static Config Config { get ; set ; } = ConfigManager . Read ( ) ;
29
29
30
30
static async Task Main ( string [ ] args )
31
31
{
32
32
Console . WriteLine ( "Hello, World!" ) ; // :)
33
33
int result = 0 ;
34
34
35
- if ( ! TryGetConfig ( ) )
36
- {
37
- Environment . Exit ( 2 ) ;
38
- }
39
-
40
35
if ( args . Length == 0 )
41
36
{
42
37
if ( ! string . IsNullOrEmpty ( Config . DirSource ) )
@@ -166,32 +161,4 @@ Подробнее см. в README.
166
161
167
162
Environment . Exit ( 1 ) ;
168
163
}
169
-
170
- private static JsonSerializerOptions GetJsonOptions ( )
171
- {
172
- return new ( )
173
- {
174
- WriteIndented = true
175
- } ;
176
- }
177
-
178
- private static bool TryGetConfig ( )
179
- {
180
- string appsettings = Path . ChangeExtension ( Environment . ProcessPath ! , ".config.json" ) ;
181
-
182
- if ( File . Exists ( appsettings ) )
183
- {
184
- using var stream = File . OpenRead ( appsettings ) ;
185
- Config = JsonSerializer . Deserialize < Config > ( stream ) ! ;
186
- return true ;
187
- }
188
- else
189
- {
190
- using var stream = File . OpenWrite ( appsettings ) ;
191
- JsonSerializer . Serialize ( stream , Config , GetJsonOptions ( ) ) ;
192
-
193
- Console . WriteLine ( @$ "Создан новый файл настроек ""{ appsettings } "" - откорректируйте его.") ;
194
- return false ;
195
- }
196
- }
197
164
}
You can’t perform that action at this time.
0 commit comments