Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
157 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.frostwire.jlibtorrent; | ||
|
||
import com.frostwire.jlibtorrent.swig.address; | ||
|
||
/** | ||
* @author gubatron | ||
* @author aldenml | ||
*/ | ||
public final class Address { | ||
|
||
private final address addr; | ||
|
||
public Address(address addr) { | ||
this.addr = addr; | ||
} | ||
|
||
public address getSwig() { | ||
return addr; | ||
} | ||
} |
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,20 @@ | ||
package com.frostwire.jlibtorrent; | ||
|
||
import com.frostwire.jlibtorrent.swig.tcp_endpoint; | ||
|
||
/** | ||
* @author gubatron | ||
* @author aldenml | ||
*/ | ||
public final class TcpEndpoint { | ||
|
||
private final tcp_endpoint endp; | ||
|
||
public TcpEndpoint(tcp_endpoint endp) { | ||
this.endp = endp; | ||
} | ||
|
||
public tcp_endpoint getSwig() { | ||
return endp; | ||
} | ||
} |
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
17 changes: 17 additions & 0 deletions
17
src/com/frostwire/jlibtorrent/alerts/DhtGetPeersAlert.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,17 @@ | ||
package com.frostwire.jlibtorrent.alerts; | ||
|
||
import com.frostwire.jlibtorrent.swig.dht_get_peers_alert; | ||
|
||
/** | ||
* This alert is generated when a DHT node sends a ``get_peers`` message to | ||
* our DHT node. It belongs to the ``dht_notification`` category. | ||
* | ||
* @author gubatron | ||
* @author aldenml | ||
*/ | ||
public final class DhtGetPeersAlert extends AbstractAlert<dht_get_peers_alert> { | ||
|
||
public DhtGetPeersAlert(dht_get_peers_alert alert) { | ||
super(alert); | ||
} | ||
} |
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,29 @@ | ||
package com.frostwire.jlibtorrent.alerts; | ||
|
||
import com.frostwire.jlibtorrent.Address; | ||
import com.frostwire.jlibtorrent.swig.external_ip_alert; | ||
|
||
/** | ||
* Whenever libtorrent learns about the machines external IP, this alert is | ||
* generated. The external IP address can be acquired from the tracker (if it | ||
* supports that) or from peers that supports the extension protocol. | ||
* The address can be accessed through the ``external_address`` member. | ||
* | ||
* @author gubatron | ||
* @author aldenml | ||
*/ | ||
public final class ExternalIpAlert extends AbstractAlert<external_ip_alert> { | ||
|
||
public ExternalIpAlert(external_ip_alert alert) { | ||
super(alert); | ||
} | ||
|
||
/** | ||
* the IP address that is believed to be our external IP. | ||
* | ||
* @return | ||
*/ | ||
public Address getExternalAddress() { | ||
return new Address(alert.getExternal_address()); | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
src/com/frostwire/jlibtorrent/alerts/ListenSucceededAlert.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,67 @@ | ||
package com.frostwire.jlibtorrent.alerts; | ||
|
||
import com.frostwire.jlibtorrent.TcpEndpoint; | ||
import com.frostwire.jlibtorrent.swig.listen_succeeded_alert; | ||
|
||
/** | ||
* This alert is posted when the listen port succeeds to be opened on a | ||
* particular interface. ``endpoint`` is the endpoint that successfully | ||
* was opened for listening. | ||
* | ||
* @author gubatron | ||
* @author aldenml | ||
*/ | ||
public final class ListenSucceededAlert extends AbstractAlert<listen_succeeded_alert> { | ||
|
||
public ListenSucceededAlert(listen_succeeded_alert alert) { | ||
super(alert); | ||
} | ||
|
||
/** | ||
* the endpoint libtorrent ended up listening on. The address | ||
* refers to the local interface and the port is the listen port. | ||
* | ||
* @return | ||
*/ | ||
public TcpEndpoint getEndpoint() { | ||
return new TcpEndpoint(alert.getEndpoint()); | ||
} | ||
|
||
/** | ||
* the type of listen socket this alert refers to. | ||
* | ||
* @return | ||
*/ | ||
public SocketType getSockType() { | ||
return SocketType.fromSwig(alert.getSock_type()); | ||
} | ||
|
||
public enum SocketType { | ||
|
||
TCP(listen_succeeded_alert.socket_type_t.tcp), | ||
|
||
TCP_SSL(listen_succeeded_alert.socket_type_t.tcp_ssl), | ||
|
||
UDP(listen_succeeded_alert.socket_type_t.udp); | ||
|
||
private SocketType(listen_succeeded_alert.socket_type_t swigObj) { | ||
this.swigObj = swigObj; | ||
} | ||
|
||
private final listen_succeeded_alert.socket_type_t swigObj; | ||
|
||
public listen_succeeded_alert.socket_type_t getSwig() { | ||
return swigObj; | ||
} | ||
|
||
public static SocketType fromSwig(listen_succeeded_alert.socket_type_t swigObj) { | ||
SocketType[] enumValues = SocketType.class.getEnumConstants(); | ||
for (SocketType ev : enumValues) { | ||
if (ev.getSwig() == swigObj) { | ||
return ev; | ||
} | ||
} | ||
throw new IllegalArgumentException("No enum " + SocketType.class + " with swig value " + swigObj); | ||
} | ||
} | ||
} |