aboutsummaryrefslogtreecommitdiff
path: root/src/wixext
diff options
context:
space:
mode:
authoradnan shaheen <shaheen4qau@gmail.com>2018-02-05 14:01:55 +1000
committerSean Hall <r.sean.hall@gmail.com>2020-05-22 13:34:50 +1000
commit5c851a848a6eeb86472e8a1cca814dd0cb1b0483 (patch)
treed5d0f4428ba89bbe190f027f4d0318fe7bbcc316 /src/wixext
parentcc083c765e8b7baa239c4d800a372cc729ada9d8 (diff)
downloadwix-5c851a848a6eeb86472e8a1cca814dd0cb1b0483.tar.gz
wix-5c851a848a6eeb86472e8a1cca814dd0cb1b0483.tar.bz2
wix-5c851a848a6eeb86472e8a1cca814dd0cb1b0483.zip
WIXFEAT:4009 - Add support for outbound firewall rule
Diffstat (limited to 'src/wixext')
-rw-r--r--src/wixext/FirewallCompiler.cs7
-rw-r--r--src/wixext/FirewallConstants.cs2
-rw-r--r--src/wixext/FirewallDecompiler.cs13
-rw-r--r--src/wixext/FirewallTableDefinitions.cs1
-rw-r--r--src/wixext/Tuples/WixFirewallExceptionTuple.cs8
-rw-r--r--src/wixext/firewall.xsd10
6 files changed, 40 insertions, 1 deletions
diff --git a/src/wixext/FirewallCompiler.cs b/src/wixext/FirewallCompiler.cs
index 1fa80f48..900af7aa 100644
--- a/src/wixext/FirewallCompiler.cs
+++ b/src/wixext/FirewallCompiler.cs
@@ -81,6 +81,7 @@ namespace WixToolset.Firewall
81 string scope = null; 81 string scope = null;
82 string remoteAddresses = null; 82 string remoteAddresses = null;
83 string description = null; 83 string description = null;
84 int? direction = null;
84 85
85 foreach (var attrib in element.Attributes()) 86 foreach (var attrib in element.Attributes())
86 { 87 {
@@ -177,6 +178,11 @@ namespace WixToolset.Firewall
177 case "Description": 178 case "Description":
178 description = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); 179 description = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib);
179 break; 180 break;
181 case "Outbound":
182 direction = this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib) == YesNoType.Yes
183 ? FirewallConstants.NET_FW_RULE_DIR_OUT
184 : FirewallConstants.NET_FW_RULE_DIR_IN;
185 break;
180 default: 186 default:
181 this.ParseHelper.UnexpectedAttribute(element, attrib); 187 this.ParseHelper.UnexpectedAttribute(element, attrib);
182 break; 188 break;
@@ -260,6 +266,7 @@ namespace WixToolset.Firewall
260 Profile = profile ?? FirewallConstants.NET_FW_PROFILE2_ALL, 266 Profile = profile ?? FirewallConstants.NET_FW_PROFILE2_ALL,
261 ComponentRef = componentId, 267 ComponentRef = componentId,
262 Description = description, 268 Description = description,
269 Direction = direction ?? FirewallConstants.NET_FW_RULE_DIR_IN,
263 }); 270 });
264 271
265 if (!String.IsNullOrEmpty(port)) 272 if (!String.IsNullOrEmpty(port))
diff --git a/src/wixext/FirewallConstants.cs b/src/wixext/FirewallConstants.cs
index 16caa5b4..7bb12ba4 100644
--- a/src/wixext/FirewallConstants.cs
+++ b/src/wixext/FirewallConstants.cs
@@ -9,6 +9,8 @@ namespace WixToolset.Firewall
9 static class FirewallConstants 9 static class FirewallConstants
10 { 10 {
11 // from icftypes.h 11 // from icftypes.h
12 public const int NET_FW_RULE_DIR_IN = 1;
13 public const int NET_FW_RULE_DIR_OUT = 2;
12 public const int NET_FW_IP_PROTOCOL_TCP = 6; 14 public const int NET_FW_IP_PROTOCOL_TCP = 6;
13 public const int NET_FW_IP_PROTOCOL_UDP = 17; 15 public const int NET_FW_IP_PROTOCOL_UDP = 17;
14 16
diff --git a/src/wixext/FirewallDecompiler.cs b/src/wixext/FirewallDecompiler.cs
index b060f8e2..c9478de1 100644
--- a/src/wixext/FirewallDecompiler.cs
+++ b/src/wixext/FirewallDecompiler.cs
@@ -146,6 +146,19 @@ namespace WixToolset.Firewall
146 fire.Description = (string)row[9]; 146 fire.Description = (string)row[9];
147 } 147 }
148 148
149 if (!row.IsColumnEmpty(10))
150 {
151 switch (Convert.ToInt32(row[10]))
152 {
153 case FirewallConstants.NET_FW_RULE_DIR_IN:
154 fire.Direction = Firewall.FirewallException.DirectionType.@in;
155 break;
156 case FirewallConstants.NET_FW_RULE_DIR_OUT:
157 fire.Direction = Firewall.FirewallException.DirectionType.@out;
158 break;
159 }
160 }
161
149 Wix.Component component = (Wix.Component)this.Core.GetIndexedElement("Component", (string)row[8]); 162 Wix.Component component = (Wix.Component)this.Core.GetIndexedElement("Component", (string)row[8]);
150 if (null != component) 163 if (null != component)
151 { 164 {
diff --git a/src/wixext/FirewallTableDefinitions.cs b/src/wixext/FirewallTableDefinitions.cs
index 4bae1ef0..068fe696 100644
--- a/src/wixext/FirewallTableDefinitions.cs
+++ b/src/wixext/FirewallTableDefinitions.cs
@@ -21,6 +21,7 @@ namespace WixToolset.Firewall
21 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("Profile", ColumnType.Number, 4, primaryKey: false, nullable: false, ColumnCategory.Integer, minValue: 1, maxValue: 2147483647, description: "Profile (1=domain; 2=private; 4=public; 2147483647=all)."),
22 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("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),
23 new ColumnDefinition("Description", ColumnType.String, 255, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Description displayed in Windows Firewall manager for this firewall rule."), 23 new ColumnDefinition("Description", ColumnType.String, 255, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Description displayed in Windows Firewall manager for this firewall rule."),
24 new ColumnDefinition("Direction", ColumnType.Number, 1, primaryKey: false, nullable: true, ColumnCategory.Integer, minValue: 1, maxValue: 2, description: "Direction (1=in; 2=out)"),
24 }, 25 },
25 tupleIdIsPrimaryKey: true 26 tupleIdIsPrimaryKey: true
26 ); 27 );
diff --git a/src/wixext/Tuples/WixFirewallExceptionTuple.cs b/src/wixext/Tuples/WixFirewallExceptionTuple.cs
index d08b9e45..d34b8207 100644
--- a/src/wixext/Tuples/WixFirewallExceptionTuple.cs
+++ b/src/wixext/Tuples/WixFirewallExceptionTuple.cs
@@ -20,6 +20,7 @@ namespace WixToolset.Firewall
20 new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Profile), IntermediateFieldType.Number), 20 new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Profile), IntermediateFieldType.Number),
21 new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.ComponentRef), IntermediateFieldType.String), 21 new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.ComponentRef), IntermediateFieldType.String),
22 new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Description), IntermediateFieldType.String), 22 new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Description), IntermediateFieldType.String),
23 new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Direction), IntermediateFieldType.Number),
23 }, 24 },
24 typeof(WixFirewallExceptionTuple)); 25 typeof(WixFirewallExceptionTuple));
25 } 26 }
@@ -40,6 +41,7 @@ namespace WixToolset.Firewall.Tuples
40 Profile, 41 Profile,
41 ComponentRef, 42 ComponentRef,
42 Description, 43 Description,
44 Direction,
43 } 45 }
44 46
45 public class WixFirewallExceptionTuple : IntermediateTuple 47 public class WixFirewallExceptionTuple : IntermediateTuple
@@ -107,5 +109,11 @@ namespace WixToolset.Firewall.Tuples
107 get => this.Fields[(int)WixFirewallExceptionTupleFields.Description].AsString(); 109 get => this.Fields[(int)WixFirewallExceptionTupleFields.Description].AsString();
108 set => this.Set((int)WixFirewallExceptionTupleFields.Description, value); 110 set => this.Set((int)WixFirewallExceptionTupleFields.Description, value);
109 } 111 }
112
113 public int Direction
114 {
115 get => this.Fields[(int)WixFirewallExceptionTupleFields.Direction].AsNumber();
116 set => this.Set((int)WixFirewallExceptionTupleFields.Direction, value);
117 }
110 } 118 }
111} \ No newline at end of file 119} \ No newline at end of file
diff --git a/src/wixext/firewall.xsd b/src/wixext/firewall.xsd
index d64aafef..fec7e37a 100644
--- a/src/wixext/firewall.xsd
+++ b/src/wixext/firewall.xsd
@@ -141,7 +141,7 @@
141 <xs:attribute name="IgnoreFailure" type="YesNoType"> 141 <xs:attribute name="IgnoreFailure" type="YesNoType">
142 <xs:annotation> 142 <xs:annotation>
143 <xs:documentation> 143 <xs:documentation>
144 If "yes," failures to register this firewall exception will be silently 144 If "yes", failures to register this firewall exception will be silently
145 ignored. If "no" (the default), failures will cause rollback. 145 ignored. If "no" (the default), failures will cause rollback.
146 </xs:documentation> 146 </xs:documentation>
147 </xs:annotation> 147 </xs:annotation>
@@ -170,6 +170,14 @@
170 </xs:documentation> 170 </xs:documentation>
171 </xs:annotation> 171 </xs:annotation>
172 </xs:attribute> 172 </xs:attribute>
173
174 <xs:attribute name="Outbound" type="YesNoType">
175 <xs:annotation>
176 <xs:documentation>
177 If "yes", registers an outbound firewall rule.
178 </xs:documentation>
179 </xs:annotation>
180 </xs:attribute>
173 </xs:complexType> 181 </xs:complexType>
174 </xs:element> 182 </xs:element>
175 183