virt checks in both install_easy and blockcheck

This commit is contained in:
bol-van 2022-04-13 11:47:14 +03:00
parent 341b2ab529
commit c6663a517e
3 changed files with 42 additions and 30 deletions

View File

@ -9,6 +9,7 @@ ZAPRET_BASE="$EXEDIR"
. "$ZAPRET_BASE/common/dialog.sh" . "$ZAPRET_BASE/common/dialog.sh"
. "$ZAPRET_BASE/common/elevate.sh" . "$ZAPRET_BASE/common/elevate.sh"
. "$ZAPRET_BASE/common/fwtype.sh" . "$ZAPRET_BASE/common/fwtype.sh"
. "$ZAPRET_BASE/common/virt.sh"
[ -n "$QNUM" ] || QNUM=59780 [ -n "$QNUM" ] || QNUM=59780
[ -n "$TPPORT" ] || TPPORT=993 [ -n "$TPPORT" ] || TPPORT=993
@ -1005,6 +1006,7 @@ check_system
require_root require_root
check_prerequisites check_prerequisites
check_dns check_dns
check_virt
ask_params ask_params
PID= PID=

39
common/virt.sh Normal file
View File

@ -0,0 +1,39 @@
get_virt()
{
local vm s v UNAME
UNAME=$(uname)
case "$UNAME" in
Linux)
if exists systemd-detect-virt; then
vm=$(systemd-detect-virt --vm)
elif [ -f /sys/class/dmi/id/product_name ]; then
read s </sys/class/dmi/id/product_name
for v in KVM QEMU VMware VMW VirtualBox Xen Bochs Parallels BHYVE Hyper-V; do
case "$s" in
"$v"*)
vm=$v
break
;;
esac
done
fi
;;
esac
echo "$vm"
}
check_virt()
{
echo \* checking virtualization
local vm=$(get_virt)
if [ -n "$vm" ]; then
if [ "$vm" = "none" ]; then
echo running on bare metal
else
echo "!!! WARNING. $vm virtualization detected !!!"
echo '!!! WARNING. vmware and virtualbox are known to break most of the DPI bypass techniques when network is NATed using internal hypervisor NAT !!!'
echo '!!! WARNING. if this is your case make sure you are bridged not NATed !!!'
fi
else
echo cannot detect
fi
}

View File

@ -15,6 +15,7 @@ ZAPRET_BASE="$EXEDIR"
. "$ZAPRET_BASE/common/dialog.sh" . "$ZAPRET_BASE/common/dialog.sh"
. "$ZAPRET_BASE/common/ipt.sh" . "$ZAPRET_BASE/common/ipt.sh"
. "$ZAPRET_BASE/common/installer.sh" . "$ZAPRET_BASE/common/installer.sh"
. "$ZAPRET_BASE/common/virt.sh"
# install target # install target
ZAPRET_TARGET=/opt/zapret ZAPRET_TARGET=/opt/zapret
@ -672,36 +673,6 @@ check_dns()
return 0 return 0
} }
check_virt()
{
echo \* checking virtualization
local vm s v
if exists systemd-detect-virt; then
vm=$(systemd-detect-virt --vm)
elif [ -f /sys/class/dmi/id/product_name ]; then
read s </sys/class/dmi/id/product_name
for v in KVM QEMU VMware VMW VirtualBox Xen Bochs Parallels BHYVE Hyper-V; do
case "$s" in
"$v"*)
vm=$v
break
;;
esac
done
fi
if [ -n "$vm" ]; then
if [ "$vm" = "none" ]; then
echo running on bare metal
else
echo "!!! WARNING. $vm virtualization detected !!!"
echo '!!! WARNING. vmware and virtualbox are known to break most of the DPI bypass techniques when network is NATed using internal hypervisor NAT !!!'
echo '!!! WARNING. if this is your case make sure you are bridged not NATed !!!'
fi
else
echo cannot detect
fi
}
install_systemd() install_systemd()
{ {