-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use java 15, refactor to use completion stages, add logging to disk
- Loading branch information
Showing
7 changed files
with
220 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
35 changes: 35 additions & 0 deletions
35
src/main/java/name/maxdeliso/teflon/net/InterfaceChooser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package name.maxdeliso.teflon.net; | ||
|
||
import java.net.NetworkInterface; | ||
import java.net.SocketException; | ||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
public class InterfaceChooser { | ||
private List<NetworkInterface> queryAvailableInterfaces() { | ||
try { | ||
return Collections.list(NetworkInterface.getNetworkInterfaces()); | ||
} catch (SocketException se) { | ||
return new ArrayList<>(); | ||
} | ||
} | ||
|
||
public List<NetworkInterface> queryInterfaces() { | ||
return queryAvailableInterfaces() | ||
.stream() | ||
.filter(ni -> { | ||
try { | ||
return ni.isUp() && | ||
ni.supportsMulticast() && | ||
!ni.isLoopback() && | ||
!ni.isPointToPoint() && | ||
!ni.isVirtual(); | ||
} catch (SocketException exc) { | ||
return false; | ||
} | ||
}) | ||
.collect(Collectors.toList()); | ||
} | ||
} |
Oops, something went wrong.