This repository has been archived by the owner on Dec 9, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathbind.go
683 lines (502 loc) · 14.6 KB
/
bind.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
// Code generated by go-swagger; DO NOT EDIT.
// Copyright 2019 HAProxy Technologies
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
package models
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"encoding/json"
"github.com/go-openapi/errors"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// Bind Bind
//
// HAProxy frontend bind configuration
//
// swagger:model bind
type Bind struct {
// accept netscaler cip
AcceptNetscalerCip int64 `json:"accept_netscaler_cip,omitempty"`
// accept proxy
AcceptProxy bool `json:"accept_proxy,omitempty"`
// address
// Pattern: ^[^\s]+$
Address string `json:"address,omitempty"`
// allow 0rtt
Allow0rtt bool `json:"allow_0rtt,omitempty"`
// alpn
// Pattern: ^[^\s]+$
Alpn string `json:"alpn,omitempty"`
// backlog
Backlog string `json:"backlog,omitempty"`
// ca ignore err
CaIgnoreErr string `json:"ca_ignore_err,omitempty"`
// ca sign file
CaSignFile string `json:"ca_sign_file,omitempty"`
// ca sign pass
CaSignPass string `json:"ca_sign_pass,omitempty"`
// ca verify file
CaVerifyFile string `json:"ca_verify_file,omitempty"`
// ciphers
Ciphers string `json:"ciphers,omitempty"`
// ciphersuites
Ciphersuites string `json:"ciphersuites,omitempty"`
// crl file
CrlFile string `json:"crl_file,omitempty"`
// crt ignore err
CrtIgnoreErr string `json:"crt_ignore_err,omitempty"`
// crt list
CrtList string `json:"crt_list,omitempty"`
// curves
Curves string `json:"curves,omitempty"`
// defer accept
DeferAccept bool `json:"defer_accept,omitempty"`
// ecdhe
Ecdhe string `json:"ecdhe,omitempty"`
// expose fd listeners
ExposeFdListeners bool `json:"expose_fd_listeners,omitempty"`
// force sslv3
ForceSslv3 bool `json:"force_sslv3,omitempty"`
// force tlsv10
ForceTlsv10 bool `json:"force_tlsv10,omitempty"`
// force tlsv11
ForceTlsv11 bool `json:"force_tlsv11,omitempty"`
// force tlsv12
ForceTlsv12 bool `json:"force_tlsv12,omitempty"`
// force tlsv13
ForceTlsv13 bool `json:"force_tlsv13,omitempty"`
// generate certificates
GenerateCertificates bool `json:"generate_certificates,omitempty"`
// gid
Gid int64 `json:"gid,omitempty"`
// group
Group string `json:"group,omitempty"`
// id
ID string `json:"id,omitempty"`
// interface
Interface string `json:"interface,omitempty"`
// level
// Enum: [user operator admin]
Level string `json:"level,omitempty"`
// maxconn
Maxconn int64 `json:"maxconn,omitempty"`
// mode
Mode string `json:"mode,omitempty"`
// mss
Mss string `json:"mss,omitempty"`
// name
// Required: true
// Pattern: ^[^\s]+$
Name string `json:"name"`
// namespace
Namespace string `json:"namespace,omitempty"`
// nice
Nice int64 `json:"nice,omitempty"`
// no ca names
NoCaNames bool `json:"no_ca_names,omitempty"`
// no sslv3
NoSslv3 bool `json:"no_sslv3,omitempty"`
// no tls tickets
NoTLSTickets bool `json:"no_tls_tickets,omitempty"`
// no tlsv10
NoTlsv10 bool `json:"no_tlsv10,omitempty"`
// no tlsv11
NoTlsv11 bool `json:"no_tlsv11,omitempty"`
// no tlsv12
NoTlsv12 bool `json:"no_tlsv12,omitempty"`
// no tlsv13
NoTlsv13 bool `json:"no_tlsv13,omitempty"`
// npn
Npn string `json:"npn,omitempty"`
// port
// Maximum: 65535
// Minimum: 1
Port *int64 `json:"port,omitempty"`
// port range end
// Maximum: 65535
// Minimum: 1
PortRangeEnd *int64 `json:"port-range-end,omitempty"`
// prefer client ciphers
PreferClientCiphers bool `json:"prefer_client_ciphers,omitempty"`
// process
// Pattern: ^[^\s]+$
Process string `json:"process,omitempty"`
// proto
Proto string `json:"proto,omitempty"`
// severity output
// Enum: [none number string]
SeverityOutput string `json:"severity_output,omitempty"`
// ssl
Ssl bool `json:"ssl,omitempty"`
// ssl cafile
// Pattern: ^[^\s]+$
SslCafile string `json:"ssl_cafile,omitempty"`
// ssl certificate
// Pattern: ^[^\s]+$
SslCertificate string `json:"ssl_certificate,omitempty"`
// ssl max ver
// Enum: [SSLv3 TLSv1.0 TLSv1.1 TLSv1.2 TLSv1.3]
SslMaxVer string `json:"ssl_max_ver,omitempty"`
// ssl min ver
// Enum: [SSLv3 TLSv1.0 TLSv1.1 TLSv1.2 TLSv1.3]
SslMinVer string `json:"ssl_min_ver,omitempty"`
// strict sni
StrictSni bool `json:"strict_sni,omitempty"`
// tcp user timeout
TCPUserTimeout *int64 `json:"tcp_user_timeout,omitempty"`
// tfo
Tfo bool `json:"tfo,omitempty"`
// tls ticket keys
TLSTicketKeys string `json:"tls_ticket_keys,omitempty"`
// transparent
Transparent bool `json:"transparent,omitempty"`
// uid
UID string `json:"uid,omitempty"`
// user
User string `json:"user,omitempty"`
// v4v6
V4v6 bool `json:"v4v6,omitempty"`
// v6only
V6only bool `json:"v6only,omitempty"`
// verify
// Enum: [none optional required]
Verify string `json:"verify,omitempty"`
}
// Validate validates this bind
func (m *Bind) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateAddress(formats); err != nil {
res = append(res, err)
}
if err := m.validateAlpn(formats); err != nil {
res = append(res, err)
}
if err := m.validateLevel(formats); err != nil {
res = append(res, err)
}
if err := m.validateName(formats); err != nil {
res = append(res, err)
}
if err := m.validatePort(formats); err != nil {
res = append(res, err)
}
if err := m.validatePortRangeEnd(formats); err != nil {
res = append(res, err)
}
if err := m.validateProcess(formats); err != nil {
res = append(res, err)
}
if err := m.validateSeverityOutput(formats); err != nil {
res = append(res, err)
}
if err := m.validateSslCafile(formats); err != nil {
res = append(res, err)
}
if err := m.validateSslCertificate(formats); err != nil {
res = append(res, err)
}
if err := m.validateSslMaxVer(formats); err != nil {
res = append(res, err)
}
if err := m.validateSslMinVer(formats); err != nil {
res = append(res, err)
}
if err := m.validateVerify(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *Bind) validateAddress(formats strfmt.Registry) error {
if swag.IsZero(m.Address) { // not required
return nil
}
if err := validate.Pattern("address", "body", string(m.Address), `^[^\s]+$`); err != nil {
return err
}
return nil
}
func (m *Bind) validateAlpn(formats strfmt.Registry) error {
if swag.IsZero(m.Alpn) { // not required
return nil
}
if err := validate.Pattern("alpn", "body", string(m.Alpn), `^[^\s]+$`); err != nil {
return err
}
return nil
}
var bindTypeLevelPropEnum []interface{}
func init() {
var res []string
if err := json.Unmarshal([]byte(`["user","operator","admin"]`), &res); err != nil {
panic(err)
}
for _, v := range res {
bindTypeLevelPropEnum = append(bindTypeLevelPropEnum, v)
}
}
const (
// BindLevelUser captures enum value "user"
BindLevelUser string = "user"
// BindLevelOperator captures enum value "operator"
BindLevelOperator string = "operator"
// BindLevelAdmin captures enum value "admin"
BindLevelAdmin string = "admin"
)
// prop value enum
func (m *Bind) validateLevelEnum(path, location string, value string) error {
if err := validate.Enum(path, location, value, bindTypeLevelPropEnum); err != nil {
return err
}
return nil
}
func (m *Bind) validateLevel(formats strfmt.Registry) error {
if swag.IsZero(m.Level) { // not required
return nil
}
// value enum
if err := m.validateLevelEnum("level", "body", m.Level); err != nil {
return err
}
return nil
}
func (m *Bind) validateName(formats strfmt.Registry) error {
if err := validate.RequiredString("name", "body", string(m.Name)); err != nil {
return err
}
if err := validate.Pattern("name", "body", string(m.Name), `^[^\s]+$`); err != nil {
return err
}
return nil
}
func (m *Bind) validatePort(formats strfmt.Registry) error {
if swag.IsZero(m.Port) { // not required
return nil
}
if err := validate.MinimumInt("port", "body", int64(*m.Port), 1, false); err != nil {
return err
}
if err := validate.MaximumInt("port", "body", int64(*m.Port), 65535, false); err != nil {
return err
}
return nil
}
func (m *Bind) validatePortRangeEnd(formats strfmt.Registry) error {
if swag.IsZero(m.PortRangeEnd) { // not required
return nil
}
if err := validate.MinimumInt("port-range-end", "body", int64(*m.PortRangeEnd), 1, false); err != nil {
return err
}
if err := validate.MaximumInt("port-range-end", "body", int64(*m.PortRangeEnd), 65535, false); err != nil {
return err
}
return nil
}
func (m *Bind) validateProcess(formats strfmt.Registry) error {
if swag.IsZero(m.Process) { // not required
return nil
}
if err := validate.Pattern("process", "body", string(m.Process), `^[^\s]+$`); err != nil {
return err
}
return nil
}
var bindTypeSeverityOutputPropEnum []interface{}
func init() {
var res []string
if err := json.Unmarshal([]byte(`["none","number","string"]`), &res); err != nil {
panic(err)
}
for _, v := range res {
bindTypeSeverityOutputPropEnum = append(bindTypeSeverityOutputPropEnum, v)
}
}
const (
// BindSeverityOutputNone captures enum value "none"
BindSeverityOutputNone string = "none"
// BindSeverityOutputNumber captures enum value "number"
BindSeverityOutputNumber string = "number"
// BindSeverityOutputString captures enum value "string"
BindSeverityOutputString string = "string"
)
// prop value enum
func (m *Bind) validateSeverityOutputEnum(path, location string, value string) error {
if err := validate.Enum(path, location, value, bindTypeSeverityOutputPropEnum); err != nil {
return err
}
return nil
}
func (m *Bind) validateSeverityOutput(formats strfmt.Registry) error {
if swag.IsZero(m.SeverityOutput) { // not required
return nil
}
// value enum
if err := m.validateSeverityOutputEnum("severity_output", "body", m.SeverityOutput); err != nil {
return err
}
return nil
}
func (m *Bind) validateSslCafile(formats strfmt.Registry) error {
if swag.IsZero(m.SslCafile) { // not required
return nil
}
if err := validate.Pattern("ssl_cafile", "body", string(m.SslCafile), `^[^\s]+$`); err != nil {
return err
}
return nil
}
func (m *Bind) validateSslCertificate(formats strfmt.Registry) error {
if swag.IsZero(m.SslCertificate) { // not required
return nil
}
if err := validate.Pattern("ssl_certificate", "body", string(m.SslCertificate), `^[^\s]+$`); err != nil {
return err
}
return nil
}
var bindTypeSslMaxVerPropEnum []interface{}
func init() {
var res []string
if err := json.Unmarshal([]byte(`["SSLv3","TLSv1.0","TLSv1.1","TLSv1.2","TLSv1.3"]`), &res); err != nil {
panic(err)
}
for _, v := range res {
bindTypeSslMaxVerPropEnum = append(bindTypeSslMaxVerPropEnum, v)
}
}
const (
// BindSslMaxVerSSLv3 captures enum value "SSLv3"
BindSslMaxVerSSLv3 string = "SSLv3"
// BindSslMaxVerTLSv10 captures enum value "TLSv1.0"
BindSslMaxVerTLSv10 string = "TLSv1.0"
// BindSslMaxVerTLSv11 captures enum value "TLSv1.1"
BindSslMaxVerTLSv11 string = "TLSv1.1"
// BindSslMaxVerTLSv12 captures enum value "TLSv1.2"
BindSslMaxVerTLSv12 string = "TLSv1.2"
// BindSslMaxVerTLSv13 captures enum value "TLSv1.3"
BindSslMaxVerTLSv13 string = "TLSv1.3"
)
// prop value enum
func (m *Bind) validateSslMaxVerEnum(path, location string, value string) error {
if err := validate.Enum(path, location, value, bindTypeSslMaxVerPropEnum); err != nil {
return err
}
return nil
}
func (m *Bind) validateSslMaxVer(formats strfmt.Registry) error {
if swag.IsZero(m.SslMaxVer) { // not required
return nil
}
// value enum
if err := m.validateSslMaxVerEnum("ssl_max_ver", "body", m.SslMaxVer); err != nil {
return err
}
return nil
}
var bindTypeSslMinVerPropEnum []interface{}
func init() {
var res []string
if err := json.Unmarshal([]byte(`["SSLv3","TLSv1.0","TLSv1.1","TLSv1.2","TLSv1.3"]`), &res); err != nil {
panic(err)
}
for _, v := range res {
bindTypeSslMinVerPropEnum = append(bindTypeSslMinVerPropEnum, v)
}
}
const (
// BindSslMinVerSSLv3 captures enum value "SSLv3"
BindSslMinVerSSLv3 string = "SSLv3"
// BindSslMinVerTLSv10 captures enum value "TLSv1.0"
BindSslMinVerTLSv10 string = "TLSv1.0"
// BindSslMinVerTLSv11 captures enum value "TLSv1.1"
BindSslMinVerTLSv11 string = "TLSv1.1"
// BindSslMinVerTLSv12 captures enum value "TLSv1.2"
BindSslMinVerTLSv12 string = "TLSv1.2"
// BindSslMinVerTLSv13 captures enum value "TLSv1.3"
BindSslMinVerTLSv13 string = "TLSv1.3"
)
// prop value enum
func (m *Bind) validateSslMinVerEnum(path, location string, value string) error {
if err := validate.Enum(path, location, value, bindTypeSslMinVerPropEnum); err != nil {
return err
}
return nil
}
func (m *Bind) validateSslMinVer(formats strfmt.Registry) error {
if swag.IsZero(m.SslMinVer) { // not required
return nil
}
// value enum
if err := m.validateSslMinVerEnum("ssl_min_ver", "body", m.SslMinVer); err != nil {
return err
}
return nil
}
var bindTypeVerifyPropEnum []interface{}
func init() {
var res []string
if err := json.Unmarshal([]byte(`["none","optional","required"]`), &res); err != nil {
panic(err)
}
for _, v := range res {
bindTypeVerifyPropEnum = append(bindTypeVerifyPropEnum, v)
}
}
const (
// BindVerifyNone captures enum value "none"
BindVerifyNone string = "none"
// BindVerifyOptional captures enum value "optional"
BindVerifyOptional string = "optional"
// BindVerifyRequired captures enum value "required"
BindVerifyRequired string = "required"
)
// prop value enum
func (m *Bind) validateVerifyEnum(path, location string, value string) error {
if err := validate.Enum(path, location, value, bindTypeVerifyPropEnum); err != nil {
return err
}
return nil
}
func (m *Bind) validateVerify(formats strfmt.Registry) error {
if swag.IsZero(m.Verify) { // not required
return nil
}
// value enum
if err := m.validateVerifyEnum("verify", "body", m.Verify); err != nil {
return err
}
return nil
}
// MarshalBinary interface implementation
func (m *Bind) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *Bind) UnmarshalBinary(b []byte) error {
var res Bind
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}