增加端口映射功能

This commit is contained in:
lbl8603
2024-05-08 21:31:21 +08:00
parent d3dce7a3cc
commit 607c8c2e9f
12 changed files with 342 additions and 24 deletions
@@ -54,6 +54,10 @@ public class Config {
* dns地址
*/
private String[] dns;
/**
* 端口映射
*/
private String[] portMapping;
/**
* stun服务地址
*/
@@ -201,6 +205,13 @@ public class Config {
public void setDns(String[] dns) {
this.dns = dns;
}
public String[] getPortMapping() {
return portMapping;
}
public void setPortMapping(String[] portMapping) {
this.portMapping = portMapping;
}
public String[] getStunServer() {
return stunServer;
+3 -1
View File
@@ -21,6 +21,7 @@ pub fn new_config(env: &mut JNIEnv, config: JObject) -> Result<Config, Error> {
let server_address_str = to_string_not_null(env, &config, "server")?;
let stun_server = to_string_array_not_null(env, &config, "stunServer")?;
let dns = to_string_array(env, &config, "dns")?.unwrap_or_else(|| vec![]);
let port_mapping = to_string_array(env, &config, "portMapping")?.unwrap_or_else(|| vec![]);
let cipher_model = to_string_not_null(env, &config, "cipherModel")?;
let punch_model = to_string(env, &config, "punchModel")?;
let mtu = to_integer(env, &config, "mtu")?.map(|v| v as u32);
@@ -116,12 +117,13 @@ pub fn new_config(env: &mut JNIEnv, config: JObject) -> Result<Config, Error> {
UseChannelType::from_str(&use_channel.unwrap_or_default()).unwrap_or_default(),
packet_loss_rate,
packet_delay,
port_mapping,
) {
Ok(config) => config,
Err(e) => {
env.throw_new(
"java/lang/RuntimeException",
format!("vnt start error {}", e),
format!("vnt start error {:?}", e),
)
.expect("throw");
return Err(Error::JavaException);