如何更改SRV记录格式



我使用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));
}

我得到TXT和SRV记录。SRV记录格式为inventory._itxpt_http._tcp.local 120 CLASS32769 SRV 0 0 8090 Android-2.local.

如何更改当前格式?我想删除DOT后的服务名称(库存),我希望它看起来像这样:inventory_itxpt_http._tcp.local 120 CLASS32769 SRV 0 0 8090 Android-2.local

除此之外,你的问题在这里偏离主题,与编程无关,你不能"改变"。SRV记录的格式。这些记录的格式必须为"_service._protocol"。作为前缀。

因此,inventory._itxpt_http._tcp.local名称不能附加到SRV记录,因为它不符合规范(事实上,即使您先删除inventory,服务部分也不是,因为服务部分通常是IANA服务列表中的令牌)。有关SRV记录的设计、工作和使用的更多细节和解释,请参阅RFC 2782。

inventory_itxpt_http._tcp.local格式也不正确。

如果你能更多地解释你的问题,为什么你想要这个SRV记录,因为你显然没有按照设计的方式使用它们,你可能会得到更好的回答,但可能不是在这个网站上,除非你从一个编程问题开始。

最新更新