Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

Commit

Permalink
Openssl test
Browse files Browse the repository at this point in the history
  • Loading branch information
jspspike committed Jul 30, 2020
1 parent 46d41e2 commit 8086f4e
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 19 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,15 @@ jobs:
if: matrix.build == 'macos'
run: brew install p7zip

- name: Install vcpkg OpenSSL (Windows)
if :matrix.build == 'windows'
run: |
git clone https://github.com/microsoft/vcpkg
.\vcpkg\bootstrap-vcpkg.bat
.\vcpkg\vcpkg install opensll:x64-windows
env:
VCPKGRS_DYNAMIC: 1

- name: Build (Linux)
if: matrix.build == 'linux'
run: |
Expand All @@ -104,6 +113,7 @@ jobs:
run: cargo build --release
env:
RUSTFLAGS: -Ctarget-feature=+crt-static
VCPKGRS_DYNAMIC: 1

- name: Create artifact directory
run: |
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ lazy_static = "1.4.0"
log = "0.4.11"
notify = "4.0.15"
number_prefix = "0.4.0"
openssl = { version = '0.10.29', optional = true }
openssl = { version = "0.10.29"}
percent-encoding = "2.1.0"
predicates = "1.0.5"
prettytable-rs = "0.8.0"
Expand Down
3 changes: 3 additions & 0 deletions src/commands/login.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
//use crate::login;

pub fn run() {}
1 change: 1 addition & 0 deletions src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pub mod dev;
pub mod generate;
pub mod init;
pub mod kv;
pub mod login;
mod preview;
pub mod publish;
pub mod route;
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pub mod http;
pub mod install;
pub mod installer;
pub mod kv;
pub mod login;
pub mod settings;
pub mod sites;
pub mod tail;
Expand Down
22 changes: 22 additions & 0 deletions src/login/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//use crate::terminal::{interactive::confirm, open_browser};

//use openssl::base64;
use openssl::rsa::Rsa;

pub fn run() -> Result<(), failure::Error> {
let rsa = Rsa::generate(1024)?;
let _ = rsa.public_key_to_pem_pkcs1()?;

Ok(())
}

#[cfg(test)]
mod tests {
use openssl::rsa::Rsa;

#[test]
fn test_rsa() {
let rsa = Rsa::generate(1024).unwrap();
rsa.public_key_to_pem_pkcs1().unwrap();
}
}
19 changes: 1 addition & 18 deletions src/preview/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ pub use request_payload::RequestPayload;
mod upload;
pub use upload::upload;

use std::process::Command;
use std::sync::mpsc::channel;
use std::thread;

Expand All @@ -22,7 +21,7 @@ use crate::build;
use crate::http;
use crate::settings::global_user::GlobalUser;
use crate::settings::toml::Target;
use crate::terminal::message;
use crate::terminal::{message, open_browser};
use crate::watch::watch_and_build;

pub fn preview(
Expand Down Expand Up @@ -93,22 +92,6 @@ pub struct PreviewOpt {
pub headless: bool,
}

fn open_browser(url: &str) -> Result<(), failure::Error> {
let _output = if cfg!(target_os = "windows") {
let url_escaped = url.replace("&", "^&");
let windows_cmd = format!("start {}", url_escaped);
Command::new("cmd").args(&["/C", &windows_cmd]).output()?
} else if cfg!(target_os = "linux") {
let linux_cmd = format!(r#"xdg-open "{}""#, url);
Command::new("sh").arg("-c").arg(&linux_cmd).output()?
} else {
let mac_cmd = format!(r#"open "{}""#, url);
Command::new("sh").arg("-c").arg(&mac_cmd).output()?
};

Ok(())
}

fn client_request(payload: &RequestPayload, script_id: &str, sites_preview: bool) {
let client = http::client();

Expand Down
17 changes: 17 additions & 0 deletions src/terminal/browser.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use std::process::Command;

pub fn open_browser(url: &str) -> Result<(), failure::Error> {
let _output = if cfg!(target_os = "windows") {
let url_escaped = url.replace("&", "^&");
let windows_cmd = format!("start {}", url_escaped);
Command::new("cmd").args(&["/C", &windows_cmd]).output()?
} else if cfg!(target_os = "linux") {
let linux_cmd = format!(r#"xdg-open "{}""#, url);
Command::new("sh").arg("-c").arg(&linux_cmd).output()?
} else {
let mac_cmd = format!(r#"open "{}""#, url);
Command::new("sh").arg("-c").arg(&mac_cmd).output()?
};

Ok(())
}
2 changes: 2 additions & 0 deletions src/terminal/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
mod browser;
pub mod emoji;
pub mod interactive;
pub mod message;
pub mod styles;
pub use browser::open_browser;

0 comments on commit 8086f4e

Please sign in to comment.