Class NetworkInterfaceWrapper
java.lang.Object
org.eblocker.server.common.network.NetworkInterfaceWrapper
Network utilities
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface -
Constructor Summary
ConstructorsConstructorDescriptionNetworkInterfaceWrapper(NetworkInterfaceFactory networkInterfaceFactory, String interfaceName, Ip4Address emergencyIp, String findGatewayScript, String vpnInterfaceName, ScriptRunner scriptRunner) -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidLook for a gateway, and if found write it to Redis (script)Returns the primary IPv4 IP addressbyte[]intgetMtu()intgetNetworkPrefixLength(IpAddress ipAddress) Returns the network prefix length (in bits) of the given IP addressbooleanvoidinit()booleanisUp()voidOnce a NetworkInterface object has been created its IP addresses do not change.voidnotifyIPAddressChanged(Ip4Address newIP) This method actually updates the current IPv4 address from the network interface; Call this method, if e.g. the device got a new IPv4 address via DHCP in automatic mode.
-
Constructor Details
-
NetworkInterfaceWrapper
@Inject public NetworkInterfaceWrapper(NetworkInterfaceFactory networkInterfaceFactory, String interfaceName, Ip4Address emergencyIp, String findGatewayScript, String vpnInterfaceName, ScriptRunner scriptRunner)
-
-
Method Details
-
init
public void init() -
getFirstIPv4Address
Returns the primary IPv4 IP address -
notifyIPAddressChanged
This method actually updates the current IPv4 address from the network interface; Call this method, if e.g. the device got a new IPv4 address via DHCP in automatic mode. -
notifyIp6AddressChanged
public void notifyIp6AddressChanged()Once a NetworkInterface object has been created its IP addresses do not change. Therefore, an external process must detect IPv6 address updates and call this method to reload the NetworkInterface. -
getIp6LinkLocalAddress
-
getAddresses
-
hasGlobalIp6Address
public boolean hasGlobalIp6Address() -
getNetworkPrefixLength
Returns the network prefix length (in bits) of the given IP address- Parameters:
ipAddress- IP address- Returns:
- -1 if there was no networkInterface
-
getHardwareAddress
public byte[] getHardwareAddress() -
getHardwareAddressHex
-
getInterfaceName
-
findGatewayAndWriteToRedis
public void findGatewayAndWriteToRedis()Look for a gateway, and if found write it to Redis (script) -
isUp
public boolean isUp() -
getVpnIpv4Address
-
getMtu
public int getMtu() -
addIpAddressChangeListener
-