Fixes #12167
(cherry picked from commit 3ecb390b10
)
Co-authored-by: Greg Fitzgerald <greg@solana.com>
This commit is contained in:
@ -23,7 +23,7 @@ use solana_sdk::{
|
|||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
io,
|
io,
|
||||||
net::SocketAddr,
|
net::{Ipv4Addr, SocketAddr},
|
||||||
sync::{
|
sync::{
|
||||||
atomic::AtomicBool,
|
atomic::AtomicBool,
|
||||||
mpsc::{channel, Receiver, Sender},
|
mpsc::{channel, Receiver, Sender},
|
||||||
@ -245,7 +245,12 @@ pub async fn start_tcp_server(
|
|||||||
.filter_map(|r| future::ready(r.ok()))
|
.filter_map(|r| future::ready(r.ok()))
|
||||||
.map(server::BaseChannel::with_defaults)
|
.map(server::BaseChannel::with_defaults)
|
||||||
// Limit channels to 1 per IP.
|
// Limit channels to 1 per IP.
|
||||||
.max_channels_per_key(1, |t| t.as_ref().peer_addr().unwrap().ip())
|
.max_channels_per_key(1, |t| {
|
||||||
|
t.as_ref()
|
||||||
|
.peer_addr()
|
||||||
|
.map(|x| x.ip())
|
||||||
|
.unwrap_or_else(|_| Ipv4Addr::new(0, 0, 0, 0).into())
|
||||||
|
})
|
||||||
// serve is generated by the service attribute. It takes as input any type implementing
|
// serve is generated by the service attribute. It takes as input any type implementing
|
||||||
// the generated Banks trait.
|
// the generated Banks trait.
|
||||||
.map(move |chan| {
|
.map(move |chan| {
|
||||||
|
Reference in New Issue
Block a user