Skip to content

Commit

Permalink
mDNS, minor
Browse files Browse the repository at this point in the history
  • Loading branch information
veniware committed Aug 8, 2024
1 parent c546a05 commit bdf64ba
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Protest/Front/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ class Fetch extends Tabs {
const dns = this.AddCheckBoxLabel(this.tabsPanel, this.dnsCheckBox, "DNS");
dns.style.gridArea = "5 / 3";

//TODO: mDNS, SSDP
//TODO: SSDP

this.tabsPanel.appendChild(this.snmp2Checkbox);
const snmp2 = this.AddCheckBoxLabel(this.tabsPanel, this.snmp2Checkbox, "SNMP V1/2");
Expand Down
12 changes: 6 additions & 6 deletions Protest/Protocols/Mdns.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ namespace Protest.Protocols;

internal class Mdns {

private static readonly IPAddress MULTICAST_IP_V4 = IPAddress.Parse("224.0.0.251");
private static readonly IPAddress MULTICAST_IP_V6 = IPAddress.Parse("ff02::fb");
private static readonly IPAddress MDNS_MULTICAST_ADDRESS_V4 = IPAddress.Parse("224.0.0.251");
private static readonly IPAddress MDNS_MULTICAST_ADDRESS_V6 = IPAddress.Parse("ff02::fb");
private static readonly int MDNS_PORT = 5353;

private struct Answer {
Expand Down Expand Up @@ -75,13 +75,13 @@ public static byte[] Resolve(string queryString, int timeout = 2000, RecordType
try {
if (localAddress.AddressFamily == AddressFamily.InterNetwork) {
socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
socket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(MULTICAST_IP_V4, localAddress));
remoteEndPoint = new IPEndPoint(MULTICAST_IP_V4, MDNS_PORT);
socket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(MDNS_MULTICAST_ADDRESS_V4, localAddress));
remoteEndPoint = new IPEndPoint(MDNS_MULTICAST_ADDRESS_V4, MDNS_PORT);
}
else if (localAddress.AddressFamily == AddressFamily.InterNetworkV6) {
socket = new Socket(AddressFamily.InterNetworkV6, SocketType.Dgram, ProtocolType.Udp);
socket.SetSocketOption(SocketOptionLevel.IPv6, SocketOptionName.AddMembership, new IPv6MulticastOption(MULTICAST_IP_V6));
remoteEndPoint = new IPEndPoint(MULTICAST_IP_V6, MDNS_PORT);
socket.SetSocketOption(SocketOptionLevel.IPv6, SocketOptionName.AddMembership, new IPv6MulticastOption(MDNS_MULTICAST_ADDRESS_V6));
remoteEndPoint = new IPEndPoint(MDNS_MULTICAST_ADDRESS_V6, MDNS_PORT);
}
else {
continue;
Expand Down

0 comments on commit bdf64ba

Please sign in to comment.