Skip to content

Commit

Permalink
revert(server): desperate
Browse files Browse the repository at this point in the history
  • Loading branch information
NiccoMlt committed Aug 30, 2024
1 parent 7e5ea16 commit a6bad96
Show file tree
Hide file tree
Showing 33 changed files with 496 additions and 717 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
import static org.carapaceproxy.utils.APIUtils.certificateModeToString;
import static org.carapaceproxy.utils.APIUtils.certificateStateToString;
import static org.carapaceproxy.utils.APIUtils.stringToCertificateMode;
import static org.carapaceproxy.core.ssl.CertificatesUtils.createKeystore;
import static org.carapaceproxy.core.ssl.CertificatesUtils.loadKeyStoreFromFile;
import static org.carapaceproxy.utils.CertificatesUtils.createKeystore;
import static org.carapaceproxy.utils.CertificatesUtils.loadKeyStoreFromFile;
import java.io.IOException;
import java.io.InputStream;
import java.security.GeneralSecurityException;
Expand Down Expand Up @@ -74,7 +74,7 @@
import org.carapaceproxy.server.config.ConfigurationNotValidException;
import org.carapaceproxy.server.config.SSLCertificateConfiguration;
import org.carapaceproxy.server.config.SSLCertificateConfiguration.CertificateMode;
import org.carapaceproxy.core.ssl.CertificatesUtils;
import org.carapaceproxy.utils.CertificatesUtils;

/**
* Access to certificates
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import lombok.Data;
import org.carapaceproxy.client.EndpointKey;
import org.carapaceproxy.core.HttpProxyServer;
import org.carapaceproxy.server.config.NetworkListenerConfiguration;

/**
* Access to listeners
Expand Down Expand Up @@ -57,21 +59,21 @@ public static final class ListenerBean {
@GET
public Map<String, ListenerBean> getAllListeners() {
HttpProxyServer server = (HttpProxyServer) context.getAttribute("server");
return server.getListeners()
.getListeningChannels()
.values()
.stream()
.collect(Collectors.toMap(
channel -> channel.getHostPort().toString(),
channel -> new ListenerBean(
channel.getHostPort().host(),
channel.getHostPort().port(),
channel.getConfig().isSsl(),
channel.getConfig().getSslCiphers(),
channel.getConfig().getSslProtocols(),
channel.getConfig().getDefaultCertificate(),
channel.getTotalRequests()
)));

return server.getListeners().getListeningChannels().entrySet().stream().map(listener -> {
NetworkListenerConfiguration config = listener.getValue().getConfig();
int port = listener.getKey().port();
ListenerBean bean = new ListenerBean(
config.getHost(),
port,
config.isSsl(),
config.getSslCiphers(),
config.getSslProtocols(),
config.getDefaultCertificate(),
(int) listener.getValue().getTotalRequests().get()
);
return Map.entry(EndpointKey.make(config.getHost(), port).getHostPort(), bean);
}).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
package org.carapaceproxy.client;

import lombok.Data;
import org.carapaceproxy.server.config.HostPort;

/**
* Identifier of an endpoint
Expand All @@ -33,10 +32,6 @@ public final class EndpointKey {
private final String host;
private final int port;

public static EndpointKey make(HostPort hostPort) {
return new EndpointKey(hostPort.host(), hostPort.port());
}

public static EndpointKey make(String host, int port) {
return new EndpointKey(host, port);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
import java.util.Base64;
import static org.carapaceproxy.core.ssl.CertificatesUtils.createKeystore;
import static org.carapaceproxy.core.ssl.CertificatesUtils.readChainFromKeystore;
import static org.carapaceproxy.utils.CertificatesUtils.createKeystore;
import static org.carapaceproxy.utils.CertificatesUtils.readChainFromKeystore;

public final class ConfigurationStoreUtils {

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,11 @@ public class HttpProxyServer implements AutoCloseable {
@Getter
private int listenersOffsetPort = 0;

public static HttpProxyServer buildForTests(String host, int port, EndpointMapper mapper, File baseDir) throws ConfigurationNotValidException, InterruptedException {
public static HttpProxyServer buildForTests(String host, int port, EndpointMapper mapper, File baseDir) throws ConfigurationNotValidException {
HttpProxyServer res = new HttpProxyServer(mapper, baseDir.getAbsoluteFile());
res.currentConfiguration.addListener(new NetworkListenerConfiguration(host, port));
res.proxyRequestsManager.reloadConfiguration(res.currentConfiguration, mapper.getBackends().values());
// res.getListeners().reloadConfiguration(res.currentConfiguration); // todo maybe not needed

return res;
}

Expand Down
Loading

0 comments on commit a6bad96

Please sign in to comment.