mirror of
https://github.com/processing/processing4.git
synced 2026-02-03 13:49:18 +01:00
detect changes to /etc/hosts and warn user (#4738)
This commit is contained in:
@@ -34,6 +34,8 @@ import java.awt.GraphicsEnvironment;
|
||||
import java.awt.Point;
|
||||
import java.io.*;
|
||||
import java.net.ConnectException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.*;
|
||||
|
||||
import com.sun.jdi.*;
|
||||
@@ -82,6 +84,8 @@ public class Runner implements MessageConsumer {
|
||||
// this.sketch = sketch;
|
||||
this.build = build;
|
||||
|
||||
checkLocalHost();
|
||||
|
||||
if (listener instanceof Editor) {
|
||||
this.editor = (Editor) listener;
|
||||
sketchErr = editor.getConsole().getErr();
|
||||
@@ -116,6 +120,29 @@ public class Runner implements MessageConsumer {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Has the user screwed up their hosts file?
|
||||
* https://github.com/processing/processing/issues/4738
|
||||
*/
|
||||
private void checkLocalHost() throws SketchException {
|
||||
try {
|
||||
InetAddress address = InetAddress.getByName("localhost");
|
||||
if (!address.getHostAddress().equals("127.0.0.1")) {
|
||||
System.err.println("Your computer is not properly mapping 'localhost' to '127.0.0.1',");
|
||||
System.err.println("which prevents sketches from working properly because 'localhost'");
|
||||
System.err.println("is needed to connect the PDE to your sketch while it's running.");
|
||||
System.err.println("If you don't recall making this change, or know how to fix it:");
|
||||
System.err.println("https://www.google.com/search?q=add+localhost+to+hosts+file+" + Platform.getName());
|
||||
throw new SketchException("Cannot run due to changes in your 'hosts' file. " +
|
||||
"See the console for details.", false);
|
||||
}
|
||||
|
||||
} catch (UnknownHostException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public VirtualMachine launch(String[] args) {
|
||||
if (launchVirtualMachine(false, args)) {
|
||||
generateTrace();
|
||||
|
||||
Reference in New Issue
Block a user