Skip to content
This repository has been archived by the owner on Aug 23, 2020. It is now read-only.

Commit

Permalink
Enabling (--remote) access.
Browse files Browse the repository at this point in the history
  • Loading branch information
davassi committed Dec 16, 2016
1 parent dd7fa09 commit 599eee1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
12 changes: 10 additions & 2 deletions src/main/java/com/iota/iri/IRI.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ private static void validateParams(final String[] args) {
final Option<String> cors = parser.addStringOption('c', "enabled-cors");
final Option<Boolean> headless = parser.addBooleanOption("headless");
final Option<Boolean> debug = parser.addBooleanOption('d', "debug");
final Option<Boolean> remote = parser.addBooleanOption("remote");
final Option<String> neighbors = parser.addStringOption('n', "neighbors");
final Option<Boolean> experimental = parser.addBooleanOption('e', "experimental");
final Option<Boolean> help = parser.addBooleanOption('h', "help");
Expand Down Expand Up @@ -117,6 +118,11 @@ private static void validateParams(final String[] args) {
if (parser.getOptionValue(headless) != null) {
Configuration.put(DefaultConfSettings.HEADLESS, "true");
}

if (parser.getOptionValue(remote) != null) {
log.info("Remote access enabled. Binding API socket to listen any interface.");
Configuration.put(DefaultConfSettings.API_HOST, "0.0.0.0");
}

if (parser.getOptionValue(debug) != null) {
Configuration.put(DefaultConfSettings.DEBUG, "true");
Expand All @@ -140,7 +146,9 @@ private static void printUsage() {
"[{-r,--receiver-port} 14265] " +
"[{-c,--enabled-cors} *] " +
"[{-h}] [{--headless}] " +
"[{-d,--debug}] [{-e,--experimental}]" +
"[{-d,--debug}] " +
"[{-e,--experimental}]" +
"[{--remote}]" +
// + "[{-t,--testnet} false] " // -> TBDiscussed (!)
"[{-n,--neighbors} '<list of neighbors>'] ", NAME, VERSION);
System.exit(0);
Expand Down Expand Up @@ -170,7 +178,7 @@ private static void showIotaLogo() {
final Path path = Paths.get("logo.ans");
Files.readAllLines(path, Charset.forName(charset)).forEach(log::info);
} catch (IOException e) {
log.error("Impossible to display logo. Charset {} not supported.", charset);
log.error("Impossible to display logo. Charset {} not supported by terminal.", charset);
}
}
}
2 changes: 2 additions & 0 deletions src/main/java/com/iota/iri/conf/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class Configuration {

public enum DefaultConfSettings {
API_PORT,
API_HOST,
TANGLE_RECEIVER_PORT,
CORS_ENABLED,
TESTNET, // not used yet
Expand All @@ -30,6 +31,7 @@ public enum DefaultConfSettings {
static {
// defaults
conf.put(DefaultConfSettings.API_PORT.name(), "14265");
conf.put(DefaultConfSettings.API_HOST.name(), "localhost");
conf.put(DefaultConfSettings.TANGLE_RECEIVER_PORT.name(), "14265");
conf.put(DefaultConfSettings.CORS_ENABLED.name(), "*");
conf.put(DefaultConfSettings.TESTNET.name(), "false");
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/com/iota/iri/service/API.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,12 @@ public class API {

public void init() throws IOException {

int apiPort = Configuration.integer(DefaultConfSettings.API_PORT);
final int apiPort = Configuration.integer(DefaultConfSettings.API_PORT);
final String apiHost = Configuration.string(DefaultConfSettings.API_HOST);

server = Undertow.builder().addHttpListener(apiPort, "localhost")
log.debug("Binding JSON-REST API Undertown server on {}:{}" , apiHost, apiPort);

server = Undertow.builder().addHttpListener(apiPort, apiHost)
.setHandler(path().addPrefixPath("/", new HttpHandler() {
@Override
public void handleRequest(final HttpServerExchange exchange) throws Exception {
Expand Down

0 comments on commit 599eee1

Please sign in to comment.