mirror of
https://github.com/fafhrd91/actix-net
synced 2025-08-14 10:00:31 +02:00
Compare commits
4 Commits
test-serve
...
connect-v0
Author | SHA1 | Date | |
---|---|---|---|
|
3b314e4c8c | ||
|
ae27b87641 | ||
|
fc2dcadc7a | ||
|
54f62b5035 |
@@ -1,5 +1,16 @@
|
|||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
|
## [0.1.5] - 2019-04-19
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
* `Connect::set_addr()`
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
* Use trust-dns-resolver 0.11.0
|
||||||
|
|
||||||
|
|
||||||
## [0.1.4] - 2019-04-12
|
## [0.1.4] - 2019-04-12
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "actix-connect"
|
name = "actix-connect"
|
||||||
version = "0.1.4"
|
version = "0.1.5"
|
||||||
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
||||||
description = "Actix Connector - tcp connector service"
|
description = "Actix Connector - tcp connector service"
|
||||||
keywords = ["network", "framework", "async", "futures"]
|
keywords = ["network", "framework", "async", "futures"]
|
||||||
@@ -34,13 +34,13 @@ actix-service = "0.3.6"
|
|||||||
actix-codec = "0.1.2"
|
actix-codec = "0.1.2"
|
||||||
actix-utils = "0.3.5"
|
actix-utils = "0.3.5"
|
||||||
derive_more = "0.14.0"
|
derive_more = "0.14.0"
|
||||||
either = "1.5.1"
|
either = "1.5.2"
|
||||||
futures = "0.1.25"
|
futures = "0.1.25"
|
||||||
http = { version = "0.1.16", optional = true }
|
http = { version = "0.1.17", optional = true }
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
tokio-tcp = "0.1.3"
|
tokio-tcp = "0.1.3"
|
||||||
tokio-current-thread = "0.1.5"
|
tokio-current-thread = "0.1.5"
|
||||||
trust-dns-resolver = { version="0.11.0-alpha.3", default-features = false }
|
trust-dns-resolver = { version="0.11.0", default-features = false }
|
||||||
|
|
||||||
# openssl
|
# openssl
|
||||||
openssl = { version="0.10", optional = true }
|
openssl = { version="0.10", optional = true }
|
||||||
@@ -48,8 +48,7 @@ tokio-openssl = { version="0.3", optional = true }
|
|||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
bytes = "0.4"
|
bytes = "0.4"
|
||||||
#actix-test-server = { version="0.2.0", features=["ssl"] }
|
actix-test-server = { version="0.2.1", features=["ssl"] }
|
||||||
actix-test-server = { path="../actix-test-server", features=["ssl"] }
|
|
||||||
actix-server-config = "0.1.0"
|
actix-server-config = "0.1.0"
|
||||||
actix-utils = "0.3.4"
|
actix-utils = "0.3.4"
|
||||||
tokio-tcp = "0.1"
|
tokio-tcp = "0.1"
|
@@ -69,6 +69,14 @@ impl<T: Address> Connect<T> {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Use address.
|
||||||
|
pub fn set_addr(mut self, addr: Option<SocketAddr>) -> Self {
|
||||||
|
if let Some(addr) = addr {
|
||||||
|
self.addr = Some(Either::Left(addr));
|
||||||
|
}
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
/// Host name
|
/// Host name
|
||||||
pub fn host(&self) -> &str {
|
pub fn host(&self) -> &str {
|
||||||
self.req.host()
|
self.req.host()
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "actix-server-config"
|
name = "actix-server-config"
|
||||||
version = "0.1.0"
|
version = "0.1.1"
|
||||||
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
||||||
description = "Actix server config utils"
|
description = "Actix server config utils"
|
||||||
homepage = "https://actix.rs"
|
homepage = "https://actix.rs"
|
||||||
@@ -13,5 +13,22 @@ workspace = ".."
|
|||||||
name = "actix_server_config"
|
name = "actix_server_config"
|
||||||
path = "src/lib.rs"
|
path = "src/lib.rs"
|
||||||
|
|
||||||
|
[package.metadata.docs.rs]
|
||||||
|
features = ["ssl", "rust-tls"]
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = []
|
||||||
|
|
||||||
|
# openssl
|
||||||
|
ssl = ["tokio-openssl"]
|
||||||
|
|
||||||
|
# rustls
|
||||||
|
rust-tls = ["rustls", "tokio-rustls"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
futures = "0.1.25"
|
futures = "0.1.25"
|
||||||
|
tokio-io = "0.1.12"
|
||||||
|
tokio-tcp = "0.1"
|
||||||
|
tokio-openssl = { version="0.3.0", optional = true }
|
||||||
|
rustls = { version = "0.15.2", optional = true }
|
||||||
|
tokio-rustls = { version = "0.9.1", optional = true }
|
||||||
|
7
actix-server-config/changes.md
Normal file
7
actix-server-config/changes.md
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
# Changes
|
||||||
|
|
||||||
|
## [0.1.1] - 2019-04-16
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
* `IoStream` trait and impls for TcpStream, SslStream and TlsStream
|
@@ -1,7 +1,10 @@
|
|||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use std::fmt;
|
|
||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
use std::{fmt, io, net, time};
|
||||||
|
|
||||||
|
use tokio_io::{AsyncRead, AsyncWrite};
|
||||||
|
use tokio_tcp::TcpStream;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct ServerConfig {
|
pub struct ServerConfig {
|
||||||
@@ -130,3 +133,86 @@ impl<T: fmt::Debug, P> fmt::Debug for Io<T, P> {
|
|||||||
write!(f, "Io {{{:?}}}", self.io)
|
write!(f, "Io {{{:?}}}", self.io)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Low-level io stream operations
|
||||||
|
pub trait IoStream: AsyncRead + AsyncWrite {
|
||||||
|
/// Returns the socket address of the remote peer of this TCP connection.
|
||||||
|
fn peer_addr(&self) -> Option<SocketAddr> {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Sets the value of the TCP_NODELAY option on this socket.
|
||||||
|
fn set_nodelay(&mut self, nodelay: bool) -> io::Result<()>;
|
||||||
|
|
||||||
|
fn set_linger(&mut self, dur: Option<time::Duration>) -> io::Result<()>;
|
||||||
|
|
||||||
|
fn set_keepalive(&mut self, dur: Option<time::Duration>) -> io::Result<()>;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl IoStream for TcpStream {
|
||||||
|
#[inline]
|
||||||
|
fn peer_addr(&self) -> Option<net::SocketAddr> {
|
||||||
|
TcpStream::peer_addr(self).ok()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn set_nodelay(&mut self, nodelay: bool) -> io::Result<()> {
|
||||||
|
TcpStream::set_nodelay(self, nodelay)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn set_linger(&mut self, dur: Option<time::Duration>) -> io::Result<()> {
|
||||||
|
TcpStream::set_linger(self, dur)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn set_keepalive(&mut self, dur: Option<time::Duration>) -> io::Result<()> {
|
||||||
|
TcpStream::set_keepalive(self, dur)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(any(feature = "ssl"))]
|
||||||
|
impl<T: IoStream> IoStream for tokio_openssl::SslStream<T> {
|
||||||
|
#[inline]
|
||||||
|
fn peer_addr(&self) -> Option<net::SocketAddr> {
|
||||||
|
self.get_ref().get_ref().peer_addr()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn set_nodelay(&mut self, nodelay: bool) -> io::Result<()> {
|
||||||
|
self.get_mut().get_mut().set_nodelay(nodelay)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn set_linger(&mut self, dur: Option<time::Duration>) -> io::Result<()> {
|
||||||
|
self.get_mut().get_mut().set_linger(dur)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn set_keepalive(&mut self, dur: Option<time::Duration>) -> io::Result<()> {
|
||||||
|
self.get_mut().get_mut().set_keepalive(dur)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(any(feature = "rust-tls"))]
|
||||||
|
impl<T: IoStream> IoStream for tokio_rustls::TlsStream<T, rustls::ServerSession> {
|
||||||
|
#[inline]
|
||||||
|
fn peer_addr(&self) -> Option<net::SocketAddr> {
|
||||||
|
self.get_ref().0.peer_addr()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn set_nodelay(&mut self, nodelay: bool) -> io::Result<()> {
|
||||||
|
self.get_mut().0.set_nodelay(nodelay)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn set_linger(&mut self, dur: Option<time::Duration>) -> io::Result<()> {
|
||||||
|
self.get_mut().0.set_linger(dur)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn set_keepalive(&mut self, dur: Option<time::Duration>) -> io::Result<()> {
|
||||||
|
self.get_mut().0.set_keepalive(dur)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -1,5 +1,16 @@
|
|||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
|
## [0.4.3] - 2019-04-16
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
* Re-export `IoStream` trait
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
* Deppend on `ssl` and `rust-tls` features from actix-server-config
|
||||||
|
|
||||||
|
|
||||||
## [0.4.2] - 2019-03-30
|
## [0.4.2] - 2019-03-30
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "actix-server"
|
name = "actix-server"
|
||||||
version = "0.4.2"
|
version = "0.4.3"
|
||||||
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
||||||
description = "Actix server - General purpose tcp server"
|
description = "Actix server - General purpose tcp server"
|
||||||
keywords = ["network", "framework", "async", "futures"]
|
keywords = ["network", "framework", "async", "futures"]
|
||||||
@@ -27,20 +27,20 @@ default = []
|
|||||||
tls = ["native-tls"]
|
tls = ["native-tls"]
|
||||||
|
|
||||||
# openssl
|
# openssl
|
||||||
ssl = ["openssl", "tokio-openssl"]
|
ssl = ["openssl", "tokio-openssl", "actix-server-config/ssl"]
|
||||||
|
|
||||||
# rustls
|
# rustls
|
||||||
rust-tls = ["rustls", "tokio-rustls", "webpki", "webpki-roots"]
|
rust-tls = ["rustls", "tokio-rustls", "webpki", "webpki-roots", "actix-server-config/rust-tls"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-rt = "0.2.1"
|
actix-rt = "0.2.1"
|
||||||
actix-service = "0.3.4"
|
actix-service = "0.3.4"
|
||||||
actix-server-config = "0.1.0"
|
actix-server-config = "0.1.1"
|
||||||
|
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
num_cpus = "1.0"
|
num_cpus = "1.0"
|
||||||
|
|
||||||
mio = "^0.6.13"
|
mio = "0.6.13"
|
||||||
net2 = "0.2"
|
net2 = "0.2"
|
||||||
futures = "0.1"
|
futures = "0.1"
|
||||||
slab = "0.4"
|
slab = "0.4"
|
||||||
@@ -58,12 +58,12 @@ openssl = { version="0.10", optional = true }
|
|||||||
tokio-openssl = { version="0.3", optional = true }
|
tokio-openssl = { version="0.3", optional = true }
|
||||||
|
|
||||||
#rustls
|
#rustls
|
||||||
rustls = { version = "^0.15", optional = true }
|
rustls = { version = "0.15.2", optional = true }
|
||||||
tokio-rustls = { version = "^0.9", optional = true }
|
tokio-rustls = { version = "0.9.1", optional = true }
|
||||||
webpki = { version = "0.19", optional = true }
|
webpki = { version = "0.19", optional = true }
|
||||||
webpki-roots = { version = "0.16", optional = true }
|
webpki-roots = { version = "0.16", optional = true }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
bytes = "0.4"
|
bytes = "0.4"
|
||||||
actix-codec = "0.1.0"
|
actix-codec = "0.1.2"
|
||||||
env_logger = "0.6"
|
env_logger = "0.6"
|
||||||
|
@@ -10,7 +10,7 @@ mod signals;
|
|||||||
pub mod ssl;
|
pub mod ssl;
|
||||||
mod worker;
|
mod worker;
|
||||||
|
|
||||||
pub use actix_server_config::{Io, Protocol, ServerConfig};
|
pub use actix_server_config::{Io, IoStream, Protocol, ServerConfig};
|
||||||
|
|
||||||
pub use self::builder::ServerBuilder;
|
pub use self::builder::ServerBuilder;
|
||||||
pub use self::config::{ServiceConfig, ServiceRuntime};
|
pub use self::config::{ServiceConfig, ServiceRuntime};
|
||||||
|
@@ -8,10 +8,13 @@ pub type BoxedService<Req, Res, Err> = Box<
|
|||||||
Request = Req,
|
Request = Req,
|
||||||
Response = Res,
|
Response = Res,
|
||||||
Error = Err,
|
Error = Err,
|
||||||
Future = Either<FutureResult<Res, Err>, Box<Future<Item = Res, Error = Err>>>,
|
Future = BoxedServiceResponse<Res, Err>,
|
||||||
>,
|
>,
|
||||||
>;
|
>;
|
||||||
|
|
||||||
|
pub type BoxedServiceResponse<Res, Err> =
|
||||||
|
Either<FutureResult<Res, Err>, Box<Future<Item = Res, Error = Err>>>;
|
||||||
|
|
||||||
/// Create boxed new service
|
/// Create boxed new service
|
||||||
pub fn new_service<T, C>(
|
pub fn new_service<T, C>(
|
||||||
service: T,
|
service: T,
|
||||||
|
Reference in New Issue
Block a user