Remove or_upgrade and let users build OrUpgrade manually

This commit is contained in:
Pierre Krieger
2017-12-12 12:48:28 +01:00
parent 582f9891b2
commit e0aca7e3e3
4 changed files with 43 additions and 34 deletions

View File

@ -29,7 +29,7 @@ extern crate tokio_io;
use bytes::BytesMut;
use futures::{Future, Sink, Stream};
use swarm::{SimpleProtocol, Transport};
use swarm::{UpgradeExt, SimpleProtocol, Transport};
use tcp::TcpConfig;
use tokio_core::reactor::Core;
use tokio_io::codec::length_delimited;
@ -44,13 +44,18 @@ fn main() {
// On top of TCP/IP, we will use either the plaintext protocol or the secio protocol,
// depending on which one the remote supports.
.with_upgrade(swarm::PlainTextConfig)
.or_upgrade({
let private_key = include_bytes!("test-private-key.pk8");
let public_key = include_bytes!("test-public-key.der").to_vec();
secio::SecioConfig {
key: secio::SecioKeyPair::rsa_from_pkcs8(private_key, public_key).unwrap(),
}
.with_upgrade({
let plain_text = swarm::PlainTextConfig;
let secio = {
let private_key = include_bytes!("test-private-key.pk8");
let public_key = include_bytes!("test-public-key.der").to_vec();
secio::SecioConfig {
key: secio::SecioKeyPair::rsa_from_pkcs8(private_key, public_key).unwrap(),
}
};
plain_text.or_upgrade(secio)
})
.with_upgrade(multiplex::MultiplexConfig);