输出增加颜色
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
use std::process;
|
use std::process;
|
||||||
|
|
||||||
|
use console::style;
|
||||||
|
|
||||||
use vnt::handle::callback::ConnectInfo;
|
use vnt::handle::callback::ConnectInfo;
|
||||||
use vnt::{DeviceInfo, ErrorInfo, HandshakeInfo, RegisterInfo, VntCallback};
|
use vnt::{DeviceInfo, ErrorInfo, HandshakeInfo, RegisterInfo, VntCallback};
|
||||||
|
|
||||||
@@ -8,7 +10,7 @@ pub struct VntHandler {}
|
|||||||
|
|
||||||
impl VntCallback for VntHandler {
|
impl VntCallback for VntHandler {
|
||||||
fn success(&self) {
|
fn success(&self) {
|
||||||
println!(" ====== Connect Successfully ====== ")
|
println!(" {} ", style("====== Connect Successfully ======").green())
|
||||||
}
|
}
|
||||||
fn create_tun(&self, info: DeviceInfo) {
|
fn create_tun(&self, info: DeviceInfo) {
|
||||||
println!("create_tun {}", info)
|
println!("create_tun {}", info)
|
||||||
@@ -24,12 +26,12 @@ impl VntCallback for VntHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn register(&self, info: RegisterInfo) -> bool {
|
fn register(&self, info: RegisterInfo) -> bool {
|
||||||
println!("register {}", info);
|
println!("register {}", style(info).green());
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
fn error(&self, info: ErrorInfo) {
|
fn error(&self, info: ErrorInfo) {
|
||||||
println!("error {}", info);
|
println!("{}", style(format!("error {}", info)).red());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn stop(&self) {
|
fn stop(&self) {
|
||||||
|
|||||||
@@ -165,6 +165,7 @@ pub enum ErrorType {
|
|||||||
AddressExhausted,
|
AddressExhausted,
|
||||||
IpAlreadyExists,
|
IpAlreadyExists,
|
||||||
InvalidIp,
|
InvalidIp,
|
||||||
|
LocalIpExists,
|
||||||
Unknown,
|
Unknown,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,7 +177,8 @@ impl Into<u8> for ErrorType {
|
|||||||
ErrorType::AddressExhausted => 3,
|
ErrorType::AddressExhausted => 3,
|
||||||
ErrorType::IpAlreadyExists => 4,
|
ErrorType::IpAlreadyExists => 4,
|
||||||
ErrorType::InvalidIp => 5,
|
ErrorType::InvalidIp => 5,
|
||||||
ErrorType::Unknown => 6,
|
ErrorType::LocalIpExists => 6,
|
||||||
|
ErrorType::Unknown => 255,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -262,7 +262,7 @@ impl<Call: VntCallback> ServerPacketHandler<Call> {
|
|||||||
}
|
}
|
||||||
if let Err(e) = self.device.set_ip(virtual_ip, virtual_netmask) {
|
if let Err(e) = self.device.set_ip(virtual_ip, virtual_netmask) {
|
||||||
self.callback.error(ErrorInfo::new_msg(
|
self.callback.error(ErrorInfo::new_msg(
|
||||||
ErrorType::Unknown,
|
ErrorType::LocalIpExists,
|
||||||
format!("set_ip {:?}", e),
|
format!("set_ip {:?}", e),
|
||||||
));
|
));
|
||||||
return Ok(());
|
return Ok(());
|
||||||
|
|||||||
Reference in New Issue
Block a user