Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
WyntersN committed Jul 11, 2024
1 parent 9e58ecc commit 2b22f5d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 15 deletions.
12 changes: 11 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ include = [
"**/*",
]

[profile.release]
opt-level = "z"
lto = true
codegen-units = 1
debug = false
panic = "unwind"
strip = "symbols"

#[lib]
#proc-macro = true

Expand Down Expand Up @@ -52,4 +60,6 @@ rust-i18n = "3"
base64 = "0.22"
encoding_rs = "0.8.34"
gmsm = "0.1"
bollard = "*"
bollard = "*"


9 changes: 6 additions & 3 deletions src/bin/panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @version:
* @Author: Wynters
* @Date: 2024-05-07 15:35:18
* @LastEditTime: 2024-07-11 06:34:58
* @LastEditTime: 2024-07-11 15:04:25
* @FilePath: \RustPanel\src\bin\panel.rs
*/
use actix_files as fs;
Expand Down Expand Up @@ -60,7 +60,10 @@ async fn main() -> std::io::Result<()> {
match get_all_ip_addresses() {
Ok(ip_addresses) => {
for ip in ip_addresses {
println!("http://{}:{}/#/login?v={}", ip, CONF.app.port, CONF.app.security_dir);
if ip.is_ipv4() {
println!("http://{}:{}/#/login?v={}", ip, CONF.app.port, CONF.app.security_dir);
}

}
}
Err(e) => {
Expand All @@ -83,7 +86,7 @@ async fn main() -> std::io::Result<()> {
.call()
.unwrap()
.into_string()
.unwrap();
.unwrap_or(String::from("127.0.0.1"));

println!(
"http://{}:{}/#/login?v={}",
Expand Down
25 changes: 14 additions & 11 deletions src/models/docker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
* @version:
* @Author: Wynters
* @Date: 2024-05-27 17:51:07
* @LastEditTime: 2024-06-02 17:57:25
* @LastEditTime: 2024-07-11 15:15:42
* @FilePath: \RustPanel\src\models\docker\mod.rs
*/
pub mod container;
pub mod image;
pub mod network;
use bollard::Docker;

use std::{error::Error, fmt};
use std::process::{Command, Stdio};
use std::io::{BufRead, BufReader};
Expand All @@ -22,20 +23,22 @@ pub struct DockerError {
}

impl fmt::Display for DockerError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.message)
}
}

impl Error for DockerError {}
pub fn docker() -> Result<bollard::Docker, Box<dyn Error>> {
match Docker::connect_with_socket_defaults() {
Ok(res) => return Ok(res),
Err(e) => {
return Err(Box::new(DockerError {
message: e.to_string(),
}))
}
};

impl DockerError {
fn new(message: String) -> Self {
DockerError { message }
}
}

pub fn docker() -> Result<Docker, Box<dyn Error + Send + Sync>> {
Docker::connect_with_socket_defaults()
.map_err(|e| Box::new(DockerError::new(e.to_string())) as Box<dyn Error + Send + Sync>)
}

pub fn install() -> Result<(), Box<dyn Error>> {
Expand Down

0 comments on commit 2b22f5d

Please sign in to comment.