diff options
Diffstat (limited to 'src/gnunet/service/gns/block_handler.go')
-rw-r--r-- | src/gnunet/service/gns/block_handler.go | 134 |
1 files changed, 74 insertions, 60 deletions
diff --git a/src/gnunet/service/gns/block_handler.go b/src/gnunet/service/gns/block_handler.go index a0e7874..b00fac2 100644 --- a/src/gnunet/service/gns/block_handler.go +++ b/src/gnunet/service/gns/block_handler.go | |||
@@ -19,19 +19,21 @@ | |||
19 | package gns | 19 | package gns |
20 | 20 | ||
21 | import ( | 21 | import ( |
22 | "crypto/sha256" | ||
22 | "encoding/hex" | 23 | "encoding/hex" |
23 | "fmt" | 24 | "fmt" |
24 | 25 | ||
25 | "gnunet/crypto" | 26 | "gnunet/crypto" |
26 | "gnunet/enums" | 27 | "gnunet/enums" |
27 | "gnunet/message" | 28 | "gnunet/service/dht/blocks" |
29 | "gnunet/service/gns/rr" | ||
28 | "gnunet/util" | 30 | "gnunet/util" |
29 | 31 | ||
30 | "github.com/bfix/gospel/logger" | 32 | "github.com/bfix/gospel/logger" |
31 | ) | 33 | ) |
32 | 34 | ||
33 | // HdlrInst is the type for functions that instantiate custom block handlers. | 35 | // HdlrInst is the type for functions that instantiate custom block handlers. |
34 | type HdlrInst func(*message.ResourceRecord, []string) (BlockHandler, error) | 36 | type HdlrInst func(*blocks.ResourceRecord, []string) (BlockHandler, error) |
35 | 37 | ||
36 | // Error codes | 38 | // Error codes |
37 | var ( | 39 | var ( |
@@ -70,7 +72,7 @@ type BlockHandler interface { | |||
70 | // processing. The handler can inspect the remaining labels in a path | 72 | // processing. The handler can inspect the remaining labels in a path |
71 | // if required. The method returns an error if a record is not accepted | 73 | // if required. The method returns an error if a record is not accepted |
72 | // by the block handler (RR not of required type). | 74 | // by the block handler (RR not of required type). |
73 | AddRecord(rr *message.ResourceRecord, labels []string) error | 75 | AddRecord(rr *blocks.ResourceRecord, labels []string) error |
74 | 76 | ||
75 | // Coexist checks if a custom block handler can co-exist with other | 77 | // Coexist checks if a custom block handler can co-exist with other |
76 | // resource records in the same block. 'cm' maps the resource type | 78 | // resource records in the same block. 'cm' maps the resource type |
@@ -80,7 +82,7 @@ type BlockHandler interface { | |||
80 | 82 | ||
81 | // Records returns a list of RR of the given types associated with | 83 | // Records returns a list of RR of the given types associated with |
82 | // the custom handler | 84 | // the custom handler |
83 | Records(kind RRTypeList) *message.RecordSet | 85 | Records(kind RRTypeList) *blocks.RecordSet |
84 | 86 | ||
85 | // Name returns the human-readable name of the handler | 87 | // Name returns the human-readable name of the handler |
86 | Name() string | 88 | Name() string |
@@ -108,7 +110,7 @@ type BlockHandlerList struct { | |||
108 | 110 | ||
109 | // NewBlockHandlerList instantiates an a list of active block handlers | 111 | // NewBlockHandlerList instantiates an a list of active block handlers |
110 | // for a given set of records (GNS block). | 112 | // for a given set of records (GNS block). |
111 | func NewBlockHandlerList(records []*message.ResourceRecord, labels []string) (*BlockHandlerList, []*message.ResourceRecord, error) { | 113 | func NewBlockHandlerList(records []*blocks.ResourceRecord, labels []string) (*BlockHandlerList, []*blocks.ResourceRecord, error) { |
112 | // initialize block handler list | 114 | // initialize block handler list |
113 | hl := &BlockHandlerList{ | 115 | hl := &BlockHandlerList{ |
114 | list: make(map[enums.GNSType]BlockHandler), | 116 | list: make(map[enums.GNSType]BlockHandler), |
@@ -116,19 +118,19 @@ func NewBlockHandlerList(records []*message.ResourceRecord, labels []string) (*B | |||
116 | } | 118 | } |
117 | 119 | ||
118 | // first pass: build list of shadow records in this block | 120 | // first pass: build list of shadow records in this block |
119 | shadows := make([]*message.ResourceRecord, 0) | 121 | shadows := make([]*blocks.ResourceRecord, 0) |
120 | for _, rec := range records { | 122 | for _, rec := range records { |
121 | // filter out shadow records... | 123 | // filter out shadow records... |
122 | if (int(rec.Flags) & enums.GNS_FLAG_SHADOW) != 0 { | 124 | if (rec.Flags & enums.GNS_FLAG_SHADOW) != 0 { |
123 | shadows = append(shadows, rec) | 125 | shadows = append(shadows, rec) |
124 | } | 126 | } |
125 | } | 127 | } |
126 | // second pass: normalize block by filtering out expired records (and | 128 | // second pass: normalize block by filtering out expired records (and |
127 | // replacing them with shadow records if available | 129 | // replacing them with shadow records if available |
128 | active := make([]*message.ResourceRecord, 0) | 130 | active := make([]*blocks.ResourceRecord, 0) |
129 | for _, rec := range records { | 131 | for _, rec := range records { |
130 | // don't process shadow records again | 132 | // don't process shadow records again |
131 | if (int(rec.Flags) & enums.GNS_FLAG_SHADOW) != 0 { | 133 | if (rec.Flags & enums.GNS_FLAG_SHADOW) != 0 { |
132 | continue | 134 | continue |
133 | } | 135 | } |
134 | // check for expired record | 136 | // check for expired record |
@@ -137,7 +139,7 @@ func NewBlockHandlerList(records []*message.ResourceRecord, labels []string) (*B | |||
137 | for _, shadow := range shadows { | 139 | for _, shadow := range shadows { |
138 | if shadow.RType == rec.RType && !shadow.Expire.Expired() { | 140 | if shadow.RType == rec.RType && !shadow.Expire.Expired() { |
139 | // deliver un-expired shadow record instead. | 141 | // deliver un-expired shadow record instead. |
140 | shadow.Flags &^= uint32(enums.GNS_FLAG_SHADOW) | 142 | shadow.Flags &^= enums.GNS_FLAG_SHADOW |
141 | active = append(active, shadow) | 143 | active = append(active, shadow) |
142 | } | 144 | } |
143 | } | 145 | } |
@@ -149,11 +151,11 @@ func NewBlockHandlerList(records []*message.ResourceRecord, labels []string) (*B | |||
149 | // Third pass: Traverse active list and build list of handler instances. | 151 | // Third pass: Traverse active list and build list of handler instances. |
150 | for _, rec := range active { | 152 | for _, rec := range active { |
151 | // update counter map for non-supplemental records | 153 | // update counter map for non-supplemental records |
152 | if (int(rec.Flags) & enums.GNS_FLAG_SUPPL) != 0 { | 154 | if (rec.Flags & enums.GNS_FLAG_SUPPL) != 0 { |
153 | logger.Printf(logger.DBG, "[gns] handler_list: skip %v\n", rec) | 155 | logger.Printf(logger.DBG, "[gns] handler_list: skip %v\n", rec) |
154 | continue | 156 | continue |
155 | } | 157 | } |
156 | rrType := enums.GNSType(rec.RType) | 158 | rrType := rec.RType |
157 | hl.counts.Add(rrType) | 159 | hl.counts.Add(rrType) |
158 | 160 | ||
159 | // check for custom handler type | 161 | // check for custom handler type |
@@ -205,7 +207,7 @@ func (hl *BlockHandlerList) GetHandler(types ...enums.GNSType) BlockHandler { | |||
205 | } | 207 | } |
206 | 208 | ||
207 | // FinalizeRecord post-processes records | 209 | // FinalizeRecord post-processes records |
208 | func (hl *BlockHandlerList) FinalizeRecord(rec *message.ResourceRecord) *message.ResourceRecord { | 210 | func (hl *BlockHandlerList) FinalizeRecord(rec *blocks.ResourceRecord) *blocks.ResourceRecord { |
209 | // no implementation yet | 211 | // no implementation yet |
210 | return rec | 212 | return rec |
211 | } | 213 | } |
@@ -216,13 +218,13 @@ func (hl *BlockHandlerList) FinalizeRecord(rec *message.ResourceRecord) *message | |||
216 | 218 | ||
217 | // ZoneKeyHandler implementing the BlockHandler interface | 219 | // ZoneKeyHandler implementing the BlockHandler interface |
218 | type ZoneKeyHandler struct { | 220 | type ZoneKeyHandler struct { |
219 | ztype uint32 // zone type | 221 | ztype enums.GNSType // zone type |
220 | zkey *crypto.ZoneKey // Zone key | 222 | zkey *crypto.ZoneKey // Zone key |
221 | rec *message.ResourceRecord // associated recource record | 223 | rec *blocks.ResourceRecord // associated recource record |
222 | } | 224 | } |
223 | 225 | ||
224 | // NewZoneHandler returns a new BlockHandler instance | 226 | // NewZoneHandler returns a new BlockHandler instance |
225 | func NewZoneHandler(rec *message.ResourceRecord, labels []string) (BlockHandler, error) { | 227 | func NewZoneHandler(rec *blocks.ResourceRecord, labels []string) (BlockHandler, error) { |
226 | // check if we have an implementation for the zone type | 228 | // check if we have an implementation for the zone type |
227 | if crypto.GetImplementation(rec.RType) == nil { | 229 | if crypto.GetImplementation(rec.RType) == nil { |
228 | return nil, ErrInvalidRecordType | 230 | return nil, ErrInvalidRecordType |
@@ -240,7 +242,7 @@ func NewZoneHandler(rec *message.ResourceRecord, labels []string) (BlockHandler, | |||
240 | } | 242 | } |
241 | 243 | ||
242 | // AddRecord inserts a PKEY record into the handler. | 244 | // AddRecord inserts a PKEY record into the handler. |
243 | func (h *ZoneKeyHandler) AddRecord(rec *message.ResourceRecord, labels []string) (err error) { | 245 | func (h *ZoneKeyHandler) AddRecord(rec *blocks.ResourceRecord, labels []string) (err error) { |
244 | // check record type | 246 | // check record type |
245 | if rec.RType != h.ztype { | 247 | if rec.RType != h.ztype { |
246 | return ErrInvalidRecordType | 248 | return ErrInvalidRecordType |
@@ -266,8 +268,8 @@ func (h *ZoneKeyHandler) Coexist(cm util.Counter[enums.GNSType]) bool { | |||
266 | } | 268 | } |
267 | 269 | ||
268 | // Records returns a list of RR of the given type associated with this handler | 270 | // Records returns a list of RR of the given type associated with this handler |
269 | func (h *ZoneKeyHandler) Records(kind RRTypeList) *message.RecordSet { | 271 | func (h *ZoneKeyHandler) Records(kind RRTypeList) *blocks.RecordSet { |
270 | rs := message.NewRecordSet() | 272 | rs := blocks.NewRecordSet() |
271 | if kind.HasType(enums.GNS_TYPE_PKEY) { | 273 | if kind.HasType(enums.GNS_TYPE_PKEY) { |
272 | rs.AddRecord(h.rec) | 274 | rs.AddRecord(h.rec) |
273 | } | 275 | } |
@@ -285,20 +287,20 @@ func (h *ZoneKeyHandler) Name() string { | |||
285 | 287 | ||
286 | // Gns2DnsHandler implementing the BlockHandler interface | 288 | // Gns2DnsHandler implementing the BlockHandler interface |
287 | type Gns2DnsHandler struct { | 289 | type Gns2DnsHandler struct { |
288 | Query string // DNS query name | 290 | Query string // DNS query name |
289 | Servers []string // DNS servers to ask | 291 | Servers []string // DNS servers to ask |
290 | recs []*message.ResourceRecord // list of rersource records | 292 | recs []*blocks.ResourceRecord // list of rersource records |
291 | } | 293 | } |
292 | 294 | ||
293 | // NewGns2DnsHandler returns a new BlockHandler instance | 295 | // NewGns2DnsHandler returns a new BlockHandler instance |
294 | func NewGns2DnsHandler(rec *message.ResourceRecord, labels []string) (BlockHandler, error) { | 296 | func NewGns2DnsHandler(rec *blocks.ResourceRecord, labels []string) (BlockHandler, error) { |
295 | if enums.GNSType(rec.RType) != enums.GNS_TYPE_GNS2DNS { | 297 | if rec.RType != enums.GNS_TYPE_GNS2DNS { |
296 | return nil, ErrInvalidRecordType | 298 | return nil, ErrInvalidRecordType |
297 | } | 299 | } |
298 | h := &Gns2DnsHandler{ | 300 | h := &Gns2DnsHandler{ |
299 | Query: "", | 301 | Query: "", |
300 | Servers: make([]string, 0), | 302 | Servers: make([]string, 0), |
301 | recs: make([]*message.ResourceRecord, 0), | 303 | recs: make([]*blocks.ResourceRecord, 0), |
302 | } | 304 | } |
303 | if err := h.AddRecord(rec, labels); err != nil { | 305 | if err := h.AddRecord(rec, labels); err != nil { |
304 | return nil, err | 306 | return nil, err |
@@ -307,8 +309,8 @@ func NewGns2DnsHandler(rec *message.ResourceRecord, labels []string) (BlockHandl | |||
307 | } | 309 | } |
308 | 310 | ||
309 | // AddRecord inserts a GNS2DNS record into the handler. | 311 | // AddRecord inserts a GNS2DNS record into the handler. |
310 | func (h *Gns2DnsHandler) AddRecord(rec *message.ResourceRecord, labels []string) error { | 312 | func (h *Gns2DnsHandler) AddRecord(rec *blocks.ResourceRecord, labels []string) error { |
311 | if enums.GNSType(rec.RType) != enums.GNS_TYPE_GNS2DNS { | 313 | if rec.RType != enums.GNS_TYPE_GNS2DNS { |
312 | return ErrInvalidRecordType | 314 | return ErrInvalidRecordType |
313 | } | 315 | } |
314 | logger.Printf(logger.DBG, "[gns] GNS2DNS data: %s\n", hex.EncodeToString(rec.Data)) | 316 | logger.Printf(logger.DBG, "[gns] GNS2DNS data: %s\n", hex.EncodeToString(rec.Data)) |
@@ -341,8 +343,8 @@ func (h *Gns2DnsHandler) Coexist(cm util.Counter[enums.GNSType]) bool { | |||
341 | } | 343 | } |
342 | 344 | ||
343 | // Records returns a list of RR of the given type associated with this handler | 345 | // Records returns a list of RR of the given type associated with this handler |
344 | func (h *Gns2DnsHandler) Records(kind RRTypeList) *message.RecordSet { | 346 | func (h *Gns2DnsHandler) Records(kind RRTypeList) *blocks.RecordSet { |
345 | rs := message.NewRecordSet() | 347 | rs := blocks.NewRecordSet() |
346 | if kind.HasType(enums.GNS_TYPE_GNS2DNS) { | 348 | if kind.HasType(enums.GNS_TYPE_GNS2DNS) { |
347 | for _, rec := range h.recs { | 349 | for _, rec := range h.recs { |
348 | rs.AddRecord(rec) | 350 | rs.AddRecord(rec) |
@@ -360,14 +362,21 @@ func (h *Gns2DnsHandler) Name() string { | |||
360 | // BOX handler | 362 | // BOX handler |
361 | //---------------------------------------------------------------------- | 363 | //---------------------------------------------------------------------- |
362 | 364 | ||
365 | // Box record for handler logic | ||
366 | type Box struct { | ||
367 | rr.BOX | ||
368 | key string // map key for box instance | ||
369 | rec *blocks.ResourceRecord // originating RR | ||
370 | } | ||
371 | |||
363 | // BoxHandler implementing the BlockHandler interface | 372 | // BoxHandler implementing the BlockHandler interface |
364 | type BoxHandler struct { | 373 | type BoxHandler struct { |
365 | boxes map[string]*Box // map of found boxes | 374 | boxes map[string]*Box // map of found boxes |
366 | } | 375 | } |
367 | 376 | ||
368 | // NewBoxHandler returns a new BlockHandler instance | 377 | // NewBoxHandler returns a new BlockHandler instance |
369 | func NewBoxHandler(rec *message.ResourceRecord, labels []string) (BlockHandler, error) { | 378 | func NewBoxHandler(rec *blocks.ResourceRecord, labels []string) (BlockHandler, error) { |
370 | if enums.GNSType(rec.RType) != enums.GNS_TYPE_BOX { | 379 | if rec.RType != enums.GNS_TYPE_BOX { |
371 | return nil, ErrInvalidRecordType | 380 | return nil, ErrInvalidRecordType |
372 | } | 381 | } |
373 | h := &BoxHandler{ | 382 | h := &BoxHandler{ |
@@ -380,8 +389,8 @@ func NewBoxHandler(rec *message.ResourceRecord, labels []string) (BlockHandler, | |||
380 | } | 389 | } |
381 | 390 | ||
382 | // AddRecord inserts a BOX record into the handler. | 391 | // AddRecord inserts a BOX record into the handler. |
383 | func (h *BoxHandler) AddRecord(rec *message.ResourceRecord, labels []string) error { | 392 | func (h *BoxHandler) AddRecord(rec *blocks.ResourceRecord, labels []string) error { |
384 | if enums.GNSType(rec.RType) != enums.GNS_TYPE_BOX { | 393 | if rec.RType != enums.GNS_TYPE_BOX { |
385 | return ErrInvalidRecordType | 394 | return ErrInvalidRecordType |
386 | } | 395 | } |
387 | logger.Printf(logger.DBG, "[box-rr] for labels %v\n", labels) | 396 | logger.Printf(logger.DBG, "[box-rr] for labels %v\n", labels) |
@@ -395,7 +404,12 @@ func (h *BoxHandler) AddRecord(rec *message.ResourceRecord, labels []string) err | |||
395 | return nil | 404 | return nil |
396 | } | 405 | } |
397 | // (3) check of "svc" and "proto" match values in the BOX | 406 | // (3) check of "svc" and "proto" match values in the BOX |
398 | box := NewBox(rec) | 407 | hsh := sha256.Sum256(rec.Data) |
408 | box := &Box{ | ||
409 | BOX: *rr.NewBOX(rec.Data), | ||
410 | key: hex.EncodeToString(hsh[:8]), | ||
411 | rec: rec, | ||
412 | } | ||
399 | if box.Matches(labels) { | 413 | if box.Matches(labels) { |
400 | logger.Println(logger.DBG, "[box-rr] MATCH -- adding record") | 414 | logger.Println(logger.DBG, "[box-rr] MATCH -- adding record") |
401 | h.boxes[box.key] = box | 415 | h.boxes[box.key] = box |
@@ -411,12 +425,12 @@ func (h *BoxHandler) Coexist(cm util.Counter[enums.GNSType]) bool { | |||
411 | } | 425 | } |
412 | 426 | ||
413 | // Records returns a list of RR of the given type associated with this handler | 427 | // Records returns a list of RR of the given type associated with this handler |
414 | func (h *BoxHandler) Records(kind RRTypeList) *message.RecordSet { | 428 | func (h *BoxHandler) Records(kind RRTypeList) *blocks.RecordSet { |
415 | rs := message.NewRecordSet() | 429 | rs := blocks.NewRecordSet() |
416 | for _, box := range h.boxes { | 430 | for _, box := range h.boxes { |
417 | if kind.HasType(enums.GNSType(box.Type)) { | 431 | if kind.HasType(box.Type) { |
418 | // valid box found: assemble new resource record. | 432 | // valid box found: assemble new resource record. |
419 | rr := new(message.ResourceRecord) | 433 | rr := new(blocks.ResourceRecord) |
420 | rr.Expire = box.rec.Expire | 434 | rr.Expire = box.rec.Expire |
421 | rr.Flags = box.rec.Flags | 435 | rr.Flags = box.rec.Flags |
422 | rr.RType = box.Type | 436 | rr.RType = box.Type |
@@ -440,12 +454,12 @@ func (h *BoxHandler) Name() string { | |||
440 | // LehoHandler implementing the BlockHandler interface | 454 | // LehoHandler implementing the BlockHandler interface |
441 | type LehoHandler struct { | 455 | type LehoHandler struct { |
442 | name string | 456 | name string |
443 | rec *message.ResourceRecord | 457 | rec *blocks.ResourceRecord |
444 | } | 458 | } |
445 | 459 | ||
446 | // NewLehoHandler returns a new BlockHandler instance | 460 | // NewLehoHandler returns a new BlockHandler instance |
447 | func NewLehoHandler(rec *message.ResourceRecord, labels []string) (BlockHandler, error) { | 461 | func NewLehoHandler(rec *blocks.ResourceRecord, labels []string) (BlockHandler, error) { |
448 | if enums.GNSType(rec.RType) != enums.GNS_TYPE_LEHO { | 462 | if rec.RType != enums.GNS_TYPE_LEHO { |
449 | return nil, ErrInvalidRecordType | 463 | return nil, ErrInvalidRecordType |
450 | } | 464 | } |
451 | h := &LehoHandler{ | 465 | h := &LehoHandler{ |
@@ -458,8 +472,8 @@ func NewLehoHandler(rec *message.ResourceRecord, labels []string) (BlockHandler, | |||
458 | } | 472 | } |
459 | 473 | ||
460 | // AddRecord inserts a LEHO record into the handler. | 474 | // AddRecord inserts a LEHO record into the handler. |
461 | func (h *LehoHandler) AddRecord(rec *message.ResourceRecord, labels []string) error { | 475 | func (h *LehoHandler) AddRecord(rec *blocks.ResourceRecord, labels []string) error { |
462 | if enums.GNSType(rec.RType) != enums.GNS_TYPE_LEHO { | 476 | if rec.RType != enums.GNS_TYPE_LEHO { |
463 | return ErrInvalidRecordType | 477 | return ErrInvalidRecordType |
464 | } | 478 | } |
465 | h.name = string(rec.Data) | 479 | h.name = string(rec.Data) |
@@ -475,8 +489,8 @@ func (h *LehoHandler) Coexist(cm util.Counter[enums.GNSType]) bool { | |||
475 | } | 489 | } |
476 | 490 | ||
477 | // Records returns a list of RR of the given type associated with this handler | 491 | // Records returns a list of RR of the given type associated with this handler |
478 | func (h *LehoHandler) Records(kind RRTypeList) *message.RecordSet { | 492 | func (h *LehoHandler) Records(kind RRTypeList) *blocks.RecordSet { |
479 | rs := message.NewRecordSet() | 493 | rs := blocks.NewRecordSet() |
480 | if kind.HasType(enums.GNS_TYPE_LEHO) { | 494 | if kind.HasType(enums.GNS_TYPE_LEHO) { |
481 | rs.AddRecord(h.rec) | 495 | rs.AddRecord(h.rec) |
482 | } | 496 | } |
@@ -495,12 +509,12 @@ func (h *LehoHandler) Name() string { | |||
495 | // CnameHandler implementing the BlockHandler interface | 509 | // CnameHandler implementing the BlockHandler interface |
496 | type CnameHandler struct { | 510 | type CnameHandler struct { |
497 | name string | 511 | name string |
498 | rec *message.ResourceRecord | 512 | rec *blocks.ResourceRecord |
499 | } | 513 | } |
500 | 514 | ||
501 | // NewCnameHandler returns a new BlockHandler instance | 515 | // NewCnameHandler returns a new BlockHandler instance |
502 | func NewCnameHandler(rec *message.ResourceRecord, labels []string) (BlockHandler, error) { | 516 | func NewCnameHandler(rec *blocks.ResourceRecord, labels []string) (BlockHandler, error) { |
503 | if enums.GNSType(rec.RType) != enums.GNS_TYPE_DNS_CNAME { | 517 | if rec.RType != enums.GNS_TYPE_DNS_CNAME { |
504 | return nil, ErrInvalidRecordType | 518 | return nil, ErrInvalidRecordType |
505 | } | 519 | } |
506 | h := &CnameHandler{ | 520 | h := &CnameHandler{ |
@@ -513,8 +527,8 @@ func NewCnameHandler(rec *message.ResourceRecord, labels []string) (BlockHandler | |||
513 | } | 527 | } |
514 | 528 | ||
515 | // AddRecord inserts a CNAME record into the handler. | 529 | // AddRecord inserts a CNAME record into the handler. |
516 | func (h *CnameHandler) AddRecord(rec *message.ResourceRecord, labels []string) error { | 530 | func (h *CnameHandler) AddRecord(rec *blocks.ResourceRecord, labels []string) error { |
517 | if enums.GNSType(rec.RType) != enums.GNS_TYPE_DNS_CNAME { | 531 | if rec.RType != enums.GNS_TYPE_DNS_CNAME { |
518 | return ErrInvalidRecordType | 532 | return ErrInvalidRecordType |
519 | } | 533 | } |
520 | if h.rec != nil { | 534 | if h.rec != nil { |
@@ -533,8 +547,8 @@ func (h *CnameHandler) Coexist(cm util.Counter[enums.GNSType]) bool { | |||
533 | } | 547 | } |
534 | 548 | ||
535 | // Records returns a list of RR of the given type associated with this handler | 549 | // Records returns a list of RR of the given type associated with this handler |
536 | func (h *CnameHandler) Records(kind RRTypeList) *message.RecordSet { | 550 | func (h *CnameHandler) Records(kind RRTypeList) *blocks.RecordSet { |
537 | rs := message.NewRecordSet() | 551 | rs := blocks.NewRecordSet() |
538 | if kind.HasType(enums.GNS_TYPE_DNS_CNAME) { | 552 | if kind.HasType(enums.GNS_TYPE_DNS_CNAME) { |
539 | rs.AddRecord(h.rec) | 553 | rs.AddRecord(h.rec) |
540 | } | 554 | } |
@@ -552,12 +566,12 @@ func (h *CnameHandler) Name() string { | |||
552 | 566 | ||
553 | // VpnHandler implementing the BlockHandler interface | 567 | // VpnHandler implementing the BlockHandler interface |
554 | type VpnHandler struct { | 568 | type VpnHandler struct { |
555 | rec *message.ResourceRecord | 569 | rec *blocks.ResourceRecord |
556 | } | 570 | } |
557 | 571 | ||
558 | // NewVpnHandler returns a new BlockHandler instance | 572 | // NewVpnHandler returns a new BlockHandler instance |
559 | func NewVpnHandler(rec *message.ResourceRecord, labels []string) (BlockHandler, error) { | 573 | func NewVpnHandler(rec *blocks.ResourceRecord, labels []string) (BlockHandler, error) { |
560 | if enums.GNSType(rec.RType) != enums.GNS_TYPE_VPN { | 574 | if rec.RType != enums.GNS_TYPE_VPN { |
561 | return nil, ErrInvalidRecordType | 575 | return nil, ErrInvalidRecordType |
562 | } | 576 | } |
563 | h := &VpnHandler{} | 577 | h := &VpnHandler{} |
@@ -568,8 +582,8 @@ func NewVpnHandler(rec *message.ResourceRecord, labels []string) (BlockHandler, | |||
568 | } | 582 | } |
569 | 583 | ||
570 | // AddRecord inserts a VPN record into the handler. | 584 | // AddRecord inserts a VPN record into the handler. |
571 | func (h *VpnHandler) AddRecord(rec *message.ResourceRecord, labels []string) error { | 585 | func (h *VpnHandler) AddRecord(rec *blocks.ResourceRecord, labels []string) error { |
572 | if enums.GNSType(rec.RType) != enums.GNS_TYPE_VPN { | 586 | if rec.RType != enums.GNS_TYPE_VPN { |
573 | return ErrInvalidRecordType | 587 | return ErrInvalidRecordType |
574 | } | 588 | } |
575 | if h.rec != nil { | 589 | if h.rec != nil { |
@@ -587,8 +601,8 @@ func (h *VpnHandler) Coexist(cm util.Counter[enums.GNSType]) bool { | |||
587 | } | 601 | } |
588 | 602 | ||
589 | // Records returns a list of RR of the given type associated with this handler | 603 | // Records returns a list of RR of the given type associated with this handler |
590 | func (h *VpnHandler) Records(kind RRTypeList) *message.RecordSet { | 604 | func (h *VpnHandler) Records(kind RRTypeList) *blocks.RecordSet { |
591 | rs := message.NewRecordSet() | 605 | rs := blocks.NewRecordSet() |
592 | if kind.HasType(enums.GNS_TYPE_VPN) { | 606 | if kind.HasType(enums.GNS_TYPE_VPN) { |
593 | rs.AddRecord(h.rec) | 607 | rs.AddRecord(h.rec) |
594 | } | 608 | } |