Skip to content

Commit

Permalink
Merge pull request #32 from lucid-kv/https-support
Browse files Browse the repository at this point in the history
Implement HTTPS support
  • Loading branch information
Clint.Network committed Nov 30, 2019
2 parents c96370e + 8c23b6b commit c33c6ea
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 8 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@
#**/*.rs.bk

**/resource.rc
**/resource.lib
**/resource.lib

# Ignore SSL certificate folder
tls
35 changes: 35 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ app_dirs = "*"
ring = "*"
uuid = "*"
rand = "*"
warp = "*"
chashmap = "*"
plugin = "*"
tree_magic = "*"
Expand All @@ -49,3 +48,7 @@ fern = "*"
[dependencies.clap]
version = "*"
features = ["yaml"]

[dependencies.warp]
version = "*"
features = ["tls"]
8 changes: 6 additions & 2 deletions src/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ impl Configuration {
Configuration {
default: Base {
bind_address: IpAddr::from(Ipv4Addr::LOCALHOST),
port: 7021, // TODO: change after implementing SSL
port: 7020,
port_ssl: 7021,
use_ssl: false,
use_ssl: true,
ssl_certificate: String::new(),
ssl_certificate_key: String::new()
},
authentication: Authentication {
enabled: true,
Expand Down Expand Up @@ -56,6 +58,8 @@ pub struct Base {
pub port: u16,
pub port_ssl: u16,
pub use_ssl: bool,
pub ssl_certificate: String,
pub ssl_certificate_key: String,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
Expand Down
10 changes: 6 additions & 4 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,12 @@ impl Server {
.with(warp::reply::with::header("Server", format!("Lucid v{}", crate_version!())))
.with(log);

warp::serve(routes).run((
configuration.default.bind_address,
configuration.default.port,
), );
let instance = warp::serve(routes);
if configuration.default.use_ssl {
instance.tls(&configuration.default.ssl_certificate, &configuration.default.ssl_certificate_key).run((configuration.default.bind_address, configuration.default.port_ssl));
} else {
instance.run((configuration.default.bind_address, configuration.default.port));
}
}
}

Expand Down

0 comments on commit c33c6ea

Please sign in to comment.