I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 6c88eb52 authored by zzz's avatar zzz
Browse files

BOB: Register with port mapper

parent 7b2355a8
No related branches found
No related tags found
No related merge requests found
...@@ -38,6 +38,7 @@ import net.i2p.I2PAppContext; ...@@ -38,6 +38,7 @@ import net.i2p.I2PAppContext;
import net.i2p.app.*; import net.i2p.app.*;
import net.i2p.client.I2PClient; import net.i2p.client.I2PClient;
import net.i2p.util.I2PAppThread; import net.i2p.util.I2PAppThread;
import net.i2p.util.PortMapper;
import net.i2p.util.SimpleTimer2; import net.i2p.util.SimpleTimer2;
/** /**
...@@ -131,6 +132,7 @@ public class BOB implements Runnable, ClientApp { ...@@ -131,6 +132,7 @@ public class BOB implements Runnable, ClientApp {
// no longer used. // no longer used.
// private static int maxConnections = 0; // private static int maxConnections = 0;
private final I2PAppContext _context;
private final Logger _log; private final Logger _log;
private final ClientAppManager _mgr; private final ClientAppManager _mgr;
private final String[] _args; private final String[] _args;
...@@ -158,6 +160,7 @@ public class BOB implements Runnable, ClientApp { ...@@ -158,6 +160,7 @@ public class BOB implements Runnable, ClientApp {
* @since 0.9.10 * @since 0.9.10
*/ */
public BOB(I2PAppContext context, ClientAppManager mgr, String[] args) { public BOB(I2PAppContext context, ClientAppManager mgr, String[] args) {
_context = context;
// If we were run from command line, log to stdout // If we were run from command line, log to stdout
boolean logToStdout = false; boolean logToStdout = false;
URL classResource = BOB.class.getResource("BOB.class"); URL classResource = BOB.class.getResource("BOB.class");
...@@ -218,7 +221,7 @@ public class BOB implements Runnable, ClientApp { ...@@ -218,7 +221,7 @@ public class BOB implements Runnable, ClientApp {
{ {
File cfg = new File(configLocation); File cfg = new File(configLocation);
if (!cfg.isAbsolute()) { if (!cfg.isAbsolute()) {
cfg = new File(I2PAppContext.getGlobalContext().getConfigDir(), configLocation); cfg = new File(_context.getConfigDir(), configLocation);
} }
FileInputStream fi = null; FileInputStream fi = null;
try { try {
...@@ -275,7 +278,7 @@ public class BOB implements Runnable, ClientApp { ...@@ -275,7 +278,7 @@ public class BOB implements Runnable, ClientApp {
if (save) { if (save) {
File cfg = new File(configLocation); File cfg = new File(configLocation);
if (!cfg.isAbsolute()) { if (!cfg.isAbsolute()) {
cfg = new File(I2PAppContext.getGlobalContext().getConfigDir(), configLocation); cfg = new File(_context.getConfigDir(), configLocation);
} }
FileOutputStream fo = null; FileOutputStream fo = null;
try { try {
...@@ -316,6 +319,8 @@ public class BOB implements Runnable, ClientApp { ...@@ -316,6 +319,8 @@ public class BOB implements Runnable, ClientApp {
_log.info("BOB is now running."); _log.info("BOB is now running.");
if (_mgr != null) if (_mgr != null)
_mgr.register(this); _mgr.register(this);
_context.portMapper().register(PortMapper.SVC_BOB, props.getProperty(PROP_BOB_HOST),
Integer.parseInt(props.getProperty(PROP_BOB_PORT)));
int i = 0; int i = 0;
boolean g = false; boolean g = false;
...@@ -353,6 +358,7 @@ public class BOB implements Runnable, ClientApp { ...@@ -353,6 +358,7 @@ public class BOB implements Runnable, ClientApp {
changeState(STOPPING, e); changeState(STOPPING, e);
} finally { } finally {
_log.info("BOB is now shutting down..."); _log.info("BOB is now shutting down...");
_context.portMapper().unregister(PortMapper.SVC_BOB);
// Clean up everything. // Clean up everything.
try { try {
listener.close(); listener.close();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment