Skip to content

Commit

Permalink
virt checks in both install_easy and blockcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
bol-van committed Apr 13, 2022
1 parent 341b2ab commit c6663a5
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 30 deletions.
2 changes: 2 additions & 0 deletions blockcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ ZAPRET_BASE="$EXEDIR"
. "$ZAPRET_BASE/common/dialog.sh"
. "$ZAPRET_BASE/common/elevate.sh"
. "$ZAPRET_BASE/common/fwtype.sh"
. "$ZAPRET_BASE/common/virt.sh"

[ -n "$QNUM" ] || QNUM=59780
[ -n "$TPPORT" ] || TPPORT=993
Expand Down Expand Up @@ -1005,6 +1006,7 @@ check_system
require_root
check_prerequisites
check_dns
check_virt
ask_params

PID=
Expand Down
39 changes: 39 additions & 0 deletions common/virt.sh
Original file line number Diff line number Diff line change
@@ -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
}
31 changes: 1 addition & 30 deletions install_easy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ ZAPRET_BASE="$EXEDIR"
. "$ZAPRET_BASE/common/dialog.sh"
. "$ZAPRET_BASE/common/ipt.sh"
. "$ZAPRET_BASE/common/installer.sh"
. "$ZAPRET_BASE/common/virt.sh"

# install target
ZAPRET_TARGET=/opt/zapret
Expand Down Expand Up @@ -672,36 +673,6 @@ check_dns()
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()
{
Expand Down

0 comments on commit c6663a5

Please sign in to comment.