Permalink
Show file tree
Hide file tree
20 changes: 16 additions & 4 deletions
20
core/src/main/scala/org/http4s/blaze/channel/nio1/NIO1HeadStage.scala
8 changes: 8 additions & 0 deletions
8
core/src/main/scala/org/http4s/blaze/channel/nio1/NIO1SocketConnection.scala
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Merge pull request from GHSA-xmw9-q7x9-j5qc
Fix GHSA-xmw9-q7x9-j5qc by limiting accepted connections
- Loading branch information
Showing
14 changed files
with
296 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 12 additions & 2 deletions
14
core/src/main/scala-2.11-2.12/org/http4s/blaze/internal/compat.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
core/src/main/scala/org/http4s/blaze/channel/nio1/NIO1ClientChannel.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| /* | ||
| * Copyright 2014 http4s.org | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.http4s.blaze.channel.nio1 | ||
|
|
||
| import org.http4s.blaze.channel.{ChannelOptions, OptionValue} | ||
|
|
||
| import java.net.SocketAddress | ||
| import java.nio.ByteBuffer | ||
| import java.nio.channels.{SelectableChannel, SocketChannel} | ||
| import java.util.concurrent.atomic.AtomicBoolean | ||
|
|
||
| private[blaze] final class NIO1ClientChannel( | ||
| private[this] val underlying: SocketChannel, | ||
| private[this] val onClose: () => Unit) | ||
| extends NIO1Channel { | ||
|
|
||
| private[this] val closed = new AtomicBoolean(false) | ||
|
|
||
| override val selectableChannel: SelectableChannel = underlying | ||
|
|
||
| def configureBlocking(block: Boolean): Unit = { | ||
| underlying.configureBlocking(block) | ||
| () | ||
| } | ||
|
|
||
| def getRemoteAddress: SocketAddress = | ||
| underlying.getRemoteAddress | ||
|
|
||
| def getLocalAddress: SocketAddress = | ||
| underlying.getLocalAddress | ||
|
|
||
| def configureOptions(options: ChannelOptions): Unit = | ||
| options.options.foreach { case OptionValue(k, v) => | ||
| underlying.setOption(k, v) | ||
| } | ||
|
|
||
| def read(dst: ByteBuffer): Int = | ||
| underlying.read(dst) | ||
|
|
||
| def write(src: ByteBuffer): Int = | ||
| underlying.write(src) | ||
|
|
||
| def write(srcs: Array[ByteBuffer]): Long = | ||
| underlying.write(srcs) | ||
|
|
||
| def isOpen: Boolean = | ||
| underlying.isOpen | ||
|
|
||
| override def close(): Unit = | ||
| try underlying.close() | ||
| finally if (closed.compareAndSet(false, true)) { | ||
| onClose() | ||
| } | ||
|
|
||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.