解析注册中心地址配置为多个连接地址

@param registryIp 注册中心地址
@return 可以连接注册中心的本机IP
195916
public static List<InetSocketAddress> getIpListByRegistry(String registryIp) {
        List<String[]> ips = new ArrayList<String[]>();
        String defaultPort = null;

        String[] srcIps = registryIp.split(",");
        for (String add : srcIps) {
            int a = add.indexOf("://");
            if (a > -1) {
                add = add.substring(a + 3); // 去掉协议头
            }
            String[] s1 = add.split(":");
            if (s1.length > 1) {
                if (defaultPort == null && s1[1] != null && s1[1].length() > 0) {
                    defaultPort = s1[1];
                }
                ips.add(new String[] { s1[0], s1[1] }); // 得到ip和端口
            } else {
                ips.add(new String[] { s1[0], defaultPort });
            }
        }

        List<InetSocketAddress> ads = new ArrayList<InetSocketAddress>();
        for (int j = 0; j < ips.size(); j++) {
            String[] ip = ips.get(j);
            try {
                InetSocketAddress address = new InetSocketAddress(ip[0],
                    Integer.parseInt(ip[1] == null ? defaultPort : ip[1]));
                ads.add(address);
            } catch (Exception ignore) { //NOPMD
            }
        }

        return ads;
    }
402394
public static Registry createRegistry(int port, RMIClientSocketFactory csf, RMIServerSocketFactory ssf) throws RemoteException {
		synchronized(registryCache) {
			Integer portObj = port;
			Registry registry = registryCache.get(portObj);
			if(registry==null) {
				registry = LocateRegistry.createRegistry(port, csf, ssf);
				registryCache.put(portObj, registry);
			}
			return registry;
		}
	}
1307622
public static Inet6Address getIPv4MappedIPv6Address(Inet4Address ip) {
        byte[] from = ip.getAddress();
        byte[] bytes = new byte[] {
                0x0,0x0,0x0,0x0,
                0x0,0x0,0x0,0x0,
                0x0,0x0,(byte)0xff,(byte)0xff,
                from[0],from[1],from[2],from[3]
        };

        return getInet6Address(bytes);
    }
463683
static String setRegistrationId(Context context, String regId) {
        final SharedPreferences prefs = getGCMPreferences(context);
        String oldRegistrationId = prefs.getString(PROPERTY_REG_ID, "");
        int appVersion = getAppVersion(context);
        Log.v(TAG, "Saving regId on app version " + appVersion);
        Editor editor = prefs.edit();
        editor.putString(PROPERTY_REG_ID, regId);
        editor.putInt(PROPERTY_APP_VERSION, appVersion);
        editor.commit();
        return oldRegistrationId;
    }
1116816
public static String queryIp(String host) {
		InetAddress[] addresses;
		try {
			addresses = InetAddress.getAllByName(host);
		}
		catch (UnknownHostException e) {
			return null;
		}
		// System.out.println("len:" + addresses.length);
		if (addresses.length == 1) {
			return addresses[0].getHostAddress();
		}
		else {
			// 多IP时，随机返回一个
			int random = new Random().nextInt(addresses.length);
			return addresses[random].getHostAddress();
		}
	}
280910
RegistryEntry getRegistryEntry(String pid) {
        if (pid == null) {
            return null;
        }
        return entryMap.get(pid);
    }
528548
public static vpnglobal_intranetip_binding[] get(nitro_service service) throws Exception{
		vpnglobal_intranetip_binding obj = new vpnglobal_intranetip_binding();
		vpnglobal_intranetip_binding response[] = (vpnglobal_intranetip_binding[]) obj.get_resources(service);
		return response;
	}
822061
private <T> Provider<T> autoProvider(InjectionPoint<T> ip)
  {
    for (InjectAutoBind autoBind : _autoBind) {
      Provider<T> provider = autoBind.provider(this, ip);

      if (provider != null) {
        return provider;
      }
    }

    return providerDefault(ip.key());
  }
