AddressLookUp() public method

Called during LookUp to perform translation from hostname to IP. If an entry isn't in cache, we can try to get it from the Dht. Throws an exception if the name is invalid and returns null if no name is found.
public AddressLookUp ( String name ) : String
name String The name to lookup
return String
Beispiel #1
0
        public void Test()
        {
            StaticDns dns = new StaticDns(
                MemBlock.Reference(Utils.StringToBytes("10.250.0.0", '.')),
                MemBlock.Reference(Utils.StringToBytes("255.255.0.0", '.')),
                string.Empty, false);

            Assert.AreEqual(dns.NameLookUp("10.250.1.1"), "C250001001.ipop", "NameLookUp Dns set in range.");

            try {
                Assert.AreEqual(dns.NameLookUp("10.251.1.1"), null, "NameLookUp Dns set out of range.");
            } catch { }

            Assert.AreEqual(dns.AddressLookUp("C250001001.ipop"), "10.250.1.1", "AddressLookUp Dns set.");

            try {
                Assert.AreEqual(dns.AddressLookUp("C250001001.blaha"), null, "AddressLookUp Dns set bad dns name: blaha.");
            } catch { }

            try {
                Assert.AreEqual(dns.AddressLookUp("C250001001.blah"), null, "AddressLookUp Dns set bad dns name: blah.");
            } catch { }

            dns = new StaticDns(
                MemBlock.Reference(Utils.StringToBytes("10.251.0.0", '.')),
                MemBlock.Reference(Utils.StringToBytes("255.255.0.0", '.')),
                string.Empty, false);

            try {
                Assert.AreEqual(dns.NameLookUp("10.250.1.1"), null, "NameLookUp Dns changed out of range.");
            } catch { }

            Assert.AreEqual(dns.NameLookUp("10.251.1.1"), "C251001001.ipop", "NameLookUp Dns changed in range.");
        }
Beispiel #2
0
        public void SmallMaskTest()
        {
            StaticDns dns = new StaticDns(
                MemBlock.Reference(Utils.StringToBytes("10.1.2.0", '.')),
                MemBlock.Reference(Utils.StringToBytes("255.255.255.0", '.')),
                string.Empty, false);

            Assert.AreEqual(dns.NameLookUp("10.1.2.94"), "C001002094.ipop", "test1");
            Assert.AreEqual(dns.AddressLookUp("C001002094.ipop"), "10.1.2.94", "test2");
        }
Beispiel #3
0
    public void Test() {
      StaticDns dns = new StaticDns(
          MemBlock.Reference(Utils.StringToBytes("10.250.0.0", '.')),
          MemBlock.Reference(Utils.StringToBytes("255.255.0.0", '.')),
          string.Empty, false);

      Assert.AreEqual(dns.NameLookUp("10.250.1.1"), "C250001001.ipop", "NameLookUp Dns set in range.");

      try {
        Assert.AreEqual(dns.NameLookUp("10.251.1.1"), null, "NameLookUp Dns set out of range.");
      } catch { }

      Assert.AreEqual(dns.AddressLookUp("C250001001.ipop"), "10.250.1.1", "AddressLookUp Dns set.");

      try {
        Assert.AreEqual(dns.AddressLookUp("C250001001.blaha"), null, "AddressLookUp Dns set bad dns name: blaha.");
      } catch { }

      try {
        Assert.AreEqual(dns.AddressLookUp("C250001001.blah"), null, "AddressLookUp Dns set bad dns name: blah.");
      } catch { }

      dns = new StaticDns(
          MemBlock.Reference(Utils.StringToBytes("10.251.0.0", '.')),
          MemBlock.Reference(Utils.StringToBytes("255.255.0.0", '.')),
          string.Empty, false);

      try {
        Assert.AreEqual(dns.NameLookUp("10.250.1.1"), null, "NameLookUp Dns changed out of range.");
      } catch { }

      Assert.AreEqual(dns.NameLookUp("10.251.1.1"), "C251001001.ipop", "NameLookUp Dns changed in range.");
    }
Beispiel #4
0
    public void SmallMaskTest() {
      StaticDns dns = new StaticDns(
          MemBlock.Reference(Utils.StringToBytes("10.1.2.0", '.')),
          MemBlock.Reference(Utils.StringToBytes("255.255.255.0", '.')),
          string.Empty, false);

      Assert.AreEqual(dns.NameLookUp("10.1.2.94"), "C001002094.ipop", "test1");
      Assert.AreEqual(dns.AddressLookUp("C001002094.ipop"), "10.1.2.94", "test2");
    }