代码拉取完成,页面将自动刷新
diff --git a/frameworks/js/napi/vpn/src/vpn_config_utils.cpp b/frameworks/js/napi/vpn/src/vpn_config_utils.cpp
index 1c83339..926b5e1 100644
--- a/frameworks/js/napi/vpn/src/vpn_config_utils.cpp
+++ b/frameworks/js/napi/vpn/src/vpn_config_utils.cpp
@@ -189,6 +189,8 @@ sptr<IpsecVpnConfig> CreateAndParseIpsecVpnConf(napi_env env, napi_value config)
ipsecVpnConfig->ipsecPrivateServerCertFilePath_);
GetStringFromJsOptionItem(env, config, CONFIG_IPSEC_PUBLIC_SERVER_CERT_FILE_PATH,
ipsecVpnConfig->ipsecPublicServerCertFilePath_);
+ GetStringFromJsOptionItem(env, config, CONFIG_IPSEC_CONF, ipsecVpnConfig->ipsecConf_);
+ GetStringFromJsOptionItem(env, config, CONFIG_IPSEC_SECRETS, ipsecVpnConfig->ipsecSecrets_);
return ipsecVpnConfig;
}
@@ -549,6 +551,8 @@ napi_value CreateNapiIpsecVpnConfig(napi_env env, sptr<SysVpnConfig> &sysVpnConf
ipsecVpnConfig->ipsecPrivateServerCertFilePath_);
NapiUtils::SetStringPropertyUtf8(env, config, CONFIG_IPSEC_PUBLIC_SERVER_CERT_FILE_PATH,
ipsecVpnConfig->ipsecPublicServerCertFilePath_);
+ NapiUtils::SetStringPropertyUtf8(env, config, CONFIG_IPSEC_CONF, ipsecVpnConfig->ipsecConf_);
+ NapiUtils::SetStringPropertyUtf8(env, config, CONFIG_IPSEC_SECRETS, ipsecVpnConfig->ipsecSecrets_);
ipsecVpnConfig = nullptr;
return config;
}
diff --git a/frameworks/native/netvpnclient/src/ipsecvpn_config.cpp b/frameworks/native/netvpnclient/src/ipsecvpn_config.cpp
index 5f57a91..aa98b94 100755
--- a/frameworks/native/netvpnclient/src/ipsecvpn_config.cpp
+++ b/frameworks/native/netvpnclient/src/ipsecvpn_config.cpp
@@ -21,6 +21,8 @@ namespace NetManagerStandard {
bool IpsecVpnConfig::Marshalling(Parcel &parcel) const
{
bool allOK = SysVpnConfig::Marshalling(parcel) &&
+ parcel.WriteString(ipsecConf_) &&
+ parcel.WriteString(ipsecSecrets_) &&
parcel.WriteString(ipsecPreSharedKey_) &&
parcel.WriteString(ipsecIdentifier_) &&
parcel.WriteString(swanctlConf_) &&
@@ -47,6 +49,8 @@ sptr<IpsecVpnConfig> IpsecVpnConfig::Unmarshalling(Parcel &parcel)
}
bool allOK = SysVpnConfig::Unmarshalling(parcel, ptr) &&
+ parcel.ReadString(ptr->ipsecConf_) &&
+ parcel.ReadString(ptr->ipsecSecrets_) &&
parcel.ReadString(ptr->ipsecPreSharedKey_) &&
parcel.ReadString(ptr->ipsecIdentifier_) &&
parcel.ReadString(ptr->swanctlConf_) &&
diff --git a/frameworks/native/netvpnclient/src/vpn_data_bean.cpp b/frameworks/native/netvpnclient/src/vpn_data_bean.cpp
index 855271d..92fbd81 100644
--- a/frameworks/native/netvpnclient/src/vpn_data_bean.cpp
+++ b/frameworks/native/netvpnclient/src/vpn_data_bean.cpp
@@ -21,6 +21,7 @@ namespace OHOS {
namespace NetManagerStandard {
sptr<SysVpnConfig> VpnDataBean::ConvertVpnBeanToSysVpnConfig(sptr<VpnDataBean> &vpnBean)
{
+ NETMGR_EXT_LOG_I("zx %{public}s vpnType_:%{public}d", __func__, vpnBean->vpnType_);
if (vpnBean == nullptr) {
NETMGR_EXT_LOG_E("ConvertVpnBeanToSysVpnConfig vpnBean is null");
return nullptr;
@@ -117,6 +118,11 @@ sptr<IpsecVpnConfig> VpnDataBean::ConvertVpnBeanToIpsecVpnConfig(sptr<VpnDataBea
ipsecVpnConfig->ipsecPublicUserCertFilePath_ = vpnBean->ipsecPublicUserCertFilePath_;
ipsecVpnConfig->ipsecPrivateServerCertFilePath_ = vpnBean->ipsecPrivateServerCertFilePath_;
ipsecVpnConfig->ipsecPublicServerCertFilePath_ = vpnBean->ipsecPublicServerCertFilePath_;
+
+ // ipsec 新增
+ NETMGR_EXT_LOG_I("zx %{public}s %{public}s:", __func__, vpnBean->ipsecConf_.c_str());
+ ipsecVpnConfig->ipsecConf_ = vpnBean->ipsecConf_;
+ ipsecVpnConfig->ipsecSecrets_ = vpnBean->ipsecSecrets_;
return ipsecVpnConfig;
}
@@ -160,6 +166,7 @@ sptr<L2tpVpnConfig> VpnDataBean::ConvertVpnBeanToL2tpVpnConfig(sptr<VpnDataBean>
l2tpVpnConfig->ipsecPrivateServerCertFilePath_ = vpnBean->ipsecPrivateServerCertFilePath_;
l2tpVpnConfig->ipsecPublicServerCertFilePath_ = vpnBean->ipsecPublicServerCertFilePath_;
+ NETMGR_EXT_LOG_I("zx %{public}s %{public}s:", __func__, vpnBean->ipsecConf_.c_str());
l2tpVpnConfig->ipsecConf_ = vpnBean->ipsecConf_;
l2tpVpnConfig->ipsecSecrets_ = vpnBean->ipsecSecrets_;
l2tpVpnConfig->optionsL2tpdClient_ = vpnBean->optionsL2tpdClient_;
@@ -170,6 +177,7 @@ sptr<L2tpVpnConfig> VpnDataBean::ConvertVpnBeanToL2tpVpnConfig(sptr<VpnDataBean>
sptr<VpnDataBean> VpnDataBean::ConvertSysVpnConfigToVpnBean(sptr<SysVpnConfig> &sysVpnConfig)
{
+ NETMGR_EXT_LOG_I("zx %{public}s", __func__);
if (sysVpnConfig == nullptr) {
NETMGR_EXT_LOG_E("ConvertSysVpnConfigToVpnBean sysVpnConfig is null");
return nullptr;
@@ -180,6 +188,7 @@ sptr<VpnDataBean> VpnDataBean::ConvertSysVpnConfigToVpnBean(sptr<SysVpnConfig> &
return nullptr;
}
ConvertCommonVpnConfigToVpnBean(sysVpnConfig, vpnBean);
+ NETMGR_EXT_LOG_I("zx %{public}s vpnType_ = %{public}d", __func__, sysVpnConfig->vpnType_);
switch (sysVpnConfig->vpnType_) {
case VpnType::IKEV2_IPSEC_MSCHAPv2:
case VpnType::IKEV2_IPSEC_PSK:
@@ -266,6 +275,7 @@ void VpnDataBean::ConvertIpsecVpnConfigToVpnBean(sptr<SysVpnConfig> sysVpnConfig
NETMGR_EXT_LOG_E("ConvertIpsecVpnConfigToVpnBean ipsecVpnConfig is null");
return;
}
+ NETMGR_EXT_LOG_I("zx %{public}s ----- ipsecConf_ %{public}s", __func__, ipsecVpnConfig->ipsecConf_.c_str());
vpnBean->ipsecPreSharedKey_ = ipsecVpnConfig->ipsecPreSharedKey_;
vpnBean->ipsecIdentifier_ = ipsecVpnConfig->ipsecIdentifier_;
vpnBean->swanctlConf_ = ipsecVpnConfig->swanctlConf_;
@@ -280,6 +290,13 @@ void VpnDataBean::ConvertIpsecVpnConfigToVpnBean(sptr<SysVpnConfig> sysVpnConfig
vpnBean->ipsecPublicUserCertFilePath_ = ipsecVpnConfig->ipsecPublicUserCertFilePath_;
vpnBean->ipsecPrivateServerCertFilePath_ = ipsecVpnConfig->ipsecPrivateServerCertFilePath_;
vpnBean->ipsecPublicServerCertFilePath_ = ipsecVpnConfig->ipsecPublicServerCertFilePath_;
+ if (ipsecVpnConfig->ipsecConf_.empty()) {
+ vpnBean->ipsecConf_ = "IyBpcHNlYy5jb25mIC0gc3Ryb25nU3dhbiBJUHNlYyBjb25";
+ } else {
+ vpnBean->ipsecConf_ = ipsecVpnConfig->ipsecConf_;
+ }
+
+ vpnBean->ipsecSecrets_ = ipsecVpnConfig->ipsecSecrets_;
ipsecVpnConfig = nullptr;
}
diff --git a/interfaces/innerkits/netvpnclient/include/ipsecvpn_config.h b/interfaces/innerkits/netvpnclient/include/ipsecvpn_config.h
index 37dbda3..cc09a1a 100755
--- a/interfaces/innerkits/netvpnclient/include/ipsecvpn_config.h
+++ b/interfaces/innerkits/netvpnclient/include/ipsecvpn_config.h
@@ -37,6 +37,10 @@ struct IpsecVpnConfig : SysVpnConfig {
std::string ipsecPrivateServerCertFilePath_;
std::string ipsecPublicServerCertFilePath_;
+ // IPSec新增
+ std::string ipsecConf_;
+ std::string ipsecSecrets_;
+
bool Marshalling(Parcel &parcel) const override;
static sptr<IpsecVpnConfig> Unmarshalling(Parcel &parcel);
};
diff --git a/interfaces/innerkits/netvpnclient/include/vpn_data_bean.h b/interfaces/innerkits/netvpnclient/include/vpn_data_bean.h
index 9f88a77..253467c 100644
--- a/interfaces/innerkits/netvpnclient/include/vpn_data_bean.h
+++ b/interfaces/innerkits/netvpnclient/include/vpn_data_bean.h
@@ -70,7 +70,7 @@ struct VpnDataBean : public virtual RefBase {
std::string ipsecPrivateServerCertFilePath_;
std::string ipsecPublicServerCertFilePath_;
- //l2tp
+ //l2tp + ipsec
std::string ipsecConf_;
std::string ipsecSecrets_;
std::string optionsL2tpdClient_;
diff --git a/services/vpnmanager/include/ipsec_vpn_ctl.h b/services/vpnmanager/include/ipsec_vpn_ctl.h
index 11a8040..133257e 100644
--- a/services/vpnmanager/include/ipsec_vpn_ctl.h
+++ b/services/vpnmanager/include/ipsec_vpn_ctl.h
@@ -24,15 +24,16 @@
#include "netsys_controller.h"
#define IPSEC_PIDDIR "/data/service/el1/public/vpn"
+// #define IPSEC_PIDDIR "/data/service/el1/public/netmanager"
namespace OHOS {
namespace NetManagerStandard {
namespace {
const std::string SWAN_CTL_FILE = IPSEC_PIDDIR "/swanctl.conf";
const std::string SWAN_CONFIG_FILE = IPSEC_PIDDIR "/strongswan.conf";
-const std::string L2TP_IPSEC_CFG = IPSEC_PIDDIR "/ipsec.conf";
+const std::string IPSEC_CFG = IPSEC_PIDDIR "/ipsec.conf";
const std::string L2TP_CFG = IPSEC_PIDDIR "/xl2tpd.conf";
-const std::string L2TP_IPSEC_SECRETS_CFG = IPSEC_PIDDIR "/ipsec.secrets.conf";
+const std::string IPSEC_SECRETS_CFG = IPSEC_PIDDIR "/ipsec.secrets.conf";
const std::string OPTIONS_L2TP_CLIENT = IPSEC_PIDDIR "/options.l2tpd.client.conf";
const std::string IPSEC_START_TAG = "start";
const std::string SWANCTL_START_TAG = "config";
diff --git a/services/vpnmanager/src/ipsec_vpn_ctl.cpp b/services/vpnmanager/src/ipsec_vpn_ctl.cpp
index ff7972d..5ce4ff5 100644
--- a/services/vpnmanager/src/ipsec_vpn_ctl.cpp
+++ b/services/vpnmanager/src/ipsec_vpn_ctl.cpp
@@ -56,7 +56,7 @@ int32_t IpsecVpnCtl::StopSysVpn()
int32_t IpsecVpnCtl::StartSysVpn()
{
- NETMGR_EXT_LOG_I("start ipsec vpn");
+ NETMGR_EXT_LOG_I("zx start ipsec vpn");
state_ = IpsecVpnStateCode::STATE_INIT;
InitConfigFile();
NetsysController::GetInstance().ProcessVpnStage(SysVpnStageCode::VPN_STAGE_RESTART);
@@ -65,7 +65,9 @@ int32_t IpsecVpnCtl::StartSysVpn()
int32_t IpsecVpnCtl::InitConfigFile()
{
+ NETMGR_EXT_LOG_I("zx InitConfigFile 001");
CleanTempFiles();
+ NETMGR_EXT_LOG_I("zx InitConfigFile 002");
if (ipsecVpnConfig_ == nullptr) {
NETMGR_EXT_LOG_E("InitConfigFile ipsecVpnConfig is null");
return NETMANAGER_EXT_ERR_INTERNAL;
@@ -83,6 +85,23 @@ int32_t IpsecVpnCtl::InitConfigFile()
CommonUtils::WriteFile(SWAN_CONFIG_FILE, strongswanCfg);
}
}
+
+ NETMGR_EXT_LOG_I("zx InitConfigFile WriteFile ipsecConf && ipsecSecretsis null");
+ // IPSec 新增
+ if (!ipsecVpnConfig_->ipsecConf_.empty()) {
+ std::string ipsecConf = Base64::Decode(ipsecVpnConfig_->ipsecConf_);
+ if (!ipsecConf.empty()) {
+ CommonUtils::WriteFile(IPSEC_CFG, ipsecConf);
+ NETMGR_EXT_LOG_I("zx ipsecConf_ %{public}s:", ipsecConf.c_str());
+ }
+ }
+ if (!ipsecVpnConfig_->ipsecSecrets_.empty()) {
+ std::string ipsecSecrets = Base64::Decode(ipsecVpnConfig_->ipsecSecrets_);
+ if (!ipsecSecrets.empty()) {
+ CommonUtils::WriteFile(IPSEC_SECRETS_CFG, ipsecSecrets);
+ }
+ }
+
return NETMANAGER_EXT_SUCCESS;
}
@@ -91,8 +110,8 @@ void IpsecVpnCtl::CleanTempFiles()
DeleteTempFile(SWAN_CTL_FILE);
DeleteTempFile(SWAN_CONFIG_FILE);
DeleteTempFile(L2TP_CFG);
- DeleteTempFile(L2TP_IPSEC_CFG);
- DeleteTempFile(L2TP_IPSEC_SECRETS_CFG);
+ DeleteTempFile(IPSEC_CFG);
+ DeleteTempFile(IPSEC_SECRETS_CFG);
DeleteTempFile(OPTIONS_L2TP_CLIENT);
}
@@ -107,6 +126,7 @@ void IpsecVpnCtl::DeleteTempFile(const std::string &fileName)
int32_t IpsecVpnCtl::NotifyConnectStage(const std::string &stage, const int32_t &result)
{
+ NETMGR_EXT_LOG_I("zx enter %{public}s stage: %{public}s", __func__, stage.c_str());
if (stage.empty()) {
NETMGR_EXT_LOG_E("stage is empty");
return NETMANAGER_EXT_ERR_PARAMETER_ERROR;
diff --git a/services/vpnmanager/src/l2tp_vpn_ctl.cpp b/services/vpnmanager/src/l2tp_vpn_ctl.cpp
index 82fe90e..2356e7e 100644
--- a/services/vpnmanager/src/l2tp_vpn_ctl.cpp
+++ b/services/vpnmanager/src/l2tp_vpn_ctl.cpp
@@ -70,13 +70,13 @@ int32_t L2tpVpnCtl::InitConfigFile()
if (!l2tpVpnConfig_->ipsecConf_.empty()) {
std::string ipsecConf = Base64::Decode(l2tpVpnConfig_->ipsecConf_);
if (!ipsecConf.empty()) {
- CommonUtils::WriteFile(L2TP_IPSEC_CFG, ipsecConf);
+ CommonUtils::WriteFile(IPSEC_CFG, ipsecConf);
}
}
if (!l2tpVpnConfig_->ipsecSecrets_.empty()) {
std::string ipsecSecrets = Base64::Decode(l2tpVpnConfig_->ipsecSecrets_);
if (!ipsecSecrets.empty()) {
- CommonUtils::WriteFile(L2TP_IPSEC_SECRETS_CFG, ipsecSecrets);
+ CommonUtils::WriteFile(IPSEC_SECRETS_CFG, ipsecSecrets);
}
}
if (!l2tpVpnConfig_->optionsL2tpdClient_.empty()) {
diff --git a/services/vpnmanager/src/networkvpn_service.cpp b/services/vpnmanager/src/networkvpn_service.cpp
index d3f52a3..8f89436 100644
--- a/services/vpnmanager/src/networkvpn_service.cpp
+++ b/services/vpnmanager/src/networkvpn_service.cpp
@@ -810,6 +810,7 @@ std::shared_ptr<IpsecVpnCtl> NetworkVpnService::CreateIpsecVpnCtl(sptr<VpnDataBe
int32_t NetworkVpnService::AddSysVpnConfig(sptr<SysVpnConfig> &config)
{
+ NETMGR_EXT_LOG_I("zx %{public}s", __func__);
if (config == nullptr) {
NETMGR_EXT_LOG_E("config is null");
return NETMANAGER_EXT_ERR_PARAMETER_ERROR;
@@ -823,6 +824,8 @@ int32_t NetworkVpnService::AddSysVpnConfig(sptr<SysVpnConfig> &config)
return ret;
}
+ NETMGR_EXT_LOG_I("zx %{public}s, LINE: %{public}d", __func__, __LINE__);
+
NETMGR_EXT_LOG_I("AddSysVpnConfig id=%{public}s name=%{public}s type=%{public}d",
config->vpnId_.c_str(), config->vpnName_.c_str(), config->vpnType_);
config->userId_ = userId;
@@ -882,7 +885,7 @@ int32_t NetworkVpnService::GetSysVpnConfig(sptr<SysVpnConfig> &config, const std
return ret;
}
- NETMGR_EXT_LOG_I("GetSysVpnConfig id=%{public}s", vpnId.c_str());
+ NETMGR_EXT_LOG_I("zx GetSysVpnConfig id=%{public}s", vpnId.c_str());
sptr<VpnDataBean> vpnBean = new (std::nothrow) VpnDataBean();
if (vpnBean == nullptr) {
NETMGR_EXT_LOG_E("vpnBean is nullptr");
diff --git a/services/vpnmanager/src/vpn_database_helper.cpp b/services/vpnmanager/src/vpn_database_helper.cpp
index a45c0e5..3d82d1b 100644
--- a/services/vpnmanager/src/vpn_database_helper.cpp
+++ b/services/vpnmanager/src/vpn_database_helper.cpp
@@ -84,6 +84,7 @@ int32_t VpnDataBaseCallBack::OnDowngrade(OHOS::NativeRdb::RdbStore &store, int32
int32_t VpnDatabaseHelper::InsertOrUpdateData(const sptr<VpnDataBean> &vpnBean)
{
+ NETMGR_EXT_LOG_E("zx %{public}s ===================", __func__);
if (vpnBean == nullptr) {
NETMGR_EXT_LOG_E("InsertOrUpdateData vpnBean is nullptr");
return NETMANAGER_EXT_ERR_INVALID_PARAMETER;
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。