57068368 发表于 2019-7-12 23:03:54

求助关于大猫猫脚本改进


[*]###使用前请确保你当前没有使用穿透进行管理###
[*]###请删除之前自己创建的CTS穿透VPN连接,方可使用本脚本。###
[*]###建议5-10分钟循环执行一次。6.38.5测试通过。###
[*]###定义CTS服务器IP###
[*]:global ctsip 120.24.176.137
[*]###定义CTS服务器虚拟网关###
[*]:global ctsgw 172.34.56.1
[*]###定义CTS服务器用户名###
[*]:global ctsuser "user"
[*]###定义CTS服务器密码###
[*]:global ctspass "passwd"
[*]###获取当前使用的CTS的VPN类型###
[*]:global usedvpn ""
[*]###获取当前CTS连接状态###
[*]:global stvpn   
[*]:if (!="") do={
[*]:set usedvpn pptp
[*]:set stvpn }
[*]:if (!="") do={
[*]:set usedvpn l2tp
[*]:set stvpn }
[*]:if (!="") do={
[*]:set usedvpn sstp
[*]:set stvpn }
[*]:if (!="") do={
[*]:set usedvpn ovpn
[*]:set stvpn }
[*]###没有发现任何符合条件的穿透接口,我来创建一个###
[*]:if (usedvpn="") do={
[*]:if (!="") do={
[*]/interface pptp-client set name=CTS-PPTP
[*]:set usedvpn pptp}
[*]:if (!="") do={
[*]/interface l2tp-client set name=CTS-L2TP
[*]:set usedvpn l2tp}
[*]:if (!="") do={
[*]/interface sstp-client set ($ctsip.":22")] name=CTS-SSTP
[*]:set usedvpn sstp}
[*]:if (!="") do={
[*]/interface ovpn-client set name=CTS-OVPN
[*]:set usedvpn ovpn}}
[*]:if (usedvpn="") do={/interface ovpn-client add cipher=aes128 connect-to=$ctsip port=110 name=CTS-OVPN user=$ctsuser password=$ctspass profile=default-encryption}
[*]###检测CTS当前连接是否正常,不正常则切换VPN协议###
[*]:if ($stvpn="") do={
[*]:if ($usedvpn="pptp") do={
[*]/interface pptp-client remove
[*]/interface l2tp-client add connect-to=$ctsip disabled=no name=CTS-L2TP user=$ctsuser password=$ctspass profile=default-encryption}
[*]:if ($usedvpn="l2tp") do={
[*]/interface l2tp-client remove
[*]/interface sstp-client
[*]add connect-to=($ctsip.":22") disabled=no name=CTS-SSTP profile=default-encryption user=$ctsuser password=$ctspass}
[*]:if ($usedvpn="sstp") do={
[*]/interface sstp-client remove
[*]/interface ovpn-client add cipher=aes128 connect-to=$ctsip port=110 name=CTS-OVPN user=$ctsuser password=$ctspass profile=default-encryption}
[*]:if ($usedvpn="ovpn") do={
[*]/interface ovpn-client remove
[*]#/interface pptp-client add connect-to=$ctsip name=CTS-PPTP user=$ctsuser password=$ctspass profile=default-encryption disabled=no
[*]/interface l2tp-client add connect-to=$ctsip disabled=no name=CTS-L2TP user=$ctsuser password=$ctspass profile=default-encryption}
[*]} else={
[*]:if (=0) do={
[*]:if ($usedvpn="pptp") do={
[*]/interface pptp-client remove
[*]/interface l2tp-client add connect-to=$ctsip disabled=no name=CTS-L2TP user=$ctsuser password=$ctspass profile=default-encryption}
[*]:if ($usedvpn="l2tp") do={
[*]/interface l2tp-client remove
[*]/interface sstp-client
[*]add connect-to=($ctsip.":22") disabled=no name=CTS-SSTP profile=default-encryption user=$ctsuser password=$ctspass}
[*]:if ($usedvpn="sstp") do={
[*]/interface sstp-client remove
[*]/interface ovpn-client add cipher=aes128 connect-to=$ctsip port=110 name=CTS-OVPN user=$ctsuser password=$ctspass profile=default-encryption}
[*]:if ($usedvpn="ovpn") do={
[*]/interface ovpn-client remove
[*]#/interface pptp-client add connect-to=$ctsip name=CTS-PPTP user=$ctsuser password=$ctspass profile=default-encryption disabled=no
[*]/interface l2tp-client add connect-to=$ctsip disabled=no name=CTS-L2TP user=$ctsuser password=$ctspass profile=default-encryption}
[*]}}


以上为大猫猫原有脚本,我想增加多服务器,比如增加2或3台VPN服务器,自动PING,PING通或延时小的自动连接,每10分钟或30分钟检测一次,如果当前正常则不动,我自己在上面增加了,
{{
:if ([:ping count=4 1.1.1.1<1) do={
:global ctsip 1.1.1.1
:log info "使用1.1.1.1地址"
} else={
:global ctsip 2.2.2.2
:log info "使用2.2.2.地址"
}

增加这个代码以后执行不通过。想问问各位前辈如何更改。


57068368 发表于 2019-7-31 12:27:39

那些大神能指点一二啊,谢谢了。
页: [1]
查看完整版本: 求助关于大猫猫脚本改进