├── .github ├── CODEOWNERS ├── dependabot.yml └── workflows │ ├── benchmark.yml │ ├── branch_snapshot.yml │ ├── gradle-wrapper-validation.yml │ ├── pr.yml │ ├── release.yml │ ├── snapshot.yml │ └── stale.yml ├── .gitignore ├── .netflixoss ├── CHANGELOG.md ├── LICENSE ├── OSSMETADATA ├── README.md ├── build.gradle ├── codequality └── checkstyle.xml ├── dependencies.lock ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle ├── zuul-core ├── build.gradle ├── dependencies.lock └── src │ ├── jmh │ └── java │ │ └── com │ │ └── netflix │ │ └── zuul │ │ └── message │ │ └── HeadersBenchmark.java │ ├── main │ └── java │ │ └── com │ │ └── netflix │ │ ├── config │ │ ├── DynamicIntegerSetProperty.java │ │ └── PatternListStringProperty.java │ │ ├── netty │ │ └── common │ │ │ ├── AbstrHttpConnectionExpiryHandler.java │ │ │ ├── ByteBufUtil.java │ │ │ ├── CategorizedThreadFactory.java │ │ │ ├── CloseOnIdleStateHandler.java │ │ │ ├── ConnectionCloseChannelAttributes.java │ │ │ ├── ConnectionCloseType.java │ │ │ ├── Http1ConnectionCloseHandler.java │ │ │ ├── Http1ConnectionExpiryHandler.java │ │ │ ├── Http2ConnectionCloseHandler.java │ │ │ ├── Http2ConnectionExpiryHandler.java │ │ │ ├── HttpChannelFlags.java │ │ │ ├── HttpClientLifecycleChannelHandler.java │ │ │ ├── HttpLifecycleChannelHandler.java │ │ │ ├── HttpRequestReadTimeoutEvent.java │ │ │ ├── HttpRequestReadTimeoutHandler.java │ │ │ ├── HttpServerLifecycleChannelHandler.java │ │ │ ├── LeastConnsEventLoopChooserFactory.java │ │ │ ├── RequestResponseCompleteEvent.java │ │ │ ├── SourceAddressChannelHandler.java │ │ │ ├── SslExceptionsHandler.java │ │ │ ├── SwallowSomeHttp2ExceptionsHandler.java │ │ │ ├── accesslog │ │ │ ├── AccessLogChannelHandler.java │ │ │ └── AccessLogPublisher.java │ │ │ ├── channel │ │ │ └── config │ │ │ │ ├── ChannelConfig.java │ │ │ │ ├── ChannelConfigKey.java │ │ │ │ ├── ChannelConfigValue.java │ │ │ │ └── CommonChannelConfigKeys.java │ │ │ ├── http2 │ │ │ └── DynamicHttp2FrameLogger.java │ │ │ ├── metrics │ │ │ ├── EventLoopGroupMetrics.java │ │ │ ├── EventLoopMetrics.java │ │ │ ├── Http2MetricsChannelHandlers.java │ │ │ ├── HttpBodySizeRecordingChannelHandler.java │ │ │ ├── HttpMetricsChannelHandler.java │ │ │ ├── InstrumentedResourceLeakDetector.java │ │ │ └── PerEventLoopMetricsChannelHandler.java │ │ │ ├── proxyprotocol │ │ │ ├── ElbProxyProtocolChannelHandler.java │ │ │ ├── HAProxyMessageChannelHandler.java │ │ │ └── StripUntrustedProxyHeadersHandler.java │ │ │ ├── ssl │ │ │ ├── ServerSslConfig.java │ │ │ └── SslHandshakeInfo.java │ │ │ ├── status │ │ │ └── ServerStatusManager.java │ │ │ └── throttle │ │ │ ├── MaxInboundConnectionsHandler.java │ │ │ ├── RejectionType.java │ │ │ ├── RejectionUtils.java │ │ │ └── RequestRejectedEvent.java │ │ └── zuul │ │ ├── Attrs.java │ │ ├── BasicFilterUsageNotifier.java │ │ ├── BasicRequestCompleteHandler.java │ │ ├── DefaultFilterFactory.java │ │ ├── DynamicFilterLoader.java │ │ ├── ExecutionStatus.java │ │ ├── Filter.java │ │ ├── FilterCategory.java │ │ ├── FilterFactory.java │ │ ├── FilterFileManager.java │ │ ├── FilterLoader.java │ │ ├── FilterUsageNotifier.java │ │ ├── RequestCompleteHandler.java │ │ ├── StaticFilterLoader.java │ │ ├── ZuulApplicationInfo.java │ │ ├── constants │ │ ├── ZuulConstants.java │ │ └── ZuulHeaders.java │ │ ├── context │ │ ├── CommonContextKeys.java │ │ ├── Debug.java │ │ ├── SessionCleaner.java │ │ ├── SessionContext.java │ │ ├── SessionContextDecorator.java │ │ ├── SessionContextFactory.java │ │ └── ZuulSessionContextDecorator.java │ │ ├── exception │ │ ├── ErrorType.java │ │ ├── OutboundErrorType.java │ │ ├── OutboundException.java │ │ ├── RequestExpiredException.java │ │ ├── ZuulException.java │ │ └── ZuulFilterConcurrencyExceededException.java │ │ ├── filters │ │ ├── BaseFilter.java │ │ ├── BaseSyncFilter.java │ │ ├── Endpoint.java │ │ ├── FilterError.java │ │ ├── FilterRegistry.java │ │ ├── FilterSyncType.java │ │ ├── FilterType.java │ │ ├── MutableFilterRegistry.java │ │ ├── ShouldFilter.java │ │ ├── SyncZuulFilter.java │ │ ├── SyncZuulFilterAdapter.java │ │ ├── ZuulFilter.java │ │ ├── common │ │ │ ├── GZipResponseFilter.java │ │ │ └── SurgicalDebugFilter.java │ │ ├── endpoint │ │ │ ├── MissingEndpointHandlingFilter.java │ │ │ └── ProxyEndpoint.java │ │ ├── http │ │ │ ├── HttpInboundFilter.java │ │ │ ├── HttpInboundSyncFilter.java │ │ │ ├── HttpOutboundFilter.java │ │ │ ├── HttpOutboundSyncFilter.java │ │ │ └── HttpSyncEndpoint.java │ │ └── passport │ │ │ ├── InboundPassportStampingFilter.java │ │ │ ├── OutboundPassportStampingFilter.java │ │ │ └── PassportStampingFilter.java │ │ ├── logging │ │ └── Http2FrameLoggingPerClientIpHandler.java │ │ ├── message │ │ ├── Header.java │ │ ├── HeaderName.java │ │ ├── Headers.java │ │ ├── ZuulMessage.java │ │ ├── ZuulMessageImpl.java │ │ ├── http │ │ │ ├── Cookies.java │ │ │ ├── HttpHeaderNames.java │ │ │ ├── HttpHeaderNamesCache.java │ │ │ ├── HttpQueryParams.java │ │ │ ├── HttpRequestInfo.java │ │ │ ├── HttpRequestMessage.java │ │ │ ├── HttpRequestMessageImpl.java │ │ │ ├── HttpResponseInfo.java │ │ │ ├── HttpResponseMessage.java │ │ │ └── HttpResponseMessageImpl.java │ │ └── util │ │ │ └── HttpRequestBuilder.java │ │ ├── metrics │ │ ├── OriginStats.java │ │ └── OriginStatsFactory.java │ │ ├── monitoring │ │ ├── ConnCounter.java │ │ ├── ConnTimer.java │ │ ├── MonitoringHelper.java │ │ ├── Tracer.java │ │ └── TracerFactory.java │ │ ├── netty │ │ ├── ChannelUtils.java │ │ ├── NettyRequestAttemptFactory.java │ │ ├── RequestCancelledEvent.java │ │ ├── SpectatorUtils.java │ │ ├── connectionpool │ │ │ ├── BasicRequestStat.java │ │ │ ├── ClientChannelManager.java │ │ │ ├── ClientTimeoutHandler.java │ │ │ ├── ConnectionPoolConfig.java │ │ │ ├── ConnectionPoolConfigImpl.java │ │ │ ├── ConnectionPoolHandler.java │ │ │ ├── ConnectionPoolMetrics.java │ │ │ ├── DefaultClientChannelManager.java │ │ │ ├── DefaultOriginChannelInitializer.java │ │ │ ├── IConnectionPool.java │ │ │ ├── NettyClientConnectionFactory.java │ │ │ ├── OriginChannelInitializer.java │ │ │ ├── OriginConnectException.java │ │ │ ├── PerServerConnectionPool.java │ │ │ ├── PooledConnection.java │ │ │ ├── PooledConnectionFactory.java │ │ │ ├── RequestStat.java │ │ │ └── ZuulNettyExceptionMapper.java │ │ ├── filter │ │ │ ├── BaseZuulFilterRunner.java │ │ │ ├── FilterRunner.java │ │ │ ├── ZuulEndPointRunner.java │ │ │ ├── ZuulFilterChainHandler.java │ │ │ └── ZuulFilterChainRunner.java │ │ ├── insights │ │ │ ├── PassportLoggingHandler.java │ │ │ ├── PassportStateHttpClientHandler.java │ │ │ ├── PassportStateHttpServerHandler.java │ │ │ ├── PassportStateListener.java │ │ │ ├── PassportStateOriginHandler.java │ │ │ └── ServerStateHandler.java │ │ ├── ratelimiting │ │ │ └── NullChannelHandlerProvider.java │ │ ├── server │ │ │ ├── BaseServerStartup.java │ │ │ ├── BaseZuulChannelInitializer.java │ │ │ ├── ClientConnectionsShutdown.java │ │ │ ├── ClientRequestReceiver.java │ │ │ ├── ClientResponseWriter.java │ │ │ ├── DefaultEventLoopConfig.java │ │ │ ├── DirectMemoryMonitor.java │ │ │ ├── EventLoopConfig.java │ │ │ ├── Http1MutualSslChannelInitializer.java │ │ │ ├── ListenerSpec.java │ │ │ ├── MethodBinding.java │ │ │ ├── NamedSocketAddress.java │ │ │ ├── OriginResponseReceiver.java │ │ │ ├── Server.java │ │ │ ├── ServerTimeout.java │ │ │ ├── SocketAddressProperty.java │ │ │ ├── ZuulDependencyKeys.java │ │ │ ├── ZuulServerChannelInitializer.java │ │ │ ├── http2 │ │ │ │ ├── DummyChannelHandler.java │ │ │ │ ├── Http2Configuration.java │ │ │ │ ├── Http2ConnectionErrorHandler.java │ │ │ │ ├── Http2ContentLengthEnforcingHandler.java │ │ │ │ ├── Http2OrHttpHandler.java │ │ │ │ ├── Http2ResetFrameHandler.java │ │ │ │ ├── Http2SslChannelInitializer.java │ │ │ │ ├── Http2StreamErrorHandler.java │ │ │ │ ├── Http2StreamHeaderCleaner.java │ │ │ │ └── Http2StreamInitializer.java │ │ │ ├── psk │ │ │ │ ├── ClientPSKIdentityInfo.java │ │ │ │ ├── ExternalTlsPskProvider.java │ │ │ │ ├── PskCreationFailureException.java │ │ │ │ ├── TlsPskDecoder.java │ │ │ │ ├── TlsPskHandler.java │ │ │ │ ├── TlsPskServerProtocol.java │ │ │ │ ├── TlsPskUtils.java │ │ │ │ └── ZuulPskServer.java │ │ │ ├── push │ │ │ │ ├── PushAuthHandler.java │ │ │ │ ├── PushChannelInitializer.java │ │ │ │ ├── PushClientProtocolHandler.java │ │ │ │ ├── PushConnection.java │ │ │ │ ├── PushConnectionRegistry.java │ │ │ │ ├── PushMessageFactory.java │ │ │ │ ├── PushMessageSender.java │ │ │ │ ├── PushMessageSenderInitializer.java │ │ │ │ ├── PushProtocol.java │ │ │ │ ├── PushRegistrationHandler.java │ │ │ │ └── PushUserAuth.java │ │ │ └── ssl │ │ │ │ └── SslHandshakeInfoHandler.java │ │ ├── ssl │ │ │ ├── BaseSslContextFactory.java │ │ │ ├── ClientSslContextFactory.java │ │ │ └── SslContextFactory.java │ │ └── timeouts │ │ │ ├── HttpHeadersTimeoutHandler.java │ │ │ └── OriginTimeoutManager.java │ │ ├── niws │ │ ├── RequestAttempt.java │ │ └── RequestAttempts.java │ │ ├── origins │ │ ├── BasicNettyOrigin.java │ │ ├── BasicNettyOriginManager.java │ │ ├── InstrumentedOrigin.java │ │ ├── NettyOrigin.java │ │ ├── Origin.java │ │ ├── OriginConcurrencyExceededException.java │ │ ├── OriginManager.java │ │ ├── OriginName.java │ │ └── OriginThrottledException.java │ │ ├── passport │ │ ├── CurrentPassport.java │ │ ├── PassportItem.java │ │ ├── PassportState.java │ │ └── StartAndEnd.java │ │ ├── plugins │ │ └── Tracer.java │ │ ├── stats │ │ ├── AmazonInfoHolder.java │ │ ├── BasicRequestMetricsPublisher.java │ │ ├── ErrorStatsData.java │ │ ├── ErrorStatsManager.java │ │ ├── NamedCountingMonitor.java │ │ ├── RequestMetricsPublisher.java │ │ ├── RouteStatusCodeMonitor.java │ │ ├── StatsManager.java │ │ ├── monitoring │ │ │ ├── Monitor.java │ │ │ ├── MonitorRegistry.java │ │ │ └── NamedCount.java │ │ └── status │ │ │ ├── StatusCategory.java │ │ │ ├── StatusCategoryGroup.java │ │ │ ├── StatusCategoryUtils.java │ │ │ ├── ZuulStatusCategory.java │ │ │ └── ZuulStatusCategoryGroup.java │ │ └── util │ │ ├── Gzipper.java │ │ ├── HttpUtils.java │ │ ├── JsonUtility.java │ │ ├── ProxyUtils.java │ │ └── VipUtils.java │ └── test │ └── java │ └── com │ └── netflix │ ├── netty │ └── common │ │ ├── CloseOnIdleStateHandlerTest.java │ │ ├── HttpServerLifecycleChannelHandlerTest.java │ │ ├── SourceAddressChannelHandlerTest.java │ │ ├── metrics │ │ └── InstrumentedResourceLeakDetectorTest.java │ │ ├── proxyprotocol │ │ ├── ElbProxyProtocolChannelHandlerTest.java │ │ ├── HAProxyMessageChannelHandlerTest.java │ │ └── StripUntrustedProxyHeadersHandlerTest.java │ │ └── throttle │ │ └── MaxInboundConnectionsHandlerTest.java │ └── zuul │ ├── AttrsTest.java │ ├── DynamicFilterLoaderTest.java │ ├── StaticFilterLoaderTest.java │ ├── com │ └── netflix │ │ └── zuul │ │ └── netty │ │ └── server │ │ └── push │ │ └── PushConnectionTest.java │ ├── context │ ├── DebugTest.java │ └── SessionContextTest.java │ ├── filters │ ├── BaseFilterTest.java │ ├── common │ │ └── GZipResponseFilterTest.java │ └── endpoint │ │ └── ProxyEndpointTest.java │ ├── message │ ├── HeadersTest.java │ ├── ZuulMessageImplTest.java │ └── http │ │ ├── HttpQueryParamsTest.java │ │ ├── HttpRequestMessageImplTest.java │ │ └── HttpResponseMessageImplTest.java │ ├── monitoring │ ├── ConnCounterTest.java │ └── ConnTimerTest.java │ ├── netty │ ├── connectionpool │ │ ├── ClientTimeoutHandlerTest.java │ │ ├── ConnectionPoolConfigImplTest.java │ │ ├── ConnectionPoolMetricsTest.java │ │ ├── DefaultClientChannelManagerTest.java │ │ └── PerServerConnectionPoolTest.java │ ├── filter │ │ ├── BaseZuulFilterRunnerTest.java │ │ ├── ZuulEndPointRunnerTest.java │ │ └── ZuulFilterChainRunnerTest.java │ ├── insights │ │ └── ServerStateHandlerTest.java │ ├── server │ │ ├── BaseZuulChannelInitializerTest.java │ │ ├── ClientConnectionsShutdownTest.java │ │ ├── ClientRequestReceiverTest.java │ │ ├── ClientResponseWriterTest.java │ │ ├── IoUringTest.java │ │ ├── ServerTest.java │ │ ├── SocketAddressPropertyTest.java │ │ ├── http2 │ │ │ ├── Http2ConnectionErrorHandlerTest.java │ │ │ ├── Http2ContentLengthEnforcingHandlerTest.java │ │ │ └── Http2OrHttpHandlerTest.java │ │ ├── push │ │ │ ├── PushAuthHandlerTest.java │ │ │ ├── PushConnectionRegistryTest.java │ │ │ ├── PushMessageSenderInitializerTest.java │ │ │ └── PushRegistrationHandlerTest.java │ │ └── ssl │ │ │ └── SslHandshakeInfoHandlerTest.java │ ├── ssl │ │ ├── BaseSslContextFactoryTest.java │ │ ├── ClientSslContextFactoryTest.java │ │ └── OpenSslTest.java │ └── timeouts │ │ └── OriginTimeoutManagerTest.java │ ├── niws │ └── RequestAttemptTest.java │ ├── origins │ └── OriginNameTest.java │ ├── passport │ └── CurrentPassportTest.java │ ├── stats │ ├── ErrorStatsDataTest.java │ ├── ErrorStatsManagerTest.java │ ├── RouteStatusCodeMonitorTest.java │ ├── StatsManagerTest.java │ └── status │ │ └── ZuulStatusCategoryTest.java │ └── util │ ├── HttpUtilsTest.java │ ├── JsonUtilityTest.java │ └── VipUtilsTest.java ├── zuul-discovery ├── build.gradle ├── dependencies.lock └── src │ ├── main │ └── java │ │ └── com │ │ └── netflix │ │ └── zuul │ │ ├── discovery │ │ ├── DiscoveryResult.java │ │ ├── DynamicServerResolver.java │ │ ├── NonDiscoveryServer.java │ │ ├── ResolverResult.java │ │ └── SimpleMetaInfo.java │ │ └── resolver │ │ ├── Resolver.java │ │ └── ResolverListener.java │ └── test │ └── java │ └── com │ └── netflix │ └── zuul │ └── discovery │ ├── DiscoveryResultTest.java │ └── DynamicServerResolverTest.java ├── zuul-integration-test ├── build.gradle ├── dependencies.lock └── src │ └── test │ ├── java │ └── com │ │ └── netflix │ │ ├── netty │ │ └── common │ │ │ └── metrics │ │ │ └── CustomLeakDetector.java │ │ └── zuul │ │ └── integration │ │ ├── IntegrationTest.java │ │ └── server │ │ ├── Bootstrap.java │ │ ├── HeaderNames.java │ │ ├── OriginServerList.java │ │ ├── ServerStartup.java │ │ ├── TestUtil.java │ │ └── filters │ │ ├── BodyUtil.java │ │ ├── InboundRoutesFilter.java │ │ ├── NeedsBodyBufferedInboundFilter.java │ │ ├── NeedsBodyBufferedOutboundFilter.java │ │ ├── RequestHeaderFilter.java │ │ └── ResponseHeaderFilter.java │ └── resources │ └── log4j2-test.xml ├── zuul-processor ├── build.gradle ├── dependencies.lock └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── netflix │ │ │ └── zuul │ │ │ └── filters │ │ │ └── processor │ │ │ └── FilterProcessor.java │ └── resources │ │ └── META-INF │ │ ├── gradle │ │ └── incremental.annotation.processors │ │ └── services │ │ └── javax.annotation.processing.Processor │ └── test │ └── java │ └── com │ └── netflix │ └── zuul │ └── filters │ └── processor │ ├── FilterProcessorTest.java │ ├── TestFilter.java │ ├── TopLevelFilter.java │ ├── override │ ├── SubpackageFilter.java │ └── package-info.java │ └── subpackage │ └── OverrideFilter.java └── zuul-sample ├── build.gradle ├── dependencies.lock └── src └── main ├── java └── com │ └── netflix │ └── zuul │ └── sample │ ├── Bootstrap.java │ ├── SampleServerStartup.java │ ├── SampleService.java │ ├── filters │ ├── Debug.java │ ├── endpoint │ │ └── Healthcheck.java │ ├── inbound │ │ ├── DebugRequest.java │ │ ├── Routes.java │ │ └── SampleServiceFilter.java │ └── outbound │ │ └── ZuulResponseFilter.java │ └── push │ ├── SamplePushAuthHandler.java │ ├── SamplePushMessageSender.java │ ├── SamplePushMessageSenderInitializer.java │ ├── SamplePushUserAuth.java │ ├── SampleSSEPushChannelInitializer.java │ ├── SampleSSEPushClientProtocolHandler.java │ ├── SampleWebSocketPushChannelInitializer.java │ └── SampleWebSocketPushClientProtocolHandler.java └── resources ├── application-benchmark.properties ├── application-test.properties ├── application.properties ├── log4j2.xml └── ssl ├── client.cert ├── client.key ├── server.cert ├── server.key ├── truststore.jks └── truststore.key /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Default reviewers for Zuul OSS 2 | * @argha-c @jguerra @gavinbunney @lalernehl @lindseyreynolds @connorworley 3 | 4 | # Note: exclusions aren't well supported atm. 5 | # If needed, use workflows to exclude specific files from review. 6 | 7 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "gradle" 4 | directory: "/" 5 | schedule: 6 | interval: "daily" 7 | - package-ecosystem: "github-actions" 8 | directory: "/" 9 | schedule: 10 | interval: "daily" 11 | -------------------------------------------------------------------------------- /.github/workflows/benchmark.yml: -------------------------------------------------------------------------------- 1 | name: benchmark 2 | 3 | on: 4 | workflow_dispatch: 5 | 6 | permissions: 7 | contents: read 8 | 9 | env: 10 | JDK: '21' 11 | DISTRIBUTION: 'zulu' 12 | GRADLE_COMMAND: './gradlew --no-daemon' 13 | 14 | jobs: 15 | benchmark: 16 | runs-on: ubuntu-latest 17 | steps: 18 | - uses: actions/checkout@v4 19 | - name: Set up JDK ${{ env.JDK }} 20 | uses: actions/setup-java@v4 21 | with: 22 | java-version: ${{ env.JDK }} 23 | distribution: ${{ env.DISTRIBUTION }} 24 | - name: JMH 25 | run: ${{ env.GRADLE_COMMAND }} clean :zuul-core:jmh 26 | -------------------------------------------------------------------------------- /.github/workflows/branch_snapshot.yml: -------------------------------------------------------------------------------- 1 | name: Branch Snapshot 2 | 3 | on: 4 | workflow_dispatch: 5 | inputs: 6 | branch: 7 | description: 'Branch to publish snapshot of' 8 | required: true 9 | default: 'master' 10 | repository: 11 | description: 'Repository name (override for forks)' 12 | required: false 13 | default: Netflix/zuul 14 | version: 15 | description: 'The version number to use' 16 | required: true 17 | 18 | jobs: 19 | build: 20 | runs-on: ubuntu-latest 21 | steps: 22 | - name: Setup Git 23 | run: | 24 | git config --global user.name 'Zuul Build' 25 | git config --global user.email 'zuul-build@netflix.com' 26 | - uses: actions/checkout@v4 27 | with: 28 | fetch-depth: 0 29 | ref: ${{ github.event.inputs.branch }} 30 | repository: ${{ github.event.inputs.repository }} 31 | - name: Set up JDK 32 | uses: actions/setup-java@v4 33 | with: 34 | distribution: 'temurin' 35 | java-version: 21 36 | cache: 'gradle' 37 | - name: Build snapshot 38 | run: ./gradlew build snapshot -Prelease.version="$BUILD_VERSION" 39 | env: 40 | BUILD_VERSION: ${{ github.event.inputs.version }} 41 | NETFLIX_OSS_SIGNING_KEY: ${{ secrets.ORG_SIGNING_KEY }} 42 | NETFLIX_OSS_SIGNING_PASSWORD: ${{ secrets.ORG_SIGNING_PASSWORD }} 43 | NETFLIX_OSS_REPO_USERNAME: ${{ secrets.ORG_NETFLIXOSS_USERNAME }} 44 | NETFLIX_OSS_REPO_PASSWORD: ${{ secrets.ORG_NETFLIXOSS_PASSWORD }} 45 | -------------------------------------------------------------------------------- /.github/workflows/gradle-wrapper-validation.yml: -------------------------------------------------------------------------------- 1 | name: "Validate Gradle Wrapper" 2 | on: [push, pull_request] 3 | 4 | jobs: 5 | validation: 6 | name: "Gradle wrapper validation" 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/checkout@v4 10 | - uses: gradle/wrapper-validation-action@v3 11 | -------------------------------------------------------------------------------- /.github/workflows/pr.yml: -------------------------------------------------------------------------------- 1 | name: PR Build 2 | 3 | on: [pull_request] 4 | 5 | jobs: 6 | build: 7 | runs-on: ubuntu-latest 8 | strategy: 9 | matrix: 10 | java: [21] 11 | steps: 12 | - uses: actions/checkout@v4 13 | with: 14 | fetch-depth: 0 15 | - name: Set up JDK ${{ matrix.java }} 16 | uses: actions/setup-java@v4 17 | with: 18 | distribution: 'zulu' 19 | java-version: ${{ matrix.java }} 20 | cache: 'gradle' 21 | - name: Build 22 | run: | 23 | sudo env "PATH=$PATH" bash -c "ulimit -l 65536 && ulimit -a && ./gradlew --no-daemon build" 24 | echo "Status of build: $?" 25 | validation: 26 | name: "Gradle Validation" 27 | runs-on: ubuntu-latest 28 | steps: 29 | - uses: actions/checkout@v4 30 | - uses: gradle/wrapper-validation-action@v3 31 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | 3 | on: 4 | push: 5 | tags: 6 | - v[0-9]+.[0-9]+.[0-9]+ 7 | - v[0-9]+.[0-9]+.[0-9]+-rc.[0-9]+ 8 | 9 | jobs: 10 | build: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - name: Setup Git 14 | run: | 15 | git config --global user.name 'Zuul Build' 16 | git config --global user.email 'zuul-build@netflix.com' 17 | - uses: actions/checkout@v4 18 | - uses: gradle/wrapper-validation-action@v3 19 | - name: Set up JDK 20 | uses: actions/setup-java@v4 21 | with: 22 | distribution: 'temurin' 23 | java-version: 21 24 | cache: 'gradle' 25 | - name: Build candidate 26 | if: contains(github.ref, '-rc.') 27 | run: ./gradlew --info --stacktrace -Prelease.useLastTag=true candidate 28 | env: 29 | NETFLIX_OSS_SIGNING_KEY: ${{ secrets.ORG_SIGNING_KEY }} 30 | NETFLIX_OSS_SIGNING_PASSWORD: ${{ secrets.ORG_SIGNING_PASSWORD }} 31 | NETFLIX_OSS_REPO_USERNAME: ${{ secrets.ORG_NETFLIXOSS_USERNAME }} 32 | NETFLIX_OSS_REPO_PASSWORD: ${{ secrets.ORG_NETFLIXOSS_PASSWORD }} 33 | - name: Build release 34 | if: (!contains(github.ref, '-rc.')) 35 | run: ./gradlew --info -Prelease.useLastTag=true final 36 | env: 37 | NETFLIX_OSS_SONATYPE_USERNAME: ${{ secrets.ORG_SONATYPE_USERNAME }} 38 | NETFLIX_OSS_SONATYPE_PASSWORD: ${{ secrets.ORG_SONATYPE_PASSWORD }} 39 | NETFLIX_OSS_SIGNING_KEY: ${{ secrets.ORG_SIGNING_KEY }} 40 | NETFLIX_OSS_SIGNING_PASSWORD: ${{ secrets.ORG_SIGNING_PASSWORD }} 41 | NETFLIX_OSS_REPO_USERNAME: ${{ secrets.ORG_NETFLIXOSS_USERNAME }} 42 | NETFLIX_OSS_REPO_PASSWORD: ${{ secrets.ORG_NETFLIXOSS_PASSWORD }} 43 | -------------------------------------------------------------------------------- /.github/workflows/snapshot.yml: -------------------------------------------------------------------------------- 1 | name: Snapshot 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - name: Setup Git 13 | run: | 14 | git config --global user.name 'Zuul Build' 15 | git config --global user.email 'zuul-build@netflix.com' 16 | - uses: actions/checkout@v4 17 | with: 18 | fetch-depth: 0 19 | - name: Set up JDK 20 | uses: actions/setup-java@v4 21 | with: 22 | distribution: 'temurin' 23 | java-version: 21 24 | cache: 'gradle' 25 | - name: Build snapshot 26 | run: ./gradlew build snapshot 27 | env: 28 | NETFLIX_OSS_SIGNING_KEY: ${{ secrets.ORG_SIGNING_KEY }} 29 | NETFLIX_OSS_SIGNING_PASSWORD: ${{ secrets.ORG_SIGNING_PASSWORD }} 30 | NETFLIX_OSS_REPO_USERNAME: ${{ secrets.ORG_NETFLIXOSS_USERNAME }} 31 | NETFLIX_OSS_REPO_PASSWORD: ${{ secrets.ORG_NETFLIXOSS_PASSWORD }} 32 | -------------------------------------------------------------------------------- /.github/workflows/stale.yml: -------------------------------------------------------------------------------- 1 | name: 'Close stale issues and PRs' 2 | on: 3 | schedule: 4 | - cron: "*/10 5 * * *" 5 | 6 | jobs: 7 | stale: 8 | runs-on: ubuntu-latest 9 | permissions: 10 | issues: write 11 | pull-requests: write 12 | steps: 13 | - uses: actions/stale@v9 14 | with: 15 | stale-issue-message: 'This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.' 16 | stale-pr-message: 'This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.' 17 | close-issue-message: 'This issue was closed because it has been stalled for 7 days with no activity.' 18 | close-pr-message: 'This PR was closed because it has been stalled for 7 days with no activity.' -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled source # 2 | ################### 3 | *.com 4 | *.class 5 | *.dll 6 | *.exe 7 | *.o 8 | *.so 9 | 10 | # Packages # 11 | ############ 12 | # it's better to unpack these files and commit the raw source 13 | # git has its own built in compression methods 14 | *.7z 15 | *.dmg 16 | *.gz 17 | *.iso 18 | *.jar 19 | *.rar 20 | *.tar 21 | *.zip 22 | 23 | # Logs and databases # 24 | ###################### 25 | *.log 26 | 27 | # OS generated files # 28 | ###################### 29 | .DS_Store* 30 | ehthumbs.db 31 | Icon? 32 | Thumbs.db 33 | 34 | # Editor Files # 35 | ################ 36 | *~ 37 | *.swp 38 | 39 | # Gradle Files # 40 | ################ 41 | .gradle 42 | 43 | # Build output directies 44 | /target 45 | */target 46 | /build 47 | */build 48 | .m2 49 | /classes 50 | # IntelliJ specific files/directories 51 | out 52 | .idea 53 | *.ipr 54 | *.iws 55 | *.iml 56 | atlassian-ide-plugin.xml 57 | 58 | # Visual Studio Code 59 | .vscode 60 | 61 | # Java heap profile 62 | *.hprof 63 | 64 | # Eclipse specific files/directories 65 | .classpath 66 | .project 67 | .settings 68 | .metadata 69 | 70 | zuul-sample/src/main/generated/ 71 | 72 | # NetBeans specific files/directories 73 | .nbattrs 74 | 75 | # publishing secrets 76 | secrets/signing-key 77 | -------------------------------------------------------------------------------- /.netflixoss: -------------------------------------------------------------------------------- 1 | jdk=8 2 | 3 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Netflix/zuul/dd8e8870cac4ee4a1683d8e2d9ee34cd53631866/CHANGELOG.md -------------------------------------------------------------------------------- /OSSMETADATA: -------------------------------------------------------------------------------- 1 | osslifecycle=active 2 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | versions_ribbon=2.4.4 2 | versions_netty=4.1.119.Final 3 | versions_netty_io_uring=0.0.26.Final 4 | versions_brotli4j=1.16.0 5 | release.scope=patch 6 | release.version=3.0.0-SNAPSHOT 7 | org.gradle.jvmargs=-Xms1g -Xmx2g 8 | 9 | com.netflix.testcontainers-cloud.enabled=false 10 | 11 | palantir.native.formatter=true 12 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Netflix/zuul/dd8e8870cac4ee4a1683d8e2d9ee34cd53631866/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name='zuul' 2 | 3 | include 'zuul-core' 4 | include 'zuul-processor' 5 | include 'zuul-sample' 6 | include 'zuul-discovery' 7 | include 'zuul-integration-test' 8 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/config/DynamicIntegerSetProperty.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.config; 18 | 19 | import java.util.Set; 20 | 21 | public class DynamicIntegerSetProperty extends DynamicSetProperty { 22 | public DynamicIntegerSetProperty(String propName, String defaultValue) { 23 | super(propName, defaultValue); 24 | } 25 | 26 | public DynamicIntegerSetProperty(String propName, String defaultValue, String delimiterRegex) { 27 | super(propName, defaultValue, delimiterRegex); 28 | } 29 | 30 | public DynamicIntegerSetProperty(String propName, Set defaultValue) { 31 | super(propName, defaultValue); 32 | } 33 | 34 | public DynamicIntegerSetProperty(String propName, Set defaultValue, String delimiterRegex) { 35 | super(propName, defaultValue, delimiterRegex); 36 | } 37 | 38 | @Override 39 | protected Integer from(String value) { 40 | return Integer.valueOf(value); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/netty/common/CategorizedThreadFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.netty.common; 18 | 19 | import io.netty.util.concurrent.FastThreadLocalThread; 20 | import java.util.concurrent.ThreadFactory; 21 | 22 | /** 23 | * User: Mike Smith 24 | * Date: 6/8/16 25 | * Time: 11:49 AM 26 | */ 27 | public class CategorizedThreadFactory implements ThreadFactory { 28 | private final String category; 29 | private int num = 0; 30 | 31 | public CategorizedThreadFactory(String category) { 32 | super(); 33 | this.category = category; 34 | } 35 | 36 | @Override 37 | public Thread newThread(Runnable r) { 38 | FastThreadLocalThread t = new FastThreadLocalThread(r, category + "-" + num++); 39 | return t; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/netty/common/CloseOnIdleStateHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Netflix, Inc. 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 5 | * the License. You may obtain a copy of the License at 6 | *

