mirror of https://github.com/dswd/vpncloud.git
Small improvements
This commit is contained in:
parent
791ecfb0fe
commit
65eef143cd
|
@ -8,7 +8,7 @@ from datetime import date
|
|||
# Note: this script will run for ~8 minutes and incur costs of about $ 0.02
|
||||
|
||||
FILE = "../target/release/vpncloud"
|
||||
VERSION = "2.0.0-alpha1"
|
||||
VERSION = "2.0.1"
|
||||
REGION = "eu-central-1"
|
||||
|
||||
env = EC2Environment(
|
||||
|
|
|
@ -5,7 +5,7 @@ import atexit, argparse, os
|
|||
|
||||
REGION = "eu-central-1"
|
||||
|
||||
VERSION = "2.0.0"
|
||||
VERSION = "2.0.1"
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser(description='Create a test setup')
|
||||
|
@ -25,15 +25,22 @@ if args.keyname:
|
|||
with open(args.keyfile, 'r') as fp:
|
||||
privatekey = fp.read()
|
||||
|
||||
opts = {}
|
||||
if os.path.exists(args.version):
|
||||
opts["vpncloud_file"] = args.version
|
||||
opts["vpncloud_version"] = None
|
||||
else:
|
||||
opts["vpncloud_version"] = args.version
|
||||
|
||||
setup = EC2Environment(
|
||||
region = REGION,
|
||||
node_count = args.count,
|
||||
instance_type = args.instancetype,
|
||||
vpncloud_version = args.version,
|
||||
cluster_nodes = args.cluster,
|
||||
subnet = args.subnet or CREATE,
|
||||
keyname = args.keyname or CREATE,
|
||||
privatekey = privatekey
|
||||
privatekey = privatekey,
|
||||
**opts
|
||||
)
|
||||
|
||||
if not args.keyname:
|
||||
|
|
|
@ -358,7 +358,7 @@ pub struct Args {
|
|||
pub mode: Option<Mode>,
|
||||
|
||||
/// The shared password to encrypt all traffic
|
||||
#[structopt(short, long, required_unless_one = &["private-key", "config", "genkey", "version", "completion"], env)]
|
||||
#[structopt(short, long, env)]
|
||||
pub password: Option<String>,
|
||||
|
||||
/// The private key to use
|
||||
|
|
|
@ -10,7 +10,6 @@ use std::{
|
|||
collections::{HashMap, VecDeque},
|
||||
io::Write,
|
||||
net::SocketAddr,
|
||||
str::FromStr,
|
||||
sync::{
|
||||
atomic::{AtomicUsize, Ordering},
|
||||
Once
|
||||
|
@ -91,12 +90,12 @@ impl<P: Protocol> Simulator<P> {
|
|||
let mut config = config.clone();
|
||||
MockSocket::set_nat(nat);
|
||||
config.listen = format!("[::]:{}", self.next_port);
|
||||
let addr = config.listen.parse::<SocketAddr>().unwrap();
|
||||
if config.crypto.password.is_none() && config.crypto.private_key.is_none() {
|
||||
config.crypto.password = Some("test123".to_string())
|
||||
}
|
||||
DebugLogger::set_node(self.next_port as usize);
|
||||
self.next_port += 1;
|
||||
let addr = SocketAddr::from_str(&config.listen).unwrap();
|
||||
let node = TestNode::new(&config, MockSocket::new(addr), MockDevice::new(), None, None);
|
||||
DebugLogger::set_node(0);
|
||||
self.nodes.insert(addr, node);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use super::{
|
||||
net::{mapped_addr, get_ip, parse_listen, Socket},
|
||||
net::{get_ip, mapped_addr, parse_listen, Socket},
|
||||
poll::{WaitImpl, WaitResult},
|
||||
port_forwarding::PortForwarding,
|
||||
util::MsgBuffer
|
||||
|
@ -47,6 +47,7 @@ fn read_addr<R: Read>(mut r: R) -> Result<SocketAddr, io::Error> {
|
|||
fn serve_proxy_connection(stream: TcpStream) -> Result<(), io::Error> {
|
||||
let peer = stream.peer_addr()?;
|
||||
info!("WS client {} connected", peer);
|
||||
stream.set_nodelay(true)?;
|
||||
let mut websocket = io_error!(accept(stream), "Failed to initialize websocket with {}: {}", peer)?;
|
||||
let udpsocket = UdpSocket::bind("[::]:0")?;
|
||||
let mut msg = Vec::with_capacity(18);
|
||||
|
@ -56,7 +57,7 @@ fn serve_proxy_connection(stream: TcpStream) -> Result<(), io::Error> {
|
|||
write_addr(addr, &mut msg)?;
|
||||
io_error!(websocket.write_message(Message::Binary(msg)), "Failed to write to ws connection: {}")?;
|
||||
let websocketfd = websocket.get_ref().as_raw_fd();
|
||||
let poll = WaitImpl::new(websocketfd, udpsocket.as_raw_fd(), 60*1000)?;
|
||||
let poll = WaitImpl::new(websocketfd, udpsocket.as_raw_fd(), 60 * 1000)?;
|
||||
let mut buffer = [0; 65535];
|
||||
for evt in poll {
|
||||
match evt {
|
||||
|
@ -90,6 +91,7 @@ fn serve_proxy_connection(stream: TcpStream) -> Result<(), io::Error> {
|
|||
pub fn run_proxy(listen: &str) -> Result<(), io::Error> {
|
||||
let addr = parse_listen(listen);
|
||||
let server = TcpListener::bind(addr)?;
|
||||
info!("Listening on ws://{}", server.local_addr()?);
|
||||
for stream in server.incoming() {
|
||||
let stream = stream?;
|
||||
let peer = stream.peer_addr()?;
|
||||
|
@ -126,7 +128,8 @@ impl AsRawFd for ProxyConnection {
|
|||
impl Socket for ProxyConnection {
|
||||
fn listen(url: &str) -> Result<Self, io::Error> {
|
||||
let parsed_url = io_error!(Url::parse(url), "Invalid URL {}: {}", url)?;
|
||||
let (socket, _) = io_error!(connect(parsed_url), "Failed to connect to URL {}: {}", url)?;
|
||||
let (mut socket, _) = io_error!(connect(parsed_url), "Failed to connect to URL {}: {}", url)?;
|
||||
socket.get_mut().set_nodelay(true)?;
|
||||
let addr = "0.0.0.0:0".parse::<SocketAddr>().unwrap();
|
||||
let mut con = ProxyConnection { addr, socket };
|
||||
let addr_data = con.read_message()?;
|
||||
|
|
Loading…
Reference in New Issue