discovery: support large attributes in mdns
Each txt record in mDNS is limited to 255 bytes.
This CL support large attributes than this limit by splitting
the attribute into multiple txt records.
But the total txt records size is still limited to 1300 bytes
by the underlying mdns package.
Also add an optional InstanceName attribute to service.
MultiPart: 2/2
Change-Id: I9d67c006f73d989aadea6022e73ad8acc93dd693
diff --git a/lib/discovery/advertise.go b/lib/discovery/advertise.go
index 3930f63..5abdbe4 100644
--- a/lib/discovery/advertise.go
+++ b/lib/discovery/advertise.go
@@ -25,15 +25,13 @@
if len(service.InterfaceName) == 0 {
return verror.New(errNoInterfaceName, ctx)
}
- if !IsAttributePackable(service.Attrs) {
- return verror.New(errNotPackableAttributes, ctx)
- }
if len(service.Addrs) == 0 {
return verror.New(errNoAddresses, ctx)
}
- if !IsAddressPackable(service.Addrs) {
- return verror.New(errNotPackableAddresses, ctx)
+ if err := validateAttributes(service.Attrs); err != nil {
+ return err
}
+
if len(service.InstanceUuid) == 0 {
service.InstanceUuid = NewInstanceUUID()
}