增加日志输出内容

This commit is contained in:
lbl8603
2024-05-10 23:19:52 +08:00
parent 9df324f402
commit 0e4294415e
7 changed files with 90 additions and 17 deletions
Generated
+29
View File
@@ -67,6 +67,24 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0"
[[package]]
name = "android_log-sys"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ecc8056bf6ab9892dcd53216c83d1597487d7dacac16c8df6b877d127df9937"
[[package]]
name = "android_logger"
version = "0.13.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c494134f746c14dc653a35a4ea5aca24ac368529da5370ecf41fe0341c35772f"
dependencies = [
"android_log-sys",
"env_logger",
"log",
"once_cell",
]
[[package]]
name = "android_system_properties"
version = "0.1.5"
@@ -382,6 +400,16 @@ version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f"
[[package]]
name = "env_logger"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580"
dependencies = [
"log",
"regex",
]
[[package]]
name = "equivalent"
version = "1.0.1"
@@ -1618,6 +1646,7 @@ dependencies = [
name = "vnt-jni"
version = "1.2.9"
dependencies = [
"android_logger",
"common",
"jni",
"log",
+3
View File
@@ -14,5 +14,8 @@ jni = { version = "0.21.1", default-features = false }
log = "0.4.20"
spki = { version = "0.7.2", features = ["fingerprint", "alloc","base64","pem"]}
[target.'cfg(target_os = "android")'.dependencies]
android_logger = "0.13"
[lib]
crate-type = ["staticlib", "cdylib"]
+35 -13
View File
@@ -1,13 +1,16 @@
package top.wherewego.vnt.jni;
import java.io.Serializable;
import java.util.Arrays;
/**
* 启动配置
*
* @author https://github.com/lbl8603/vnt
*/
public class Config {
public class Config implements Serializable {
/**
* 是否是tap模式,仅支持windows和linux
* 是否是tap模式,仅支持windows
*/
private boolean tap;
/**
@@ -38,10 +41,6 @@ public class Config {
* 是否开启服务端加密
*/
private boolean serverEncrypt;
/**
* 仅使用中继转发
*/
private boolean relay;
/**
* 设备id,请使用唯一值
*/
@@ -174,13 +173,6 @@ public class Config {
this.serverEncrypt = serverEncrypt;
}
public boolean isRelay() {
return relay;
}
public void setRelay(boolean relay) {
this.relay = relay;
}
public String getDeviceId() {
return deviceId;
@@ -308,4 +300,34 @@ public class Config {
public void setPacketDelay(Integer packetDelay) {
this.packetDelay = packetDelay;
}
@Override
public String toString() {
return "Config{" +
"tap=" + tap +
", token='" + token + '\'' +
", name='" + name + '\'' +
", password='" + password + '\'' +
", cipherModel='" + cipherModel + '\'' +
", punchModel='" + punchModel + '\'' +
", mtu=" + mtu +
", serverEncrypt=" + serverEncrypt +
", deviceId='" + deviceId + '\'' +
", server='" + server + '\'' +
", dns=" + Arrays.toString(dns) +
", portMapping=" + Arrays.toString(portMapping) +
", stunServer=" + Arrays.toString(stunServer) +
", tcp=" + tcp +
", ip='" + ip + '\'' +
", finger=" + finger +
", firstLatency=" + firstLatency +
", inIps=" + Arrays.toString(inIps) +
", outIps=" + Arrays.toString(outIps) +
", ports=" + Arrays.toString(ports) +
", deviceName='" + deviceName + '\'' +
", useChannel='" + useChannel + '\'' +
", packetLossRate=" + packetLossRate +
", packetDelay=" + packetDelay +
'}';
}
}
+1
View File
@@ -2,3 +2,4 @@ pub mod callback;
pub mod config;
pub mod utils;
pub mod vnt;
pub(crate) mod vnt_logger;
+1 -1
View File
@@ -11,7 +11,6 @@ use vnt::core::Vnt;
use vnt::handle::PeerDeviceInfo;
use crate::callback::CallBack;
#[no_mangle]
pub unsafe extern "C" fn Java_top_wherewego_vnt_jni_Vnt_new0(
mut env: JNIEnv<'static>,
@@ -19,6 +18,7 @@ pub unsafe extern "C" fn Java_top_wherewego_vnt_jni_Vnt_new0(
config: JObject,
call_back: JObject<'static>,
) -> jlong {
crate::vnt_logger::init_log();
let jvm = if let Ok(jvm) = env.get_java_vm() {
jvm
} else {
+12
View File
@@ -0,0 +1,12 @@
#[cfg(target_os = "android")]
pub fn init_log() {
use android_logger::Config;
use log::LevelFilter;
android_logger::init_once(
Config::default()
.with_max_level(LevelFilter::Info) // limit log level
.with_tag("vnt_jni"), // logs will show under mytag tag
);
}
#[cfg(not(target_os = "android"))]
pub fn init_log() {}
+9 -3
View File
@@ -166,11 +166,17 @@ fn recv_handle(
}
}
}
_ => {}
h => {
log::warn!("不支持的icmp代理 {:?},{:?}", peer_ip, h)
}
},
Err(_) => {}
Err(e) => {
log::warn!("icmp {:?}", e)
}
},
Err(_) => {}
Err(e) => {
log::warn!("icmp {:?}", e)
}
}
}