Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Julian Dehm
briar
Commits
cd4897e6
Verified
Commit
cd4897e6
authored
Aug 23, 2018
by
akwizgran
Browse files
Check whether getNetworkInterfaces() returns null.
parent
d84e176b
Changes
2
Hide whitespace changes
Inline
Side-by-side
bramble-core/src/main/java/org/briarproject/bramble/plugin/tcp/TcpPlugin.java
View file @
cd4897e6
...
...
@@ -24,7 +24,7 @@ import java.net.SocketException;
import
java.net.UnknownHostException
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.
Collec
tion
s
;
import
java.util.
Enumera
tion
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map.Entry
;
...
...
@@ -35,6 +35,9 @@ import java.util.regex.Pattern;
import
javax.annotation.Nullable
;
import
static
java
.
net
.
NetworkInterface
.
getNetworkInterfaces
;
import
static
java
.
util
.
Collections
.
emptyList
;
import
static
java
.
util
.
Collections
.
list
;
import
static
java
.
util
.
logging
.
Level
.
INFO
;
import
static
java
.
util
.
logging
.
Level
.
WARNING
;
import
static
org
.
briarproject
.
bramble
.
util
.
LogUtils
.
logException
;
...
...
@@ -303,16 +306,16 @@ abstract class TcpPlugin implements DuplexPlugin {
}
Collection
<
InetAddress
>
getLocalIpAddresses
()
{
List
<
NetworkInterface
>
ifaces
;
try
{
ifaces
=
Collections
.
list
(
NetworkInterface
.
getNetworkInterfaces
());
Enumeration
<
NetworkInterface
>
ifaces
=
getNetworkInterfaces
();
if
(
ifaces
==
null
)
return
emptyList
();
List
<
InetAddress
>
addrs
=
new
ArrayList
<>();
for
(
NetworkInterface
iface
:
list
(
ifaces
))
addrs
.
addAll
(
list
(
iface
.
getInetAddresses
()));
return
addrs
;
}
catch
(
SocketException
e
)
{
logException
(
LOG
,
WARNING
,
e
);
return
Collections
.
emptyList
();
return
emptyList
();
}
List
<
InetAddress
>
addrs
=
new
ArrayList
<>();
for
(
NetworkInterface
iface
:
ifaces
)
addrs
.
addAll
(
Collections
.
list
(
iface
.
getInetAddresses
()));
return
addrs
;
}
}
bramble-core/src/main/java/org/briarproject/bramble/system/AbstractSecureRandomProvider.java
View file @
cd4897e6
...
...
@@ -7,13 +7,15 @@ import java.io.DataOutputStream;
import
java.io.IOException
;
import
java.net.InetAddress
;
import
java.net.NetworkInterface
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Enumeration
;
import
java.util.Map.Entry
;
import
java.util.Properties
;
import
javax.annotation.concurrent.Immutable
;
import
static
java
.
net
.
NetworkInterface
.
getNetworkInterfaces
;
import
static
java
.
util
.
Collections
.
list
;
@Immutable
@NotNullByDefault
abstract
class
AbstractSecureRandomProvider
implements
SecureRandomProvider
{
...
...
@@ -23,13 +25,14 @@ abstract class AbstractSecureRandomProvider implements SecureRandomProvider {
out
.
writeLong
(
System
.
currentTimeMillis
());
out
.
writeLong
(
System
.
nanoTime
());
out
.
writeLong
(
Runtime
.
getRuntime
().
freeMemory
());
List
<
NetworkInterface
>
ifaces
=
Collections
.
list
(
NetworkInterface
.
getNetworkInterfaces
());
for
(
NetworkInterface
i
:
ifaces
)
{
List
<
InetAddress
>
addrs
=
Collections
.
list
(
i
.
getInetAddresses
());
for
(
InetAddress
a
:
addrs
)
out
.
write
(
a
.
getAddress
());
byte
[]
hardware
=
i
.
getHardwareAddress
();
if
(
hardware
!=
null
)
out
.
write
(
hardware
);
Enumeration
<
NetworkInterface
>
ifaces
=
getNetworkInterfaces
();
if
(
ifaces
!=
null
)
{
for
(
NetworkInterface
i
:
list
(
ifaces
))
{
for
(
InetAddress
a
:
list
(
i
.
getInetAddresses
()))
out
.
write
(
a
.
getAddress
());
byte
[]
hardware
=
i
.
getHardwareAddress
();
if
(
hardware
!=
null
)
out
.
write
(
hardware
);
}
}
for
(
Entry
<
String
,
String
>
e
:
System
.
getenv
().
entrySet
())
{
out
.
writeUTF
(
e
.
getKey
());
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment