4
4
"context"
5
5
"crypto/tls"
6
6
"net"
7
+ "slices"
7
8
"time"
8
9
9
10
"github.com/domainr/epp2/internal"
@@ -17,22 +18,54 @@ type Options interface {
17
18
// Config is an optimized form of EPP options,
18
19
// suitable for passing via the call stack.
19
20
type Config struct {
20
- Context context.Context
21
- KeepAlive time. Duration
22
- Timeout time. Duration
21
+ Context context.Context
22
+
23
+ // Network options
23
24
Dialer ContextDialer
24
25
TLSConfig * tls.Config
26
+ KeepAlive time.Duration
27
+ Timeout time.Duration
25
28
Pipeline int
26
- Schemas schema.Schemas
29
+
30
+ // EPP options
31
+ Versions []string
32
+ Objects []string
33
+ Extensions []string
34
+ UnannouncedExtensions []string
35
+ Schemas schema.Schemas
27
36
}
28
37
29
38
func (* Config ) EPPOptions (internal.Internal ) {}
30
39
40
+ // Clone returns a 1-level deep clone of cfg.
41
+ // Slice members and tls.Config will be cloned.
42
+ func (cfg * Config ) Clone () * Config {
43
+ return & Config {
44
+ Context : cfg .Context ,
45
+
46
+ // Network options
47
+ Dialer : cfg .Dialer ,
48
+ TLSConfig : cfg .TLSConfig .Clone (),
49
+ KeepAlive : cfg .KeepAlive ,
50
+ Timeout : cfg .Timeout ,
51
+ Pipeline : cfg .Pipeline ,
52
+
53
+ // EPP options
54
+ Versions : slices .Clone (cfg .Versions ),
55
+ Objects : slices .Clone (cfg .Objects ),
56
+ Extensions : slices .Clone (cfg .Extensions ),
57
+ UnannouncedExtensions : slices .Clone (cfg .UnannouncedExtensions ),
58
+ Schemas : slices .Clone (cfg .Schemas ),
59
+ }
60
+ }
61
+
31
62
func (cfg * Config ) Join (opts ... Options ) {
32
63
for _ , src := range opts {
33
64
switch src := src .(type ) {
34
65
case nil :
35
66
continue
67
+ case * Config :
68
+ * cfg = * (src .Clone ())
36
69
case Context :
37
70
cfg .Context = src .Context
38
71
case KeepAlive :
0 commit comments