Class EnumNet.IpInterface

java.lang.Object
com.frostwire.jlibtorrent.EnumNet.IpInterface
Enclosing class:
EnumNet

public static final class EnumNet.IpInterface extends Object
Network interface information including address, netmask, and interface name.

IpInterface represents a single network interface on the local system with its IP address, netmask, and descriptive names. Used to select which network interfaces to bind BitTorrent traffic to.

Interface Properties:

  • Address: IPv4 or IPv6 address assigned to interface
  • Netmask: Network mask determining subnet size
  • Name: System interface name (eth0, wlan0, en0, etc)
  • Friendly Name: Human-readable interface name
  • Description: Hardware or connection description
  • Preferred: Whether this is the primary/default interface

Accessing Interface Information:

 EnumNet.IpInterface iface = ...;

 // Get address information
 Address addr = iface.interfaceAddress();
 System.out.println(\"IP: \" + addr);

 // Get netmask (determines network range)
 Address netmask = iface.netmask();
 System.out.println(\"Netmask: \" + netmask);

 // Get names
 System.out.println(\"System name: \" + iface.name());
 System.out.println(\"Friendly name: \" + iface.friendlyName());
 System.out.println(\"Description: \" + iface.description());

 // Check if preferred
 if (iface.preferred()) {
     System.out.println(\"This is the primary interface\");
 }
 

IPv4 vs IPv6:

 // Identify address type
 Address addr = iface.interfaceAddress();
 if (addr.isV4()) {
     System.out.println(\"IPv4: \" + addr);
 } else if (addr.isV6()) {
     System.out.println(\"IPv6: \" + addr);
 }
 

Selecting Interfaces for BitTorrent:

 // Find suitable interfaces for listening
 for (EnumNet.IpInterface iface : EnumNet.enumInterfaces(sm)) {
     Address addr = iface.interfaceAddress();

     // Skip loopback (127.0.0.1, ::1)
     if (addr.isLoopback()) continue;

     // Skip link-local IPv6
     if (addr.isV6() && addr.toString().startsWith(\"fe80:\")) continue;

     System.out.println(\"Good for listening: \" + iface.name() + \" - \" + addr);
 }
 
  • Method Details

    • swig

      public com.frostwire.jlibtorrent.swig.ip_interface swig()
    • interfaceAddress

      public Address interfaceAddress()
    • netmask

      public Address netmask()
    • name

      public String name()
    • friendlyName

      public String friendlyName()
    • description

      public String description()
    • preferred

      public boolean preferred()
    • toString

      public String toString()
      Overrides:
      toString in class Object