函数:crevpn 创建 VPN

函数名称:创建 VPN

函数功能:创建一个新的 VPN

函数方法

info = { securID, password, VPNLocalIdentifier, VPNRemotedentifier, authType, eapType, VPNType, authorization, dispName, secret, server, } crevpn(info)

不同类型 VPN 必填项不同,注意区别

参数 类型 必填 说明
dispName string VPN 描述
VPNType number VPN 类型,
0 - L2TP,
1 - PPTP,
2 - IPSec,
4 - IKEv2
server string 服务器地址
authorization string VPN 账号
password string VPN 密码
VPNLocalIdentifier string 本地 ID
VPNRemotedentifier string 远程 ID,
当 VPN 类型为 4 时必填
authType number 用户鉴定,
0 - 无,
1 - 用户名
eapType string 证书
securID string RSA SecURLID
secret string 秘钥

函数用例

function file_exists(file_name) --检测指定文件是否存在
    local f = io.open(file_name, "r")
    return f ~= nil and f:close()
end
if  file_exists(userPath().."/plugin/vpncfg.tsl") == false then
    dialog("库文件不存在,请手动导入 vpncfg.tsl 文件到"..userPath().."/plugin目录下", 0)
    lua_exit()
end
local tsld = loadTSLibrary("vpncfg.tsl") --库加载,返回一个 table
if tsld.granted == 0 then
    dialog("插件未授权!", 0)
    return
end
if tsld.status == 0 then --验证判断
    dialog("插件加载异常", 0)
    return
end
require("vpncfg") --需要加载
--以上代码请在脚本开头先调用验证加载,只需加载一次
local tab = {
    VPNType=0,
    dispName="test",
    server="123.123.com",
    authorization="123",
    password="123",
    authType = 0,
}--table 内写入 VPN 配置信息
crevpn(tab)

注意事项

  • 不同系统的 VPN 类型有差别
  • 函数需要在设置界面调用才生效
Copyright 北京帮你玩科技有限公司 2023 all right reserved,powered by Gitbook该文章修订时间: 2024-03-06 17:50:18

results matching ""

    No results matching ""