判断本机ip是否和node.getIp()相同
765592
private void checkNidVaild(String nid) {
        Node node = configClientService.currentNode();
        String hostIp = AddressUtils.getHostIp();
        String nodeIp = node.getIp();
        int nodePort = node.getPort().intValue();
        if (!AddressUtils.isHostIp(nodeIp)) {
            throw new IllegalArgumentException(
                                               String.format("node[%s] ip[%s] port[%s] , but your host ip[%s] is not matched!",
                                                             nid, nodeIp, nodePort, hostIp));
        }
    }
315447
def get_neighbor_ip(ip_addr, cidr="30"):
    
    our_octet = None
    neighbor_octet = None
    try:
        ip_addr_split = ip_addr.split(".")
        max_counter = 0
        if int(cidr) == 30:
            ranger = 4
        elif int(cidr) == 31:
            ranger = 2
        while max_counter < 256:
            try:
                if int(ip_addr_split[3]) >= max_counter and int(ip_addr_split[3]) < (max_counter + ranger):
                    if ranger == 4:
                        our_octet = max_counter + 1
                        neighbor_octet = max_counter + 2
                        break
                    elif ranger == 2:
                        our_octet = max_counter
                        neighbor_octet = max_counter + 1
                        break   
                max_counter += ranger
            except UnboundLocalError:
                print("The mask between the neighbors must be 30, or 31")
                exit("BAD NEIGHBOR MASK")
        if int(ip_addr_split[3]) == our_octet:
            our_ip_addr = "%s.%s.%s.%i" % (ip_addr_split[0], ip_addr_split[1], ip_addr_split[2], our_octet)
            neighbor_ip_addr = "%s.%s.%s.%i" % (ip_addr_split[0], ip_addr_split[1], ip_addr_split[2], neighbor_octet)
        elif int(ip_addr_split[3]) == neighbor_octet:
            neighbor_ip_addr = "%s.%s.%s.%i" % (ip_addr_split[0], ip_addr_split[1], ip_addr_split[2], our_octet)
            our_ip_addr = "%s.%s.%s.%i" % (ip_addr_split[0], ip_addr_split[1], ip_addr_split[2], neighbor_octet)
        else:
            our_ip_addr = "%s.%s.%s.%i" % (ip_addr_split[0], ip_addr_split[1], ip_addr_split[2], our_octet)
            neighbor_ip_addr = "%s.%s.%s.%i" % (ip_addr_split[0], ip_addr_split[1], ip_addr_split[2], neighbor_octet)
        return our_ip_addr, neighbor_ip_addr
    except IndexError:
        LOGGER.critical('Function get_neighbor_ip IndexError ip_addr {item} cidr {cidr}'.format(item=ip_addr,
                                                                                                cidr=cidr))
        raise IndexError("You have entered invalid input, you must enter a ipv4 address")
800264
public static int aton(final String ip)
	{
		try
		{
			return aton(InetAddress.getByName(ip));
		}
		catch (UnknownHostException e)
		{
			throw new IllegalArgumentException("must pass a valid ip. Illegal input was: " + ip, e);
		}
	}
1082959
@Override
  public InetSocketAddress ipLocal()
  {
    Socket s = getSocket();
    
    if (s != null) {
      return (InetSocketAddress) s.getLocalSocketAddress();
    }
    else {
      return null;
    }
  }
27624
function ip(input, output) {

  var i = 0;
  var event = input[0];
  var out = [ output ];
  for ( var ips in event) {
    ++i;
    out.push([ ips, cyan + event[ips].counter + close ]);
  }
  if (i === 0) {
    return [];
  }
  out.push('', [ 'unique ip', ansi.underline.open + i + ansi.underline.close ],
    '');
  return out;
}
230852
private String determinateLocalIP() throws IOException {
		Socket socket = null;

		try {
			URL url = new URL(defaultRepositoryUrl);
			int port = url.getPort() > -1 ? url.getPort() : url.getDefaultPort();

			log.debug("Determinating local IP-Adress by connect to {}:{}", defaultRepositoryUrl, port);
			InetAddress address = Inet4Address.getByName(url.getHost());

			socket = new Socket();
			socket.connect(new InetSocketAddress(address, port), 3000);
			InputStream stream = socket.getInputStream();
			InetAddress localAddress = socket.getLocalAddress();
			stream.close();

			String localIp = localAddress.getHostAddress();

			log.info("Local IP-Adress is {}", localIp);

			return localIp;
		} finally {
			if (socket != null) {
				socket.close();
			}
		}
	}
34553
def local_ip():
    """"""
    ip = socket.gethostbyname(socket.gethostname())
    if ip.startswith('127.'):
        # Check eth0, eth1, eth2, en0, ...
        interfaces = [
            i + str(n) for i in ("eth", "en", "wlan") for n in xrange(3)
        ]  # :(
        for interface in interfaces:
            try:
                ip = interface_ip(interface)
                break
            except IOError:
                pass
    return ip
668400
def get_ip_address():
  """"""
  try:
    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    s.connect(("8.8.8.8", 80))
    ip_address = s.getsockname()[0]
  except socket_error as sockerr:
    if sockerr.errno != errno.ENETUNREACH:
      raise sockerr
    ip_address = socket.gethostbyname(socket.getfqdn())
  finally:
    s.close()

  return ip_address
