@@ -114,6 +114,28 @@ func buildListenDirective(port string, proxyProtocol bool, listenType listenerTy
114
114
return directive
115
115
}
116
116
117
+ func buildTransportListenDirective (listenType listenerType , port string , ssl * StreamSSL , udp bool ) string {
118
+ base := "listen"
119
+ var directive string
120
+
121
+ if listenType == ipv6 {
122
+ directive = base + " [::]:" + port
123
+ } else {
124
+ directive = base + " " + port
125
+ }
126
+
127
+ if ssl .Enabled {
128
+ directive += " ssl"
129
+ }
130
+
131
+ if udp {
132
+ directive += " udp"
133
+ }
134
+
135
+ directive += ";\n "
136
+ return directive
137
+ }
138
+
117
139
func makeHTTPListener (s Server ) string {
118
140
return makeListener (http , s )
119
141
}
@@ -122,6 +144,20 @@ func makeHTTPSListener(s Server) string {
122
144
return makeListener (https , s )
123
145
}
124
146
147
+ func makeTransportListener (s StreamServer ) string {
148
+ var directives string
149
+ port := strconv .Itoa (s .Port )
150
+
151
+ directives += buildTransportListenDirective (ipv4 , port , s .SSL , s .UDP )
152
+
153
+ if ! s .DisableIPV6 {
154
+ directives += spacing
155
+ directives += buildTransportListenDirective (ipv6 , port , s .SSL , s .UDP )
156
+ }
157
+
158
+ return directives
159
+ }
160
+
125
161
func makeHeaderQueryValue (apiKey APIKey ) string {
126
162
var parts []string
127
163
@@ -140,16 +176,17 @@ func makeHeaderQueryValue(apiKey APIKey) string {
140
176
}
141
177
142
178
var helperFunctions = template.FuncMap {
143
- "headerListToCIMap" : headerListToCIMap ,
144
- "hasCIKey" : hasCIKey ,
145
- "contains" : strings .Contains ,
146
- "hasPrefix" : strings .HasPrefix ,
147
- "hasSuffix" : strings .HasSuffix ,
148
- "toLower" : strings .ToLower ,
149
- "toUpper" : strings .ToUpper ,
150
- "replaceAll" : strings .ReplaceAll ,
151
- "makeHTTPListener" : makeHTTPListener ,
152
- "makeHTTPSListener" : makeHTTPSListener ,
153
- "makeSecretPath" : commonhelpers .MakeSecretPath ,
154
- "makeHeaderQueryValue" : makeHeaderQueryValue ,
179
+ "headerListToCIMap" : headerListToCIMap ,
180
+ "hasCIKey" : hasCIKey ,
181
+ "contains" : strings .Contains ,
182
+ "hasPrefix" : strings .HasPrefix ,
183
+ "hasSuffix" : strings .HasSuffix ,
184
+ "toLower" : strings .ToLower ,
185
+ "toUpper" : strings .ToUpper ,
186
+ "replaceAll" : strings .ReplaceAll ,
187
+ "makeHTTPListener" : makeHTTPListener ,
188
+ "makeHTTPSListener" : makeHTTPSListener ,
189
+ "makeSecretPath" : commonhelpers .MakeSecretPath ,
190
+ "makeHeaderQueryValue" : makeHeaderQueryValue ,
191
+ "makeTransportListener" : makeTransportListener ,
155
192
}
0 commit comments