equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
35 * 4. none. |
35 * 4. none. |
36 * Platforms that do not require a default interface implement a dummy |
36 * Platforms that do not require a default interface implement a dummy |
37 * that returns null. |
37 * that returns null. |
38 */ |
38 */ |
39 |
39 |
|
40 import java.security.AccessController; |
|
41 import java.security.PrivilegedAction; |
40 import java.util.Enumeration; |
42 import java.util.Enumeration; |
41 import java.io.IOException; |
43 import java.io.IOException; |
42 |
44 |
43 class DefaultInterface { |
45 class DefaultInterface { |
44 |
46 |
80 try { |
82 try { |
81 if (!ni.isUp() || !ni.supportsMulticast()) |
83 if (!ni.isUp() || !ni.supportsMulticast()) |
82 continue; |
84 continue; |
83 |
85 |
84 boolean ip4 = false, ip6 = false; |
86 boolean ip4 = false, ip6 = false; |
85 Enumeration<InetAddress> addrs = ni.getInetAddresses(); |
87 PrivilegedAction<Enumeration<InetAddress>> pa = ni::getInetAddresses; |
|
88 Enumeration<InetAddress> addrs = AccessController.doPrivileged(pa); |
86 while (addrs.hasMoreElements()) { |
89 while (addrs.hasMoreElements()) { |
87 InetAddress addr = addrs.nextElement(); |
90 InetAddress addr = addrs.nextElement(); |
88 if (!addr.isAnyLocalAddress()) { |
91 if (!addr.isAnyLocalAddress()) { |
89 if (addr instanceof Inet4Address) { |
92 if (addr instanceof Inet4Address) { |
90 ip4 = true; |
93 ip4 = true; |