Publish TXT record on FTP service, only show MiniDexed FTP servers in updater

pull/896/head
probonopd 2 weeks ago
parent d209d39e2e
commit ce6c79adbf
  1. 6
      src/minidexed.cpp
  2. 8
      updater.py

@ -2334,7 +2334,8 @@ void CMiniDexed::UpdateNetwork()
} }
static constexpr const char *ServiceTypeFTP = "_ftp._tcp"; static constexpr const char *ServiceTypeFTP = "_ftp._tcp";
if (!m_pmDNSPublisher->PublishService (m_pConfig->GetNetworkHostname(), ServiceTypeFTP, 21)) static const char *ftpTxt[] = { "app=MiniDexed", nullptr };
if (!m_pmDNSPublisher->PublishService (m_pConfig->GetNetworkHostname(), ServiceTypeFTP, 21, ftpTxt))
{ {
LOGPANIC ("Cannot publish mdns service"); LOGPANIC ("Cannot publish mdns service");
} }
@ -2384,7 +2385,8 @@ void CMiniDexed::UpdateNetwork()
} }
static constexpr const char *ServiceTypeFTP = "_ftp._tcp"; static constexpr const char *ServiceTypeFTP = "_ftp._tcp";
if (!m_pmDNSPublisher->PublishService (m_pConfig->GetNetworkHostname(), ServiceTypeFTP, 21)) static const char *ftpTxt[] = { "app=MiniDexed", nullptr };
if (!m_pmDNSPublisher->PublishService (m_pConfig->GetNetworkHostname(), ServiceTypeFTP, 21, ftpTxt))
{ {
LOGPANIC ("Cannot publish mdns service"); LOGPANIC ("Cannot publish mdns service");
} }

@ -36,10 +36,18 @@ class MyListener(ServiceListener):
info = zc.get_service_info(type_, name) info = zc.get_service_info(type_, name)
print(f"Service {name} added, service info: {info}") print(f"Service {name} added, service info: {info}")
if info and info.addresses: if info and info.addresses:
# Only add if TXT record contains 'MiniDexed'
txt_records = info.properties
if txt_records:
for k, v in txt_records.items():
# v may be bytes, decode if needed
val = v.decode() if isinstance(v, bytes) else v
if (b"MiniDexed" in k or b"MiniDexed" in v) or ("MiniDexed" in str(k) or "MiniDexed" in str(val)):
ip = socket.inet_ntoa(info.addresses[0]) ip = socket.inet_ntoa(info.addresses[0])
if ip not in self.ip_list: if ip not in self.ip_list:
self.ip_list.append(ip) self.ip_list.append(ip)
self.name_list.append(info.server.rstrip('.')) self.name_list.append(info.server.rstrip('.'))
break
# Constants # Constants

Loading…
Cancel
Save