private static File locateHostsFile() { File hostsFile; if (PlatformDependent.isWindows()) { hostsFile = new File(System.getenv("SystemRoot") + WINDOWS_HOSTS_FILE_RELATIVE_PATH); if (!hostsFile.exists()) { hostsFile = new File(WINDOWS_DEFAULT_SYSTEM_ROOT + WINDOWS_HOSTS_FILE_RELATIVE_PATH); } } else { hostsFile = new File(X_PLATFORMS_HOSTS_FILE_PATH); } return hostsFile; }
private static boolean maybeSuperUser0() { String username = SystemPropertyUtil.get("user.name"); if (isWindows()) { return "Administrator".equals(username); } // Check for root and toor as some BSDs have a toor user that is basically the same as root. return "root".equals(username) || "toor".equals(username); }
private static File locateHostsFile() { File hostsFile; if (PlatformDependent.isWindows()) { hostsFile = new File(System.getenv("SystemRoot") + WINDOWS_HOSTS_FILE_RELATIVE_PATH); if (!hostsFile.exists()) { hostsFile = new File(WINDOWS_DEFAULT_SYSTEM_ROOT + WINDOWS_HOSTS_FILE_RELATIVE_PATH); } } else { hostsFile = new File(X_PLATFORMS_HOSTS_FILE_PATH); } return hostsFile; }
private static boolean maybeSuperUser0() { String username = SystemPropertyUtil.get("user.name"); if (isWindows()) { return "Administrator".equals(username); } // Check for root and toor as some BSDs have a toor user that is basically the same as root. return "root".equals(username) || "toor".equals(username); }
private DnsServerAddressStreamProvider provider() { // If on windows just use the DefaultDnsServerAddressStreamProvider.INSTANCE as otherwise // we will log some error which may be confusing. return PlatformDependent.isWindows() ? DefaultDnsServerAddressStreamProvider.INSTANCE : UnixResolverDnsServerAddressStreamProvider.parseSilently(); } };
private static File locateHostsFile() { File hostsFile; if (PlatformDependent.isWindows()) { hostsFile = new File(System.getenv("SystemRoot") + WINDOWS_HOSTS_FILE_RELATIVE_PATH); if (!hostsFile.exists()) { hostsFile = new File(WINDOWS_DEFAULT_SYSTEM_ROOT + WINDOWS_HOSTS_FILE_RELATIVE_PATH); } } else { hostsFile = new File(X_PLATFORMS_HOSTS_FILE_PATH); } return hostsFile; }
private InetAddress resolveHostsFileEntry(String hostname) { if (hostsFileEntriesResolver == null) { return null; } else { InetAddress address = hostsFileEntriesResolver.address(hostname, resolvedAddressTypes); if (address == null && PlatformDependent.isWindows() && LOCALHOST.equalsIgnoreCase(hostname)) { // If we tried to resolve localhost we need workaround that windows removed localhost from its // hostfile in later versions. // See https://github.com/netty/netty/issues/5386 return LOCALHOST_ADDRESS; } return address; } }
private static HostsFileEntries parseEntries() { if (PlatformDependent.isWindows()) { // Ony windows there seems to be no standard for the encoding used for the hosts file, so let us // try multiple until we either were able to parse it or there is none left and so we return an // empty intstance. return HostsFileParser.parseSilently(Charset.defaultCharset(), CharsetUtil.UTF_16, CharsetUtil.UTF_8); } return HostsFileParser.parseSilently(); } }
private static boolean maybeSuperUser0() { String username = SystemPropertyUtil.get("user.name"); if (isWindows()) { return "Administrator".equals(username); } // Check for root and toor as some BSDs have a toor user that is basically the same as root. return "root".equals(username) || "toor".equals(username); }
if (PlatformDependent.isWindows()) { sleepTimeMs = sleepTimeMs / 10 * 10;
private static HostsFileEntries parseEntries() { if (PlatformDependent.isWindows()) { // Ony windows there seems to be no standard for the encoding used for the hosts file, so let us // try multiple until we either were able to parse it or there is none left and so we return an // empty intstance. return HostsFileParser.parseSilently(Charset.defaultCharset(), CharsetUtil.UTF_16, CharsetUtil.UTF_8); } return HostsFileParser.parseSilently(); } }
private InetAddress resolveHostsFileEntry(String hostname) { if (hostsFileEntriesResolver == null) { return null; } else { InetAddress address = hostsFileEntriesResolver.address(hostname, resolvedAddressTypes); if (address == null && PlatformDependent.isWindows() && LOCALHOST.equalsIgnoreCase(hostname)) { // If we tried to resolve localhost we need workaround that windows removed localhost from its // hostfile in later versions. // See https://github.com/netty/netty/issues/5386 return LOCALHOST_ADDRESS; } return address; } }
if (PlatformDependent.isWindows()) { sleepTimeMs = sleepTimeMs / 10 * 10;
int somaxconn = PlatformDependent.isWindows() ? 200 : 128; File file = new File("/proc/sys/net/core/somaxconn"); BufferedReader in = null;
@Override public DatagramChannelConfig setBroadcast(boolean broadcast) { try { // See: https://github.com/netty/netty/issues/576 if (broadcast && !javaSocket.getLocalAddress().isAnyLocalAddress() && !PlatformDependent.isWindows() && !PlatformDependent.maybeSuperUser()) { // Warn a user about the fact that a non-root user can't receive a // broadcast packet on *nix if the socket is bound on non-wildcard address. logger.warn( "A non-root user can't receive a broadcast packet if the socket " + "is not bound to a wildcard address; setting the SO_BROADCAST flag " + "anyway as requested on the socket which is bound to " + javaSocket.getLocalSocketAddress() + '.'); } javaSocket.setBroadcast(broadcast); } catch (SocketException e) { throw new ChannelException(e); } return this; }
@Override public Object decode(ByteBuf buf, State state) throws IOException { List<Object> result = new ArrayList<Object>(); int keyLen; if (PlatformDependent.isWindows()) { keyLen = buf.readIntLE(); } else { keyLen = (int) buf.readLongLE(); } ByteBuf keyBuf = buf.readSlice(keyLen); Object key = codec.getMapKeyDecoder().decode(keyBuf, state); result.add(key); int valueLen; if (PlatformDependent.isWindows()) { valueLen = buf.readIntLE(); } else { valueLen = (int) buf.readLongLE(); } ByteBuf valueBuf = buf.readSlice(valueLen); Object value = codec.getMapValueDecoder().decode(valueBuf, state); result.add(value); if (sync) { double syncId = buf.order(ByteOrder.LITTLE_ENDIAN).readDouble(); result.add(syncId); } return result; } };
@Override public Object decode(ByteBuf buf, State state) throws IOException { List<Object> result = new ArrayList<Object>(); int keyLen; if (PlatformDependent.isWindows()) { keyLen = buf.readIntLE(); } else { keyLen = (int) buf.readLongLE(); } ByteBuf keyBuf = buf.readSlice(keyLen); Object key = codec.getMapKeyDecoder().decode(keyBuf, state); result.add(key); int valueLen; if (PlatformDependent.isWindows()) { valueLen = buf.readIntLE(); } else { valueLen = (int) buf.readLongLE(); } ByteBuf valueBuf = buf.readSlice(valueLen); Object value = codec.getMapValueDecoder().decode(valueBuf, state); result.add(value); if (sync) { double syncId = buf.order(ByteOrder.LITTLE_ENDIAN).readDouble(); result.add(syncId); } return result; } };
@Override public DatagramChannelConfig setBroadcast(boolean broadcast) { try { // See: https://github.com/netty/netty/issues/576 if (broadcast && !javaSocket.getLocalAddress().isAnyLocalAddress() && !PlatformDependent.isWindows() && !PlatformDependent.maybeSuperUser()) { // Warn a user about the fact that a non-root user can't receive a // broadcast packet on *nix if the socket is bound on non-wildcard address. logger.warn( "A non-root user can't receive a broadcast packet if the socket " + "is not bound to a wildcard address; setting the SO_BROADCAST flag " + "anyway as requested on the socket which is bound to " + javaSocket.getLocalSocketAddress() + '.'); } javaSocket.setBroadcast(broadcast); } catch (SocketException e) { throw new ChannelException(e); } return this; }
localAddress instanceof InetSocketAddress && !((InetSocketAddress) localAddress).getAddress().isAnyLocalAddress() && !PlatformDependent.isWindows() && !PlatformDependent.maybeSuperUser()) {