예제 #1
0
 /// <inheritdoc />
 public override void WriteData(PresentationWriter writer)
 {
     writer.WriteUInt16(Priority);
     writer.WriteUInt16(Weight);
     writer.WriteUInt16(Port);
     writer.WriteDomainName(Target, appendSpace: false);
 }
예제 #2
0
        private static void RunServer()
        {
            var service = "_appletv.local.appletv._local.appletv.local.appletv.local";
            var mdns    = new MulticastService();

            mdns.QueryReceived += (s, e) =>
            {
                var msg = e.Message;
                if (msg.Questions.Any(q => q.Name == service))
                {
                    var res       = msg.CreateResponse();
                    var addresses = MulticastService.GetIPAddresses()
                                    .Where(ip => ip.AddressFamily == AddressFamily.InterNetwork);
                    foreach (var address in addresses)
                    {
                        var ar = new ARecord
                        {
                            Name    = service,
                            Address = address
                        };
                        var writer = new PresentationWriter(new StringWriter());
                        writer.WriteString("123qweq");
                        ar.WriteData(writer);
                        ar.Name = "qweqeqweq";
                        res.Answers.Add(ar);
                    }
                    mdns.SendAnswer(res);
                }
            };
            advertiseThread = new Thread(new ThreadStart(() =>
            {
                sd     = new ServiceDiscovery(mdns);
                var sp = new ServiceProfile("_itxpt_multicast._tcp.", "_itxpt._tcp", 5353, new List <IPAddress> {
                    IPAddress.Parse("192.168.88.239")
                });
                //sp.AddProperty("host", "192.168.88.239");
                //sp.AddProperty("port", "14005");
                sp.Resources.Add(new ARecord {
                    Name = "_itxpt_multicast._tcp.", Address = IPAddress.Parse("192.168.88.239"), Class = DnsClass.ANY
                });
                sp.Resources.Add(new SRVRecord {
                    Name = "_itxpt_multicast._tcp.", Port = 5353, Priority = 0, Weight = 0, Class = DnsClass.ANY
                });
                sp.Resources.Add(new PTRRecord {
                    Name = "_itxpt_multicast._tcp.", DomainName = "192.168.88.239"
                });
                sd.Advertise(sp);
            }));
            advertiseThread.Start();

            mdns.Start();
        }
예제 #3
0
        public void Serialize()
        {
            var stream = new FileStream("settings.txt", FileMode.OpenOrCreate);
            var sw     = new StreamWriter(stream);
            var writer = new PresentationWriter(sw);

            foreach (var info in DomainInformation.Values)
            {
                foreach (var rec in info.DomainRecords)
                {
                    writer.WriteEndOfLine();
                    rec.Write(writer);
                }
            }

            stream.Position = 0;
            sw.Close();
        }
예제 #4
0
 /// <inheritdoc />
 public override void WriteData(PresentationWriter writer)
 {
     writer.WriteDomainName(Mailbox);
     writer.WriteDomainName(TextName, appendSpace: false);
 }
예제 #5
0
 /// <inheritdoc />
 public override void WriteData(PresentationWriter writer)
 {
     writer.WriteString(Cpu);
     writer.WriteString(OS, appendSpace: false);
 }
예제 #6
0
 /// <inheritdoc />
 public override void WriteData(PresentationWriter writer)
 {
     writer.WriteDomainName(Authority, appendSpace: false);
 }
예제 #7
0
 /// <inheritdoc />
 public override void WriteData(PresentationWriter writer)
 {
     writer.WriteUInt16(Preference);
     writer.WriteDomainName(Exchange, appendSpace: false);
 }
예제 #8
0
 /// <inheritdoc />
 public override void WriteData(PresentationWriter writer)
 {
     writer.WriteUInt16(Subtype);
     writer.WriteDomainName(Target, appendSpace: false);
 }