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. 8
      src/minidexed.cpp
  2. 16
      updater.py

@ -833,7 +833,7 @@ void CMiniDexed::SetMIDIChannel (uint8_t uchChannel, unsigned nTG)
assert (nActiveTGs <= 8); assert (nActiveTGs <= 8);
static const unsigned Log2[] = {0, 0, 1, 2, 2, 3, 3, 3, 3}; static const unsigned Log2[] = {0, 0, 1, 2, 2, 3, 3, 3, 3};
m_nActiveTGsLog2 = Log2[nActiveTGs]; m_nActiveTGsLog2 = Log2[nActiveTGs];
*/ */
#endif #endif
@ -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:
ip = socket.inet_ntoa(info.addresses[0]) # Only add if TXT record contains 'MiniDexed'
if ip not in self.ip_list: txt_records = info.properties
self.ip_list.append(ip) if txt_records:
self.name_list.append(info.server.rstrip('.')) 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])
if ip not in self.ip_list:
self.ip_list.append(ip)
self.name_list.append(info.server.rstrip('.'))
break
# Constants # Constants

Loading…
Cancel
Save