563092
private void parseRemoteIp(Map<Object, Object> props) {
        Object value = props.get(HttpConfigConstants.PROPNAME_REMOTE_IP);
        if (null != value) {

            this.useForwardingHeaders = convertBoolean(value);

            if (this.useForwardingHeaders && (TraceComponent.isAnyTracingEnabled()) && (tc.isEventEnabled())) {
                Tr.event(tc, "HTTP Channel Config: remoteIp has been enabled");
            }
        }

    }
642171
private static void storeRegistrationId(Context context, String regId) {
        final SharedPreferences prefs = getGcmPreferences(context);
        int appVersion = getAppVersion(context);
        SharedPreferences.Editor editor = prefs.edit();
        editor.putString(PROPERTY_REG_ID, regId);
        editor.putInt(PROPERTY_APP_VERSION, appVersion);
        editor.commit();
    }
96425
def ip(ip_addr, return_tuple=True):
    
    regex_ip = __re.compile("^((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9]?[0-9]))$")
    if return_tuple:
        while not regex_ip.match(ip_addr):
            print("Not a good IP.")
            print("Please try again.")
            ip_addr = input("Please enter a IP address in the following format x.x.x.x: ")
        return ip_addr
    elif not return_tuple:
        if not regex_ip.match(ip_addr):
            return False
        else:
            return True
796394
public static IntervalCounter get(Registry registry, Id id) {
    ConcurrentMap<Id, Object> state = registry.state();
    Object c = Utils.computeIfAbsent(state, id, i -> new IntervalCounter(registry, i));
    if (!(c instanceof IntervalCounter)) {
      Utils.propagateTypeError(registry, id, IntervalCounter.class, c.getClass());
      c = new IntervalCounter(new NoopRegistry(), id);
    }
    return (IntervalCounter) c;
  }
1215125
private static String getDomainRoot(URI uri) {

        String host = uri.getHost();
        return SUFFIX_LIST_CACHE.getPublicSuffixList().getRegistrableDomain(host);
    }
467703
public static long ipToLong(String ip) {
        if (!isValidIp(ip)) {
            throw new IllegalArgumentException("Invalid IP address: " + ip);
        }

        long result = 0;
        String[] ipArr = ip.split("\\.");
        for (int i = 3; i >= 0; i--) {
            long part = Long.parseLong(ipArr[3 - i]);
            result |= part << (i * 8);
        }
        return result;
    }
663875
public String getProxyRemoteAddr(String realIpHeader) {
        String ip = null;
        if (realIpHeader != null && realIpHeader.length() != 0) {
            ip = getHeaderString(realIpHeader);
        }
        if (StringUtils.isBlank(ip)) {
            ip = getHeaderString("X-Real-IP");
            if (StringUtils.isBlank(ip) || "unknown".equalsIgnoreCase(ip)) {
                ip = getHeaderString("X-Forwarded-For");
                if (StringUtils.isNotBlank(ip) && !"unknown".equalsIgnoreCase(ip)) {
                    ip = ip.split(",")[0];
                }
            }
            if (StringUtils.isBlank(ip) || "unknown".equalsIgnoreCase(ip)) {
                ip = getHeaderString("Proxy-Client-IP");
            }
            if (StringUtils.isBlank(ip) || "unknown".equalsIgnoreCase(ip)) {
                ip = getHeaderString("WL-Proxy-Client-IP");
            }
            if (StringUtils.isNotBlank(ip)) {
                ip = ip.toLowerCase();
            }
        }
        return ip;
    }
1052768
public synchronized Registry getRegistry() throws RemoteException {
    if (registry == null) {
      registry = LocateRegistry.createRegistry(JdcpUtil.DEFAULT_PORT);
    }
    return registry;
  }
1072156
@Override
  public void register(final Identifier id, final InetSocketAddress addr)
      throws Exception {
    LOG.log(Level.FINE, "Register {0} : {1}", new Object[]{id, addr});
    this.registryClient.register(id, addr);
  }