mirror of
https://github.com/octoleo/plantuml.git
synced 2024-11-29 00:06:34 +00:00
* Allow specifying the bind address that picoweb will listen on (e.g. -picoweb:8000:localhost).
* Change picoweb server to print the actual port being listened on when port 0 was specified.
This commit is contained in:
parent
0dc13cccf2
commit
f850b5f400
@ -79,6 +79,7 @@ public class Option {
|
|||||||
private boolean textProgressBar = false;
|
private boolean textProgressBar = false;
|
||||||
private int nbThreads = 0;
|
private int nbThreads = 0;
|
||||||
private int ftpPort = -1;
|
private int ftpPort = -1;
|
||||||
|
private String picowebBindAddress = null;
|
||||||
private int picowebPort = -1;
|
private int picowebPort = -1;
|
||||||
private boolean hideMetadata = false;
|
private boolean hideMetadata = false;
|
||||||
private boolean checkMetadata = false;
|
private boolean checkMetadata = false;
|
||||||
@ -370,12 +371,9 @@ public class Option {
|
|||||||
this.ftpPort = Integer.parseInt(s.substring(x + 1));
|
this.ftpPort = Integer.parseInt(s.substring(x + 1));
|
||||||
}
|
}
|
||||||
} else if (StringUtils.goLowerCase(s).startsWith("-picoweb")) {
|
} else if (StringUtils.goLowerCase(s).startsWith("-picoweb")) {
|
||||||
final int x = s.indexOf(':');
|
final String[] parts = s.split(":");
|
||||||
if (x == -1) {
|
this.picowebPort = parts.length > 1 ? Integer.parseInt(parts[1]) : 8080;
|
||||||
this.picowebPort = 8080;
|
this.picowebBindAddress = parts.length > 2 ? parts[2] : null;
|
||||||
} else {
|
|
||||||
this.picowebPort = Integer.parseInt(s.substring(x + 1));
|
|
||||||
}
|
|
||||||
} else if (s.startsWith("-c")) {
|
} else if (s.startsWith("-c")) {
|
||||||
s = s.substring(2);
|
s = s.substring(2);
|
||||||
config.add(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(s));
|
config.add(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(s));
|
||||||
@ -403,6 +401,10 @@ public class Option {
|
|||||||
return ftpPort;
|
return ftpPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getPicowebBindAddress() {
|
||||||
|
return picowebBindAddress;
|
||||||
|
}
|
||||||
|
|
||||||
public int getPicowebPort() {
|
public int getPicowebPort() {
|
||||||
return picowebPort;
|
return picowebPort;
|
||||||
}
|
}
|
||||||
|
@ -334,9 +334,7 @@ public class Run {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void goPicoweb(Option option) throws IOException {
|
private static void goPicoweb(Option option) throws IOException {
|
||||||
final int picoWebport = option.getPicowebPort();
|
PicoWebServer.startServer(option.getPicowebPort(), option.getPicowebBindAddress());
|
||||||
System.err.println("webPort=" + picoWebport);
|
|
||||||
PicoWebServer.startServer(picoWebport);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void printFonts() {
|
public static void printFonts() {
|
||||||
|
@ -42,6 +42,7 @@ import java.io.ByteArrayOutputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
import java.net.InetAddress;
|
||||||
import java.net.ServerSocket;
|
import java.net.ServerSocket;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@ -72,11 +73,13 @@ public class PicoWebServer implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) throws IOException {
|
public static void main(String[] args) throws IOException {
|
||||||
startServer(8080);
|
startServer(8080, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void startServer(final int port) throws IOException {
|
public static void startServer(final int port, final String bindAddress) throws IOException {
|
||||||
final ServerSocket serverConnect = new ServerSocket(port);
|
final InetAddress bindAddress1 = bindAddress == null ? null : InetAddress.getByName(bindAddress);
|
||||||
|
final ServerSocket serverConnect = new ServerSocket(port, 50, bindAddress1);
|
||||||
|
System.err.println("webPort=" + serverConnect.getLocalPort());
|
||||||
while (true) {
|
while (true) {
|
||||||
final PicoWebServer myServer = new PicoWebServer(serverConnect.accept());
|
final PicoWebServer myServer = new PicoWebServer(serverConnect.accept());
|
||||||
final Thread thread = new Thread(myServer);
|
final Thread thread = new Thread(myServer);
|
||||||
|
Loading…
Reference in New Issue
Block a user