@@ -18,38 +18,22 @@ You should have received a copy of the GNU General Public License
1818
1919*/
2020
21- using System ;
2221using System . Collections . Generic ;
2322using System . ComponentModel . DataAnnotations ;
2423using System . Text . Json ;
2524using System . Text . Json . Serialization ;
2625using TechnitiumLibrary . Net . Dns ;
26+ using static LogExporter . SinkConfig ;
2727
2828namespace LogExporter
2929{
3030 public class AppConfig
3131 {
32- [ JsonPropertyName ( "maxQueueSize" ) ]
33- [ Range ( 1 , int . MaxValue , ErrorMessage = "maxQueueSize must be greater than zero." ) ]
34- public int MaxQueueSize { get ; set ; }
35-
36- [ JsonPropertyName ( "enableEdnsLogging" ) ]
37- public bool EnableEdnsLogging { get ; set ; }
38-
39- [ JsonPropertyName ( "enablePslResolution" ) ]
40- public PSLEnrichment ? PSLEnrichment { get ; set ; }
41-
42- [ JsonPropertyName ( "console" ) ]
43- public ConsoleSinkConfig ? ConsoleSinkConfig { get ; set ; }
44-
45- [ JsonPropertyName ( "file" ) ]
46- public FileSinkConfig ? FileSinkConfig { get ; set ; }
32+ [ JsonPropertyName ( "sinks" ) ]
33+ public SinkConfig Sinks { get ; set ; }
4734
48- [ JsonPropertyName ( "http" ) ]
49- public HttpSinkConfig ? HttpSinkConfig { get ; set ; }
50-
51- [ JsonPropertyName ( "syslog" ) ]
52- public SyslogSinkConfig ? SyslogSinkConfig { get ; set ; }
35+ [ JsonPropertyName ( "pipeline" ) ]
36+ public PipelineConfig Pipeline { get ; set ; }
5337
5438 /// <summary>
5539 /// Loads config and enforces DataAnnotations validation.
@@ -69,14 +53,15 @@ public static AppConfig Deserialize(string json)
6953 ValidateObject ( config ) ;
7054
7155 // Validate enabled targets only — disabled ones may be incomplete by design.
72- if ( config . FileSinkConfig ? . Enabled is true )
73- ValidateObject ( config . FileSinkConfig ) ;
7456
75- if ( config . HttpSinkConfig ? . Enabled is true )
76- ValidateObject ( config . HttpSinkConfig ) ;
57+ if ( config . Sinks . FileSinkConfig ? . Enabled is true )
58+ ValidateObject ( config . Sinks . FileSinkConfig ) ;
7759
78- if ( config . SyslogSinkConfig ? . Enabled is true )
79- ValidateObject ( config . SyslogSinkConfig ) ;
60+ if ( config . Sinks . HttpSinkConfig ? . Enabled is true )
61+ ValidateObject ( config . Sinks . HttpSinkConfig ) ;
62+
63+ if ( config . Sinks . SyslogSinkConfig ? . Enabled is true )
64+ ValidateObject ( config . Sinks . SyslogSinkConfig ) ;
8065
8166 return config ;
8267 }
@@ -87,60 +72,83 @@ private static void ValidateObject(object instance)
8772 Validator . ValidateObject ( instance , ctx , validateAllProperties : true ) ;
8873 }
8974 }
90-
91- #region Enrichments
92- public class EnrichmentConfigBase
75+ public class FeatureBase
9376 {
9477 [ JsonPropertyName ( "enabled" ) ]
95- public bool Enabled { get ; set ; }
78+ public bool Enabled { get ; set ; } = true ;
9679 }
9780
98- public class PSLEnrichment : EnrichmentConfigBase { }
99- #endregion
100-
101- #region Sinks
102- public class SinkConfigBase
81+ public class SinkConfig
10382 {
104- [ JsonPropertyName ( "enabled" ) ]
105- public bool Enabled { get ; set ; }
106- }
83+ [ Range ( 1 , int . MaxValue , ErrorMessage = "maxQueueSize must be greater than zero." ) ]
10784
108- public class ConsoleSinkConfig : SinkConfigBase { }
85+ [ JsonPropertyName ( "maxQueueSize" ) ]
86+ public int MaxQueueSize { get ; set ; } = int . MaxValue ;
10987
110- public class SyslogSinkConfig : SinkConfigBase
111- {
112- [ JsonPropertyName ( "address" ) ]
113- [ Required ( ErrorMessage = "syslog.address is required when syslog logging is enabled." ) ]
114- public string Address { get ; set ; } = string . Empty ;
88+ [ JsonPropertyName ( "enableEdnsLogging" ) ]
89+ public bool EnableEdnsLogging { get ; set ; } = true ;
11590
116- [ JsonPropertyName ( "port" ) ]
117- [ Range ( 1 , 65535 ) ]
118- public int ? Port { get ; set ; }
91+ [ JsonPropertyName ( "console" ) ]
92+ public ConsoleSink ConsoleSinkConfig { get ; set ; }
11993
120- [ JsonPropertyName ( "protocol" ) ]
121- [ AllowedValues ( [ "UDP" , "TCP" , "TLS" , "LOCAL" ] ) ]
122- public string ? Protocol { get ; set ; }
123- }
94+ [ JsonPropertyName ( "file" ) ]
95+ public FileSink FileSinkConfig { get ; set ; }
12496
125- public class FileSinkConfig : SinkConfigBase
126- {
127- [ JsonPropertyName ( "path" ) ]
128- [ Required ( ErrorMessage = "file.path is required when file logging is enabled." ) ]
129- public string Path { get ; set ; } = string . Empty ;
97+ [ JsonPropertyName ( "http" ) ]
98+ public HttpSink HttpSinkConfig { get ; set ; }
99+
100+ [ JsonPropertyName ( "syslog" ) ]
101+ public SyslogSink SyslogSinkConfig { get ; set ; }
102+
103+ public class SyslogSink : FeatureBase
104+ {
105+ [ Required ( ErrorMessage = "syslog.address is required when syslog logging is enabled." ) ]
106+ [ JsonPropertyName ( "address" ) ]
107+ public string Address { get ; set ; }
108+
109+ [ Range ( 1 , 65535 ) ]
110+ [ JsonPropertyName ( "port" ) ]
111+ public int ? Port { get ; set ; }
112+
113+ [ AllowedValues ( [ "UDP" , "TCP" , "TLS" , "LOCAL" ] ) ]
114+ [ JsonPropertyName ( "protocol" ) ]
115+ public string Protocol { get ; set ; }
116+ }
117+
118+ public class ConsoleSink : FeatureBase
119+ {
120+ }
121+
122+ public class FileSink : FeatureBase
123+ {
124+ [ Required ( ErrorMessage = "file.path is required when syslog logging is enabled." ) ]
125+ [ JsonPropertyName ( "path" ) ]
126+ public string Path { get ; set ; }
127+ }
128+
129+ public class HttpSink : FeatureBase
130+ {
131+
132+ [ Required ( ErrorMessage = "http.endpoint is required when HTTP logging is enabled." ) ]
133+ [ Url ]
134+ [ JsonPropertyName ( "endpoint" ) ]
135+ public string Endpoint { get ; set ; }
136+
137+ [ JsonPropertyName ( "headers" ) ]
138+ public Dictionary < string , string ? > ? Headers { get ; set ; }
139+ }
130140 }
131141
132- public class HttpSinkConfig : SinkConfigBase
142+ public class PipelineConfig
133143 {
134- [ JsonPropertyName ( "endpoint" ) ]
135- [ Required ( ErrorMessage = "http.endpoint is required when HTTP logging is enabled." ) ]
136- [ Url ]
137- public string Endpoint { get ; set ; } = string . Empty ;
144+ [ JsonPropertyName ( "normalize" ) ]
145+ public NormalizeProcess NormalizeProcessConfig { get ; set ; }
138146
139- [ JsonPropertyName ( "headers" ) ]
140- public Dictionary < string , string ? > ? Headers { get ; set ; }
141- }
142- #endregion
147+ public class NormalizeProcess : FeatureBase
148+ {
143149
150+ }
151+ }
144152 /// <summary>
145153 /// Shared serializer configuration for reading dnsApp.config.
146154 /// ADR: The serializer options are centralized so that parsing behavior
0 commit comments