Search code examples
dnsnsdnsdmanager

How to change SRV record format


I registered service using NsdManager:

    public void RegisterService(string serviceName, int port, Dictionary<string, string> attributes, string serviceType = "_itxpt_http._tcp.")
    {
        var serviceInfo = new NsdServiceInfo()
        {
            ServiceName = serviceName,
            Port = port,
            ServiceType = serviceType
        };

        if (attributes != null && attributes.Count > 0)
        {
            foreach (var keyValuePair in attributes)
            {
                serviceInfo.SetAttribute(keyValuePair.Key, keyValuePair.Value ?? string.Empty);
            }
        }

        NsdManager.RegisterService(serviceInfo, NsdProtocol.DnsSd, new ListenerWrapper(_eventLogger));
    }

And I get TXT and SRV recods. Format of SRV record is inventory._itxpt_http._tcp.local 120 CLASS32769 SRV 0 0 8090 Android-2.local.

How can I change current format? I want to remove DOT after service name (inventory), I want it to look like this: inventory_itxpt_http._tcp.local 120 CLASS32769 SRV 0 0 8090 Android-2.local


Solution

  • Besides the fact that your question is offtopic here as not really related to programming, you can not "change" the format of an SRV record. These records have to be in the format "_service._protocol" as prefix.

    As such inventory._itxpt_http._tcp.local name can not be attached to an SRV record as it does not follow the specification (neither is the service part in fact even if you remove inventory first, as the service part is normally a token among the IANA list of services). See RFC 2782 for further details and explanations on how an SRV record is designed and expected to work and be used.

    inventory_itxpt_http._tcp.local is also not in correct format.

    If you would explain more your problems and why you want this to SRV record as you obviously are not using them the way they are designed, you might get better replies, but probably not on this website except if you start with a programming question.