From 6259b3b50d7dfdef8f34b4facd54aa9625713503 Mon Sep 17 00:00:00 2001 From: yma Date: Mon, 31 Mar 2025 22:47:58 +0800 Subject: [PATCH] Add egress.sites for Indy Config --- ...ContentFilteringTransferDecoratorTest.java | 3 +- pom.xml | 4 +- .../http/IndyGlobalProxyConfigProducer.java | 42 ++++++++++++------- .../indy/subsys/http/conf/IndyHttpConfig.java | 6 +++ 4 files changed, 36 insertions(+), 19 deletions(-) diff --git a/addons/pkg-maven/common/src/test/java/org/commonjava/indy/pkg/maven/content/MavenContentFilteringTransferDecoratorTest.java b/addons/pkg-maven/common/src/test/java/org/commonjava/indy/pkg/maven/content/MavenContentFilteringTransferDecoratorTest.java index ad0c6892ed..4ad9b4117e 100644 --- a/addons/pkg-maven/common/src/test/java/org/commonjava/indy/pkg/maven/content/MavenContentFilteringTransferDecoratorTest.java +++ b/addons/pkg-maven/common/src/test/java/org/commonjava/indy/pkg/maven/content/MavenContentFilteringTransferDecoratorTest.java @@ -34,6 +34,7 @@ import java.io.InputStream; import java.io.OutputStream; +import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; @@ -155,7 +156,7 @@ private Transfer getTestHttpTransfer(final String path, final String content) th assertThat( transfer.exists(), equalTo( false ) ); HttpDownload dl = new HttpDownload( url, location, transfer, new HashMap<>(), new EventMetadata(), - fixture.getHttp().getHttp(), new ObjectMapper(), true, metricRegistry, metricConfig, new NoOpProxySitesCache() ); + fixture.getHttp().getHttp(), new ObjectMapper(), true, metricRegistry, metricConfig, new ArrayList<>(), new NoOpProxySitesCache() ); return dl.call().getTransfer(); } diff --git a/pom.xml b/pom.xml index d01bf5bb11..b09341ecc3 100644 --- a/pom.xml +++ b/pom.xml @@ -94,14 +94,14 @@ 1.5 3.4.0 1.1.4 - 1.19 + 1.20-SNAPSHOT 1.24 3.2.1 1.16 2.13 2.3 - 1.14 + 1.15-SNAPSHOT 1.5.1 1.5 0.13.1 diff --git a/subsys/http/src/main/java/org/commonjava/indy/subsys/http/IndyGlobalProxyConfigProducer.java b/subsys/http/src/main/java/org/commonjava/indy/subsys/http/IndyGlobalProxyConfigProducer.java index 7816f7c445..968b557f89 100644 --- a/subsys/http/src/main/java/org/commonjava/indy/subsys/http/IndyGlobalProxyConfigProducer.java +++ b/subsys/http/src/main/java/org/commonjava/indy/subsys/http/IndyGlobalProxyConfigProducer.java @@ -56,20 +56,6 @@ public GlobalProxyConfig getGlobalProxyConfig() private void setupGlobalProxyConfig() { logger.debug( "Setup global proxy config, host: {}", defaultSiteConfig.getProxyHost() ); - final String allowTypes = defaultSiteConfig.getProxyAllowHttpJobTypes(); - final List list = new ArrayList<>(); - if ( isNotBlank( allowTypes ) ) - { - String[] toks = allowTypes.split( "," ); - for ( String s : toks ) - { - s = s.trim(); - if ( isNotBlank( s ) ) - { - list.add( s ); - } - } - } globalProxyConfig = new GlobalProxyConfig() { @Override @@ -93,16 +79,40 @@ public String getUser() @Override public List getAllowHttpJobTypes() { - return list; + return getList( defaultSiteConfig.getProxyAllowHttpJobTypes() ); + } + + @Override + public List getEgressSites() + { + return getList( defaultSiteConfig.getEgressSites() ); } @Override public String toString() { return String.format( "GlobalProxyConfig [host=%s, port=%s, allowHttpJobTypes=%s]", getHost(), - getPort(), allowTypes ); + getPort(), defaultSiteConfig.getProxyAllowHttpJobTypes() ); } }; logger.debug( "Global proxy config produced: {}", globalProxyConfig ); } + + private List getList( String value ) + { + final List list = new ArrayList<>(); + if ( isNotBlank( value ) ) + { + String[] toks = value.split( "," ); + for ( String s : toks ) + { + s = s.trim(); + if ( isNotBlank( s ) ) + { + list.add( s ); + } + } + } + return list; + } } diff --git a/subsys/http/src/main/java/org/commonjava/indy/subsys/http/conf/IndyHttpConfig.java b/subsys/http/src/main/java/org/commonjava/indy/subsys/http/conf/IndyHttpConfig.java index c5af5a5a30..d0405c35bd 100644 --- a/subsys/http/src/main/java/org/commonjava/indy/subsys/http/conf/IndyHttpConfig.java +++ b/subsys/http/src/main/java/org/commonjava/indy/subsys/http/conf/IndyHttpConfig.java @@ -60,6 +60,8 @@ public class IndyHttpConfig public static final String PROXY_ALLOW_HTTP_JOB_TYPES = "proxy.allow.http.job.types"; + public static final String EGRESS_SITES = "egress.sites"; + public static final String TRUST_TYPE = "trust.type"; public static final String KEY_CERT_PEM = "key.cert.pem"; @@ -105,6 +107,7 @@ public void sectionComplete( String name ) throws ConfigurationException case PROXY_PORT: case PROXY_USER: case PROXY_ALLOW_HTTP_JOB_TYPES: + case EGRESS_SITES: case TRUST_TYPE: case KEY_CERT_PEM: case KEY_CERT_PEM_PATH: @@ -227,6 +230,9 @@ private void withEntry( SiteConfigBuilder siteConfigBuilder, String realKey, Str case PROXY_ALLOW_HTTP_JOB_TYPES: siteConfigBuilder.withProxyAllowHttpJobTypes( value ); break; + case EGRESS_SITES: + siteConfigBuilder.withEgressSites( value ); + break; case TRUST_TYPE: siteConfigBuilder.withTrustType( SiteTrustType.getType( value ) ); break;