Implement UDP start/stop
Add UDP config, default false Change UDP port
This commit is contained in:
@ -5,6 +5,10 @@
|
|||||||
# minimum 900 (15 minutes), maximum 21600 (6 hours)
|
# minimum 900 (15 minutes), maximum 21600 (6 hours)
|
||||||
interval=1620
|
interval=1620
|
||||||
#
|
#
|
||||||
|
# Enable UDP announces
|
||||||
|
# default false
|
||||||
|
udp=false
|
||||||
|
#
|
||||||
# UDP connection lifetime in seconds
|
# UDP connection lifetime in seconds
|
||||||
# minimum 60 (1 minute), maximum 21600 (6 hours)
|
# minimum 60 (1 minute), maximum 21600 (6 hours)
|
||||||
lifetime=1200
|
lifetime=1200
|
||||||
|
@ -52,11 +52,11 @@ public class UDPHandler implements I2PSessionMuxedListener {
|
|||||||
// conn ID to dest and time added
|
// conn ID to dest and time added
|
||||||
private final Map<Long, DestAndTime> _connectCache;
|
private final Map<Long, DestAndTime> _connectCache;
|
||||||
private final Cleaner _cleaner;
|
private final Cleaner _cleaner;
|
||||||
|
private volatile boolean _running;
|
||||||
|
|
||||||
// The listen port.
|
// The listen port.
|
||||||
// We listen on all ports, so the announce URL
|
// Not configurable.
|
||||||
// doesn't need a port.
|
public static final int PORT = 6969;
|
||||||
public static final int PORT = I2PSession.PORT_ANY;
|
|
||||||
private static final long MAGIC = 0x41727101980L;
|
private static final long MAGIC = 0x41727101980L;
|
||||||
private static final int ACTION_CONNECT = 0;
|
private static final int ACTION_CONNECT = 0;
|
||||||
private static final int ACTION_ANNOUNCE = 1;
|
private static final int ACTION_ANNOUNCE = 1;
|
||||||
@ -82,12 +82,21 @@ public class UDPHandler implements I2PSessionMuxedListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void start() {
|
public void start() {
|
||||||
|
_running = true;
|
||||||
(new I2PAppThread(new Waiter(), "ZzzOT UDP startup", true)).start();
|
(new I2PAppThread(new Waiter(), "ZzzOT UDP startup", true)).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 0.20.0
|
||||||
|
*/
|
||||||
|
public void stop() {
|
||||||
|
_running = false;
|
||||||
|
_cleaner.cancel();
|
||||||
|
}
|
||||||
|
|
||||||
private class Waiter implements Runnable {
|
private class Waiter implements Runnable {
|
||||||
public void run() {
|
public void run() {
|
||||||
while (true) {
|
while (_running) {
|
||||||
// requires I2P 0.9.53 (1.7.0)
|
// requires I2P 0.9.53 (1.7.0)
|
||||||
List<I2PSession> sessions = _tunnel.getSessions();
|
List<I2PSession> sessions = _tunnel.getSessions();
|
||||||
if (sessions.isEmpty()) {
|
if (sessions.isEmpty()) {
|
||||||
|
@ -70,6 +70,8 @@ public class ZzzOTController implements ClientApp {
|
|||||||
private static boolean _showfooter;
|
private static boolean _showfooter;
|
||||||
private static String _footertext;
|
private static String _footertext;
|
||||||
private static boolean _fullScrape;
|
private static boolean _fullScrape;
|
||||||
|
private final boolean _enableUDP;
|
||||||
|
private UDPHandler _udp;
|
||||||
|
|
||||||
private ClientAppState _state = UNINITIALIZED;
|
private ClientAppState _state = UNINITIALIZED;
|
||||||
|
|
||||||
@ -83,6 +85,8 @@ public class ZzzOTController implements ClientApp {
|
|||||||
private static final String PROP_FOOTERTEXT = "footertext";
|
private static final String PROP_FOOTERTEXT = "footertext";
|
||||||
private static final String PROP_FULLSCRAPE = "allowFullScrape";
|
private static final String PROP_FULLSCRAPE = "allowFullScrape";
|
||||||
private static final String DEFAULT_FULLSCRAPE = "false";
|
private static final String DEFAULT_FULLSCRAPE = "false";
|
||||||
|
private static final String PROP_UDP = "udp";
|
||||||
|
private static final String DEFAULT_UDP = "false";
|
||||||
private static final String CONFIG_FILE = "zzzot.config";
|
private static final String CONFIG_FILE = "zzzot.config";
|
||||||
private static final String BACKUP_SUFFIX = ".jetty8";
|
private static final String BACKUP_SUFFIX = ".jetty8";
|
||||||
private static final String[] xmlFiles = {
|
private static final String[] xmlFiles = {
|
||||||
@ -114,6 +118,7 @@ public class ZzzOTController implements ClientApp {
|
|||||||
_showfooter = Boolean.parseBoolean(props.getProperty(PROP_SHOWFOOTER, DEFAULT_SHOWFOOTER));
|
_showfooter = Boolean.parseBoolean(props.getProperty(PROP_SHOWFOOTER, DEFAULT_SHOWFOOTER));
|
||||||
_footertext = props.getProperty(PROP_FOOTERTEXT, DEFAULT_FOOTERTEXT);
|
_footertext = props.getProperty(PROP_FOOTERTEXT, DEFAULT_FOOTERTEXT);
|
||||||
_fullScrape = Boolean.parseBoolean(props.getProperty(PROP_FULLSCRAPE, DEFAULT_FULLSCRAPE));
|
_fullScrape = Boolean.parseBoolean(props.getProperty(PROP_FULLSCRAPE, DEFAULT_FULLSCRAPE));
|
||||||
|
_enableUDP = Boolean.parseBoolean(props.getProperty(PROP_UDP, DEFAULT_UDP));
|
||||||
_state = INITIALIZED;
|
_state = INITIALIZED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,12 +191,11 @@ public class ZzzOTController implements ClientApp {
|
|||||||
startJetty(pluginDir, dest);
|
startJetty(pluginDir, dest);
|
||||||
startI2PTunnel(pluginDir, dest);
|
startI2PTunnel(pluginDir, dest);
|
||||||
_zzzot.start();
|
_zzzot.start();
|
||||||
/*
|
// requires I2P 0.9.66 (2.9.0)
|
||||||
// requires I2P 0.9.53 (1.7.0)
|
if (_enableUDP) {
|
||||||
UDPHandler udp = new UDPHandler(_context, _tunnel.getTunnel(), _zzzot);
|
_udp = new UDPHandler(_context, _tunnel.getTunnel(), _zzzot);
|
||||||
udp.start();
|
_udp.start();
|
||||||
*/
|
}
|
||||||
// SeedlessAnnouncer.announce(_tunnel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -247,6 +251,8 @@ public class ZzzOTController implements ClientApp {
|
|||||||
private void stop() {
|
private void stop() {
|
||||||
stopI2PTunnel();
|
stopI2PTunnel();
|
||||||
stopJetty();
|
stopJetty();
|
||||||
|
if (_udp != null)
|
||||||
|
_udp.stop();
|
||||||
_zzzot.stop();
|
_zzzot.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user