Commit 6b2be280 authored by Jujube Orange's avatar Jujube Orange Committed by Bergamote Orange
Browse files

feat(scheduler): can optionnaly use http proxy

parent 675fb0fa
Pipeline #574944 canceled with stages
in 4 minutes and 56 seconds
......@@ -55,6 +55,10 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
......
......@@ -5,6 +5,7 @@ import com.eatthepath.pushy.apns.auth.ApnsSigningKey;
import fr.gouv.stopc.robert.pushnotif.scheduler.apns.MicrometerApnsClientMetricsListener;
import fr.gouv.stopc.robert.pushnotif.scheduler.apns.template.*;
import io.micrometer.core.instrument.MeterRegistry;
import io.netty.handler.proxy.HttpProxyHandler;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
......@@ -45,6 +46,12 @@ public class ApnsClientConfiguration {
)
.setMetricsListener(listener);
if (robertPushServerProperties.getApns().getHttpProxySocketAddress() != null) {
apnsClientBuilder.setProxyHandlerFactory(
() -> new HttpProxyHandler(robertPushServerProperties.getApns().getHttpProxySocketAddress())
);
}
if (robertPushServerProperties.getApns().getTrustedClientCertificateChain() != null) {
apnsClientBuilder.setTrustedServerCertificateChain(
robertPushServerProperties.getApns().getTrustedClientCertificateChain().getInputStream()
......
......@@ -8,11 +8,10 @@ import org.springframework.boot.context.properties.ConstructorBinding;
import org.springframework.core.io.Resource;
import javax.validation.Valid;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Positive;
import javax.validation.constraints.*;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.util.List;
@Value
......@@ -58,6 +57,17 @@ public class RobertPushServerProperties {
Resource trustedClientCertificateChain;
@Pattern(regexp = "|[^:]+:\\d+")
String httpProxy;
public SocketAddress getHttpProxySocketAddress() {
if (null == httpProxy) {
return null;
}
final var host = httpProxy.replaceAll(":.*", "");
final var port = httpProxy.replaceAll(".*:", "");
return new InetSocketAddress(host, Integer.parseInt(port));
}
}
@Value
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment