diff options
Diffstat (limited to 'src/gnunet/service/gns/block_handler.go')
-rw-r--r-- | src/gnunet/service/gns/block_handler.go | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/src/gnunet/service/gns/block_handler.go b/src/gnunet/service/gns/block_handler.go index ee87065..a0e7874 100644 --- a/src/gnunet/service/gns/block_handler.go +++ b/src/gnunet/service/gns/block_handler.go | |||
@@ -132,10 +132,10 @@ func NewBlockHandlerList(records []*message.ResourceRecord, labels []string) (*B | |||
132 | continue | 132 | continue |
133 | } | 133 | } |
134 | // check for expired record | 134 | // check for expired record |
135 | if rec.Expires.Expired() { | 135 | if rec.Expire.Expired() { |
136 | // do we have an associated shadow record? | 136 | // do we have an associated shadow record? |
137 | for _, shadow := range shadows { | 137 | for _, shadow := range shadows { |
138 | if shadow.Type == rec.Type && !shadow.Expires.Expired() { | 138 | if shadow.RType == rec.RType && !shadow.Expire.Expired() { |
139 | // deliver un-expired shadow record instead. | 139 | // deliver un-expired shadow record instead. |
140 | shadow.Flags &^= uint32(enums.GNS_FLAG_SHADOW) | 140 | shadow.Flags &^= uint32(enums.GNS_FLAG_SHADOW) |
141 | active = append(active, shadow) | 141 | active = append(active, shadow) |
@@ -153,7 +153,7 @@ func NewBlockHandlerList(records []*message.ResourceRecord, labels []string) (*B | |||
153 | logger.Printf(logger.DBG, "[gns] handler_list: skip %v\n", rec) | 153 | logger.Printf(logger.DBG, "[gns] handler_list: skip %v\n", rec) |
154 | continue | 154 | continue |
155 | } | 155 | } |
156 | rrType := enums.GNSType(rec.Type) | 156 | rrType := enums.GNSType(rec.RType) |
157 | hl.counts.Add(rrType) | 157 | hl.counts.Add(rrType) |
158 | 158 | ||
159 | // check for custom handler type | 159 | // check for custom handler type |
@@ -224,12 +224,12 @@ type ZoneKeyHandler struct { | |||
224 | // NewZoneHandler returns a new BlockHandler instance | 224 | // NewZoneHandler returns a new BlockHandler instance |
225 | func NewZoneHandler(rec *message.ResourceRecord, labels []string) (BlockHandler, error) { | 225 | func NewZoneHandler(rec *message.ResourceRecord, labels []string) (BlockHandler, error) { |
226 | // check if we have an implementation for the zone type | 226 | // check if we have an implementation for the zone type |
227 | if crypto.GetImplementation(rec.Type) == nil { | 227 | if crypto.GetImplementation(rec.RType) == nil { |
228 | return nil, ErrInvalidRecordType | 228 | return nil, ErrInvalidRecordType |
229 | } | 229 | } |
230 | // assemble handler | 230 | // assemble handler |
231 | h := &ZoneKeyHandler{ | 231 | h := &ZoneKeyHandler{ |
232 | ztype: rec.Type, | 232 | ztype: rec.RType, |
233 | zkey: nil, | 233 | zkey: nil, |
234 | } | 234 | } |
235 | // add the record to the handler | 235 | // add the record to the handler |
@@ -242,7 +242,7 @@ func NewZoneHandler(rec *message.ResourceRecord, labels []string) (BlockHandler, | |||
242 | // AddRecord inserts a PKEY record into the handler. | 242 | // AddRecord inserts a PKEY record into the handler. |
243 | func (h *ZoneKeyHandler) AddRecord(rec *message.ResourceRecord, labels []string) (err error) { | 243 | func (h *ZoneKeyHandler) AddRecord(rec *message.ResourceRecord, labels []string) (err error) { |
244 | // check record type | 244 | // check record type |
245 | if rec.Type != h.ztype { | 245 | if rec.RType != h.ztype { |
246 | return ErrInvalidRecordType | 246 | return ErrInvalidRecordType |
247 | } | 247 | } |
248 | // check for sole zone key record in block | 248 | // check for sole zone key record in block |
@@ -292,7 +292,7 @@ type Gns2DnsHandler struct { | |||
292 | 292 | ||
293 | // NewGns2DnsHandler returns a new BlockHandler instance | 293 | // NewGns2DnsHandler returns a new BlockHandler instance |
294 | func NewGns2DnsHandler(rec *message.ResourceRecord, labels []string) (BlockHandler, error) { | 294 | func NewGns2DnsHandler(rec *message.ResourceRecord, labels []string) (BlockHandler, error) { |
295 | if enums.GNSType(rec.Type) != enums.GNS_TYPE_GNS2DNS { | 295 | if enums.GNSType(rec.RType) != enums.GNS_TYPE_GNS2DNS { |
296 | return nil, ErrInvalidRecordType | 296 | return nil, ErrInvalidRecordType |
297 | } | 297 | } |
298 | h := &Gns2DnsHandler{ | 298 | h := &Gns2DnsHandler{ |
@@ -308,7 +308,7 @@ func NewGns2DnsHandler(rec *message.ResourceRecord, labels []string) (BlockHandl | |||
308 | 308 | ||
309 | // AddRecord inserts a GNS2DNS record into the handler. | 309 | // AddRecord inserts a GNS2DNS record into the handler. |
310 | func (h *Gns2DnsHandler) AddRecord(rec *message.ResourceRecord, labels []string) error { | 310 | func (h *Gns2DnsHandler) AddRecord(rec *message.ResourceRecord, labels []string) error { |
311 | if enums.GNSType(rec.Type) != enums.GNS_TYPE_GNS2DNS { | 311 | if enums.GNSType(rec.RType) != enums.GNS_TYPE_GNS2DNS { |
312 | return ErrInvalidRecordType | 312 | return ErrInvalidRecordType |
313 | } | 313 | } |
314 | logger.Printf(logger.DBG, "[gns] GNS2DNS data: %s\n", hex.EncodeToString(rec.Data)) | 314 | logger.Printf(logger.DBG, "[gns] GNS2DNS data: %s\n", hex.EncodeToString(rec.Data)) |
@@ -367,7 +367,7 @@ type BoxHandler struct { | |||
367 | 367 | ||
368 | // NewBoxHandler returns a new BlockHandler instance | 368 | // NewBoxHandler returns a new BlockHandler instance |
369 | func NewBoxHandler(rec *message.ResourceRecord, labels []string) (BlockHandler, error) { | 369 | func NewBoxHandler(rec *message.ResourceRecord, labels []string) (BlockHandler, error) { |
370 | if enums.GNSType(rec.Type) != enums.GNS_TYPE_BOX { | 370 | if enums.GNSType(rec.RType) != enums.GNS_TYPE_BOX { |
371 | return nil, ErrInvalidRecordType | 371 | return nil, ErrInvalidRecordType |
372 | } | 372 | } |
373 | h := &BoxHandler{ | 373 | h := &BoxHandler{ |
@@ -381,7 +381,7 @@ func NewBoxHandler(rec *message.ResourceRecord, labels []string) (BlockHandler, | |||
381 | 381 | ||
382 | // AddRecord inserts a BOX record into the handler. | 382 | // AddRecord inserts a BOX record into the handler. |
383 | func (h *BoxHandler) AddRecord(rec *message.ResourceRecord, labels []string) error { | 383 | func (h *BoxHandler) AddRecord(rec *message.ResourceRecord, labels []string) error { |
384 | if enums.GNSType(rec.Type) != enums.GNS_TYPE_BOX { | 384 | if enums.GNSType(rec.RType) != enums.GNS_TYPE_BOX { |
385 | return ErrInvalidRecordType | 385 | return ErrInvalidRecordType |
386 | } | 386 | } |
387 | logger.Printf(logger.DBG, "[box-rr] for labels %v\n", labels) | 387 | logger.Printf(logger.DBG, "[box-rr] for labels %v\n", labels) |
@@ -417,9 +417,9 @@ func (h *BoxHandler) Records(kind RRTypeList) *message.RecordSet { | |||
417 | if kind.HasType(enums.GNSType(box.Type)) { | 417 | if kind.HasType(enums.GNSType(box.Type)) { |
418 | // valid box found: assemble new resource record. | 418 | // valid box found: assemble new resource record. |
419 | rr := new(message.ResourceRecord) | 419 | rr := new(message.ResourceRecord) |
420 | rr.Expires = box.rec.Expires | 420 | rr.Expire = box.rec.Expire |
421 | rr.Flags = box.rec.Flags | 421 | rr.Flags = box.rec.Flags |
422 | rr.Type = box.Type | 422 | rr.RType = box.Type |
423 | rr.Size = uint32(len(box.RR)) | 423 | rr.Size = uint32(len(box.RR)) |
424 | rr.Data = box.RR | 424 | rr.Data = box.RR |
425 | rs.AddRecord(rr) | 425 | rs.AddRecord(rr) |
@@ -445,7 +445,7 @@ type LehoHandler struct { | |||
445 | 445 | ||
446 | // NewLehoHandler returns a new BlockHandler instance | 446 | // NewLehoHandler returns a new BlockHandler instance |
447 | func NewLehoHandler(rec *message.ResourceRecord, labels []string) (BlockHandler, error) { | 447 | func NewLehoHandler(rec *message.ResourceRecord, labels []string) (BlockHandler, error) { |
448 | if enums.GNSType(rec.Type) != enums.GNS_TYPE_LEHO { | 448 | if enums.GNSType(rec.RType) != enums.GNS_TYPE_LEHO { |
449 | return nil, ErrInvalidRecordType | 449 | return nil, ErrInvalidRecordType |
450 | } | 450 | } |
451 | h := &LehoHandler{ | 451 | h := &LehoHandler{ |
@@ -459,7 +459,7 @@ func NewLehoHandler(rec *message.ResourceRecord, labels []string) (BlockHandler, | |||
459 | 459 | ||
460 | // AddRecord inserts a LEHO record into the handler. | 460 | // AddRecord inserts a LEHO record into the handler. |
461 | func (h *LehoHandler) AddRecord(rec *message.ResourceRecord, labels []string) error { | 461 | func (h *LehoHandler) AddRecord(rec *message.ResourceRecord, labels []string) error { |
462 | if enums.GNSType(rec.Type) != enums.GNS_TYPE_LEHO { | 462 | if enums.GNSType(rec.RType) != enums.GNS_TYPE_LEHO { |
463 | return ErrInvalidRecordType | 463 | return ErrInvalidRecordType |
464 | } | 464 | } |
465 | h.name = string(rec.Data) | 465 | h.name = string(rec.Data) |
@@ -500,7 +500,7 @@ type CnameHandler struct { | |||
500 | 500 | ||
501 | // NewCnameHandler returns a new BlockHandler instance | 501 | // NewCnameHandler returns a new BlockHandler instance |
502 | func NewCnameHandler(rec *message.ResourceRecord, labels []string) (BlockHandler, error) { | 502 | func NewCnameHandler(rec *message.ResourceRecord, labels []string) (BlockHandler, error) { |
503 | if enums.GNSType(rec.Type) != enums.GNS_TYPE_DNS_CNAME { | 503 | if enums.GNSType(rec.RType) != enums.GNS_TYPE_DNS_CNAME { |
504 | return nil, ErrInvalidRecordType | 504 | return nil, ErrInvalidRecordType |
505 | } | 505 | } |
506 | h := &CnameHandler{ | 506 | h := &CnameHandler{ |
@@ -514,7 +514,7 @@ func NewCnameHandler(rec *message.ResourceRecord, labels []string) (BlockHandler | |||
514 | 514 | ||
515 | // AddRecord inserts a CNAME record into the handler. | 515 | // AddRecord inserts a CNAME record into the handler. |
516 | func (h *CnameHandler) AddRecord(rec *message.ResourceRecord, labels []string) error { | 516 | func (h *CnameHandler) AddRecord(rec *message.ResourceRecord, labels []string) error { |
517 | if enums.GNSType(rec.Type) != enums.GNS_TYPE_DNS_CNAME { | 517 | if enums.GNSType(rec.RType) != enums.GNS_TYPE_DNS_CNAME { |
518 | return ErrInvalidRecordType | 518 | return ErrInvalidRecordType |
519 | } | 519 | } |
520 | if h.rec != nil { | 520 | if h.rec != nil { |
@@ -557,7 +557,7 @@ type VpnHandler struct { | |||
557 | 557 | ||
558 | // NewVpnHandler returns a new BlockHandler instance | 558 | // NewVpnHandler returns a new BlockHandler instance |
559 | func NewVpnHandler(rec *message.ResourceRecord, labels []string) (BlockHandler, error) { | 559 | func NewVpnHandler(rec *message.ResourceRecord, labels []string) (BlockHandler, error) { |
560 | if enums.GNSType(rec.Type) != enums.GNS_TYPE_VPN { | 560 | if enums.GNSType(rec.RType) != enums.GNS_TYPE_VPN { |
561 | return nil, ErrInvalidRecordType | 561 | return nil, ErrInvalidRecordType |
562 | } | 562 | } |
563 | h := &VpnHandler{} | 563 | h := &VpnHandler{} |
@@ -569,7 +569,7 @@ func NewVpnHandler(rec *message.ResourceRecord, labels []string) (BlockHandler, | |||
569 | 569 | ||
570 | // AddRecord inserts a VPN record into the handler. | 570 | // AddRecord inserts a VPN record into the handler. |
571 | func (h *VpnHandler) AddRecord(rec *message.ResourceRecord, labels []string) error { | 571 | func (h *VpnHandler) AddRecord(rec *message.ResourceRecord, labels []string) error { |
572 | if enums.GNSType(rec.Type) != enums.GNS_TYPE_VPN { | 572 | if enums.GNSType(rec.RType) != enums.GNS_TYPE_VPN { |
573 | return ErrInvalidRecordType | 573 | return ErrInvalidRecordType |
574 | } | 574 | } |
575 | if h.rec != nil { | 575 | if h.rec != nil { |