Implement PAC (Proxy Auto Config)
This commit is contained in:
parent
af7c556283
commit
8f5ee9d57a
|
@ -26,6 +26,12 @@
|
||||||
<filtered>true</filtered>
|
<filtered>true</filtered>
|
||||||
<destName>ctbrec-no-splash.sh</destName>
|
<destName>ctbrec-no-splash.sh</destName>
|
||||||
</file>
|
</file>
|
||||||
|
<file>
|
||||||
|
<source>${project.basedir}/src/assembly/pac.js</source>
|
||||||
|
<outputDirectory>ctbrec</outputDirectory>
|
||||||
|
<filtered>true</filtered>
|
||||||
|
<destName>pac.js</destName>
|
||||||
|
</file>
|
||||||
<file>
|
<file>
|
||||||
<source>${project.build.directory}/${project.artifactId}-${project.version}.jar</source>
|
<source>${project.build.directory}/${project.artifactId}-${project.version}.jar</source>
|
||||||
<outputDirectory>ctbrec</outputDirectory>
|
<outputDirectory>ctbrec</outputDirectory>
|
||||||
|
|
|
@ -26,6 +26,12 @@
|
||||||
<filtered>true</filtered>
|
<filtered>true</filtered>
|
||||||
<destName>ctbrec-no-splash.sh</destName>
|
<destName>ctbrec-no-splash.sh</destName>
|
||||||
</file>
|
</file>
|
||||||
|
<file>
|
||||||
|
<source>${project.basedir}/src/assembly/pac.js</source>
|
||||||
|
<outputDirectory>ctbrec</outputDirectory>
|
||||||
|
<filtered>true</filtered>
|
||||||
|
<destName>pac.js</destName>
|
||||||
|
</file>
|
||||||
<file>
|
<file>
|
||||||
<source>${project.build.directory}/${project.artifactId}-${project.version}.jar
|
<source>${project.build.directory}/${project.artifactId}-${project.version}.jar
|
||||||
</source>
|
</source>
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
function FindProxyForURL(url, host) {
|
||||||
|
if (shExpMatch(host, "*stripchat.com")) {
|
||||||
|
return "SOCKS 127.0.0.1:1080";
|
||||||
|
} else if (shExpMatch(host, "*chaturbate.com")) {
|
||||||
|
return "PROXY 127.0.0.1:8080";
|
||||||
|
} else {
|
||||||
|
return "DIRECT";
|
||||||
|
}
|
||||||
|
}
|
|
@ -22,6 +22,12 @@
|
||||||
<source>${project.build.directory}/ctbrec-no-splash.exe</source>
|
<source>${project.build.directory}/ctbrec-no-splash.exe</source>
|
||||||
<outputDirectory>ctbrec</outputDirectory>
|
<outputDirectory>ctbrec</outputDirectory>
|
||||||
</file>
|
</file>
|
||||||
|
<file>
|
||||||
|
<source>${project.basedir}/src/assembly/pac.js</source>
|
||||||
|
<outputDirectory>ctbrec</outputDirectory>
|
||||||
|
<filtered>true</filtered>
|
||||||
|
<destName>pac.js</destName>
|
||||||
|
</file>
|
||||||
<file>
|
<file>
|
||||||
<source>${project.build.directory}/${project.artifactId}-${project.version}.jar</source>
|
<source>${project.build.directory}/${project.artifactId}-${project.version}.jar</source>
|
||||||
<outputDirectory>ctbrec</outputDirectory>
|
<outputDirectory>ctbrec</outputDirectory>
|
||||||
|
|
|
@ -83,6 +83,7 @@ public class SettingsTab extends Tab implements TabSelectionListener {
|
||||||
private SimpleStringProperty proxyPort;
|
private SimpleStringProperty proxyPort;
|
||||||
private SimpleStringProperty proxyUser;
|
private SimpleStringProperty proxyUser;
|
||||||
private SimpleStringProperty proxyPassword;
|
private SimpleStringProperty proxyPassword;
|
||||||
|
private SimpleStringProperty pacUrl;
|
||||||
private SimpleDirectoryProperty recordingsDir;
|
private SimpleDirectoryProperty recordingsDir;
|
||||||
private SimpleListProperty<DirectoryStructure> directoryStructure;
|
private SimpleListProperty<DirectoryStructure> directoryStructure;
|
||||||
private SimpleListProperty<SplitAfterOption> splitAfter;
|
private SimpleListProperty<SplitAfterOption> splitAfter;
|
||||||
|
@ -160,11 +161,12 @@ public class SettingsTab extends Tab implements TabSelectionListener {
|
||||||
maximumResolutionPlayer = new SimpleIntegerProperty(null, "maximumResolutionPlayer", settings.maximumResolutionPlayer);
|
maximumResolutionPlayer = new SimpleIntegerProperty(null, "maximumResolutionPlayer", settings.maximumResolutionPlayer);
|
||||||
showPlayerStarting = new SimpleBooleanProperty(null, "showPlayerStarting", settings.showPlayerStarting);
|
showPlayerStarting = new SimpleBooleanProperty(null, "showPlayerStarting", settings.showPlayerStarting);
|
||||||
singlePlayer = new SimpleBooleanProperty(null, "singlePlayer", settings.singlePlayer);
|
singlePlayer = new SimpleBooleanProperty(null, "singlePlayer", settings.singlePlayer);
|
||||||
proxyType = new SimpleListProperty<>(null, "proxyType", FXCollections.observableList(List.of(DIRECT, HTTP, SOCKS4, SOCKS5)));
|
proxyType = new SimpleListProperty<>(null, "proxyType", FXCollections.observableList(List.of(DIRECT, HTTP, SOCKS4, SOCKS5, PAC)));
|
||||||
proxyHost = new SimpleStringProperty(null, "proxyHost", settings.proxyHost);
|
proxyHost = new SimpleStringProperty(null, "proxyHost", settings.proxyHost);
|
||||||
proxyPort = new SimpleStringProperty(null, "proxyPort", settings.proxyPort);
|
proxyPort = new SimpleStringProperty(null, "proxyPort", settings.proxyPort);
|
||||||
proxyUser = new SimpleStringProperty(null, "proxyUser", settings.proxyUser);
|
proxyUser = new SimpleStringProperty(null, "proxyUser", settings.proxyUser);
|
||||||
proxyPassword = new SimpleStringProperty(null, "proxyPassword", settings.proxyPassword);
|
proxyPassword = new SimpleStringProperty(null, "proxyPassword", settings.proxyPassword);
|
||||||
|
pacUrl = new SimpleStringProperty(null, "pacUrl", settings.pacUrl);
|
||||||
recordingsDir = new SimpleDirectoryProperty(null, "recordingsDir", settings.recordingsDir);
|
recordingsDir = new SimpleDirectoryProperty(null, "recordingsDir", settings.recordingsDir);
|
||||||
directoryStructure = new SimpleListProperty<>(null, "recordingsDirStructure",
|
directoryStructure = new SimpleListProperty<>(null, "recordingsDirStructure",
|
||||||
FXCollections.observableList(List.of(FLAT, ONE_PER_MODEL, ONE_PER_GROUP, ONE_PER_RECORDING)));
|
FXCollections.observableList(List.of(FLAT, ONE_PER_MODEL, ONE_PER_GROUP, ONE_PER_RECORDING)));
|
||||||
|
@ -320,7 +322,8 @@ public class SettingsTab extends Tab implements TabSelectionListener {
|
||||||
Setting.of("Host", proxyHost).needsRestart(),
|
Setting.of("Host", proxyHost).needsRestart(),
|
||||||
Setting.of("Port", proxyPort).needsRestart(),
|
Setting.of("Port", proxyPort).needsRestart(),
|
||||||
Setting.of("Username", proxyUser).needsRestart(),
|
Setting.of("Username", proxyUser).needsRestart(),
|
||||||
Setting.of("Password", proxyPassword).needsRestart())),
|
Setting.of("Password", proxyPassword).needsRestart(),
|
||||||
|
Setting.of("PAC URL", pacUrl, "URL to your Proxy Auto-Config (PAC) file (e.g. http://example.com/pac.js or file:///G:/path/to/pac.js)").needsRestart())),
|
||||||
Category.of("Advanced / Devtools",
|
Category.of("Advanced / Devtools",
|
||||||
Group.of("Networking",
|
Group.of("Networking",
|
||||||
Setting.of("Playlist request timeout (ms)", playlistRequestTimeout, "Timeout in ms for playlist requests")),
|
Setting.of("Playlist request timeout (ms)", playlistRequestTimeout, "Timeout in ms for playlist requests")),
|
||||||
|
|
|
@ -41,6 +41,11 @@
|
||||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.bidib.com.github.markusbernhardt</groupId>
|
||||||
|
<artifactId>proxy-vole</artifactId>
|
||||||
|
<version>1.1.6</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mapstruct</groupId>
|
<groupId>org.mapstruct</groupId>
|
||||||
<artifactId>mapstruct</artifactId>
|
<artifactId>mapstruct</artifactId>
|
||||||
|
|
|
@ -32,7 +32,8 @@ public class Settings {
|
||||||
DIRECT,
|
DIRECT,
|
||||||
HTTP,
|
HTTP,
|
||||||
SOCKS4,
|
SOCKS4,
|
||||||
SOCKS5
|
SOCKS5,
|
||||||
|
PAC
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum SplitStrategy {
|
public enum SplitStrategy {
|
||||||
|
@ -139,6 +140,7 @@ public class Settings {
|
||||||
public String proxyPort;
|
public String proxyPort;
|
||||||
public ProxyType proxyType = ProxyType.DIRECT;
|
public ProxyType proxyType = ProxyType.DIRECT;
|
||||||
public String proxyUser;
|
public String proxyUser;
|
||||||
|
public String pacUrl;
|
||||||
public boolean recentlyWatched = true;
|
public boolean recentlyWatched = true;
|
||||||
public List<String> recordLaterTableColumnOrder = new ArrayList<>();
|
public List<String> recordLaterTableColumnOrder = new ArrayList<>();
|
||||||
public Map<String, Boolean> recordLaterTableColumnVisibility = new HashMap<>();
|
public Map<String, Boolean> recordLaterTableColumnVisibility = new HashMap<>();
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
package ctbrec.io;
|
package ctbrec.io;
|
||||||
|
|
||||||
|
|
||||||
|
import com.github.markusbernhardt.proxy.selector.pac.PacProxySelector;
|
||||||
|
import com.github.markusbernhardt.proxy.selector.pac.UrlPacScriptSource;
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import ctbrec.Config;
|
import ctbrec.Config;
|
||||||
import ctbrec.LoggingInterceptor;
|
import ctbrec.LoggingInterceptor;
|
||||||
|
@ -20,6 +23,7 @@ import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.Authenticator;
|
import java.net.Authenticator;
|
||||||
import java.net.PasswordAuthentication;
|
import java.net.PasswordAuthentication;
|
||||||
|
import java.net.ProxySelector;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.security.KeyManagementException;
|
import java.security.KeyManagementException;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
@ -90,6 +94,18 @@ public abstract class HttpClient {
|
||||||
Authenticator.setDefault(new SocksProxyAuth(username, password));
|
Authenticator.setDefault(new SocksProxyAuth(username, password));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case PAC:
|
||||||
|
String pacUrl = config.getSettings().pacUrl;
|
||||||
|
if (pacUrl != null && !pacUrl.isEmpty()) {
|
||||||
|
try {
|
||||||
|
UrlPacScriptSource pacSource = new UrlPacScriptSource(pacUrl);
|
||||||
|
ProxySelector pacSelector = new PacProxySelector(pacSource);
|
||||||
|
ProxySelector.setDefault(pacSelector);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn("Failed to load PAC file: {}", e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
case DIRECT:
|
case DIRECT:
|
||||||
default:
|
default:
|
||||||
System.clearProperty(ProxyConstants.HTTP_PROXY_HOST);
|
System.clearProperty(ProxyConstants.HTTP_PROXY_HOST);
|
||||||
|
@ -155,6 +171,10 @@ public abstract class HttpClient {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (config.getSettings().proxyType == ProxyType.PAC) {
|
||||||
|
builder.proxySelector(ProxySelector.getDefault());
|
||||||
|
}
|
||||||
|
|
||||||
ProxyType proxyType = config.getSettings().proxyType;
|
ProxyType proxyType = config.getSettings().proxyType;
|
||||||
if (proxyType == ProxyType.HTTP) {
|
if (proxyType == ProxyType.HTTP) {
|
||||||
String username = config.getSettings().proxyUser;
|
String username = config.getSettings().proxyUser;
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
function FindProxyForURL(url, host) {
|
||||||
|
if (shExpMatch(host, "*stripchat.com")) {
|
||||||
|
return "SOCKS 127.0.0.1:1080";
|
||||||
|
} else if (shExpMatch(host, "*chaturbate.com")) {
|
||||||
|
return "PROXY 127.0.0.1:8080";
|
||||||
|
} else {
|
||||||
|
return "DIRECT";
|
||||||
|
}
|
||||||
|
}
|
|
@ -26,6 +26,12 @@
|
||||||
<outputDirectory>ctbrec</outputDirectory>
|
<outputDirectory>ctbrec</outputDirectory>
|
||||||
<filtered>true</filtered>
|
<filtered>true</filtered>
|
||||||
</file>
|
</file>
|
||||||
|
<file>
|
||||||
|
<source>${project.basedir}/src/assembly/pac.js</source>
|
||||||
|
<outputDirectory>ctbrec</outputDirectory>
|
||||||
|
<filtered>true</filtered>
|
||||||
|
<destName>pac.js</destName>
|
||||||
|
</file>
|
||||||
<file>
|
<file>
|
||||||
<source>${project.basedir}/../CHANGELOG.md</source>
|
<source>${project.basedir}/../CHANGELOG.md</source>
|
||||||
<outputDirectory>ctbrec</outputDirectory>
|
<outputDirectory>ctbrec</outputDirectory>
|
||||||
|
|
Loading…
Reference in New Issue