468376
public static JSONObject getIpInfo(String ip) throws IOException {
        String param = "?ip=" + ip;
        String ipInfoStr = getIpInfoByIp(URL.IP_INFO_URI + param);
        JSONObject jsonObject = JSON.parseObject(ipInfoStr);
        Integer code = (Integer) jsonObject.get("code");
        if (code == 0) {
            return jsonObject.getJSONObject("data");
        }
        return null;
    }
1309272
function(ip) {
    this.connectionparams = {
        host: ip,
        port: 23,
        timeout: 1000, //  The RESPONSE should be sent within 200ms of receiving the request COMMAND. (plus network delay)
        sendTimeout: 1200,
        negotiationMandatory: false,
        ors: '\r', // Set outbound record separator
        irs: '\r'
    };
    this.cmdCue = [];
    this.connection = null;
}
1177430
def Get(self,key):
		""""""

		for public_ip in self.public_ips:
			if public_ip.id == key:  return(public_ip)
			elif key == public_ip.internal:  return(public_ip)
796908
def determine_node(self):
        

        # Manually set node_type as simultaneous.
        if self.node_type == "simultaneous":
            if self.nat_type != "unknown":
                return "simultaneous"

        # Get IP of binding interface.
        unspecific_bind = ["0.0.0.0", "127.0.0.1", "localhost"]
        if self.passive_bind in unspecific_bind:
            lan_ip = get_lan_ip(self.interface)
        else:
            lan_ip = self.passive_bind

        # Passive node checks.
        if lan_ip is not None \
                and self.passive_port is not None and self.enable_forwarding:
            self.debug_print("Checking if port is forwarded.")

            # Check port isn't already forwarded.
            if is_port_forwarded(lan_ip, self.passive_port, "TCP",
                                 self.forwarding_servers):
                msg = "Port already forwarded. Skipping NAT traversal."
                self.debug_print(msg)

                self.forwarding_type = "forwarded"
                return "passive"
            else:
                self.debug_print("Port is not already forwarded.")

            # Most routers.
            try:
                self.debug_print("Trying UPnP")

                UPnP(self.interface).forward_port("TCP", self.passive_port,
                                                  lan_ip)

                if is_port_forwarded(lan_ip, self.passive_port, "TCP",
                                     self.forwarding_servers):
                    self.forwarding_type = "UPnP"
                    self.debug_print("Forwarded port with UPnP.")
                else:
                    self.debug_print("UPnP failed to forward port.")

            except Exception as e:
                # Log exception.
                error = parse_exception(e)
                log_exception(self.error_log_path, error)
                self.debug_print("UPnP failed to forward port.")

                # Apple devices.
                try:
                    self.debug_print("Trying NATPMP.")
                    NatPMP(self.interface).forward_port("TCP",
                                                        self.passive_port,
                                                        lan_ip)
                    if is_port_forwarded(lan_ip, self.passive_port, "TCP",
                                         self.forwarding_servers):
                        self.forwarding_type = "NATPMP"
                        self.debug_print("Port forwarded with NATPMP.")
                    else:
                        self.debug_print("Failed to forward port with NATPMP.")
                        self.debug_print("Falling back on TCP hole punching or"
                                         " proxying.")
                except Exception as e:
                    # Log exception
                    error = parse_exception(e)
                    log_exception(self.error_log_path, error)
                    self.debug_print("Failed to forward port with NATPMP.")

            # Check it worked.
            if self.forwarding_type != "manual":
                return "passive"

        # Fail-safe node types.
        if self.nat_type != "unknown":
            return "simultaneous"
        else:
            return "active"
701414
private String getHostNameForIp(String ipAddr) {
    try {
      // this handles the case where the hostlist contains names
      // and the datanodes are using IPs
      InetAddress addr = InetAddress.getByName(ipAddr);
      return addr.getHostName();
    } catch (Exception e) { 
      // this can be safely ignored
    }
    return null;
  }
85457
@Override
  public InetSocketAddress ipRemote()
  {
    if (_ipRemote == null) {
      try {
        _ipRemote = InetSocketAddress.createUnresolved(getLocalHost(),
                                                      portLocal());
      } catch (Exception e) {
        log.log(Level.FINE, e.toString(), e);
      }
    }

    return _ipLocal;
  }
889054
def detect(self):
        
        theip = find_ip(family=self.opts_family)
        self.set_current_value(theip)
        return theip
1273347
function client_ip(){
        if (isset($_SERVER)) {
            if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])) {
                $real_ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
            } else if (isset($_SERVER["HTTP_CLIENT_IP"])) {
                $real_ip = $_SERVER["HTTP_CLIENT_IP"];
            } else {
                $real_ip = $_SERVER["REMOTE_ADDR"];
            }
        } else {
            if (getenv("HTTP_X_FORWARDED_FOR")) {
                $real_ip = getenv("HTTP_X_FORWARDED_FOR");
            } else if (getenv("HTTP_CLIENT_IP")) {
                $real_ip = getenv("HTTP_CLIENT_IP");
            } else {
                $real_ip = getenv("REMOTE_ADDR");
            }
        }
        return $real_ip;
    }
1174750
private static String getMultistageReverseProxyIp(String ip) {
		// 多级反向代理检测
		if (ip != null && ip.indexOf(",") > 0) {
			final String[] ips = ip.trim().split(",");
			for (String subIp : ips) {
				if (false == isUnknow(subIp)) {
					ip = subIp;
					break;
				}
			}
		}
		return ip;
	}