Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible proxy fix (built, but not tested) #501

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 24 additions & 6 deletions app/src/processing/app/SingleInstance.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@
package processing.app;

import java.awt.EventQueue;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.io.*;
import java.util.*;

import processing.core.PApplet;
import processing.app.ui.Toolkit;
import processing.core.*;


/**
Expand Down Expand Up @@ -120,6 +120,13 @@ public void run() {


static boolean sendArguments(String[] args) { //, long timeout) {
boolean toRet;
Messages.log("Proxy settings will now be temporarily erased");
System.clearProperty("http.proxyHost");
System.clearProperty("https.proxyHost");
System.clearProperty("socksProxyHost");
System.clearProperty("java.net.useSystemProxies"); // bye bye settings for now
Messages.log("Proxy settings have been erased.");
try {
Messages.log("Checking to see if Processing is already running");
int port = Preferences.getInteger(SERVER_PORT);
Expand All @@ -139,12 +146,23 @@ static boolean sendArguments(String[] args) { //, long timeout) {
}
writer.flush();
writer.close();
return true;
toRet = true; // Critical that proxy is reset
}
} catch (IOException e) {
Messages.err("Error sending commands to other instance", e);
}
Messages.log("Processing is not already running (or could not connect)");
return false;
toRet = false; // Critical that proxy is reset
Messages.log("Proxy settings are returning");
if (Preferences.get("proxy.system").equals("true")) {
// Use the system proxy settings by default
// https://github.com/processing/processing/issues/2643
System.setProperty("java.net.useSystemProxies", "true");
}
Preferences.handleProxy("http", "http.proxyHost", "http.proxyPort");
Preferences.handleProxy("https", "https.proxyHost", "https.proxyPort");
Preferences.handleProxy("socks", "socksProxyHost", "socksProxyPort");
Messages.log("Proxy settings are back.");
return toRet;
}
}