7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | *

9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package com.netflix.netty.common; 14 | 15 | import com.netflix.spectator.api.Counter; 16 | import com.netflix.spectator.api.Registry; 17 | import io.netty.channel.ChannelHandlerContext; 18 | import io.netty.channel.ChannelInboundHandlerAdapter; 19 | import io.netty.handler.timeout.IdleStateEvent; 20 | 21 | /** 22 | * Just listens for the IdleStateEvent and closes the channel if received. 23 | */ 24 | public class CloseOnIdleStateHandler extends ChannelInboundHandlerAdapter { 25 | 26 | private final Counter counter; 27 | 28 | public CloseOnIdleStateHandler(Registry registry, String metricId) { 29 | this.counter = registry.counter("server.connections.idle.timeout", "id", metricId); 30 | } 31 | 32 | @Override 33 | public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { 34 | super.userEventTriggered(ctx, evt); 35 | 36 | if (evt instanceof IdleStateEvent) { 37 | counter.increment(); 38 | ctx.close(); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/netty/common/ConnectionCloseType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.netty.common; 18 | 19 | import io.netty.channel.Channel; 20 | 21 | /** 22 | * User: michaels@netflix.com 23 | * Date: 2/8/17 24 | * Time: 2:04 PM 25 | */ 26 | public enum ConnectionCloseType { 27 | IMMEDIATE, 28 | GRACEFUL, 29 | DELAYED_GRACEFUL; 30 | 31 | public static ConnectionCloseType fromChannel(Channel ch) { 32 | ConnectionCloseType type = 33 | ch.attr(ConnectionCloseChannelAttributes.CLOSE_TYPE).get(); 34 | if (type == null) { 35 | // Default to immediate. 36 | type = ConnectionCloseType.IMMEDIATE; 37 | } 38 | return type; 39 | } 40 | 41 | public static void setForChannel(Channel ch, ConnectionCloseType type) { 42 | ch.attr(ConnectionCloseChannelAttributes.CLOSE_TYPE).set(type); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/netty/common/Http1ConnectionExpiryHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.netty.common; 18 | 19 | import io.netty.handler.codec.http.HttpResponse; 20 | 21 | /** 22 | * User: michaels@netflix.com 23 | * Date: 2/8/17 24 | * Time: 9:58 AM 25 | */ 26 | public class Http1ConnectionExpiryHandler extends AbstrHttpConnectionExpiryHandler { 27 | public Http1ConnectionExpiryHandler(int maxRequests, int maxRequestsUnderBrownout, int maxExpiry) { 28 | super(ConnectionCloseType.GRACEFUL, maxRequestsUnderBrownout, maxRequests, maxExpiry); 29 | } 30 | 31 | @Override 32 | protected boolean isResponseHeaders(Object msg) { 33 | return msg instanceof HttpResponse; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/netty/common/Http2ConnectionExpiryHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.netty.common; 18 | 19 | import io.netty.channel.ChannelHandler; 20 | import io.netty.handler.codec.http2.Http2HeadersFrame; 21 | 22 | /** 23 | * This needs to be inserted in the pipeline after the Http2 Codex, but before any h2->h1 conversion. 24 | * 25 | * User: michaels@netflix.com 26 | * Date: 2/8/17 27 | * Time: 9:58 AM 28 | */ 29 | @ChannelHandler.Sharable 30 | public class Http2ConnectionExpiryHandler extends AbstrHttpConnectionExpiryHandler { 31 | public Http2ConnectionExpiryHandler(int maxRequests, int maxRequestsUnderBrownout, int maxExpiry) { 32 | super(ConnectionCloseType.DELAYED_GRACEFUL, maxRequestsUnderBrownout, maxRequests, maxExpiry); 33 | } 34 | 35 | @Override 36 | protected boolean isResponseHeaders(Object msg) { 37 | return msg instanceof Http2HeadersFrame; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/netty/common/HttpRequestReadTimeoutEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.netty.common; 18 | 19 | /** 20 | * Indicates a timeout in reading the full http request. 21 | * 22 | * ie. time between receiving request headers and LastHttpContent of request body. 23 | */ 24 | public class HttpRequestReadTimeoutEvent { 25 | public static final HttpRequestReadTimeoutEvent INSTANCE = new HttpRequestReadTimeoutEvent(); 26 | } 27 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/netty/common/RequestResponseCompleteEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.netty.common; 18 | 19 | /** 20 | * User: michaels@netflix.com 21 | * Date: 5/24/16 22 | * Time: 1:04 PM 23 | */ 24 | public class RequestResponseCompleteEvent {} 25 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/netty/common/channel/config/ChannelConfigKey.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.netty.common.channel.config; 18 | 19 | /** 20 | * User: michaels@netflix.com 21 | * Date: 2/8/17 22 | * Time: 6:17 PM 23 | */ 24 | public class ChannelConfigKey { 25 | private final String key; 26 | private final T defaultValue; 27 | 28 | public ChannelConfigKey(String key, T defaultValue) { 29 | this.key = key; 30 | this.defaultValue = defaultValue; 31 | } 32 | 33 | public ChannelConfigKey(String key) { 34 | this.key = key; 35 | this.defaultValue = null; 36 | } 37 | 38 | public String key() { 39 | return key; 40 | } 41 | 42 | public T defaultValue() { 43 | return defaultValue; 44 | } 45 | 46 | public boolean hasDefaultValue() { 47 | return defaultValue != null; 48 | } 49 | 50 | @Override 51 | public String toString() { 52 | return "ChannelConfigKey{" + "key='" + key + '\'' + ", defaultValue=" + defaultValue + '}'; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/netty/common/channel/config/ChannelConfigValue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.netty.common.channel.config; 18 | 19 | /** 20 | * User: michaels@netflix.com 21 | * Date: 2/8/17 22 | * Time: 6:41 PM 23 | */ 24 | public class ChannelConfigValue { 25 | private final ChannelConfigKey key; 26 | private final T value; 27 | 28 | public ChannelConfigValue(ChannelConfigKey key, T value) { 29 | this.key = key; 30 | this.value = value; 31 | } 32 | 33 | public ChannelConfigKey key() { 34 | return key; 35 | } 36 | 37 | public T value() { 38 | return value; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/netty/common/status/ServerStatusManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.netty.common.status; 18 | 19 | import com.netflix.appinfo.ApplicationInfoManager; 20 | import com.netflix.appinfo.InstanceInfo; 21 | import jakarta.inject.Inject; 22 | import jakarta.inject.Singleton; 23 | 24 | /** 25 | * User: michaels@netflix.com 26 | * Date: 7/6/17 27 | * Time: 3:37 PM 28 | */ 29 | @Singleton 30 | public class ServerStatusManager { 31 | private final ApplicationInfoManager applicationInfoManager; 32 | 33 | @Inject 34 | public ServerStatusManager(ApplicationInfoManager applicationInfoManager) { 35 | this.applicationInfoManager = applicationInfoManager; 36 | } 37 | 38 | public void localStatus(InstanceInfo.InstanceStatus status) { 39 | applicationInfoManager.setInstanceStatus(status); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/netty/common/throttle/RejectionType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.netty.common.throttle; 18 | 19 | /** 20 | * Indicates a rejection type for DoS protection. While similar, rejection is distinct from throttling in that 21 | * throttling is intended for non-malicious traffic. 22 | */ 23 | public enum RejectionType { 24 | // "It's not you, it's me." 25 | 26 | /** 27 | * Indicates that the request should not be allowed. An HTTP response will be generated as a result. 28 | */ 29 | REJECT, 30 | 31 | /** 32 | * Indicates that the connection should be closed, not allowing the request to proceed. No HTTP response will be 33 | * returned. 34 | */ 35 | CLOSE, 36 | 37 | /** 38 | * Allows the request to proceed, followed by closing the connection. This is typically used in conjunction with 39 | * throttling handling, where the response may need to be handled by the filter chain. It is not expected that the 40 | * request will be proxied. 41 | */ 42 | ALLOW_THEN_CLOSE; 43 | } 44 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/netty/common/throttle/RequestRejectedEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.netty.common.throttle; 18 | 19 | import com.netflix.zuul.stats.status.StatusCategory; 20 | import io.netty.handler.codec.http.HttpRequest; 21 | import io.netty.handler.codec.http.HttpResponseStatus; 22 | 23 | public final class RequestRejectedEvent { 24 | private final HttpRequest request; 25 | private final StatusCategory nfStatus; 26 | private final HttpResponseStatus httpStatus; 27 | private final String reason; 28 | 29 | public RequestRejectedEvent( 30 | HttpRequest request, StatusCategory nfStatus, HttpResponseStatus httpStatus, String reason) { 31 | this.request = request; 32 | this.nfStatus = nfStatus; 33 | this.httpStatus = httpStatus; 34 | this.reason = reason; 35 | } 36 | 37 | public HttpRequest request() { 38 | return request; 39 | } 40 | 41 | public StatusCategory getNfStatus() { 42 | return nfStatus; 43 | } 44 | 45 | public HttpResponseStatus getHttpStatus() { 46 | return httpStatus; 47 | } 48 | 49 | public String getReason() { 50 | return reason; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/BasicFilterUsageNotifier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul; 18 | 19 | import com.netflix.spectator.api.Registry; 20 | import com.netflix.zuul.filters.ZuulFilter; 21 | import jakarta.inject.Inject; 22 | 23 | /** 24 | * Publishes a counter metric for each filter on each use. 25 | */ 26 | public class BasicFilterUsageNotifier implements FilterUsageNotifier { 27 | 28 | private final Registry registry; 29 | 30 | @Inject 31 | public BasicFilterUsageNotifier(Registry registry) { 32 | this.registry = registry; 33 | } 34 | 35 | @Override 36 | public void notify(ZuulFilter filter, ExecutionStatus status) { 37 | registry.counter( 38 | "zuul.filter-" + filter.getClass().getSimpleName(), 39 | "status", 40 | status.name(), 41 | "filtertype", 42 | filter.filterType().toString()) 43 | .increment(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/BasicRequestCompleteHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul; 18 | 19 | import com.netflix.zuul.context.SessionContext; 20 | import com.netflix.zuul.message.http.HttpRequestInfo; 21 | import com.netflix.zuul.message.http.HttpResponseMessage; 22 | import com.netflix.zuul.stats.RequestMetricsPublisher; 23 | import jakarta.inject.Inject; 24 | import javax.annotation.Nullable; 25 | 26 | /** 27 | * User: michaels@netflix.com 28 | * Date: 6/4/15 29 | * Time: 4:26 PM 30 | */ 31 | public class BasicRequestCompleteHandler implements RequestCompleteHandler { 32 | @Inject 33 | @Nullable private RequestMetricsPublisher requestMetricsPublisher; 34 | 35 | @Override 36 | public void handle(HttpRequestInfo inboundRequest, HttpResponseMessage response) { 37 | SessionContext context = inboundRequest.getContext(); 38 | 39 | // Publish request-level metrics. 40 | if (requestMetricsPublisher != null) { 41 | requestMetricsPublisher.collectAndPublish(context); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/DefaultFilterFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.zuul; 17 | 18 | import com.netflix.zuul.filters.ZuulFilter; 19 | import java.lang.reflect.InvocationTargetException; 20 | 21 | /** 22 | * Default factory for creating instances of ZuulFilter. 23 | */ 24 | public class DefaultFilterFactory implements FilterFactory { 25 | 26 | /** 27 | * Returns a new implementation of ZuulFilter as specified by the provided 28 | * Class. The Class is instantiated using its nullary constructor. 29 | * 30 | * @param clazz the Class to instantiate 31 | * @return A new instance of ZuulFilter 32 | */ 33 | @Override 34 | public ZuulFilter newInstance(Class clazz) 35 | throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, 36 | NoSuchMethodException { 37 | return (ZuulFilter) clazz.getDeclaredConstructor().newInstance(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/ExecutionStatus.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.zuul; 17 | 18 | public enum ExecutionStatus { 19 | SUCCESS, 20 | SKIPPED, 21 | DISABLED, 22 | FAILED, 23 | BODY_AWAIT, 24 | ASYNC_AWAIT, 25 | } 26 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/FilterFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.zuul; 17 | 18 | import com.netflix.zuul.filters.ZuulFilter; 19 | 20 | /** 21 | * Interface to provide instances of ZuulFilter from a given class. 22 | */ 23 | public interface FilterFactory { 24 | 25 | /** 26 | * Returns an instance of the specified class. 27 | * 28 | * @param clazz the Class to instantiate 29 | * @return an instance of ZuulFilter 30 | * @throws Exception if an error occurs 31 | */ 32 | ZuulFilter newInstance(Class clazz) throws Exception; 33 | } 34 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/FilterUsageNotifier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.zuul; 17 | 18 | import com.netflix.zuul.filters.ZuulFilter; 19 | 20 | /** 21 | * Interface to implement for registering a callback for each time a filter 22 | * is used. 23 | * 24 | * User: michaels 25 | * Date: 5/13/14 26 | * Time: 9:55 PM 27 | */ 28 | public interface FilterUsageNotifier { 29 | void notify(ZuulFilter filter, ExecutionStatus status); 30 | } 31 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/RequestCompleteHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.zuul; 17 | 18 | import com.netflix.zuul.message.http.HttpRequestInfo; 19 | import com.netflix.zuul.message.http.HttpResponseMessage; 20 | 21 | public interface RequestCompleteHandler { 22 | void handle(HttpRequestInfo inboundRequest, HttpResponseMessage response); 23 | } 24 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/ZuulApplicationInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.zuul; 17 | 18 | /** 19 | * Metadata about the Zuul instance/ application name and "stack" 20 | * @author Mikey Cohen 21 | * Date: 2/15/13 22 | * Time: 1:56 PM 23 | */ 24 | public class ZuulApplicationInfo { 25 | public static String applicationName; 26 | public static String stack; 27 | 28 | public static String getApplicationName() { 29 | return applicationName; 30 | } 31 | 32 | public static void setApplicationName(String applicationName) { 33 | ZuulApplicationInfo.applicationName = applicationName; 34 | } 35 | 36 | public static String getStack() { 37 | return stack; 38 | } 39 | 40 | public static void setStack(String stack) { 41 | ZuulApplicationInfo.stack = stack; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/context/SessionCleaner.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.context; 18 | 19 | import rx.Observable; 20 | 21 | /** 22 | * User: michaels@netflix.com 23 | * Date: 8/3/15 24 | * Time: 12:30 PM 25 | */ 26 | public interface SessionCleaner { 27 | Observable cleanup(SessionContext context); 28 | } 29 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/context/SessionContextDecorator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.zuul.context; 17 | 18 | /** 19 | * User: michaels@netflix.com 20 | * Date: 2/25/15 21 | * Time: 4:09 PM 22 | */ 23 | public interface SessionContextDecorator { 24 | public SessionContext decorate(SessionContext ctx); 25 | } 26 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/context/SessionContextFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.zuul.context; 17 | 18 | import com.netflix.zuul.message.ZuulMessage; 19 | import rx.Observable; 20 | 21 | public interface SessionContextFactory { 22 | public ZuulMessage create(SessionContext context, T nativeRequest, V nativeResponse); 23 | 24 | public Observable write(ZuulMessage msg, V nativeResponse); 25 | } 26 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/exception/RequestExpiredException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.exception; 18 | 19 | /** 20 | * @author Argha C 21 | * @since 4/26/23 22 | */ 23 | public class RequestExpiredException extends ZuulException { 24 | 25 | public RequestExpiredException(String message) { 26 | super(message, true); 27 | setStatusCode(504); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/exception/ZuulFilterConcurrencyExceededException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.zuul.exception; 17 | 18 | import com.netflix.zuul.filters.ZuulFilter; 19 | 20 | public class ZuulFilterConcurrencyExceededException extends ZuulException { 21 | 22 | public ZuulFilterConcurrencyExceededException(ZuulFilter filter, int concurrencyLimit) { 23 | super(filter.filterName() + " exceeded concurrency limit of " + concurrencyLimit, true); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/filters/BaseSyncFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.zuul.filters; 17 | 18 | import com.netflix.zuul.message.ZuulMessage; 19 | import rx.Observable; 20 | 21 | /** 22 | * User: michaels@netflix.com 23 | * Date: 5/8/15 24 | * Time: 2:46 PM 25 | */ 26 | public abstract class BaseSyncFilter extends BaseFilter 27 | implements SyncZuulFilter { 28 | /** 29 | * A wrapper implementation of applyAsync() that is intended just to aggregate a non-blocking apply() method 30 | * in an Observable. 31 | * 32 | * A subclass filter should override this method if doing any IO. 33 | */ 34 | @Override 35 | public Observable applyAsync(I input) { 36 | return Observable.just(this.apply(input)); 37 | } 38 | 39 | @Override 40 | public FilterSyncType getSyncType() { 41 | return FilterSyncType.SYNC; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/filters/Endpoint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.filters; 18 | 19 | import com.netflix.zuul.message.ZuulMessage; 20 | 21 | /** 22 | * User: Mike Smith 23 | * Date: 5/16/15 24 | * Time: 1:57 PM 25 | */ 26 | public abstract class Endpoint extends BaseFilter { 27 | @Override 28 | public int filterOrder() { 29 | // Set all Endpoint filters to order of 0, because they are not processed sequentially like other filter types. 30 | return 0; 31 | } 32 | 33 | @Override 34 | public FilterType filterType() { 35 | return FilterType.ENDPOINT; 36 | } 37 | 38 | @Override 39 | public boolean shouldFilter(I msg) { 40 | // Always true, because Endpoint filters are chosen by name instead. 41 | return true; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/filters/FilterError.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.zuul.filters; 17 | 18 | /** 19 | * User: michaels@netflix.com 20 | * Date: 5/7/15 21 | * Time: 10:19 AM 22 | */ 23 | public class FilterError implements Cloneable { 24 | private final String filterName; 25 | private final String filterType; 26 | private Throwable exception = null; 27 | 28 | public FilterError(String filterName, String filterType, Throwable exception) { 29 | this.filterName = filterName; 30 | this.filterType = filterType; 31 | this.exception = exception; 32 | } 33 | 34 | public String getFilterName() { 35 | return filterName; 36 | } 37 | 38 | public String getFilterType() { 39 | return filterType; 40 | } 41 | 42 | public Throwable getException() { 43 | return exception; 44 | } 45 | 46 | @Override 47 | public Object clone() { 48 | return new FilterError(filterName, filterType, exception); 49 | } 50 | 51 | @Override 52 | public String toString() { 53 | return "FilterError{" + "filterName='" 54 | + filterName + '\'' + ", filterType='" 55 | + filterType + '\'' + ", exception=" 56 | + exception + '}'; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/filters/FilterRegistry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.zuul.filters; 17 | 18 | import java.util.Collection; 19 | import javax.annotation.Nullable; 20 | 21 | public interface FilterRegistry { 22 | @Nullable ZuulFilter get(String key); 23 | 24 | int size(); 25 | 26 | Collection> getAllFilters(); 27 | 28 | /** 29 | * Indicates if this registry can be modified. Implementations should not change the return; 30 | * they return the same value each time. 31 | */ 32 | boolean isMutable(); 33 | 34 | /** 35 | * Removes the filter from the registry, and returns it. Returns {@code null} no such filter 36 | * was found. Callers should check {@link #isMutable()} before calling this method. 37 | * 38 | * @throws IllegalStateException if this registry is not mutable. 39 | */ 40 | @Nullable ZuulFilter remove(String key); 41 | 42 | /** 43 | * Stores the filter into the registry. If an existing filter was present with the same key, 44 | * it is removed. Callers should check {@link #isMutable()} before calling this method. 45 | * 46 | * @throws IllegalStateException if this registry is not mutable. 47 | */ 48 | void put(String key, ZuulFilter filter); 49 | } 50 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/filters/FilterSyncType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.filters; 18 | 19 | /** 20 | * User: Mike Smith 21 | * Date: 11/13/15 22 | * Time: 9:13 PM 23 | */ 24 | public enum FilterSyncType { 25 | SYNC, 26 | ASYNC 27 | } 28 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/filters/FilterType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.filters; 18 | 19 | import java.util.Locale; 20 | 21 | /** 22 | * User: Mike Smith 23 | * Date: 11/13/15 24 | * Time: 7:50 PM 25 | */ 26 | public enum FilterType { 27 | INBOUND("in"), 28 | ENDPOINT("end"), 29 | OUTBOUND("out"); 30 | 31 | private final String shortName; 32 | 33 | private FilterType(String shortName) { 34 | this.shortName = shortName; 35 | } 36 | 37 | @Override 38 | public String toString() { 39 | return shortName; 40 | } 41 | 42 | public static FilterType parse(String str) { 43 | str = str.toLowerCase(Locale.ROOT); 44 | switch (str) { 45 | case "in": 46 | return INBOUND; 47 | case "out": 48 | return OUTBOUND; 49 | case "end": 50 | return ENDPOINT; 51 | default: 52 | throw new IllegalArgumentException("Unknown filter type! type=" + String.valueOf(str)); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/filters/ShouldFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.zuul.filters; 17 | 18 | import com.netflix.zuul.message.ZuulMessage; 19 | 20 | /** 21 | * User: michaels@netflix.com 22 | * Date: 5/7/15 23 | * Time: 3:31 PM 24 | */ 25 | public interface ShouldFilter { 26 | /** 27 | * a "true" return from this method means that the apply() method should be invoked 28 | * 29 | * @return true if the apply() method should be invoked. false will not invoke the apply() method 30 | */ 31 | boolean shouldFilter(T msg); 32 | } 33 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/filters/SyncZuulFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.filters; 18 | 19 | import com.netflix.zuul.message.ZuulMessage; 20 | 21 | /** 22 | * User: michaels@netflix.com 23 | * Date: 11/16/15 24 | * Time: 2:07 PM 25 | */ 26 | public interface SyncZuulFilter extends ZuulFilter { 27 | O apply(I input); 28 | } 29 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/filters/http/HttpInboundFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.zuul.filters.http; 17 | 18 | import com.netflix.zuul.filters.BaseFilter; 19 | import com.netflix.zuul.filters.FilterType; 20 | import com.netflix.zuul.message.http.HttpRequestMessage; 21 | 22 | /** 23 | * User: michaels@netflix.com 24 | * Date: 5/29/15 25 | * Time: 3:22 PM 26 | */ 27 | public abstract class HttpInboundFilter extends BaseFilter { 28 | @Override 29 | public FilterType filterType() { 30 | return FilterType.INBOUND; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/filters/http/HttpInboundSyncFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.zuul.filters.http; 17 | 18 | import com.netflix.zuul.filters.BaseSyncFilter; 19 | import com.netflix.zuul.filters.FilterType; 20 | import com.netflix.zuul.message.http.HttpRequestMessage; 21 | 22 | /** 23 | * User: michaels@netflix.com 24 | * Date: 5/29/15 25 | * Time: 3:22 PM 26 | */ 27 | public abstract class HttpInboundSyncFilter extends BaseSyncFilter { 28 | @Override 29 | public FilterType filterType() { 30 | return FilterType.INBOUND; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/filters/http/HttpOutboundFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.zuul.filters.http; 17 | 18 | import com.netflix.zuul.filters.BaseFilter; 19 | import com.netflix.zuul.filters.FilterType; 20 | import com.netflix.zuul.message.http.HttpResponseMessage; 21 | 22 | /** 23 | * User: michaels@netflix.com 24 | * Date: 5/29/15 25 | * Time: 3:23 PM 26 | */ 27 | public abstract class HttpOutboundFilter extends BaseFilter { 28 | @Override 29 | public FilterType filterType() { 30 | return FilterType.OUTBOUND; 31 | } 32 | 33 | @Override 34 | public HttpResponseMessage getDefaultOutput(HttpResponseMessage input) { 35 | return input; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/filters/http/HttpOutboundSyncFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.zuul.filters.http; 17 | 18 | import com.netflix.zuul.filters.BaseSyncFilter; 19 | import com.netflix.zuul.filters.FilterType; 20 | import com.netflix.zuul.message.http.HttpResponseMessage; 21 | 22 | /** 23 | * User: michaels@netflix.com 24 | * Date: 5/29/15 25 | * Time: 3:23 PM 26 | */ 27 | public abstract class HttpOutboundSyncFilter extends BaseSyncFilter { 28 | @Override 29 | public FilterType filterType() { 30 | return FilterType.OUTBOUND; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/filters/passport/InboundPassportStampingFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.filters.passport; 18 | 19 | import com.netflix.zuul.Filter; 20 | import com.netflix.zuul.filters.FilterType; 21 | import com.netflix.zuul.message.http.HttpRequestMessage; 22 | import com.netflix.zuul.passport.PassportState; 23 | 24 | /** 25 | * Created by saroskar on 3/14/17. 26 | */ 27 | @Filter(order = 0, type = FilterType.INBOUND) 28 | public final class InboundPassportStampingFilter extends PassportStampingFilter { 29 | 30 | public InboundPassportStampingFilter(PassportState stamp) { 31 | super(stamp); 32 | } 33 | 34 | @Override 35 | public FilterType filterType() { 36 | return FilterType.INBOUND; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/filters/passport/OutboundPassportStampingFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.filters.passport; 18 | 19 | import com.netflix.zuul.Filter; 20 | import com.netflix.zuul.filters.FilterType; 21 | import com.netflix.zuul.message.http.HttpResponseMessage; 22 | import com.netflix.zuul.passport.PassportState; 23 | 24 | /** 25 | * Created by saroskar on 3/14/17. 26 | */ 27 | @Filter(order = 0, type = FilterType.OUTBOUND) 28 | public final class OutboundPassportStampingFilter extends PassportStampingFilter { 29 | 30 | public OutboundPassportStampingFilter(PassportState stamp) { 31 | super(stamp); 32 | } 33 | 34 | @Override 35 | public FilterType filterType() { 36 | return FilterType.OUTBOUND; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/filters/passport/PassportStampingFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.filters.passport; 18 | 19 | import com.netflix.zuul.filters.SyncZuulFilterAdapter; 20 | import com.netflix.zuul.message.ZuulMessage; 21 | import com.netflix.zuul.passport.CurrentPassport; 22 | import com.netflix.zuul.passport.PassportState; 23 | 24 | /** 25 | * Created by saroskar on 2/18/17. 26 | */ 27 | public abstract class PassportStampingFilter extends SyncZuulFilterAdapter { 28 | 29 | private final PassportState stamp; 30 | private final String name; 31 | 32 | public PassportStampingFilter(PassportState stamp) { 33 | this.stamp = stamp; 34 | this.name = filterType().name() + "-" + stamp.name() + "-Filter"; 35 | } 36 | 37 | @Override 38 | public String filterName() { 39 | return name; 40 | } 41 | 42 | @Override 43 | public T getDefaultOutput(T input) { 44 | return input; 45 | } 46 | 47 | @Override 48 | public T apply(T input) { 49 | CurrentPassport.fromSessionContext(input.getContext()).add(stamp); 50 | return input; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/message/http/Cookies.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.message.http; 18 | 19 | import io.netty.handler.codec.http.cookie.Cookie; 20 | import java.util.ArrayList; 21 | import java.util.HashMap; 22 | import java.util.List; 23 | import java.util.Map; 24 | 25 | /** 26 | * User: Mike Smith 27 | * Date: 6/18/15 28 | * Time: 12:04 AM 29 | */ 30 | public class Cookies { 31 | private final Map> map = new HashMap<>(); 32 | private final List all = new ArrayList<>(); 33 | 34 | public void add(Cookie cookie) { 35 | map.computeIfAbsent(cookie.name(), k -> new ArrayList<>(1)).add(cookie); 36 | all.add(cookie); 37 | } 38 | 39 | public List getAll() { 40 | return all; 41 | } 42 | 43 | public List get(String name) { 44 | return map.get(name); 45 | } 46 | 47 | public Cookie getFirst(String name) { 48 | List found = map.get(name); 49 | if (found == null || found.isEmpty()) { 50 | return null; 51 | } 52 | return found.get(0); 53 | } 54 | 55 | public String getFirstValue(String name) { 56 | Cookie c = getFirst(name); 57 | String value; 58 | if (c != null) { 59 | value = c.value(); 60 | } else { 61 | value = null; 62 | } 63 | return value; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/message/http/HttpRequestMessage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.message.http; 18 | 19 | import com.netflix.zuul.message.ZuulMessage; 20 | 21 | /** 22 | * User: Mike Smith 23 | * Date: 7/15/15 24 | * Time: 5:36 PM 25 | */ 26 | public interface HttpRequestMessage extends HttpRequestInfo { 27 | void setProtocol(String protocol); 28 | 29 | void setMethod(String method); 30 | 31 | void setPath(String path); 32 | 33 | void setScheme(String scheme); 34 | 35 | void setServerName(String serverName); 36 | 37 | @Override 38 | ZuulMessage clone(); 39 | 40 | void storeInboundRequest(); 41 | 42 | HttpRequestInfo getInboundRequest(); 43 | 44 | void setQueryParams(HttpQueryParams queryParams); 45 | } 46 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/message/http/HttpResponseInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.message.http; 18 | 19 | import com.netflix.zuul.message.ZuulMessage; 20 | 21 | /** 22 | * User: michaels@netflix.com 23 | * Date: 7/6/15 24 | * Time: 5:27 PM 25 | */ 26 | public interface HttpResponseInfo extends ZuulMessage { 27 | int getStatus(); 28 | 29 | /** The immutable request that was originally received from client. */ 30 | HttpRequestInfo getInboundRequest(); 31 | 32 | @Override 33 | ZuulMessage clone(); 34 | 35 | @Override 36 | String getInfoForLogging(); 37 | 38 | Cookies parseSetCookieHeader(String setCookieValue); 39 | 40 | boolean hasSetCookieWithName(String cookieName); 41 | } 42 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/message/http/HttpResponseMessage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.message.http; 18 | 19 | import io.netty.handler.codec.http.cookie.Cookie; 20 | 21 | /** 22 | * User: Mike Smith 23 | * Date: 7/16/15 24 | * Time: 12:45 AM 25 | */ 26 | public interface HttpResponseMessage extends HttpResponseInfo { 27 | void setStatus(int status); 28 | 29 | @Override 30 | int getMaxBodySize(); 31 | 32 | void addSetCookie(Cookie cookie); 33 | 34 | void setSetCookie(Cookie cookie); 35 | 36 | boolean removeExistingSetCookie(String cookieName); 37 | 38 | /** The mutable request that will be sent to Origin. */ 39 | HttpRequestMessage getOutboundRequest(); 40 | 41 | /** The immutable response that was received from Origin. */ 42 | HttpResponseInfo getInboundResponse(); 43 | 44 | /** This should be called after response received from Origin, to store 45 | * a copy of the response as-is. */ 46 | void storeInboundResponse(); 47 | } 48 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/metrics/OriginStats.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.zuul.metrics; 17 | 18 | /** 19 | * User: michaels@netflix.com 20 | * Date: 3/20/15 21 | * Time: 5:55 PM 22 | */ 23 | public interface OriginStats { 24 | public void started(); 25 | 26 | public void completed(boolean success, long totalTimeMS); 27 | } 28 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/metrics/OriginStatsFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.zuul.metrics; 17 | 18 | /** 19 | * User: michaels@netflix.com 20 | * Date: 3/20/15 21 | * Time: 6:14 PM 22 | */ 23 | public interface OriginStatsFactory { 24 | public OriginStats create(String name); 25 | } 26 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/monitoring/MonitoringHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.zuul.monitoring; 17 | 18 | /** 19 | * Dummy implementations of CounterFactory, TracerFactory, and Tracer 20 | * @author mhawthorne 21 | */ 22 | public class MonitoringHelper { 23 | 24 | public static final void initMocks() { 25 | TracerFactory.initialize(new TracerFactoryImpl()); 26 | } 27 | 28 | private static final class TracerFactoryImpl extends TracerFactory { 29 | @Override 30 | public Tracer startMicroTracer(String name) { 31 | return new TracerImpl(); 32 | } 33 | } 34 | 35 | private static final class TracerImpl implements Tracer { 36 | @Override 37 | public void setName(String name) {} 38 | 39 | @Override 40 | public void stopAndLog() {} 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/monitoring/Tracer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.zuul.monitoring; 17 | 18 | /** 19 | * Time based monitoring metric. 20 | * 21 | * @author mhawthorne 22 | */ 23 | public interface Tracer { 24 | 25 | /** 26 | * Stops and Logs a time based tracer 27 | * 28 | */ 29 | void stopAndLog(); 30 | 31 | /** 32 | * Sets the name for the time based tracer 33 | * 34 | * @param name a String value 35 | */ 36 | void setName(String name); 37 | } 38 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/monitoring/TracerFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.monitoring; 18 | 19 | /** 20 | * Abstraction layer to provide time-based monitoring. 21 | * 22 | * @author mhawthorne 23 | */ 24 | public abstract class TracerFactory { 25 | 26 | private static TracerFactory INSTANCE; 27 | 28 | /** 29 | * sets a TracerFactory Implementation 30 | * 31 | * @param f a TracerFactory value 32 | */ 33 | public static final void initialize(TracerFactory f) { 34 | INSTANCE = f; 35 | } 36 | 37 | /** 38 | * Returns the singleton TracerFactory 39 | * 40 | * @return a TracerFactory value 41 | */ 42 | public static final TracerFactory instance() { 43 | if (INSTANCE == null) { 44 | throw new IllegalStateException(String.format("%s not initialized", TracerFactory.class.getSimpleName())); 45 | } 46 | return INSTANCE; 47 | } 48 | 49 | public abstract Tracer startMicroTracer(String name); 50 | } 51 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/netty/ChannelUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.netty; 18 | 19 | import com.netflix.zuul.passport.CurrentPassport; 20 | import io.netty.channel.Channel; 21 | 22 | public class ChannelUtils { 23 | public static String channelInfoForLogging(Channel ch) { 24 | if (ch == null) { 25 | return "null"; 26 | } 27 | 28 | String channelInfo = ch.toString() 29 | + ", active=" + ch.isActive() 30 | + ", open=" + ch.isOpen() 31 | + ", registered=" + ch.isRegistered() 32 | + ", writable=" + ch.isWritable() 33 | + ", id=" + ch.id(); 34 | 35 | CurrentPassport passport = CurrentPassport.fromChannel(ch); 36 | return "Channel: " + channelInfo + ", Passport: " + String.valueOf(passport); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/netty/RequestCancelledEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.netty; 18 | 19 | /** 20 | * User: michaels@netflix.com 21 | * Date: 4/13/17 22 | * Time: 6:09 PM 23 | */ 24 | public class RequestCancelledEvent {} 25 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/netty/connectionpool/ClientChannelManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.netty.connectionpool; 18 | 19 | import com.netflix.zuul.discovery.DiscoveryResult; 20 | import com.netflix.zuul.passport.CurrentPassport; 21 | import io.netty.channel.EventLoop; 22 | import io.netty.util.concurrent.Promise; 23 | import java.net.InetAddress; 24 | import java.util.concurrent.atomic.AtomicReference; 25 | 26 | /** 27 | * User: michaels@netflix.com 28 | * Date: 7/8/16 29 | * Time: 12:36 PM 30 | */ 31 | public interface ClientChannelManager { 32 | void init(); 33 | 34 | boolean isAvailable(); 35 | 36 | int getInflightRequestsCount(); 37 | 38 | void shutdown(); 39 | 40 | default void gracefulShutdown() { 41 | shutdown(); 42 | } 43 | 44 | boolean release(PooledConnection conn); 45 | 46 | Promise acquire(EventLoop eventLoop); 47 | 48 | Promise acquire( 49 | EventLoop eventLoop, 50 | Object key, 51 | CurrentPassport passport, 52 | AtomicReference selectedServer, 53 | AtomicReference selectedHostAddr); 54 | 55 | boolean isCold(); 56 | 57 | boolean remove(PooledConnection conn); 58 | 59 | int getConnsInPool(); 60 | 61 | int getConnsInUse(); 62 | 63 | ConnectionPoolConfig getConfig(); 64 | } 65 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/netty/connectionpool/ConnectionPoolConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.netty.connectionpool; 18 | 19 | import com.netflix.zuul.origins.OriginName; 20 | 21 | /** 22 | * Created by saroskar on 3/24/16. 23 | */ 24 | public interface ConnectionPoolConfig { 25 | 26 | /* Origin name from connection pool */ 27 | OriginName getOriginName(); 28 | 29 | /* Max number of requests per connection before it needs to be recycled */ 30 | int getMaxRequestsPerConnection(); 31 | 32 | /* Max connections per host */ 33 | int maxConnectionsPerHost(); 34 | 35 | int perServerWaterline(); 36 | 37 | /* Origin client TCP configuration options */ 38 | int getConnectTimeout(); 39 | 40 | /* number of milliseconds connection can stay idle in a connection pool before it is closed */ 41 | int getIdleTimeout(); 42 | 43 | int getTcpReceiveBufferSize(); 44 | 45 | int getTcpSendBufferSize(); 46 | 47 | int getNettyWriteBufferHighWaterMark(); 48 | 49 | int getNettyWriteBufferLowWaterMark(); 50 | 51 | boolean getTcpKeepAlive(); 52 | 53 | boolean getTcpNoDelay(); 54 | 55 | boolean getNettyAutoRead(); 56 | 57 | boolean isSecure(); 58 | 59 | boolean useIPAddrForServer(); 60 | 61 | default boolean isCloseOnCircuitBreakerEnabled() { 62 | return true; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/netty/connectionpool/IConnectionPool.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.netty.connectionpool; 18 | 19 | import com.netflix.zuul.passport.CurrentPassport; 20 | import io.netty.channel.EventLoop; 21 | import io.netty.util.concurrent.Promise; 22 | import java.net.InetAddress; 23 | import java.util.concurrent.atomic.AtomicReference; 24 | 25 | /** 26 | * User: michaels@netflix.com 27 | * Date: 7/8/16 28 | * Time: 1:10 PM 29 | */ 30 | public interface IConnectionPool { 31 | Promise acquire( 32 | EventLoop eventLoop, CurrentPassport passport, AtomicReference selectedHostAddr); 33 | 34 | boolean release(PooledConnection conn); 35 | 36 | boolean remove(PooledConnection conn); 37 | 38 | void shutdown(); 39 | 40 | default void drain() { 41 | shutdown(); 42 | } 43 | 44 | boolean isAvailable(); 45 | 46 | int getConnsInUse(); 47 | 48 | int getConnsInPool(); 49 | 50 | ConnectionPoolConfig getConfig(); 51 | } 52 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/netty/connectionpool/OriginChannelInitializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.netty.connectionpool; 18 | 19 | import com.netflix.netty.common.metrics.HttpMetricsChannelHandler; 20 | import io.netty.channel.Channel; 21 | import io.netty.channel.ChannelInitializer; 22 | 23 | /** 24 | * Origin Channel Initializer 25 | * 26 | * Author: Arthur Gonigberg 27 | * Date: December 01, 2017 28 | */ 29 | public abstract class OriginChannelInitializer extends ChannelInitializer { 30 | 31 | public abstract HttpMetricsChannelHandler getHttpMetricsHandler(); 32 | } 33 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/netty/connectionpool/OriginConnectException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.netty.connectionpool; 18 | 19 | import com.netflix.zuul.exception.ErrorType; 20 | 21 | /** 22 | * Wrapper for exceptions failing to connect to origin with details on which server failed the attempt. 23 | */ 24 | public class OriginConnectException extends Exception { 25 | 26 | private final ErrorType errorType; 27 | 28 | public OriginConnectException(String message, ErrorType errorType) { 29 | // ensure this exception does not fill its stacktrace, this causes a 10x slowdown 30 | super(message, null, true, false); 31 | this.errorType = errorType; 32 | } 33 | 34 | public OriginConnectException(String message, Throwable cause, ErrorType errorType) { 35 | // ensure this exception does not fill its stacktrace, this causes a 10x slowdown 36 | super(message, cause, true, false); 37 | this.errorType = errorType; 38 | } 39 | 40 | public ErrorType getErrorType() { 41 | return errorType; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/netty/connectionpool/PooledConnectionFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.netty.connectionpool; 18 | 19 | import io.netty.channel.Channel; 20 | 21 | /** 22 | * User: Mike Smith 23 | * Date: 7/9/16 24 | * Time: 2:25 PM 25 | */ 26 | public interface PooledConnectionFactory { 27 | PooledConnection create(Channel ch); 28 | } 29 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/netty/connectionpool/RequestStat.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.netty.connectionpool; 18 | 19 | import com.netflix.zuul.context.SessionContext; 20 | import com.netflix.zuul.discovery.DiscoveryResult; 21 | import com.netflix.zuul.exception.ErrorType; 22 | 23 | /** 24 | * Request Stat 25 | * 26 | * Author: Arthur Gonigberg 27 | * Date: November 29, 2017 28 | */ 29 | public interface RequestStat { 30 | 31 | String SESSION_CONTEXT_KEY = "niwsRequestStat"; 32 | 33 | static RequestStat putInSessionContext(RequestStat stat, SessionContext context) { 34 | context.put(SESSION_CONTEXT_KEY, stat); 35 | return stat; 36 | } 37 | 38 | static RequestStat getFromSessionContext(SessionContext context) { 39 | return (RequestStat) context.get(SESSION_CONTEXT_KEY); 40 | } 41 | 42 | RequestStat server(DiscoveryResult server); 43 | 44 | boolean isFinished(); 45 | 46 | long duration(); 47 | 48 | void serviceUnavailable(); 49 | 50 | void generalError(); 51 | 52 | void failAndSetErrorCode(ErrorType errorType); 53 | 54 | void updateWithHttpStatusCode(int httpStatusCode); 55 | 56 | void finalAttempt(boolean finalAttempt); 57 | 58 | boolean finishIfNotAlready(); 59 | } 60 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/netty/connectionpool/ZuulNettyExceptionMapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.netty.connectionpool; 18 | 19 | /** 20 | * User: Mike Smith 21 | * Date: 7/13/16 22 | * Time: 6:02 PM 23 | */ 24 | public class ZuulNettyExceptionMapper {} 25 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/netty/filter/FilterRunner.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.netty.filter; 18 | 19 | import com.netflix.zuul.message.ZuulMessage; 20 | import io.netty.handler.codec.http.HttpContent; 21 | 22 | /** 23 | * Created by saroskar on 5/18/17. 24 | */ 25 | public interface FilterRunner { 26 | 27 | void filter(I zuulMesg); 28 | 29 | void filter(I zuulMesg, HttpContent chunk); 30 | } 31 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/netty/ratelimiting/NullChannelHandlerProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.netty.ratelimiting; 18 | 19 | import io.netty.channel.ChannelHandler; 20 | import jakarta.inject.Provider; 21 | import jakarta.inject.Singleton; 22 | 23 | @Singleton 24 | public class NullChannelHandlerProvider implements Provider { 25 | @Override 26 | public ChannelHandler get() { 27 | return null; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/netty/server/EventLoopConfig.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.zuul.netty.server; 17 | 18 | public interface EventLoopConfig { 19 | int eventLoopCount(); 20 | 21 | int acceptorCount(); 22 | } 23 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/netty/server/ListenerSpec.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.netty.server; 18 | 19 | /* 20 | * @author Argha C 21 | * @since 10/2/24 22 | */ 23 | import java.net.SocketAddress; 24 | import java.util.Objects; 25 | 26 | /** 27 | * A specification of an address to listen on. 28 | */ 29 | public record ListenerSpec(String addressName, boolean defaultAddressEnabled, SocketAddress defaultAddressValue) { 30 | 31 | public ListenerSpec { 32 | Objects.requireNonNull(addressName, "addressName"); 33 | Objects.requireNonNull(defaultAddressValue, "defaultAddressValue"); 34 | } 35 | 36 | /** 37 | * The fast property name that indicates if this address is enabled. This is used when overriding 38 | * {@link #defaultAddressEnabled}. 39 | */ 40 | public String addressEnabledPropertyName() { 41 | return "zuul.server." + addressName + ".enabled"; 42 | } 43 | 44 | /** 45 | * The fast property to override the default port for the address name 46 | */ 47 | @Deprecated 48 | public String portPropertyName() { 49 | return "zuul.server.port." + addressName; 50 | } 51 | 52 | /** 53 | * The fast property to override the default address name 54 | */ 55 | public String addressPropertyName() { 56 | return "zuul.server.addr." + addressName; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/netty/server/MethodBinding.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.netty.server; 18 | 19 | import java.util.concurrent.Callable; 20 | import java.util.function.BiConsumer; 21 | 22 | /** 23 | * Utility used for binding context variables or thread variables, depending on requirements. 24 | * 25 | * Author: Arthur Gonigberg 26 | * Date: November 29, 2017 27 | */ 28 | public class MethodBinding { 29 | private final BiConsumer boundMethod; 30 | private final Callable bindingContextExtractor; 31 | 32 | public static MethodBinding NO_OP_BINDING = new MethodBinding<>((r, t) -> {}, () -> null); 33 | 34 | public MethodBinding(BiConsumer boundMethod, Callable bindingContextExtractor) { 35 | this.boundMethod = boundMethod; 36 | this.bindingContextExtractor = bindingContextExtractor; 37 | } 38 | 39 | public void bind(Runnable method) throws Exception { 40 | T bindingContext = bindingContextExtractor.call(); 41 | if (bindingContext == null) { 42 | method.run(); 43 | } else { 44 | boundMethod.accept(method, bindingContext); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/netty/server/ServerTimeout.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.netty.server; 18 | 19 | public class ServerTimeout { 20 | private final int connectionIdleTimeout; 21 | 22 | public ServerTimeout(int connectionIdleTimeout) { 23 | this.connectionIdleTimeout = connectionIdleTimeout; 24 | } 25 | 26 | public int connectionIdleTimeout() { 27 | return connectionIdleTimeout; 28 | } 29 | 30 | public int defaultRequestExpiryTimeout() { 31 | // Note this is the timeout for the inbound request to zuul, not for each outbound attempt. 32 | // It needs to align with the inbound connection idle timeout and/or the ELB idle timeout. So we 33 | // set it here to 1 sec less than that. 34 | return connectionIdleTimeout > 1000 ? connectionIdleTimeout - 1000 : 1000; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/netty/server/http2/DummyChannelHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.netty.server.http2; 18 | 19 | import io.netty.channel.ChannelHandler; 20 | import io.netty.channel.ChannelHandlerContext; 21 | 22 | /** 23 | * Dummy Channel Handler 24 | * 25 | * Author: Arthur Gonigberg 26 | * Date: December 15, 2017 27 | */ 28 | public class DummyChannelHandler implements ChannelHandler { 29 | @Override 30 | public void handlerAdded(ChannelHandlerContext ctx) throws Exception {} 31 | 32 | @Override 33 | public void handlerRemoved(ChannelHandlerContext ctx) throws Exception {} 34 | 35 | @Override 36 | public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {} 37 | } 38 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/netty/server/http2/Http2ResetFrameHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.netty.server.http2; 18 | 19 | import com.netflix.zuul.netty.RequestCancelledEvent; 20 | import io.netty.channel.ChannelHandler; 21 | import io.netty.channel.ChannelHandlerContext; 22 | import io.netty.channel.ChannelInboundHandlerAdapter; 23 | import io.netty.handler.codec.http2.Http2ResetFrame; 24 | import io.netty.util.ReferenceCountUtil; 25 | 26 | /** 27 | * User: michaels@netflix.com 28 | * Date: 4/13/17 29 | * Time: 6:02 PM 30 | */ 31 | @ChannelHandler.Sharable 32 | public class Http2ResetFrameHandler extends ChannelInboundHandlerAdapter { 33 | @Override 34 | public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { 35 | if (msg instanceof Http2ResetFrame) { 36 | // Inform zuul to cancel the request. 37 | ctx.fireUserEventTriggered(new RequestCancelledEvent()); 38 | ReferenceCountUtil.safeRelease(msg); 39 | } else { 40 | super.channelRead(ctx, msg); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/netty/server/http2/Http2StreamErrorHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.zuul.netty.server.http2; 17 | 18 | import io.netty.channel.ChannelHandler; 19 | import io.netty.channel.ChannelHandlerContext; 20 | import io.netty.channel.ChannelInboundHandlerAdapter; 21 | import io.netty.handler.codec.DecoderException; 22 | import io.netty.handler.codec.http2.DefaultHttp2ResetFrame; 23 | import io.netty.handler.codec.http2.Http2Error; 24 | import io.netty.handler.codec.http2.Http2Exception; 25 | 26 | /** 27 | * Author: Susheel Aroskar 28 | * Date: 5/7/2018 29 | */ 30 | @ChannelHandler.Sharable 31 | public class Http2StreamErrorHandler extends ChannelInboundHandlerAdapter { 32 | 33 | @Override 34 | public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { 35 | if (cause instanceof Http2Exception.StreamException streamEx) { 36 | 37 | ctx.writeAndFlush(new DefaultHttp2ResetFrame(streamEx.error())); 38 | } else if (cause instanceof DecoderException) { 39 | ctx.writeAndFlush(new DefaultHttp2ResetFrame(Http2Error.PROTOCOL_ERROR)); 40 | } else { 41 | super.exceptionCaught(ctx, cause); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/netty/server/http2/Http2StreamHeaderCleaner.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.netty.server.http2; 18 | 19 | import io.netty.channel.ChannelHandler; 20 | import io.netty.channel.ChannelHandlerContext; 21 | import io.netty.channel.ChannelInboundHandlerAdapter; 22 | import io.netty.handler.codec.http.HttpRequest; 23 | 24 | /** 25 | * The Http2ServerDowngrader currently is always incorrectly setting the "x-http2-stream-id" 26 | * header to "0", which is confusing. And as we don't actually need it and the other "x-http2-" headers, we 27 | * strip them out here to avoid the confusion. 28 | * 29 | * Hopefully in a future netty release that header value will be correct and we can then 30 | * stop doing this. Although potentially we _never_ want to pass these downstream to origins .... ? 31 | */ 32 | @ChannelHandler.Sharable 33 | public class Http2StreamHeaderCleaner extends ChannelInboundHandlerAdapter { 34 | @Override 35 | public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { 36 | if (msg instanceof HttpRequest req) { 37 | 38 | 39 | for (String name : req.headers().names()) { 40 | if (name.startsWith("x-http2-")) { 41 | req.headers().remove(name); 42 | } 43 | } 44 | } 45 | 46 | super.channelRead(ctx, msg); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/netty/server/psk/ClientPSKIdentityInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.zuul.netty.server.psk; 17 | 18 | import java.util.List; 19 | 20 | public record ClientPSKIdentityInfo(List clientPSKIdentity) {} 21 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/netty/server/psk/ExternalTlsPskProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.netty.server.psk; 18 | 19 | public interface ExternalTlsPskProvider { 20 | byte[] provide(byte[] clientPskIdentity, byte[] clientRandom) throws PskCreationFailureException; 21 | } 22 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/netty/server/psk/PskCreationFailureException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.zuul.netty.server.psk; 17 | 18 | public class PskCreationFailureException extends Exception { 19 | 20 | public enum TlsAlertMessage { 21 | /** 22 | * The server does not recognize the (client) PSK identity 23 | */ 24 | unknown_psk_identity, 25 | /** 26 | * The (client) PSK identity existed but the key was incorrect 27 | */ 28 | decrypt_error, 29 | } 30 | 31 | private final TlsAlertMessage tlsAlertMessage; 32 | 33 | public PskCreationFailureException(TlsAlertMessage tlsAlertMessage, String message) { 34 | super(message); 35 | this.tlsAlertMessage = tlsAlertMessage; 36 | } 37 | 38 | public PskCreationFailureException(TlsAlertMessage tlsAlertMessage, String message, Throwable cause) { 39 | super(message, cause); 40 | this.tlsAlertMessage = tlsAlertMessage; 41 | } 42 | 43 | public TlsAlertMessage getTlsAlertMessage() { 44 | return tlsAlertMessage; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/netty/server/psk/TlsPskUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.netty.server.psk; 18 | 19 | import io.netty.buffer.ByteBuf; 20 | import io.netty.util.ReferenceCountUtil; 21 | 22 | class TlsPskUtils { 23 | protected static byte[] readDirect(ByteBuf byteBufMsg) { 24 | int length = byteBufMsg.readableBytes(); 25 | byte[] dest = new byte[length]; 26 | byteBufMsg.readBytes(dest); 27 | return dest; 28 | } 29 | 30 | protected static byte[] getAppDataBytesAndRelease(ByteBuf byteBufMsg) { 31 | byte[] appDataBytes = byteBufMsg.hasArray() ? byteBufMsg.array() : TlsPskUtils.readDirect(byteBufMsg); 32 | ReferenceCountUtil.safeRelease(byteBufMsg); 33 | return appDataBytes; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/netty/server/push/PushClientProtocolHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.netty.server.push; 18 | 19 | import io.netty.channel.ChannelHandlerContext; 20 | import io.netty.channel.ChannelInboundHandlerAdapter; 21 | 22 | /** 23 | * Author: Susheel Aroskar 24 | * Date: 11/2/2018 25 | */ 26 | public class PushClientProtocolHandler extends ChannelInboundHandlerAdapter { 27 | 28 | protected PushUserAuth authEvent; 29 | 30 | protected boolean isAuthenticated() { 31 | return (authEvent != null && authEvent.isSuccess()); 32 | } 33 | 34 | @Override 35 | public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { 36 | if (evt instanceof PushUserAuth) { 37 | authEvent = (PushUserAuth) evt; 38 | } 39 | super.userEventTriggered(ctx, evt); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/netty/server/push/PushMessageFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.netty.server.push; 18 | 19 | import io.netty.channel.ChannelFutureListener; 20 | import io.netty.channel.ChannelHandlerContext; 21 | 22 | /** 23 | * Author: Susheel Aroskar 24 | * Date: 11/2/2018 25 | */ 26 | public abstract class PushMessageFactory { 27 | 28 | public final void sendErrorAndClose(ChannelHandlerContext ctx, int statusCode, String reasonText) { 29 | ctx.writeAndFlush(serverClosingConnectionMessage(statusCode, reasonText)) 30 | .addListener(ChannelFutureListener.CLOSE); 31 | } 32 | 33 | /** 34 | * Application level protocol for asking client to close connection 35 | * @return WebSocketFrame which when sent to client will cause it to close the WebSocket 36 | */ 37 | protected abstract Object goAwayMessage(); 38 | 39 | /** 40 | * Message server sends to the client just before it force closes connection from its side 41 | */ 42 | protected abstract Object serverClosingConnectionMessage(int statusCode, String reasonText); 43 | } 44 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/netty/server/push/PushMessageSenderInitializer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.zuul.netty.server.push; 17 | 18 | import io.netty.channel.Channel; 19 | import io.netty.channel.ChannelInitializer; 20 | import io.netty.channel.ChannelPipeline; 21 | import io.netty.handler.codec.http.HttpObjectAggregator; 22 | import io.netty.handler.codec.http.HttpServerCodec; 23 | 24 | /** 25 | * Author: Susheel Aroskar 26 | * Date: 5/16/18 27 | */ 28 | public abstract class PushMessageSenderInitializer extends ChannelInitializer { 29 | @Override 30 | protected void initChannel(Channel ch) throws Exception { 31 | ChannelPipeline pipeline = ch.pipeline(); 32 | pipeline.addLast(new HttpServerCodec()); 33 | pipeline.addLast(new HttpObjectAggregator(65536)); 34 | addPushMessageHandlers(pipeline); 35 | } 36 | 37 | protected abstract void addPushMessageHandlers(ChannelPipeline pipeline); 38 | } 39 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/netty/server/push/PushUserAuth.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.zuul.netty.server.push; 17 | 18 | public interface PushUserAuth { 19 | 20 | boolean isSuccess(); 21 | 22 | int statusCode(); 23 | 24 | String getClientIdentity(); 25 | } 26 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/netty/ssl/SslContextFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.netty.ssl; 18 | 19 | import io.netty.handler.ssl.SslContext; 20 | import io.netty.handler.ssl.SslContextBuilder; 21 | import java.security.NoSuchAlgorithmException; 22 | import java.util.List; 23 | 24 | /** 25 | * User: michaels@netflix.com 26 | * Date: 11/8/16 27 | * Time: 1:01 PM 28 | */ 29 | public interface SslContextFactory { 30 | SslContextBuilder createBuilderForServer(); 31 | 32 | String[] getProtocols(); 33 | 34 | List getCiphers() throws NoSuchAlgorithmException; 35 | 36 | void enableSessionTickets(SslContext sslContext); 37 | 38 | void configureOpenSslStatsMetrics(SslContext sslContext, String sslContextId); 39 | } 40 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/origins/BasicNettyOriginManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.origins; 18 | 19 | import com.netflix.spectator.api.Registry; 20 | import com.netflix.zuul.context.SessionContext; 21 | import jakarta.inject.Inject; 22 | import jakarta.inject.Singleton; 23 | import java.util.concurrent.ConcurrentHashMap; 24 | 25 | /** 26 | * Basic Netty Origin Manager that most apps can use. This can also serve as a useful template for creating more 27 | * complex origin managers. 28 | * 29 | * Author: Arthur Gonigberg 30 | * Date: November 30, 2017 31 | */ 32 | @Singleton 33 | public class BasicNettyOriginManager implements OriginManager { 34 | 35 | private final Registry registry; 36 | private final ConcurrentHashMap originMappings; 37 | 38 | @Inject 39 | public BasicNettyOriginManager(Registry registry) { 40 | this.registry = registry; 41 | this.originMappings = new ConcurrentHashMap<>(); 42 | } 43 | 44 | @Override 45 | public BasicNettyOrigin getOrigin(OriginName originName, String uri, SessionContext ctx) { 46 | return originMappings.computeIfAbsent(originName, n -> createOrigin(originName, uri, ctx)); 47 | } 48 | 49 | @Override 50 | public BasicNettyOrigin createOrigin(OriginName originName, String uri, SessionContext ctx) { 51 | return new BasicNettyOrigin(originName, registry); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/origins/InstrumentedOrigin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.origins; 18 | 19 | import com.netflix.zuul.message.http.HttpRequestMessage; 20 | 21 | /** 22 | * User: michaels@netflix.com 23 | * Date: 10/8/14 24 | * Time: 6:15 PM 25 | */ 26 | public interface InstrumentedOrigin extends Origin { 27 | 28 | double getErrorPercentage(); 29 | 30 | double getErrorAllPercentage(); 31 | 32 | void adjustRetryPolicyIfNeeded(HttpRequestMessage zuulRequest); 33 | 34 | void preRequestChecks(HttpRequestMessage zuulRequest); 35 | 36 | void recordSuccessResponse(); 37 | 38 | void recordProxyRequestEnd(); 39 | } 40 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/origins/Origin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.zuul.origins; 17 | 18 | /** 19 | * User: michaels@netflix.com 20 | * Date: 5/11/15 21 | * Time: 3:14 PM 22 | */ 23 | public interface Origin { 24 | OriginName getName(); 25 | 26 | boolean isAvailable(); 27 | 28 | boolean isCold(); 29 | } 30 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/origins/OriginConcurrencyExceededException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.origins; 18 | 19 | import com.netflix.zuul.stats.status.ZuulStatusCategory; 20 | 21 | public class OriginConcurrencyExceededException extends OriginThrottledException { 22 | public OriginConcurrencyExceededException(OriginName originName) { 23 | super( 24 | originName, 25 | "Max concurrent requests on origin exceeded", 26 | ZuulStatusCategory.FAILURE_LOCAL_THROTTLED_ORIGIN_CONCURRENCY); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/origins/OriginManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.zuul.origins; 17 | 18 | import com.netflix.zuul.context.SessionContext; 19 | 20 | /** 21 | * User: michaels@netflix.com 22 | * Date: 5/11/15 23 | * Time: 3:15 PM 24 | */ 25 | public interface OriginManager { 26 | 27 | T getOrigin(OriginName originName, String uri, SessionContext ctx); 28 | 29 | T createOrigin(OriginName originName, String uri, SessionContext ctx); 30 | } 31 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/origins/OriginThrottledException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.origins; 18 | 19 | import com.netflix.zuul.exception.ZuulException; 20 | import com.netflix.zuul.stats.status.StatusCategory; 21 | import java.util.Objects; 22 | 23 | public abstract class OriginThrottledException extends ZuulException { 24 | private final OriginName originName; 25 | private final StatusCategory statusCategory; 26 | 27 | public OriginThrottledException(OriginName originName, String msg, StatusCategory statusCategory) { 28 | // Ensure this exception does not fill its stacktrace as causes too much load. 29 | super(msg + ", origin=" + originName, true); 30 | this.originName = Objects.requireNonNull(originName, "originName"); 31 | this.statusCategory = statusCategory; 32 | this.setStatusCode(503); 33 | } 34 | 35 | public OriginName getOriginName() { 36 | return originName; 37 | } 38 | 39 | public StatusCategory getStatusCategory() { 40 | return statusCategory; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/passport/PassportItem.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.passport; 18 | 19 | public class PassportItem { 20 | private final long time; 21 | private final PassportState state; 22 | 23 | public PassportItem(PassportState state, long time) { 24 | this.time = time; 25 | this.state = state; 26 | } 27 | 28 | public long getTime() { 29 | return time; 30 | } 31 | 32 | public PassportState getState() { 33 | return state; 34 | } 35 | 36 | @Override 37 | public String toString() { 38 | return time + "=" + state; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/passport/StartAndEnd.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.passport; 18 | 19 | public class StartAndEnd { 20 | long startTime = -1; 21 | long endTime = -1; 22 | 23 | public long getStart() { 24 | return startTime; 25 | } 26 | 27 | public long getEnd() { 28 | return endTime; 29 | } 30 | 31 | boolean startNotFound() { 32 | return startTime == -1; 33 | } 34 | 35 | boolean endNotFound() { 36 | return endTime == -1; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/stats/AmazonInfoHolder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.zuul.stats; 17 | 18 | import com.netflix.appinfo.AmazonInfo; 19 | 20 | /** 21 | * Builds and caches an AmazonInfo instance in memory. 22 | * 23 | * @author mhawthorne 24 | */ 25 | public class AmazonInfoHolder { 26 | 27 | private static final AmazonInfo INFO = AmazonInfo.Builder.newBuilder().autoBuild("eureka"); 28 | 29 | public static final AmazonInfo getInfo() { 30 | return INFO; 31 | } 32 | 33 | private AmazonInfoHolder() {} 34 | } 35 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/stats/BasicRequestMetricsPublisher.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.stats; 18 | 19 | import com.netflix.zuul.context.SessionContext; 20 | 21 | /** 22 | * User: michaels@netflix.com 23 | * Date: 6/4/15 24 | * Time: 4:22 PM 25 | */ 26 | public class BasicRequestMetricsPublisher implements RequestMetricsPublisher { 27 | @Override 28 | public void collectAndPublish(SessionContext context) { 29 | // Record metrics here. 30 | 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/stats/RequestMetricsPublisher.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.zuul.stats; 17 | 18 | import com.netflix.zuul.context.SessionContext; 19 | 20 | /** 21 | * User: michaels@netflix.com 22 | * Date: 3/9/15 23 | * Time: 5:56 PM 24 | */ 25 | public interface RequestMetricsPublisher { 26 | void collectAndPublish(SessionContext context); 27 | } 28 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/stats/monitoring/Monitor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.zuul.stats.monitoring; 17 | 18 | /** 19 | * Interface to register a counter to monitor 20 | * @author Mikey Cohen 21 | * Date: 3/18/13 22 | * Time: 4:33 PM 23 | */ 24 | public interface Monitor { 25 | /** 26 | * Implement this to add this Counter to a Registry 27 | * @param monitorObj 28 | */ 29 | void register(NamedCount monitorObj); 30 | } 31 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/stats/monitoring/MonitorRegistry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.zuul.stats.monitoring; 17 | 18 | /** 19 | * Registry to register a Counter. a Monitor publisher should be set to get counter information. 20 | * If it isn't set, registration will be ignored. 21 | * @author Mikey Cohen 22 | * Date: 3/18/13 23 | * Time: 4:24 PM 24 | */ 25 | public class MonitorRegistry { 26 | 27 | private static final MonitorRegistry instance = new MonitorRegistry(); 28 | private Monitor publisher; 29 | 30 | /** 31 | * A Monitor implementation should be set here 32 | * @param publisher 33 | */ 34 | public void setPublisher(Monitor publisher) { 35 | this.publisher = publisher; 36 | } 37 | 38 | public static MonitorRegistry getInstance() { 39 | return instance; 40 | } 41 | 42 | public void registerObject(NamedCount monitorObj) { 43 | if (publisher != null) { 44 | publisher.register(monitorObj); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/stats/monitoring/NamedCount.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.zuul.stats.monitoring; 17 | 18 | /** 19 | * Interface for a named counter 20 | * @author Mikey Cohen 21 | * Date: 3/18/13 22 | * Time: 4:33 PM 23 | */ 24 | public interface NamedCount { 25 | String getName(); 26 | 27 | long getCount(); 28 | } 29 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/stats/status/StatusCategory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.stats.status; 18 | 19 | import com.google.errorprone.annotations.Immutable; 20 | 21 | /** 22 | * Status Category 23 | * 24 | * Author: Arthur Gonigberg 25 | * Date: December 20, 2017 26 | */ 27 | @Immutable 28 | public interface StatusCategory { 29 | String getId(); 30 | 31 | StatusCategoryGroup getGroup(); 32 | 33 | String getReason(); 34 | 35 | String name(); 36 | } 37 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/stats/status/StatusCategoryGroup.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.stats.status; 18 | 19 | import com.google.errorprone.annotations.Immutable; 20 | 21 | /** 22 | * Status Category Group 23 | * 24 | * Author: Arthur Gonigberg 25 | * Date: December 20, 2017 26 | */ 27 | @Immutable 28 | public interface StatusCategoryGroup { 29 | int getId(); 30 | 31 | String name(); 32 | } 33 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/stats/status/ZuulStatusCategoryGroup.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.stats.status; 18 | 19 | import com.google.errorprone.annotations.Immutable; 20 | 21 | /** 22 | * Zuul Status Category Group 23 | * 24 | * Author: Arthur Gonigberg 25 | * Date: December 20, 2017 26 | */ 27 | @Immutable 28 | public enum ZuulStatusCategoryGroup implements StatusCategoryGroup { 29 | SUCCESS(1), 30 | FAILURE(2); 31 | 32 | private final int id; 33 | 34 | ZuulStatusCategoryGroup(int id) { 35 | this.id = id; 36 | } 37 | 38 | @Override 39 | public int getId() { 40 | return id; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /zuul-core/src/main/java/com/netflix/zuul/util/VipUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.util; 18 | 19 | public final class VipUtils { 20 | public static String getVIPPrefix(String vipAddress) { 21 | for (int i = 0; i < vipAddress.length(); i++) { 22 | char c = vipAddress.charAt(i); 23 | if (c == '.' || c == ':') { 24 | return vipAddress.substring(0, i); 25 | } 26 | } 27 | return vipAddress; 28 | } 29 | 30 | /** 31 | * Use {@link #extractUntrustedAppNameFromVIP} instead. 32 | */ 33 | @Deprecated 34 | public static String extractAppNameFromVIP(String vipAddress) { 35 | String vipPrefix = getVIPPrefix(vipAddress); 36 | return vipPrefix.split("-", -1)[0]; 37 | } 38 | 39 | /** 40 | * Attempts to derive an app name from the VIP. Because the VIP is an arbitrary collection of characters, the 41 | * value is just a best guess and not suitable for security purposes. 42 | */ 43 | public static String extractUntrustedAppNameFromVIP(String vipAddress) { 44 | for (int i = 0; i < vipAddress.length(); i++) { 45 | char c = vipAddress.charAt(i); 46 | if (c == '-' || c == '.' || c == ':') { 47 | return vipAddress.substring(0, i); 48 | } 49 | } 50 | return vipAddress; 51 | } 52 | 53 | private VipUtils() {} 54 | } 55 | -------------------------------------------------------------------------------- /zuul-core/src/test/java/com/netflix/netty/common/metrics/InstrumentedResourceLeakDetectorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.netty.common.metrics; 18 | 19 | import static org.junit.jupiter.api.Assertions.assertEquals; 20 | 21 | import io.netty.buffer.ByteBuf; 22 | import org.junit.jupiter.api.BeforeEach; 23 | import org.junit.jupiter.api.Test; 24 | import org.junit.jupiter.api.extension.ExtendWith; 25 | import org.mockito.junit.jupiter.MockitoExtension; 26 | 27 | @ExtendWith(MockitoExtension.class) 28 | class InstrumentedResourceLeakDetectorTest { 29 | 30 | InstrumentedResourceLeakDetector leakDetector; 31 | 32 | @BeforeEach 33 | void setup() { 34 | leakDetector = new InstrumentedResourceLeakDetector<>(ByteBuf.class, 1); 35 | } 36 | 37 | @Test 38 | void test() { 39 | leakDetector.reportTracedLeak("test", "test"); 40 | assertEquals(1, leakDetector.leakCounter.get()); 41 | 42 | leakDetector.reportTracedLeak("test", "test"); 43 | assertEquals(2, leakDetector.leakCounter.get()); 44 | 45 | leakDetector.reportTracedLeak("test", "test"); 46 | assertEquals(3, leakDetector.leakCounter.get()); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /zuul-core/src/test/java/com/netflix/zuul/netty/ssl/BaseSslContextFactoryTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.netty.ssl; 18 | 19 | import static org.junit.jupiter.api.Assertions.assertEquals; 20 | 21 | import io.netty.handler.ssl.SslProvider; 22 | import org.junit.jupiter.api.Test; 23 | 24 | /** 25 | * Tests for {@link BaseSslContextFactory}. 26 | */ 27 | class BaseSslContextFactoryTest { 28 | @Test 29 | void testDefaultSslProviderIsOpenSsl() { 30 | assertEquals(SslProvider.OPENSSL, BaseSslContextFactory.chooseSslProvider()); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /zuul-core/src/test/java/com/netflix/zuul/netty/ssl/OpenSslTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.netty.ssl; 18 | 19 | import static com.google.common.truth.Truth.assertThat; 20 | import static org.junit.jupiter.api.Assertions.assertTrue; 21 | 22 | import io.netty.handler.ssl.OpenSsl; 23 | import io.netty.handler.ssl.SslProvider; 24 | import org.junit.jupiter.api.BeforeEach; 25 | import org.junit.jupiter.api.Test; 26 | 27 | class OpenSslTest { 28 | @BeforeEach 29 | void beforeEach() { 30 | OpenSsl.ensureAvailability(); 31 | assertTrue(OpenSsl.isAvailable()); 32 | } 33 | 34 | @Test 35 | void testBoringSsl() { 36 | assertThat(OpenSsl.versionString()).isEqualTo("BoringSSL"); 37 | assertTrue(SslProvider.isAlpnSupported(SslProvider.OPENSSL)); 38 | assertTrue(SslProvider.isTlsv13Supported(SslProvider.OPENSSL)); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /zuul-core/src/test/java/com/netflix/zuul/stats/ErrorStatsDataTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.stats; 18 | 19 | import static org.junit.jupiter.api.Assertions.assertEquals; 20 | import static org.junit.jupiter.api.Assertions.assertNotEquals; 21 | 22 | import org.junit.jupiter.api.Test; 23 | import org.junit.jupiter.api.extension.ExtendWith; 24 | import org.mockito.junit.jupiter.MockitoExtension; 25 | 26 | /** 27 | * Unit tests for {@link ErrorStatsData}. 28 | */ 29 | @ExtendWith(MockitoExtension.class) 30 | class ErrorStatsDataTest { 31 | 32 | @Test 33 | void testUpdateStats() { 34 | ErrorStatsData sd = new ErrorStatsData("route", "test"); 35 | sd.update(); 36 | assertEquals(1, sd.getCount()); 37 | sd.update(); 38 | assertEquals(2, sd.getCount()); 39 | } 40 | 41 | @Test 42 | void testEquals() { 43 | ErrorStatsData sd = new ErrorStatsData("route", "test"); 44 | ErrorStatsData sd1 = new ErrorStatsData("route", "test"); 45 | ErrorStatsData sd2 = new ErrorStatsData("route", "test1"); 46 | ErrorStatsData sd3 = new ErrorStatsData("route", "test"); 47 | 48 | assertEquals(sd, sd1); 49 | assertEquals(sd1, sd); 50 | assertEquals(sd, sd); 51 | assertNotEquals(sd, sd2); 52 | assertNotEquals(sd2, sd3); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /zuul-core/src/test/java/com/netflix/zuul/stats/ErrorStatsManagerTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.stats; 18 | 19 | import static org.junit.jupiter.api.Assertions.assertEquals; 20 | import static org.junit.jupiter.api.Assertions.assertNotNull; 21 | 22 | import java.util.concurrent.ConcurrentHashMap; 23 | import org.junit.jupiter.api.Test; 24 | import org.junit.jupiter.api.extension.ExtendWith; 25 | import org.mockito.junit.jupiter.MockitoExtension; 26 | 27 | /** 28 | * Unit tests for {@link ErrorStatsManager}. 29 | */ 30 | @ExtendWith(MockitoExtension.class) 31 | class ErrorStatsManagerTest { 32 | 33 | @Test 34 | void testPutStats() { 35 | ErrorStatsManager sm = new ErrorStatsManager(); 36 | assertNotNull(sm); 37 | sm.putStats("test", "cause"); 38 | assertNotNull(sm.routeMap.get("test")); 39 | ConcurrentHashMap map = sm.routeMap.get("test"); 40 | ErrorStatsData sd = map.get("cause"); 41 | assertEquals(1, sd.getCount()); 42 | sm.putStats("test", "cause"); 43 | assertEquals(2, sd.getCount()); 44 | } 45 | 46 | @Test 47 | void testGetStats() { 48 | ErrorStatsManager sm = new ErrorStatsManager(); 49 | assertNotNull(sm); 50 | sm.putStats("test", "cause"); 51 | assertNotNull(sm.getStats("test", "cause")); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /zuul-core/src/test/java/com/netflix/zuul/stats/RouteStatusCodeMonitorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.stats; 18 | 19 | import static org.junit.jupiter.api.Assertions.assertEquals; 20 | import static org.junit.jupiter.api.Assertions.assertNotEquals; 21 | 22 | import org.junit.jupiter.api.Test; 23 | 24 | /** 25 | * Unit tests for {@link RouteStatusCodeMonitor}. 26 | */ 27 | class RouteStatusCodeMonitorTest { 28 | @Test 29 | void testUpdateStats() { 30 | RouteStatusCodeMonitor sd = new RouteStatusCodeMonitor("test", 200); 31 | assertEquals("test", sd.route); 32 | sd.update(); 33 | assertEquals(1, sd.getCount()); 34 | sd.update(); 35 | assertEquals(2, sd.getCount()); 36 | } 37 | 38 | @Test 39 | void testEquals() { 40 | RouteStatusCodeMonitor sd = new RouteStatusCodeMonitor("test", 200); 41 | RouteStatusCodeMonitor sd1 = new RouteStatusCodeMonitor("test", 200); 42 | RouteStatusCodeMonitor sd2 = new RouteStatusCodeMonitor("test1", 200); 43 | RouteStatusCodeMonitor sd3 = new RouteStatusCodeMonitor("test", 201); 44 | 45 | assertEquals(sd, sd1); 46 | assertEquals(sd1, sd); 47 | assertEquals(sd, sd); 48 | assertNotEquals(sd, sd2); 49 | assertNotEquals(sd, sd3); 50 | assertNotEquals(sd2, sd3); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /zuul-core/src/test/java/com/netflix/zuul/stats/status/ZuulStatusCategoryTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.stats.status; 18 | 19 | import static org.junit.jupiter.api.Assertions.assertEquals; 20 | 21 | import java.util.Arrays; 22 | import java.util.Set; 23 | import java.util.stream.Collectors; 24 | import org.junit.jupiter.api.Test; 25 | 26 | /** 27 | * @author Justin Guerra 28 | * @since 10/29/24 29 | */ 30 | public class ZuulStatusCategoryTest { 31 | 32 | @Test 33 | public void categoriesUseUniqueIds() { 34 | ZuulStatusCategory[] values = ZuulStatusCategory.values(); 35 | Set ids = Arrays.stream(values).map(ZuulStatusCategory::getId).collect(Collectors.toSet()); 36 | assertEquals(values.length, ids.size()); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /zuul-discovery/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: "java-library" 2 | 3 | dependencies { 4 | 5 | implementation libraries.guava 6 | implementation libraries.slf4j 7 | 8 | api "com.netflix.ribbon:ribbon-loadbalancer:${versions_ribbon}" 9 | implementation "com.netflix.ribbon:ribbon-core:${versions_ribbon}" 10 | implementation "com.netflix.ribbon:ribbon-eureka:${versions_ribbon}" 11 | implementation "com.netflix.ribbon:ribbon-archaius:${versions_ribbon}" 12 | // Eureka 13 | implementation "com.netflix.eureka:eureka-client:2.0.4" 14 | // unfortunately, servo is still a transitive dependency of eureka-client that stopped getting picked up 15 | // after switching to version 2 16 | api "com.netflix.servo:servo-core:0.13.2" 17 | 18 | 19 | testImplementation libraries.jupiterApi, libraries.jupiterParams, libraries.jupiterEngine, 20 | libraries.mockito, 21 | libraries.truth 22 | } 23 | 24 | test { 25 | testLogging { 26 | showStandardStreams = false 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /zuul-discovery/src/main/java/com/netflix/zuul/discovery/NonDiscoveryServer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.discovery; 18 | 19 | import com.netflix.loadbalancer.Server; 20 | import java.util.Objects; 21 | 22 | /** 23 | * @author Argha C 24 | * @since 3/1/21 25 | *

26 | * This exists merely to wrap a resolver lookup result, that is not discovery enabled. 27 | */ 28 | public final class NonDiscoveryServer implements ResolverResult { 29 | 30 | private final Server server; 31 | 32 | public NonDiscoveryServer(String host, int port) { 33 | Objects.requireNonNull(host, "host name"); 34 | this.server = new Server(host, validatePort(port)); 35 | } 36 | 37 | @Override 38 | public String getHost() { 39 | return server.getHost(); 40 | } 41 | 42 | @Override 43 | public int getPort() { 44 | return server.getPort(); 45 | } 46 | 47 | @Override 48 | public boolean isDiscoveryEnabled() { 49 | return false; 50 | } 51 | 52 | private int validatePort(int port) { 53 | if (port < 0 || port > 0xFFFF) { 54 | throw new IllegalArgumentException("port out of range:" + port); 55 | } 56 | return port; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /zuul-discovery/src/main/java/com/netflix/zuul/discovery/ResolverResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.zuul.discovery; 17 | 18 | /** 19 | * @author Argha C 20 | * @since 2/25/21 21 | * 22 | * Wraps the result of a resolution attempt. 23 | * At this time, it doesn't encapsulate a collection of instances, but ideally should. 24 | */ 25 | public interface ResolverResult { 26 | 27 | // TODO(argha-c): This should ideally model returning a collection of host/port pairs. 28 | public String getHost(); 29 | 30 | public int getPort(); 31 | 32 | public boolean isDiscoveryEnabled(); 33 | } 34 | -------------------------------------------------------------------------------- /zuul-discovery/src/main/java/com/netflix/zuul/discovery/SimpleMetaInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.discovery; 18 | 19 | import com.netflix.loadbalancer.Server.MetaInfo; 20 | 21 | /** 22 | * @author Argha C 23 | * @since 2/25/21 24 | * 25 | * placeholder to mimic metainfo for a non-Eureka enabled server. 26 | * This exists to preserve compatibility with some current logic, but should be revisited. 27 | */ 28 | public final class SimpleMetaInfo { 29 | 30 | private final MetaInfo metaInfo; 31 | 32 | public SimpleMetaInfo(MetaInfo metaInfo) { 33 | this.metaInfo = metaInfo; 34 | } 35 | 36 | public String getServerGroup() { 37 | return metaInfo.getServerGroup(); 38 | } 39 | 40 | public String getServiceIdForDiscovery() { 41 | return metaInfo.getServiceIdForDiscovery(); 42 | } 43 | 44 | public String getInstanceId() { 45 | return metaInfo.getInstanceId(); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /zuul-discovery/src/main/java/com/netflix/zuul/resolver/Resolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.resolver; 18 | 19 | /** 20 | * @author Argha C 21 | * @since 2/25/21 22 | * 23 | * Resolves a key to a discovery result type. 24 | */ 25 | public interface Resolver { 26 | 27 | /** 28 | * 29 | * @param key unique identifier that may be used by certain resolvers as part of lookup. Implementations 30 | * can narrow this down to be nullable. 31 | * @return the result of a resolver lookup 32 | */ 33 | // TODO(argha-c) Param needs to be typed, once the ribbon LB lookup API is figured out. 34 | T resolve(Object key); 35 | 36 | /** 37 | * @return true if the resolver has available servers, false otherwise 38 | */ 39 | boolean hasServers(); 40 | 41 | /** 42 | * hook to perform activities on shutdown 43 | */ 44 | void shutdown(); 45 | 46 | default void setListener(ResolverListener listener) {} 47 | } 48 | -------------------------------------------------------------------------------- /zuul-discovery/src/main/java/com/netflix/zuul/resolver/ResolverListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.resolver; 18 | 19 | import java.util.List; 20 | 21 | /** 22 | * @author Argha C 23 | * @since 2/25/21 24 | * 25 | * Listener for resolver updates. 26 | */ 27 | public interface ResolverListener { 28 | 29 | /** 30 | * Hook to respond to resolver updates 31 | * @param removedSet the servers removed from the latest resolver update, but included in the previous update. 32 | */ 33 | void onChange(List removedSet); 34 | } 35 | -------------------------------------------------------------------------------- /zuul-integration-test/src/test/java/com/netflix/zuul/integration/server/HeaderNames.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.integration.server; 18 | 19 | public class HeaderNames { 20 | private HeaderNames() {} 21 | 22 | public static final String REQUEST_ID = "request-id"; 23 | } 24 | -------------------------------------------------------------------------------- /zuul-integration-test/src/test/java/com/netflix/zuul/integration/server/OriginServerList.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.integration.server; 18 | 19 | import com.google.common.base.Strings; 20 | import com.google.common.collect.Lists; 21 | import com.netflix.loadbalancer.ConfigurationBasedServerList; 22 | import com.netflix.loadbalancer.Server; 23 | import java.util.List; 24 | 25 | public class OriginServerList extends ConfigurationBasedServerList { 26 | @Override 27 | protected List derive(String value) { 28 | List list = Lists.newArrayList(); 29 | if (!Strings.isNullOrEmpty(value)) { 30 | for (String s : value.split(",", -1)) { 31 | String[] hostAndPort = s.split(":", -1); 32 | String host = hostAndPort[0]; 33 | int port = Integer.parseInt(hostAndPort[1]); 34 | list.add(TestUtil.makeDiscoveryEnabledServer("", host, port)); 35 | } 36 | } 37 | return list; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /zuul-integration-test/src/test/java/com/netflix/zuul/integration/server/filters/BodyUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.zuul.integration.server.filters; 17 | 18 | import com.netflix.zuul.message.http.HttpRequestMessage; 19 | 20 | public class BodyUtil { 21 | public static boolean needsRequestBodyBuffering(HttpRequestMessage request) { 22 | return request.getQueryParams().contains("bufferRequestBody", "true"); 23 | } 24 | 25 | public static boolean needsResponseBodyBuffering(HttpRequestMessage request) { 26 | return request.getQueryParams().contains("bufferResponseBody", "true"); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /zuul-integration-test/src/test/java/com/netflix/zuul/integration/server/filters/InboundRoutesFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.integration.server.filters; 18 | 19 | import com.netflix.zuul.Filter; 20 | import com.netflix.zuul.context.SessionContext; 21 | import com.netflix.zuul.filters.FilterType; 22 | import com.netflix.zuul.filters.endpoint.ProxyEndpoint; 23 | import com.netflix.zuul.filters.http.HttpInboundSyncFilter; 24 | import com.netflix.zuul.message.http.HttpRequestMessage; 25 | 26 | @Filter(order = 0, type = FilterType.INBOUND) 27 | public class InboundRoutesFilter extends HttpInboundSyncFilter { 28 | @Override 29 | public int filterOrder() { 30 | return 0; 31 | } 32 | 33 | @Override 34 | public boolean shouldFilter(HttpRequestMessage msg) { 35 | return true; 36 | } 37 | 38 | @Override 39 | public HttpRequestMessage apply(HttpRequestMessage input) { 40 | // uncomment this line to trigger a resource leak 41 | // ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); 42 | 43 | SessionContext context = input.getContext(); 44 | context.setEndpoint(ProxyEndpoint.class.getCanonicalName()); 45 | context.setRouteVIP("api"); 46 | return input; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /zuul-integration-test/src/test/java/com/netflix/zuul/integration/server/filters/NeedsBodyBufferedInboundFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.integration.server.filters; 18 | 19 | import com.netflix.zuul.Filter; 20 | import com.netflix.zuul.filters.FilterType; 21 | import com.netflix.zuul.filters.http.HttpInboundFilter; 22 | import com.netflix.zuul.message.http.HttpRequestMessage; 23 | import rx.Observable; 24 | 25 | @Filter(order = 20, type = FilterType.INBOUND) 26 | public class NeedsBodyBufferedInboundFilter extends HttpInboundFilter { 27 | 28 | @Override 29 | public boolean shouldFilter(HttpRequestMessage msg) { 30 | return msg.hasBody(); 31 | } 32 | 33 | @Override 34 | public boolean needsBodyBuffered(HttpRequestMessage message) { 35 | return BodyUtil.needsRequestBodyBuffering(message); 36 | } 37 | 38 | @Override 39 | public Observable applyAsync(HttpRequestMessage input) { 40 | return Observable.just(input); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /zuul-integration-test/src/test/java/com/netflix/zuul/integration/server/filters/NeedsBodyBufferedOutboundFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.integration.server.filters; 18 | 19 | import com.netflix.zuul.Filter; 20 | import com.netflix.zuul.filters.FilterType; 21 | import com.netflix.zuul.filters.http.HttpOutboundFilter; 22 | import com.netflix.zuul.message.http.HttpResponseMessage; 23 | import rx.Observable; 24 | 25 | @Filter(order = 450, type = FilterType.OUTBOUND) 26 | public class NeedsBodyBufferedOutboundFilter extends HttpOutboundFilter { 27 | @Override 28 | public boolean shouldFilter(HttpResponseMessage msg) { 29 | return msg.hasBody(); 30 | } 31 | 32 | @Override 33 | public boolean needsBodyBuffered(HttpResponseMessage message) { 34 | return BodyUtil.needsResponseBodyBuffering(message.getOutboundRequest()); 35 | } 36 | 37 | @Override 38 | public Observable applyAsync(HttpResponseMessage response) { 39 | return Observable.just(response); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /zuul-integration-test/src/test/java/com/netflix/zuul/integration/server/filters/RequestHeaderFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.integration.server.filters; 18 | 19 | import com.netflix.zuul.Filter; 20 | import com.netflix.zuul.filters.FilterType; 21 | import com.netflix.zuul.filters.http.HttpInboundFilter; 22 | import com.netflix.zuul.integration.server.HeaderNames; 23 | import com.netflix.zuul.message.http.HttpRequestMessage; 24 | import java.util.UUID; 25 | import rx.Observable; 26 | 27 | @Filter(order = 10, type = FilterType.INBOUND) 28 | public class RequestHeaderFilter extends HttpInboundFilter { 29 | @Override 30 | public boolean shouldFilter(HttpRequestMessage msg) { 31 | return true; 32 | } 33 | 34 | @Override 35 | public Observable applyAsync(HttpRequestMessage request) { 36 | request.getHeaders().set(HeaderNames.REQUEST_ID, "RQ-" + UUID.randomUUID()); 37 | request.storeInboundRequest(); 38 | return Observable.just(request); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /zuul-integration-test/src/test/java/com/netflix/zuul/integration/server/filters/ResponseHeaderFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.integration.server.filters; 18 | 19 | import com.netflix.zuul.Filter; 20 | import com.netflix.zuul.filters.FilterType; 21 | import com.netflix.zuul.filters.http.HttpOutboundFilter; 22 | import com.netflix.zuul.integration.server.HeaderNames; 23 | import com.netflix.zuul.message.http.HttpResponseMessage; 24 | import rx.Observable; 25 | 26 | @Filter(order = 400, type = FilterType.OUTBOUND) 27 | public class ResponseHeaderFilter extends HttpOutboundFilter { 28 | @Override 29 | public boolean shouldFilter(HttpResponseMessage msg) { 30 | return true; 31 | } 32 | 33 | @Override 34 | public Observable applyAsync(HttpResponseMessage response) { 35 | String requestId = response.getInboundRequest().getHeaders().getFirst(HeaderNames.REQUEST_ID); 36 | if (requestId != null) { 37 | response.getHeaders().set(HeaderNames.REQUEST_ID, requestId); 38 | response.storeInboundResponse(); 39 | } 40 | return Observable.just(response); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /zuul-integration-test/src/test/resources/log4j2-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /zuul-processor/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: "java" 2 | 3 | dependencies { 4 | implementation libraries.guava 5 | implementation project(":zuul-core") 6 | 7 | testImplementation libraries.jupiterApi, libraries.jupiterParams, libraries.jupiterEngine, 8 | libraries.truth 9 | testAnnotationProcessor project(":zuul-processor") 10 | } 11 | 12 | // Silences log statements during tests. This still allows normal failures to be printed. 13 | test { 14 | testLogging { 15 | showStandardStreams = false 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /zuul-processor/src/main/resources/META-INF/gradle/incremental.annotation.processors: -------------------------------------------------------------------------------- 1 | com.netflix.zuul.filters.processor.FilterProcessor,aggregating -------------------------------------------------------------------------------- /zuul-processor/src/main/resources/META-INF/services/javax.annotation.processing.Processor: -------------------------------------------------------------------------------- 1 | com.netflix.zuul.filters.processor.FilterProcessor -------------------------------------------------------------------------------- /zuul-processor/src/test/java/com/netflix/zuul/filters/processor/FilterProcessorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.filters.processor; 18 | 19 | import com.google.common.truth.Truth; 20 | import com.netflix.zuul.StaticFilterLoader; 21 | import com.netflix.zuul.filters.ZuulFilter; 22 | import com.netflix.zuul.filters.processor.override.SubpackageFilter; 23 | import com.netflix.zuul.filters.processor.subpackage.OverrideFilter; 24 | import java.util.Collection; 25 | import org.junit.jupiter.api.Test; 26 | 27 | /** 28 | * Tests for {@link FilterProcessor}. 29 | */ 30 | class FilterProcessorTest { 31 | 32 | @Test 33 | void allFilterClassedRecorded() throws Exception { 34 | Collection>> filters = 35 | StaticFilterLoader.loadFilterTypesFromResources(getClass().getClassLoader()); 36 | 37 | Truth.assertThat(filters) 38 | .containsExactly( 39 | OuterClassFilter.class, 40 | TopLevelFilter.class, 41 | TopLevelFilter.StaticSubclassFilter.class, 42 | TopLevelFilter.SubclassFilter.class, 43 | OverrideFilter.class, 44 | SubpackageFilter.class); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /zuul-processor/src/test/java/com/netflix/zuul/filters/processor/TopLevelFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.filters.processor; 18 | 19 | import com.netflix.zuul.Filter; 20 | import com.netflix.zuul.filters.FilterType; 21 | 22 | /** 23 | * Used to test generated code. 24 | */ 25 | @Filter(order = 20, type = FilterType.INBOUND) 26 | final class TopLevelFilter extends TestFilter { 27 | 28 | @Filter(order = 21, type = FilterType.INBOUND) 29 | static final class StaticSubclassFilter extends TestFilter {} 30 | 31 | @SuppressWarnings("unused") // This should be ignored by the processor, since it is abstract 32 | @Filter(order = 22, type = FilterType.INBOUND) 33 | abstract static class AbstractSubclassFilter extends TestFilter {} 34 | 35 | @SuppressWarnings("InnerClassMayBeStatic") // The purpose of this test 36 | @Filter(order = 23, type = FilterType.INBOUND) 37 | final class SubclassFilter extends TestFilter {} 38 | 39 | static { 40 | // This should be ignored by the processor, since it is private. 41 | // See https://bugs.openjdk.java.net/browse/JDK-6587158 42 | @SuppressWarnings("unused") 43 | @Filter(order = 23, type = FilterType.INBOUND) 44 | final class MethodClassFilter {} 45 | } 46 | } 47 | 48 | @Filter(order = 24, type = FilterType.INBOUND) 49 | final class OuterClassFilter extends TestFilter {} 50 | -------------------------------------------------------------------------------- /zuul-processor/src/test/java/com/netflix/zuul/filters/processor/override/SubpackageFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.filters.processor.override; 18 | 19 | import com.netflix.zuul.Filter; 20 | import com.netflix.zuul.filters.FilterType; 21 | import com.netflix.zuul.filters.processor.TestFilter; 22 | 23 | @Filter(order = 30, type = FilterType.INBOUND) 24 | public final class SubpackageFilter extends TestFilter {} 25 | -------------------------------------------------------------------------------- /zuul-processor/src/test/java/com/netflix/zuul/filters/processor/override/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | @com.netflix.zuul.Filter.FilterPackageName("MySubpackage") 18 | package com.netflix.zuul.filters.processor.override; 19 | -------------------------------------------------------------------------------- /zuul-processor/src/test/java/com/netflix/zuul/filters/processor/subpackage/OverrideFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.filters.processor.subpackage; 18 | 19 | import com.netflix.zuul.Filter; 20 | import com.netflix.zuul.filters.FilterType; 21 | import com.netflix.zuul.filters.processor.TestFilter; 22 | 23 | @Filter(order = 30, type = FilterType.INBOUND) 24 | public final class OverrideFilter extends TestFilter {} 25 | -------------------------------------------------------------------------------- /zuul-sample/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: "java" 2 | apply plugin: 'application' 3 | 4 | dependencies { 5 | implementation project(":zuul-core") 6 | implementation "com.netflix.eureka:eureka-client:2.0.4" 7 | implementation 'commons-configuration:commons-configuration:1.10' 8 | implementation "jakarta.inject:jakarta.inject-api:2.0.1" 9 | annotationProcessor project(":zuul-processor") 10 | 11 | implementation 'org.apache.logging.log4j:log4j-core:2.24.3' 12 | implementation 'org.apache.logging.log4j:log4j-api:2.24.3' 13 | implementation 'org.apache.logging.log4j:log4j-slf4j-impl:2.24.3' 14 | implementation 'org.slf4j:slf4j-simple:2.0.16' 15 | } 16 | 17 | /* 18 | * Run regular: ./gradlew run 19 | * Run benchmark: ./gradlew run -Pbench 20 | */ 21 | run { 22 | mainClassName = "com.netflix.zuul.sample.Bootstrap" 23 | 24 | applicationDefaultJvmArgs = ["-DTZ=GMT", 25 | "-Darchaius.deployment.environment=test", 26 | "-Dcom.sun.management.jmxremote", 27 | "-Dcom.sun.management.jmxremote.local.only=false", 28 | "-Deureka.validateInstanceId=false", 29 | "-Deureka.mt.num_retries=1", 30 | "-Dlog4j.configurationFile=log4j2.xml"] 31 | 32 | if (project.hasProperty('bench')) { 33 | println 'Running benchmark configuration...' 34 | jvmArgs "-Darchaius.deployment.environment=benchmark" 35 | } 36 | } 37 | 38 | -------------------------------------------------------------------------------- /zuul-sample/src/main/java/com/netflix/zuul/sample/SampleService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.sample; 18 | 19 | import java.util.concurrent.TimeUnit; 20 | import java.util.concurrent.atomic.AtomicBoolean; 21 | import rx.Observable; 22 | 23 | /** 24 | * Sample Service for demonstration in SampleServiceFilter. 25 | *

26 | * Author: Arthur Gonigberg 27 | * Date: January 04, 2018 28 | */ 29 | public class SampleService { 30 | 31 | private final AtomicBoolean status; 32 | 33 | public SampleService() { 34 | // change to true for demo 35 | this.status = new AtomicBoolean(false); 36 | } 37 | 38 | public boolean isHealthy() { 39 | return status.get(); 40 | } 41 | 42 | public Observable makeSlowRequest() { 43 | return Observable.just("test").delay(500, TimeUnit.MILLISECONDS); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /zuul-sample/src/main/java/com/netflix/zuul/sample/filters/Debug.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.sample.filters; 18 | 19 | import com.netflix.zuul.Filter; 20 | import com.netflix.zuul.filters.http.HttpInboundSyncFilter; 21 | import com.netflix.zuul.message.http.HttpRequestMessage; 22 | 23 | /** 24 | * Determine if requests need to be debugged. 25 | * 26 | * In order to test this, set query parameter "debugRequest=true" 27 | * 28 | * Author: Arthur Gonigberg 29 | * Date: December 22, 2017 30 | */ 31 | @Filter(order = 20) 32 | public class Debug extends HttpInboundSyncFilter { 33 | @Override 34 | public int filterOrder() { 35 | return 20; 36 | } 37 | 38 | @Override 39 | public boolean shouldFilter(HttpRequestMessage request) { 40 | return "true".equalsIgnoreCase(request.getQueryParams().getFirst("debugRequest")); 41 | } 42 | 43 | @Override 44 | public HttpRequestMessage apply(HttpRequestMessage request) { 45 | request.getContext().setDebugRequest(true); 46 | request.getContext().setDebugRouting(true); 47 | 48 | return request; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /zuul-sample/src/main/java/com/netflix/zuul/sample/filters/endpoint/Healthcheck.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.netflix.zuul.sample.filters.endpoint; 18 | 19 | import com.netflix.zuul.filters.http.HttpSyncEndpoint; 20 | import com.netflix.zuul.message.http.HttpRequestMessage; 21 | import com.netflix.zuul.message.http.HttpResponseMessage; 22 | import com.netflix.zuul.message.http.HttpResponseMessageImpl; 23 | import com.netflix.zuul.stats.status.StatusCategoryUtils; 24 | import com.netflix.zuul.stats.status.ZuulStatusCategory; 25 | 26 | /** 27 | * Healthcheck Sample Endpoint 28 | * 29 | * Author: Arthur Gonigberg 30 | * Date: November 21, 2017 31 | */ 32 | public class Healthcheck extends HttpSyncEndpoint { 33 | 34 | @Override 35 | public HttpResponseMessage apply(HttpRequestMessage request) { 36 | HttpResponseMessage resp = new HttpResponseMessageImpl(request.getContext(), request, 200); 37 | resp.setBodyAsText("healthy"); 38 | 39 | // need to set this manually since we are not going through the ProxyEndpoint 40 | StatusCategoryUtils.setStatusCategory(request.getContext(), ZuulStatusCategory.SUCCESS); 41 | 42 | return resp; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /zuul-sample/src/main/java/com/netflix/zuul/sample/push/SamplePushMessageSender.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Netflix, Inc. 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.zuul.sample.push; 17 | 18 | import com.google.common.base.Strings; 19 | import com.netflix.zuul.netty.server.push.PushConnectionRegistry; 20 | import com.netflix.zuul.netty.server.push.PushMessageSender; 21 | import com.netflix.zuul.netty.server.push.PushUserAuth; 22 | import io.netty.channel.ChannelHandler; 23 | import io.netty.handler.codec.http.FullHttpRequest; 24 | import io.netty.handler.codec.http.HttpResponseStatus; 25 | import jakarta.inject.Singleton; 26 | 27 | /** 28 | * Author: Susheel Aroskar 29 | * Date: 5/16/18 30 | */ 31 | @Singleton 32 | @ChannelHandler.Sharable 33 | public class SamplePushMessageSender extends PushMessageSender { 34 | 35 | public SamplePushMessageSender(PushConnectionRegistry pushConnectionRegistry) { 36 | super(pushConnectionRegistry); 37 | } 38 | 39 | @Override 40 | protected PushUserAuth getPushUserAuth(FullHttpRequest request) { 41 | String cid = request.headers().get("X-CUSTOMER_ID"); 42 | if (Strings.isNullOrEmpty(cid)) { 43 | return new SamplePushUserAuth(HttpResponseStatus.UNAUTHORIZED.code()); 44 | } 45 | return new SamplePushUserAuth(cid); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /zuul-sample/src/main/java/com/netflix/zuul/sample/push/SamplePushMessageSenderInitializer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Netflix, Inc. 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.zuul.sample.push; 17 | 18 | import com.netflix.zuul.netty.server.push.PushConnectionRegistry; 19 | import com.netflix.zuul.netty.server.push.PushMessageSender; 20 | import com.netflix.zuul.netty.server.push.PushMessageSenderInitializer; 21 | import io.netty.channel.ChannelPipeline; 22 | import jakarta.inject.Inject; 23 | import jakarta.inject.Singleton; 24 | 25 | /** 26 | * Author: Susheel Aroskar 27 | * Date: 5/16/18 28 | */ 29 | @Singleton 30 | public class SamplePushMessageSenderInitializer extends PushMessageSenderInitializer { 31 | 32 | private final PushMessageSender pushMessageSender; 33 | 34 | @Inject 35 | public SamplePushMessageSenderInitializer(PushConnectionRegistry pushConnectionRegistry) { 36 | super(); 37 | pushMessageSender = new SamplePushMessageSender(pushConnectionRegistry); 38 | } 39 | 40 | @Override 41 | protected void addPushMessageHandlers(ChannelPipeline pipeline) { 42 | pipeline.addLast(pushMessageSender); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /zuul-sample/src/main/java/com/netflix/zuul/sample/push/SamplePushUserAuth.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.netflix.zuul.sample.push; 17 | 18 | import com.netflix.zuul.netty.server.push.PushUserAuth; 19 | 20 | /** 21 | * Author: Susheel Aroskar 22 | * Date: 5/16/18 23 | */ 24 | public class SamplePushUserAuth implements PushUserAuth { 25 | 26 | private final String customerId; 27 | private final int statusCode; 28 | 29 | private SamplePushUserAuth(String customerId, int statusCode) { 30 | this.customerId = customerId; 31 | this.statusCode = statusCode; 32 | } 33 | 34 | // Successful auth 35 | public SamplePushUserAuth(String customerId) { 36 | this(customerId, 200); 37 | } 38 | 39 | // Failed auth 40 | public SamplePushUserAuth(int statusCode) { 41 | this("", statusCode); 42 | } 43 | 44 | @Override 45 | public boolean isSuccess() { 46 | return statusCode == 200; 47 | } 48 | 49 | @Override 50 | public int statusCode() { 51 | return statusCode; 52 | } 53 | 54 | @Override 55 | public String getClientIdentity() { 56 | return customerId; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /zuul-sample/src/main/resources/application-benchmark.properties: -------------------------------------------------------------------------------- 1 | ### Benchmark settings 2 | 3 | # disable safety throttles 4 | api.ribbon.MaxConnectionsPerHost=-1 5 | api.netty.client.maxRequestsPerConnection=10000 6 | api.netty.client.perServerWaterline=-1 7 | zuul.origin.api.concurrency.protect.enabled=false 8 | 9 | # disable info headers 10 | zuul.responseFilter.send.headers=false 11 | -------------------------------------------------------------------------------- /zuul-sample/src/main/resources/application-test.properties: -------------------------------------------------------------------------------- 1 | # Test properties -------------------------------------------------------------------------------- /zuul-sample/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | ### Instance env settings 2 | 3 | region=us-east-1 4 | environment=test 5 | 6 | ### Eureka instance registration for this app 7 | 8 | #Name of the application to be identified by other services 9 | eureka.name=zuul 10 | 11 | #The port where the service will be running and serving requests 12 | eureka.port=7001 13 | 14 | #Virtual host name by which the clients identifies this service 15 | eureka.vipAddress=${eureka.name}:${eureka.port} 16 | 17 | #For eureka clients running in eureka server, it needs to connect to servers in other zones 18 | eureka.preferSameZone=false 19 | 20 | # Don't register locally running instances. 21 | eureka.registration.enabled=false 22 | 23 | # By default don't valudate eureka instance is from the cloud 24 | eureka.validateInstanceId=false 25 | 26 | # Loading Filters 27 | zuul.filters.packages=com.netflix.zuul.filters.common,\ 28 | com.netflix.zuul.sample.filters,\ 29 | com.netflix.zuul.sample.filters.endpoint,\ 30 | com.netflix.zuul.sample.filters.inbound,\ 31 | com.netflix.zuul.sample.filters.outbound 32 | 33 | ### Load balancing backends with Eureka 34 | 35 | eureka.shouldUseDns=true 36 | eureka.eurekaServer.context=discovery/v2 37 | eureka.eurekaServer.domainName=discovery${environment}.netflix.net 38 | eureka.eurekaServer.gzipContent=true 39 | 40 | eureka.serviceUrl.default=http://${region}.${eureka.eurekaServer.domainName}:7001/${eureka.eurekaServer.context} 41 | 42 | api.ribbon.NIWSServerListClassName=com.netflix.niws.loadbalancer.DiscoveryEnabledNIWSServerList 43 | api.ribbon.DeploymentContextBasedVipAddresses=api-test.netflix.net:7001 44 | 45 | 46 | ### Load balancing backends without Eureka 47 | 48 | #eureka.shouldFetchRegistry=false 49 | 50 | #api.ribbon.listOfServers=100.66.23.88:7001,100.65.155.22:7001 51 | #api.ribbon.client.NIWSServerListClassName=com.netflix.loadbalancer.ConfigurationBasedServerList 52 | #api.ribbon.DeploymentContextBasedVipAddresses=api-test.netflix.net:7001 53 | 54 | 55 | 56 | 57 | # This has to be the last line 58 | @next=application-${environment}.properties 59 | -------------------------------------------------------------------------------- /zuul-sample/src/main/resources/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | %d{yyyy-MM-dd'T'HH:mm:ss.SSS} %-5level [%t] %c: %msg%n 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /zuul-sample/src/main/resources/ssl/client.cert: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIE6jCCAtICAQEwDQYJKoZIhvcNAQEFBQAwOzELMAkGA1UEBhMCVVMxCzAJBgNV 3 | BAgMAkNBMQswCQYDVQQHDAJMRzESMBAGA1UEAwwJbG9jYWxob3N0MB4XDTE3MTIx 4 | MjAwMzAzOVoXDTE4MTIxMjAwMzAzOVowOzELMAkGA1UEBhMCVVMxCzAJBgNVBAgM 5 | AkNBMQswCQYDVQQHDAJMRzESMBAGA1UEAwwJbG9jYWxob3N0MIICIjANBgkqhkiG 6 | 9w0BAQEFAAOCAg8AMIICCgKCAgEAvSVlDAU4ivsh/2V38cmsm7VvphaMe6v7xZzn 7 | elieZqxQj0b9NJ94q9dYkUvbI0JlJDfpRAiYHA32MW5GDkmIOeGZS3P+ystLnxu8 8 | TIckP+dWqKez9qpXmW211vTeqbOvqOB8zyowStpVQHLF0bQ111ttFEW358ZXKFty 9 | gdcbqxJW4CXQ2DjTTGFy5EYB0+9e2PFo9KgKgWPsN1CU/o7/C0rUuotWRa9/WcqJ 10 | IHkdTKNM5Zpi/kkSWvLlPi8NJMLjOqnstE6GUBM2ur3H1akbF+uBT+sQszEScUlx 11 | 0hujtcDOBubc5iT3U3ZbWCPN+RW90J5WwFoWvMRDDT5OQYWBmJ5wmjWum5J0s0vs 12 | aupxM4oWdbeUdcjqQjI6euLZ+qc9VmoTP3f0O5bcKWvcRjnf8t9K+jkIEBjd8bFm 13 | XOuozG6vha+fl5730ihERN56iMkZv0SRMHPjrxxEWPhKmbVMoWXou/vHx/nyLpru 14 | bkHuPg4wVkno3UOmJ2GyHmLh1VRiYSsSBokwiOK+8iocYQwGcz4ayA5WYkghwMZV 15 | d9tLahflZkMhB+ikQwRHuspMcMoA/BimkpD2mtFPMsav6u6lbKrO27qU2SCrHdm0 16 | zAHL/b/buPBw3JMTBHRKxbh4tafxgL06BGcLZAsYFdimpJXp5VoQr99xBkYukdcH 17 | 28NTjGECAwEAATANBgkqhkiG9w0BAQUFAAOCAgEAvCzmIxiPxSDmAW1jF+9659xF 18 | aKo56pkWpQOSvBkrKRo4Ia1cVXPk5DfTlOffts6w3eSpSuaaW+4NyILrV21SThsy 19 | nPnM/JLwOLOgxVmRVDQe1a2MiCfNr7tsAej+6IxbRMHFwvdjA22nhYRGNyVbknq8 20 | 9fzLu/u3v0HphPbqc5DSKWtsZjH8CXnSjLwohjCqJsfWO/EwVEcksbOdwl5LWq7E 21 | VO5BMQ8Yyrm+qftnFNWF36o2vSLRWSh6vti+vcKR1tZm7J1XEN0Z/vKoQCiSF4iY 22 | Y5KUuDWjyij9UW8TJJOhn9XsSZrwdrbEbTXB3qpVAqaUEEzwUrK8G5w65bCW7zLr 23 | 627cFbDnorX90KmZ+7QMaJu6dCt1CZrPBM2a6oJid63NR7Fmt0jEJ3/zMf7qQQCZ 24 | nKhWlC2FqcA1NhPt21m8mKgYQKmd81LGyskJXVTaz/4zm5f1A1cRSDlzCIg2hi0e 25 | DQbiw8Ciz9YE3EXcecZu80PI1B/iaPWEmGPgxPfSFEw+v/9wLFaRpU3OsfCkDJX6 26 | 7M9QPJXMFyDCN+3qq6chvwJ1EI0vKfa08OM46Y3al4pL6Y9UQkJfS18LD5x54C0K 27 | RvXaxi7glFAyQf4HB7f3ecrqUgIv0WMW2XK+SG/w+tZ9p0jKGQq1FqAy7Hb2LWC7 28 | fjDECaO9mbf8U3pr3u8= 29 | -----END CERTIFICATE----- 30 | -------------------------------------------------------------------------------- /zuul-sample/src/main/resources/ssl/server.cert: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIFVjCCAz4CCQCOVDcKFZeqxzANBgkqhkiG9w0BAQsFADBtMQswCQYDVQQGEwJV 3 | UzELMAkGA1UECAwCQ0ExCzAJBgNVBAcMAkxHMQswCQYDVQQKDAJORjELMAkGA1UE 4 | CwwCRUUxEjAQBgNVBAMMCWxvY2FsaG9zdDEWMBQGCSqGSIb3DQEJARYHYUBiLmNv 5 | bTAeFw0xNzEyMTEyMzI0MDFaFw0xODEyMTEyMzI0MDFaMG0xCzAJBgNVBAYTAlVT 6 | MQswCQYDVQQIDAJDQTELMAkGA1UEBwwCTEcxCzAJBgNVBAoMAk5GMQswCQYDVQQL 7 | DAJFRTESMBAGA1UEAwwJbG9jYWxob3N0MRYwFAYJKoZIhvcNAQkBFgdhQGIuY29t 8 | MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAw9Oud0mmtMWouKbguGq0 9 | 8vPP8gwGybDwRi/t4rmWUb/+xGHW0iqRYbVDwE4i8gCuM4g0HN3+ESglBFMvuxui 10 | BIPx60dR1sEP3IlX/22HcBv97Zj+vjchBMY/3AIP06nKgHGmnorKYYs5xczEEyxB 11 | D+0mZECeQhK+IbhoZdTphrQruOTQYpkGpkyEbpygX3u2chpGoGSxOTlz0WxBhpbR 12 | wr2jiz0IYxplLsIq2VL7XBlUd5yoaxOyrcc1to+uPH27R9sbrj5513LzZ22ebcWa 13 | dQJGtOdGfoSG+wH8k/94MSAr1bsBOJ1jq3XIuD38fbdkUyH1DPwkzCnSD6qD6sYt 14 | XMYTgfAysCYxxjw/GrcIEG1TNbys04YJCwRp5IB6alsya4ovbkqa40ToLCBAtC6v 15 | c59Ppo3ejWZPcpLSe5oIB4loRtWYlWjJnUf6kjGuCmyltTzRrgvng4P/VULq91QE 16 | FcCqsbKhI7/eoO20Pt/XYR7gDXc4z7YCuW/twaEpRsclrUiXY0E0Bq41FrhyW2rp 17 | Hl8x9kOJREGELMHp3hZycTh3FpxeN6Ti2znriz758dhNWKns5xAe8ZjSY/PpbcNq 18 | nHhDm2RQb1QiCw6ttJy4bMJmKofAEiEbE1Of4mPftRvM7zDM744nuOUPWZO1jQql 19 | p1stf6qKY5b6n771+qTQXJ0CAwEAATANBgkqhkiG9w0BAQsFAAOCAgEAWe22QQmw 20 | +t2Cmau2i0dTdgHjmYU1KCwath5fCSdb95c8lrLHWhQHQt70DCkU1KmbyPY0y/2G 21 | g9Ofkc49eQCPrzl/FrcYKb6a9OIgByTMCrEAhDzSf4iB+eeCF/nMzqYciXYj3/DF 22 | VFenBhLw9ZfqePgamlkNZWf7RICOklQu5vHCgs+/xUXlenB6CXNm+9Qy8BD9FfnP 23 | vTpr3wJVz0UK6JZafuLKcGpjaVCpUTeMmToVlr1PxyyTlgVFBbK7JfKlTXh7cZRw 24 | 4FUarTAjgk3Vk3Q+Tdir6R8+DabqghJnTjOF/tETHeNt8msAc59VzRuzhy9ZeGkI 25 | vWq+LNqs+/+deaw5hsbkbD9AoDmHmV2U9Ki7zIYnRizl545f1nZQdPNeyYHO/QIl 26 | cP/U51pPid/bqlPiVwLg7eNGC1rI19cd0wZH4cjTwUtgqQhX/I3e5Boot9kdtvEr 27 | Tr0I656jmmzksjF8863wDKqW/RJeje8lzKXbo0vc2/zv2KX11zIGC4OJ7z404BF5 28 | cEYnFmswIZQfR1mjTMN4ZfjCtBtWuc2uueDUUsgQ9YUss5bKpd8Xm1g9rguQYnBt 29 | M84aFXiDvbKhvI5t1Z5Xa9LN6FO0u0rIG+b8tOU8rlqhLp7SGYpRalb6UU2keZRh 30 | qNCCixZMahJMgVovuI8LkttwvdpTc7705W8= 31 | -----END CERTIFICATE----- 32 | -------------------------------------------------------------------------------- /zuul-sample/src/main/resources/ssl/truststore.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Netflix/zuul/dd8e8870cac4ee4a1683d8e2d9ee34cd53631866/zuul-sample/src/main/resources/ssl/truststore.jks -------------------------------------------------------------------------------- /zuul-sample/src/main/resources/ssl/truststore.key: -------------------------------------------------------------------------------- 1 | zuul123 2 | --------------------------------------------------------------------------------