diff options
author | Sean Hall <r.sean.hall@gmail.com> | 2020-04-09 09:01:29 +1000 |
---|---|---|
committer | Sean Hall <r.sean.hall@gmail.com> | 2020-04-09 10:40:30 +1000 |
commit | 2427be20a103957f204b753db45ee89ad636bb08 (patch) | |
tree | 54255a5359048e35bf5e51a35b0700fbd47484de | |
parent | 608f2f6fd9728a630ee5793bb7f24d5b6efeb5d1 (diff) | |
download | wix-2427be20a103957f204b753db45ee89ad636bb08.tar.gz wix-2427be20a103957f204b753db45ee89ad636bb08.tar.bz2 wix-2427be20a103957f204b753db45ee89ad636bb08.zip |
Modernize FirewallCompiler and tuples.
-rw-r--r-- | src/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs | 2 | ||||
-rw-r--r-- | src/wixext/FirewallCompiler.cs | 50 | ||||
-rw-r--r-- | src/wixext/FirewallExtensionData.cs | 3 | ||||
-rw-r--r-- | src/wixext/FirewallTableDefinitions.cs | 33 | ||||
-rw-r--r-- | src/wixext/FirewallWindowsInstallerBackendExtension.cs | 19 | ||||
-rw-r--r-- | src/wixext/Tuples/FirewallTupleDefinitions.cs | 43 | ||||
-rw-r--r-- | src/wixext/Tuples/WixFirewallExceptionTuple.cs | 25 | ||||
-rw-r--r-- | src/wixext/WixToolset.Firewall.wixext.csproj | 1 | ||||
-rw-r--r-- | src/wixext/tables.xml | 28 |
9 files changed, 112 insertions, 92 deletions
diff --git a/src/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs b/src/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs index e3c41181..fa64f7d3 100644 --- a/src/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs +++ b/src/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs | |||
@@ -20,7 +20,7 @@ namespace WixToolsetTest.Firewall | |||
20 | Assert.Equal(new[] | 20 | Assert.Equal(new[] |
21 | { | 21 | { |
22 | "WixFirewallException:ExampleFirewall\texample\t*\t42\t6\t\t0\t2147483647\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tAn example firewall", | 22 | "WixFirewallException:ExampleFirewall\texample\t*\t42\t6\t\t0\t2147483647\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tAn example firewall", |
23 | }, results.OrderBy(s => s).ToArray()); | 23 | }, results); |
24 | } | 24 | } |
25 | 25 | ||
26 | private static void Build(string[] args) | 26 | private static void Build(string[] args) |
diff --git a/src/wixext/FirewallCompiler.cs b/src/wixext/FirewallCompiler.cs index 353afff3..16136954 100644 --- a/src/wixext/FirewallCompiler.cs +++ b/src/wixext/FirewallCompiler.cs | |||
@@ -28,8 +28,8 @@ namespace WixToolset.Firewall | |||
28 | switch (parentElement.Name.LocalName) | 28 | switch (parentElement.Name.LocalName) |
29 | { | 29 | { |
30 | case "File": | 30 | case "File": |
31 | string fileId = context["FileId"]; | 31 | var fileId = context["FileId"]; |
32 | string fileComponentId = context["ComponentId"]; | 32 | var fileComponentId = context["ComponentId"]; |
33 | 33 | ||
34 | switch (element.Name.LocalName) | 34 | switch (element.Name.LocalName) |
35 | { | 35 | { |
@@ -42,7 +42,7 @@ namespace WixToolset.Firewall | |||
42 | } | 42 | } |
43 | break; | 43 | break; |
44 | case "Component": | 44 | case "Component": |
45 | string componentId = context["ComponentId"]; | 45 | var componentId = context["ComponentId"]; |
46 | 46 | ||
47 | switch (element.Name.LocalName) | 47 | switch (element.Name.LocalName) |
48 | { | 48 | { |
@@ -68,22 +68,20 @@ namespace WixToolset.Firewall | |||
68 | /// <param name="fileId">The file identifier of the parent element (null if nested under Component).</param> | 68 | /// <param name="fileId">The file identifier of the parent element (null if nested under Component).</param> |
69 | private void ParseFirewallExceptionElement(Intermediate intermediate, IntermediateSection section, XElement element, string componentId, string fileId) | 69 | private void ParseFirewallExceptionElement(Intermediate intermediate, IntermediateSection section, XElement element, string componentId, string fileId) |
70 | { | 70 | { |
71 | SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); | 71 | var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); |
72 | Identifier id = null; | 72 | Identifier id = null; |
73 | string name = null; | 73 | string name = null; |
74 | int attributes = 0; | 74 | int attributes = 0; |
75 | string file = null; | 75 | string file = null; |
76 | string program = null; | 76 | string program = null; |
77 | string port = null; | 77 | string port = null; |
78 | string protocolValue = null; | ||
79 | int? protocol = null; | 78 | int? protocol = null; |
80 | string profileValue = null; | ||
81 | int? profile = null; | 79 | int? profile = null; |
82 | string scope = null; | 80 | string scope = null; |
83 | string remoteAddresses = null; | 81 | string remoteAddresses = null; |
84 | string description = null; | 82 | string description = null; |
85 | 83 | ||
86 | foreach (XAttribute attrib in element.Attributes()) | 84 | foreach (var attrib in element.Attributes()) |
87 | { | 85 | { |
88 | if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) | 86 | if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) |
89 | { | 87 | { |
@@ -125,7 +123,7 @@ namespace WixToolset.Firewall | |||
125 | port = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); | 123 | port = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); |
126 | break; | 124 | break; |
127 | case "Protocol": | 125 | case "Protocol": |
128 | protocolValue = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); | 126 | var protocolValue = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); |
129 | switch (protocolValue) | 127 | switch (protocolValue) |
130 | { | 128 | { |
131 | case "tcp": | 129 | case "tcp": |
@@ -155,7 +153,7 @@ namespace WixToolset.Firewall | |||
155 | } | 153 | } |
156 | break; | 154 | break; |
157 | case "Profile": | 155 | case "Profile": |
158 | profileValue = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); | 156 | var profileValue = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); |
159 | switch (profileValue) | 157 | switch (profileValue) |
160 | { | 158 | { |
161 | case "domain": | 159 | case "domain": |
@@ -190,11 +188,10 @@ namespace WixToolset.Firewall | |||
190 | } | 188 | } |
191 | 189 | ||
192 | // parse RemoteAddress children | 190 | // parse RemoteAddress children |
193 | foreach (XElement child in element.Elements()) | 191 | foreach (var child in element.Elements()) |
194 | { | 192 | { |
195 | if (this.Namespace == child.Name.Namespace) | 193 | if (this.Namespace == child.Name.Namespace) |
196 | { | 194 | { |
197 | SourceLineNumber childSourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(child); | ||
198 | switch (child.Name.LocalName) | 195 | switch (child.Name.LocalName) |
199 | { | 196 | { |
200 | case "RemoteAddress": | 197 | case "RemoteAddress": |
@@ -218,12 +215,12 @@ namespace WixToolset.Firewall | |||
218 | } | 215 | } |
219 | } | 216 | } |
220 | 217 | ||
221 | // Id and Name are required | ||
222 | if (null == id) | 218 | if (null == id) |
223 | { | 219 | { |
224 | this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Id")); | 220 | id = this.ParseHelper.CreateIdentifier("fex", name, remoteAddresses, componentId); |
225 | } | 221 | } |
226 | 222 | ||
223 | // Name is required | ||
227 | if (null == name) | 224 | if (null == name) |
228 | { | 225 | { |
229 | this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Name")); | 226 | this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Name")); |
@@ -255,14 +252,14 @@ namespace WixToolset.Firewall | |||
255 | fileId = file; | 252 | fileId = file; |
256 | } | 253 | } |
257 | 254 | ||
258 | var tuple = new WixFirewallExceptionTuple(sourceLineNumbers, id) | 255 | var tuple = section.AddTuple(new WixFirewallExceptionTuple(sourceLineNumbers, id) |
259 | { | 256 | { |
260 | Name = name, | 257 | Name = name, |
261 | RemoteAddresses = remoteAddresses, | 258 | RemoteAddresses = remoteAddresses, |
262 | Profile = profile ?? FirewallConstants.NET_FW_PROFILE2_ALL, | 259 | Profile = profile ?? FirewallConstants.NET_FW_PROFILE2_ALL, |
263 | ComponentRef = componentId, | 260 | ComponentRef = componentId, |
264 | Description = description, | 261 | Description = description, |
265 | }; | 262 | }); |
266 | 263 | ||
267 | if (!String.IsNullOrEmpty(port)) | 264 | if (!String.IsNullOrEmpty(port)) |
268 | { | 265 | { |
@@ -275,12 +272,15 @@ namespace WixToolset.Firewall | |||
275 | } | 272 | } |
276 | } | 273 | } |
277 | 274 | ||
278 | tuple.Protocol = protocol.Value; | 275 | if (protocol.HasValue) |
276 | { | ||
277 | tuple.Protocol = protocol.Value; | ||
278 | } | ||
279 | 279 | ||
280 | if (!String.IsNullOrEmpty(fileId)) | 280 | if (!String.IsNullOrEmpty(fileId)) |
281 | { | 281 | { |
282 | tuple.Program = $"[#{fileId}]"; | 282 | tuple.Program = $"[#{fileId}]"; |
283 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "File", fileId); | 283 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, TupleDefinitions.File, fileId); |
284 | } | 284 | } |
285 | else if (!String.IsNullOrEmpty(program)) | 285 | else if (!String.IsNullOrEmpty(program)) |
286 | { | 286 | { |
@@ -292,19 +292,17 @@ namespace WixToolset.Firewall | |||
292 | tuple.Attributes = attributes; | 292 | tuple.Attributes = attributes; |
293 | } | 293 | } |
294 | 294 | ||
295 | section.Tuples.Add(tuple); | ||
296 | |||
297 | if (this.Context.Platform == Platform.ARM) | 295 | if (this.Context.Platform == Platform.ARM) |
298 | { | 296 | { |
299 | // Ensure ARM version of the CA is referenced | 297 | // Ensure ARM version of the CA is referenced |
300 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "WixSchedFirewallExceptionsInstall_ARM"); | 298 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, TupleDefinitions.CustomAction, "WixSchedFirewallExceptionsInstall_ARM"); |
301 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "WixSchedFirewallExceptionsUninstall_ARM"); | 299 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, TupleDefinitions.CustomAction, "WixSchedFirewallExceptionsUninstall_ARM"); |
302 | } | 300 | } |
303 | else | 301 | else |
304 | { | 302 | { |
305 | // All other supported platforms use x86 | 303 | // All other supported platforms use x86 |
306 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "WixSchedFirewallExceptionsInstall"); | 304 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, TupleDefinitions.CustomAction, "WixSchedFirewallExceptionsInstall"); |
307 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "WixSchedFirewallExceptionsUninstall"); | 305 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, TupleDefinitions.CustomAction, "WixSchedFirewallExceptionsUninstall"); |
308 | } | 306 | } |
309 | } | 307 | } |
310 | } | 308 | } |
@@ -315,10 +313,10 @@ namespace WixToolset.Firewall | |||
315 | /// <param name="element">The element to parse.</param> | 313 | /// <param name="element">The element to parse.</param> |
316 | private void ParseRemoteAddressElement(Intermediate intermediate, IntermediateSection section, XElement element, ref string remoteAddresses) | 314 | private void ParseRemoteAddressElement(Intermediate intermediate, IntermediateSection section, XElement element, ref string remoteAddresses) |
317 | { | 315 | { |
318 | SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); | 316 | var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); |
319 | 317 | ||
320 | // no attributes | 318 | // no attributes |
321 | foreach (XAttribute attrib in element.Attributes()) | 319 | foreach (var attrib in element.Attributes()) |
322 | { | 320 | { |
323 | if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) | 321 | if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) |
324 | { | 322 | { |
@@ -332,7 +330,7 @@ namespace WixToolset.Firewall | |||
332 | 330 | ||
333 | this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element); | 331 | this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element); |
334 | 332 | ||
335 | string address = this.ParseHelper.GetTrimmedInnerText(element); | 333 | var address = this.ParseHelper.GetTrimmedInnerText(element); |
336 | if (String.IsNullOrEmpty(address)) | 334 | if (String.IsNullOrEmpty(address)) |
337 | { | 335 | { |
338 | this.Messaging.Write(FirewallErrors.IllegalEmptyRemoteAddress(sourceLineNumbers)); | 336 | this.Messaging.Write(FirewallErrors.IllegalEmptyRemoteAddress(sourceLineNumbers)); |
diff --git a/src/wixext/FirewallExtensionData.cs b/src/wixext/FirewallExtensionData.cs index 78939c4e..44cae0d6 100644 --- a/src/wixext/FirewallExtensionData.cs +++ b/src/wixext/FirewallExtensionData.cs | |||
@@ -4,7 +4,6 @@ namespace WixToolset.Firewall | |||
4 | { | 4 | { |
5 | using WixToolset.Data; | 5 | using WixToolset.Data; |
6 | using WixToolset.Extensibility; | 6 | using WixToolset.Extensibility; |
7 | using WixToolset.Firewall.Tuples; | ||
8 | 7 | ||
9 | public sealed class FirewallExtensionData : BaseExtensionData | 8 | public sealed class FirewallExtensionData : BaseExtensionData |
10 | { | 9 | { |
@@ -12,7 +11,7 @@ namespace WixToolset.Firewall | |||
12 | 11 | ||
13 | public override bool TryGetTupleDefinitionByName(string name, out IntermediateTupleDefinition tupleDefinition) | 12 | public override bool TryGetTupleDefinitionByName(string name, out IntermediateTupleDefinition tupleDefinition) |
14 | { | 13 | { |
15 | tupleDefinition = (name == FirewallTupleDefinitionNames.WixFirewallException) ? FirewallTupleDefinitions.WixFirewallException : null; | 14 | tupleDefinition = FirewallTupleDefinitions.ByName(name); |
16 | return tupleDefinition != null; | 15 | return tupleDefinition != null; |
17 | } | 16 | } |
18 | 17 | ||
diff --git a/src/wixext/FirewallTableDefinitions.cs b/src/wixext/FirewallTableDefinitions.cs new file mode 100644 index 00000000..d6e469b8 --- /dev/null +++ b/src/wixext/FirewallTableDefinitions.cs | |||
@@ -0,0 +1,33 @@ | |||
1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | ||
2 | |||
3 | namespace WixToolset.Firewall | ||
4 | { | ||
5 | using WixToolset.Data.WindowsInstaller; | ||
6 | |||
7 | public static class FirewallTableDefinitions | ||
8 | { | ||
9 | public static readonly TableDefinition WixFirewallException = new TableDefinition( | ||
10 | "WixFirewallException", | ||
11 | new[] | ||
12 | { | ||
13 | new ColumnDefinition("WixFirewallException", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "The primary key, a non-localized token.", modularizeType: ColumnModularizeType.Column), | ||
14 | new ColumnDefinition("Name", ColumnType.Localized, 255, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Localizable display name.", modularizeType: ColumnModularizeType.Property), | ||
15 | new ColumnDefinition("RemoteAddresses", ColumnType.String, 0, primaryKey: false, nullable: false, ColumnCategory.Formatted, description: "Remote address to accept incoming connections from.", modularizeType: ColumnModularizeType.Property), | ||
16 | new ColumnDefinition("Port", ColumnType.String, 0, primaryKey: false, nullable: true, ColumnCategory.Formatted, minValue: 1, description: "Port number.", modularizeType: ColumnModularizeType.Property), | ||
17 | new ColumnDefinition("Protocol", ColumnType.Number, 1, primaryKey: false, nullable: true, ColumnCategory.Integer, minValue: 6, maxValue: 17, description: "Protocol (6=TCP; 17=UDP)."), | ||
18 | new ColumnDefinition("Program", ColumnType.String, 255, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Exception for a program (formatted path name).", modularizeType: ColumnModularizeType.Property), | ||
19 | new ColumnDefinition("Attributes", ColumnType.Number, 4, primaryKey: false, nullable: true, ColumnCategory.Unknown, description: "Vital=1"), | ||
20 | new ColumnDefinition("Profile", ColumnType.Number, 4, primaryKey: false, nullable: false, ColumnCategory.Integer, minValue: 1, maxValue: 2147483647, description: "Profile (1=domain; 2=private; 4=public; 2147483647=all)."), | ||
21 | new ColumnDefinition("Component_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "Component", keyColumn: 1, description: "Foreign key into the Component table referencing component that controls the firewall configuration.", modularizeType: ColumnModularizeType.Column), | ||
22 | new ColumnDefinition("Description", ColumnType.String, 255, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Description displayed in Windows Firewall manager for this firewall rule."), | ||
23 | }, | ||
24 | tupleDefinitionName: FirewallTupleDefinitions.WixFirewallException.Name, | ||
25 | tupleIdIsPrimaryKey: true | ||
26 | ); | ||
27 | |||
28 | public static readonly TableDefinition[] All = new[] | ||
29 | { | ||
30 | WixFirewallException, | ||
31 | }; | ||
32 | } | ||
33 | } | ||
diff --git a/src/wixext/FirewallWindowsInstallerBackendExtension.cs b/src/wixext/FirewallWindowsInstallerBackendExtension.cs index 7b731710..dea355b4 100644 --- a/src/wixext/FirewallWindowsInstallerBackendExtension.cs +++ b/src/wixext/FirewallWindowsInstallerBackendExtension.cs | |||
@@ -1,30 +1,15 @@ | |||
1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. |
2 | 2 | ||
3 | namespace WixToolset.Firewall | 3 | namespace WixToolset.Firewall |
4 | { | 4 | { |
5 | using System.Collections.Generic; | 5 | using System.Collections.Generic; |
6 | using System.Linq; | 6 | using System.Linq; |
7 | using System.Xml; | 7 | using System.Xml; |
8 | using WixToolset.Data; | ||
9 | using WixToolset.Data.WindowsInstaller; | 8 | using WixToolset.Data.WindowsInstaller; |
10 | using WixToolset.Extensibility; | 9 | using WixToolset.Extensibility; |
11 | 10 | ||
12 | public class FirewallWindowsInstallerBackendBinderExtension : BaseWindowsInstallerBackendBinderExtension | 11 | public class FirewallWindowsInstallerBackendBinderExtension : BaseWindowsInstallerBackendBinderExtension |
13 | { | 12 | { |
14 | private static readonly TableDefinition[] Tables = LoadTables(); | 13 | public override IEnumerable<TableDefinition> TableDefinitions => FirewallTableDefinitions.All; |
15 | |||
16 | public override IEnumerable<TableDefinition> TableDefinitions => Tables; | ||
17 | |||
18 | public override bool TryAddTupleToOutput(IntermediateTuple tuple, WindowsInstallerData output) => this.BackendHelper.TryAddTupleToOutputMatchingTableDefinitions(tuple, output, this.TableDefinitionsForTuples, true); | ||
19 | |||
20 | private static TableDefinition[] LoadTables() | ||
21 | { | ||
22 | using (var resourceStream = typeof(FirewallWindowsInstallerBackendBinderExtension).Assembly.GetManifestResourceStream("WixToolset.Firewall.tables.xml")) | ||
23 | using (var reader = XmlReader.Create(resourceStream)) | ||
24 | { | ||
25 | var tables = TableDefinitionCollection.Load(reader); | ||
26 | return tables.ToArray(); | ||
27 | } | ||
28 | } | ||
29 | } | 14 | } |
30 | } | 15 | } |
diff --git a/src/wixext/Tuples/FirewallTupleDefinitions.cs b/src/wixext/Tuples/FirewallTupleDefinitions.cs index df595c18..2710380e 100644 --- a/src/wixext/Tuples/FirewallTupleDefinitions.cs +++ b/src/wixext/Tuples/FirewallTupleDefinitions.cs | |||
@@ -1,30 +1,39 @@ | |||
1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. |
2 | 2 | ||
3 | namespace WixToolset.Firewall.Tuples | 3 | namespace WixToolset.Firewall |
4 | { | 4 | { |
5 | using System; | ||
5 | using WixToolset.Data; | 6 | using WixToolset.Data; |
6 | 7 | ||
7 | public static class FirewallTupleDefinitionNames | 8 | public enum FirewallTupleDefinitionType |
8 | { | 9 | { |
9 | public static string WixFirewallException { get; } = "WixFirewallException"; | 10 | WixFirewallException, |
10 | } | 11 | } |
11 | 12 | ||
12 | public static partial class FirewallTupleDefinitions | 13 | public static partial class FirewallTupleDefinitions |
13 | { | 14 | { |
14 | public static readonly IntermediateTupleDefinition WixFirewallException = new IntermediateTupleDefinition( | 15 | public static readonly Version Version = new Version("4.0.0"); |
15 | FirewallTupleDefinitionNames.WixFirewallException, | 16 | |
16 | new[] | 17 | public static IntermediateTupleDefinition ByName(string name) |
18 | { | ||
19 | if (!Enum.TryParse(name, out FirewallTupleDefinitionType type)) | ||
17 | { | 20 | { |
18 | new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Name), IntermediateFieldType.String), | 21 | return null; |
19 | new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.RemoteAddresses), IntermediateFieldType.String), | 22 | } |
20 | new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Port), IntermediateFieldType.String), | 23 | |
21 | new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Protocol), IntermediateFieldType.Number), | 24 | return ByType(type); |
22 | new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Program), IntermediateFieldType.String), | 25 | } |
23 | new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Attributes), IntermediateFieldType.Number), | 26 | |
24 | new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Profile), IntermediateFieldType.Number), | 27 | public static IntermediateTupleDefinition ByType(FirewallTupleDefinitionType type) |
25 | new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.ComponentRef), IntermediateFieldType.String), | 28 | { |
26 | new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Description), IntermediateFieldType.String), | 29 | switch (type) |
27 | }, | 30 | { |
28 | typeof(WixFirewallExceptionTuple)); | 31 | case FirewallTupleDefinitionType.WixFirewallException: |
32 | return FirewallTupleDefinitions.WixFirewallException; | ||
33 | |||
34 | default: | ||
35 | throw new ArgumentOutOfRangeException(nameof(type)); | ||
36 | } | ||
37 | } | ||
29 | } | 38 | } |
30 | } | 39 | } |
diff --git a/src/wixext/Tuples/WixFirewallExceptionTuple.cs b/src/wixext/Tuples/WixFirewallExceptionTuple.cs index 3c7cda3a..d08b9e45 100644 --- a/src/wixext/Tuples/WixFirewallExceptionTuple.cs +++ b/src/wixext/Tuples/WixFirewallExceptionTuple.cs | |||
@@ -1,5 +1,30 @@ | |||
1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. |
2 | 2 | ||
3 | namespace WixToolset.Firewall | ||
4 | { | ||
5 | using WixToolset.Data; | ||
6 | using WixToolset.Firewall.Tuples; | ||
7 | |||
8 | public static partial class FirewallTupleDefinitions | ||
9 | { | ||
10 | public static readonly IntermediateTupleDefinition WixFirewallException = new IntermediateTupleDefinition( | ||
11 | FirewallTupleDefinitionType.WixFirewallException.ToString(), | ||
12 | new[] | ||
13 | { | ||
14 | new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Name), IntermediateFieldType.String), | ||
15 | new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.RemoteAddresses), IntermediateFieldType.String), | ||
16 | new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Port), IntermediateFieldType.String), | ||
17 | new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Protocol), IntermediateFieldType.Number), | ||
18 | new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Program), IntermediateFieldType.String), | ||
19 | new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Attributes), IntermediateFieldType.Number), | ||
20 | new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Profile), IntermediateFieldType.Number), | ||
21 | new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.ComponentRef), IntermediateFieldType.String), | ||
22 | new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Description), IntermediateFieldType.String), | ||
23 | }, | ||
24 | typeof(WixFirewallExceptionTuple)); | ||
25 | } | ||
26 | } | ||
27 | |||
3 | namespace WixToolset.Firewall.Tuples | 28 | namespace WixToolset.Firewall.Tuples |
4 | { | 29 | { |
5 | using WixToolset.Data; | 30 | using WixToolset.Data; |
diff --git a/src/wixext/WixToolset.Firewall.wixext.csproj b/src/wixext/WixToolset.Firewall.wixext.csproj index b0fe04d1..07d5de56 100644 --- a/src/wixext/WixToolset.Firewall.wixext.csproj +++ b/src/wixext/WixToolset.Firewall.wixext.csproj | |||
@@ -14,7 +14,6 @@ | |||
14 | <ItemGroup> | 14 | <ItemGroup> |
15 | <Content Include="$(MSBuildThisFileName).targets" /> | 15 | <Content Include="$(MSBuildThisFileName).targets" /> |
16 | <Content Include="firewall.xsd" PackagePath="tools" /> | 16 | <Content Include="firewall.xsd" PackagePath="tools" /> |
17 | <EmbeddedResource Include="tables.xml" /> | ||
18 | <EmbeddedResource Include="$(OutputPath)..\firewall.wixlib" /> | 17 | <EmbeddedResource Include="$(OutputPath)..\firewall.wixlib" /> |
19 | </ItemGroup> | 18 | </ItemGroup> |
20 | 19 | ||
diff --git a/src/wixext/tables.xml b/src/wixext/tables.xml deleted file mode 100644 index b0c32305..00000000 --- a/src/wixext/tables.xml +++ /dev/null | |||
@@ -1,28 +0,0 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | ||
2 | <!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. --> | ||
3 | |||
4 | |||
5 | <tableDefinitions xmlns="http://wixtoolset.org/schemas/v4/wi/tables"> | ||
6 | <tableDefinition name="WixFirewallException"> | ||
7 | <columnDefinition name="WixFirewallException" type="string" length="72" primaryKey="yes" modularize="column" | ||
8 | category="identifier" description="The primary key, a non-localized token." /> | ||
9 | <columnDefinition name="Name" type="localized" length="255" nullable="yes" modularize="property" | ||
10 | category="formatted" description="Localizable display name." /> | ||
11 | <columnDefinition name="RemoteAddresses" type="string" length="0" modularize="property" | ||
12 | category="formatted" description="Remote address to accept incoming connections from." /> | ||
13 | <columnDefinition name="Port" type="string" length="0" modularize="property" nullable="yes" | ||
14 | category="formatted" minValue="1" description="Port number." /> | ||
15 | <columnDefinition name="Protocol" type="number" length="1" nullable="yes" | ||
16 | category="integer" minValue="6" maxValue="17" description="Protocol (6=TCP; 17=UDP)." /> | ||
17 | <columnDefinition name="Program" type="string" length="255" nullable="yes" modularize="property" | ||
18 | category="formatted" description="Exception for a program (formatted path name)." /> | ||
19 | <columnDefinition name="Attributes" type="number" length="4" nullable="yes" | ||
20 | description="Vital=1" /> | ||
21 | <columnDefinition name="Profile" type="number" length="4" nullable="no" | ||
22 | category="integer" minValue="1" maxValue="2147483647" description="Profile (1=domain; 2=private; 4=public; 2147483647=all)." /> | ||
23 | <columnDefinition name="Component_" type="string" length="72" modularize="column" | ||
24 | keyTable="Component" keyColumn="1" category="identifier" description="Foreign key into the Component table referencing component that controls the firewall configuration."/> | ||
25 | <columnDefinition name="Description" type="string" length="255" nullable="yes" | ||
26 | category="formatted" description="Description displayed in Windows Firewall manager for this firewall rule."/> | ||
27 | </tableDefinition> | ||
28 | </tableDefinitions> | ||