From 2940561ee211850fdade1a00f6c08eed19ed894d Mon Sep 17 00:00:00 2001
From: John Preston <johnprestonmail@gmail.com>
Date: Thu, 25 Jun 2015 21:04:40 +0300
Subject: [PATCH] added IPv6 setting checkbox in Connection Type box in
 Settings, version 0.8.33.dev

---
 Telegram/DeployLinux.sh                       |  15 +-
 Telegram/DeployLinux32.sh                     |  15 +-
 Telegram/DeployMacWin.sh                      |  62 +++---
 Telegram/DeployWin.sh                         |  43 ++--
 Telegram/PrepareLinux.sh                      |  28 +--
 Telegram/PrepareLinux32.sh                    |  28 +--
 Telegram/PrepareMac.sh                        |  31 +--
 Telegram/PrepareWin.bat                       |  38 ++--
 Telegram/Resources/lang.strings               |   7 +-
 Telegram/SourceFiles/boxes/connectionbox.cpp  |  33 +++-
 Telegram/SourceFiles/boxes/connectionbox.h    |   1 +
 Telegram/SourceFiles/config.h                 |   6 +-
 Telegram/SourceFiles/dropdown.cpp             |   4 +-
 Telegram/SourceFiles/historywidget.cpp        |   2 +-
 Telegram/SourceFiles/localstorage.cpp         |  11 +-
 .../SourceFiles/mtproto/mtpConnection.cpp     | 184 ++++++++++++++----
 Telegram/SourceFiles/mtproto/mtpConnection.h  |  40 +++-
 Telegram/SourceFiles/settings.cpp             |   5 +
 Telegram/SourceFiles/settings.h               |   1 +
 Telegram/SourceFiles/settingswidget.cpp       |  17 +-
 Telegram/SourceFiles/types.h                  |   5 +-
 Telegram/Telegram.plist                       |   2 +-
 Telegram/Telegram.rc                          | Bin 5540 -> 5540 bytes
 Telegram/Telegram.xcodeproj/project.pbxproj   |  12 +-
 Telegram/Version.sh                           |   4 +-
 25 files changed, 405 insertions(+), 189 deletions(-)

diff --git a/Telegram/DeployLinux.sh b/Telegram/DeployLinux.sh
index 629f68693..db3478e4e 100755
--- a/Telegram/DeployLinux.sh
+++ b/Telegram/DeployLinux.sh
@@ -1,20 +1,21 @@
-AppVersion=`./Version.sh | awk -F " " '{print $1}'`
-AppVersionStr=`./Version.sh | awk -F " " '{print $2}'`
-DevChannel=`./Version.sh | awk -F " " '{print $3}'`
+AppVersionStrMajor=`./Version.sh | awk -F " " '{print $1}'`
+AppVersion=`./Version.sh | awk -F " " '{print $2}'`
+AppVersionStr=`./Version.sh | awk -F " " '{print $3}'`
+DevChannel=`./Version.sh | awk -F " " '{print $4}'`
 DevPostfix=''
 if [ "$DevChannel" != "0" ]; then
   DevPostfix='.dev'
 fi
 
-if [ ! -f "./../Linux/Release/deploy/$AppVersionStr$DevPostfix/tlinuxupd$AppVersion" ]; then
+if [ ! -f "./../Linux/Release/deploy/$AppVersionStrMajor/$AppVersionStr$DevPostfix/tlinuxupd$AppVersion" ]; then
     echo "tlinuxupd$AppVersion not found!";
     exit 1
 fi
 
-if [ ! -f "./../Linux/Release/deploy/$AppVersionStr$DevPostfix/tsetup.$AppVersionStr$DevPostfix.tar.xz" ]; then
+if [ ! -f "./../Linux/Release/deploy/$AppVersionStrMajor/$AppVersionStr$DevPostfix/tsetup.$AppVersionStr$DevPostfix.tar.xz" ]; then
     echo "tsetup.$AppVersionStr$DevPostfix.tar.xz not found!"
     exit 1
 fi
 
-scp ./../Linux/Release/deploy/$AppVersionStr$DevPostfix/tlinuxupd$AppVersion tmaster:tdesktop/www/tlinux/
-scp ./../Linux/Release/deploy/$AppVersionStr$DevPostfix/tsetup.$AppVersionStr$DevPostfix.tar.xz tmaster:tdesktop/www/tlinux/
+scp ./../Linux/Release/deploy/$AppVersionStrMajor/$AppVersionStr$DevPostfix/tlinuxupd$AppVersion tmaster:tdesktop/www/tlinux/
+scp ./../Linux/Release/deploy/$AppVersionStrMajor/$AppVersionStr$DevPostfix/tsetup.$AppVersionStr$DevPostfix.tar.xz tmaster:tdesktop/www/tlinux/
diff --git a/Telegram/DeployLinux32.sh b/Telegram/DeployLinux32.sh
index 3540d3cbd..3280df52b 100755
--- a/Telegram/DeployLinux32.sh
+++ b/Telegram/DeployLinux32.sh
@@ -1,21 +1,22 @@
-AppVersion=`./Version.sh | awk -F " " '{print $1}'`
-AppVersionStr=`./Version.sh | awk -F " " '{print $2}'`
-DevChannel=`./Version.sh | awk -F " " '{print $3}'`
+AppVersionStrMajor=`./Version.sh | awk -F " " '{print $1}'`
+AppVersion=`./Version.sh | awk -F " " '{print $2}'`
+AppVersionStr=`./Version.sh | awk -F " " '{print $3}'`
+DevChannel=`./Version.sh | awk -F " " '{print $4}'`
 DevPostfix=''
 if [ "$DevChannel" != "0" ]; then
   DevPostfix='.dev'
 fi
 
-if [ ! -f "./../Linux/Release/deploy/$AppVersionStr$DevPostfix/tlinux32upd$AppVersion" ]; then
+if [ ! -f "./../Linux/Release/deploy/$AppVersionStrMajor/$AppVersionStr$DevPostfix/tlinux32upd$AppVersion" ]; then
     echo "tlinux32upd$AppVersion not found!"
     exit 1
 fi
 
-if [ ! -f "./../Linux/Release/deploy/$AppVersionStr$DevPostfix/tsetup32.$AppVersionStr$DevPostfix.tar.xz" ]; then
+if [ ! -f "./../Linux/Release/deploy/$AppVersionStrMajor/$AppVersionStr$DevPostfix/tsetup32.$AppVersionStr$DevPostfix.tar.xz" ]; then
     echo "tsetup32.$AppVersionStr$DevPostfix.zip not found!"
     exit 1
 fi
 
-scp ./../Linux/Release/deploy/$AppVersionStr$DevPostfix/tlinux32upd$AppVersion tmaster:tdesktop/www/tlinux32/
-scp ./../Linux/Release/deploy/$AppVersionStr$DevPostfix/tsetup32.$AppVersionStr$DevPostfix.tar.xz tmaster:tdesktop/www/tlinux32/
+scp ./../Linux/Release/deploy/$AppVersionStrMajor/$AppVersionStr$DevPostfix/tlinux32upd$AppVersion tmaster:tdesktop/www/tlinux32/
+scp ./../Linux/Release/deploy/$AppVersionStrMajor/$AppVersionStr$DevPostfix/tsetup32.$AppVersionStr$DevPostfix.tar.xz tmaster:tdesktop/www/tlinux32/
 
diff --git a/Telegram/DeployMacWin.sh b/Telegram/DeployMacWin.sh
index 1e8a06b12..f0a47cacb 100755
--- a/Telegram/DeployMacWin.sh
+++ b/Telegram/DeployMacWin.sh
@@ -1,38 +1,54 @@
-AppVersion=`./Version.sh | awk -F " " '{print $1}'`
-AppVersionStr=`./Version.sh | awk -F " " '{print $2}'`
-DevChannel=`./Version.sh | awk -F " " '{print $3}'`
+AppVersionStrMajor=`./Version.sh | awk -F " " '{print $1}'`
+AppVersion=`./Version.sh | awk -F " " '{print $2}'`
+AppVersionStr=`./Version.sh | awk -F " " '{print $3}'`
+DevChannel=`./Version.sh | awk -F " " '{print $4}'`
 DevPostfix=''
 if [ "$DevChannel" != "0" ]; then
   DevPostfix='.dev'
 fi
 
-if [ ! -f "./../Mac/Release/deploy/$AppVersionStr$DevPostfix/tmacupd$AppVersion" ]; then
-    echo "tmacupd$AppVersion not found!"
-    exit 1
+if [ ! -f "./../Mac/Release/deploy/$AppVersionStrMajor/$AppVersionStr$DevPostfix/tmacupd$AppVersion" ]; then
+  echo "tmacupd$AppVersion not found!"
+  exit 1
 fi
 
-if [ ! -f "./../Mac/Release/deploy/$AppVersionStr$DevPostfix/tsetup.$AppVersionStr$DevPostfix.dmg" ]; then
-    echo "tsetup.$AppVersionStr$DevPostfix.dmg not found!"
-    exit 1
+if [ ! -f "./../Mac/Release/deploy/$AppVersionStrMajor/$AppVersionStr$DevPostfix/tsetup.$AppVersionStr$DevPostfix.dmg" ]; then
+  echo "tsetup.$AppVersionStr$DevPostfix.dmg not found!"
+  exit 1
 fi
 
-if [ ! -f "./../../tother/tsetup/tupdate$AppVersion" ]; then
-    echo "tupdate$AppVersion not found!"
-    exit 1
+if [ ! -f "./../../tother/tsetup/$AppVersionStrMajor/$AppVersionStr$DevPostfix/tupdate$AppVersion" ]; then
+  echo "tupdate$AppVersion not found!"
+  exit 1
 fi
 
-if [ ! -f "./../../tother/tsetup/tportable.$AppVersionStr$DevPostfix.zip" ]; then
-    echo "tportable.$AppVersionStr$DevPostfix.zip not found!"
-    exit 1
+if [ ! -f "./../../tother/tsetup/$AppVersionStrMajor/$AppVersionStr$DevPostfix/tportable.$AppVersionStr$DevPostfix.zip" ]; then
+  echo "tportable.$AppVersionStr$DevPostfix.zip not found!"
+  exit 1
 fi
 
-if [ ! -f "./../../tother/tsetup/tsetup.$AppVersionStr$DevPostfix.exe" ]; then
-    echo "tsetup.$AppVersionStr$DevPostfix.exe not found!"
-    exit 1
+if [ ! -f "./../../tother/tsetup/$AppVersionStrMajor/$AppVersionStr$DevPostfix/tsetup.$AppVersionStr$DevPostfix.exe" ]; then
+  echo "tsetup.$AppVersionStr$DevPostfix.exe not found!"
+  exit 1
 fi
 
-scp ./../Mac/Release/deploy/$AppVersionStr$DevPostfix/tmacupd$AppVersion tmaster:tdesktop/www/tmac/
-scp ./../Mac/Release/deploy/$AppVersionStr$DevPostfix/tsetup.$AppVersionStr$DevPostfix.dmg tmaster:tdesktop/www/tmac/
-scp ./../../tother/tsetup/tupdate$AppVersion tmaster:tdesktop/www/tsetup/
-scp ./../../tother/tsetup/tportable.$AppVersionStr$DevPostfix.zip tmaster:tdesktop/www/tsetup/
-scp ./../../tother/tsetup/tsetup.$AppVersionStr$DevPostfix.exe tmaster:tdesktop/www/tsetup/
+if [ ! -d "./../../../Dropbox/Telegram/deploy/$AppVersionStrMajor" ]; then
+  mkdir "./../../../Dropbox/Telegram/deploy/$AppVersionStrMajor"
+fi
+
+if [ ! -d "./../../../Dropbox/Telegram/deploy/$AppVersionStrMajor/$AppVersionStr$DevPostfix" ]; then
+  mkdir "./../../../Dropbox/Telegram/deploy/$AppVersionStrMajor/$AppVersionStr$DevPostfix"
+fi
+
+scp ./../Mac/Release/deploy/$AppVersionStrMajor/$AppVersionStr$DevPostfix/tmacupd$AppVersion tmaster:tdesktop/www/tmac/
+scp ./../Mac/Release/deploy/$AppVersionStrMajor/$AppVersionStr$DevPostfix/tsetup.$AppVersionStr$DevPostfix.dmg tmaster:tdesktop/www/tmac/
+scp ./../../tother/tsetup/$AppVersionStrMajor/$AppVersionStr$DevPostfix/tupdate$AppVersion tmaster:tdesktop/www/tsetup/
+scp ./../../tother/tsetup/$AppVersionStrMajor/$AppVersionStr$DevPostfix/tportable.$AppVersionStr$DevPostfix.zip tmaster:tdesktop/www/tsetup/
+scp ./../../tother/tsetup/$AppVersionStrMajor/$AppVersionStr$DevPostfix/tsetup.$AppVersionStr$DevPostfix.exe tmaster:tdesktop/www/tsetup/
+
+mv -rv ./../../tother/tsetup/$AppVersionStrMajor/$AppVersionStr$DevPostfix ./../../../Dropbox/Telegram/deploy/$AppVersionStrMajor/
+
+cp -v ./../Mac/Release/deploy/$AppVersionStrMajor/$AppVersionStr$DevPostfix/tmacupd$AppVersion ./../../../Dropbox/Telegram/deploy/$AppVersionStrMajor/$AppVersionStr$DevPostfix/
+cp -v ./../Mac/Release/deploy/$AppVersionStrMajor/$AppVersionStr$DevPostfix/tsetup.$AppVersionStr$DevPostfix.dmg ./../../../Dropbox/Telegram/deploy/$AppVersionStrMajor/$AppVersionStr$DevPostfix/
+cp -rv ./../Mac/Release/deploy/$AppVersionStrMajor/$AppVersionStr$DevPostfix/Telegram.app.dSYM ./../../../Dropbox/Telegram/deploy/$AppVersionStrMajor/$AppVersionStr$DevPostfix/
+
diff --git a/Telegram/DeployWin.sh b/Telegram/DeployWin.sh
index 1284d6da5..8a667e9fe 100644
--- a/Telegram/DeployWin.sh
+++ b/Telegram/DeployWin.sh
@@ -1,26 +1,39 @@
-AppVersion=`./Version.sh | awk -F " " '{print $1}'`
-AppVersionStr=`./Version.sh | awk -F " " '{print $2}'`
-DevChannel=`./Version.sh | awk -F " " '{print $3}'`
+AppVersionStrMajor=`./Version.sh | awk -F " " '{print $1}'`
+AppVersion=`./Version.sh | awk -F " " '{print $2}'`
+AppVersionStr=`./Version.sh | awk -F " " '{print $3}'`
+DevChannel=`./Version.sh | awk -F " " '{print $4}'`
 DevPostfix=''
 if [ "$DevChannel" != "0" ]; then
   DevPostfix='.dev'
 fi
 
-if [ ! -f "./../Win32/Deploy/deploy/$AppVersionStr$DevPostfix/tupdate$AppVersion" ]; then
-    echo "tupdate$AppVersion not found!"
-    exit 1
+if [ ! -f "./../Win32/Deploy/deploy/$AppVersionStrMajor/$AppVersionStr$DevPostfix/tupdate$AppVersion" ]; then
+  echo "tupdate$AppVersion not found!"
+  exit 1
 fi
 
-if [ ! -f "./../Win32/Deploy/deploy/$AppVersionStr$DevPostfix/tportable.$AppVersionStr$DevPostfix.zip" ]; then
-    echo "tportable.$AppVersionStr$DevPostfix.zip not found!"
-    exit 1
+if [ ! -f "./../Win32/Deploy/deploy/$AppVersionStrMajor/$AppVersionStr$DevPostfix/tportable.$AppVersionStr$DevPostfix.zip" ]; then
+  echo "tportable.$AppVersionStr$DevPostfix.zip not found!"
+  exit 1
 fi
 
-if [ ! -f "./../Win32/Deploy/deploy/$AppVersionStr$DevPostfix/tsetup.$AppVersionStr$DevPostfix.exe" ]; then
-    echo "tsetup.$AppVersionStr$DevPostfix.exe not found!"
-    exit 1
+if [ ! -f "./../Win32/Deploy/deploy/$AppVersionStrMajor/$AppVersionStr$DevPostfix/tsetup.$AppVersionStr$DevPostfix.exe" ]; then
+  echo "tsetup.$AppVersionStr$DevPostfix.exe not found!"
+  exit 1
 fi
 
-cp -v ./../Win32/Deploy/deploy/$AppVersionStr$DevPostfix/tupdate$AppVersion /z/TBuild/tother/tsetup/
-cp -v ./../Win32/Deploy/deploy/$AppVersionStr$DevPostfix/tportable.$AppVersionStr$DevPostfix.zip /z/TBuild/tother/tsetup/
-cp -v ./../Win32/Deploy/deploy/$AppVersionStr$DevPostfix/tsetup.$AppVersionStr$DevPostfix.exe /z/TBuild/tother/tsetup/
+if [ ! -d "/z/TBuild/tother/tsetup/$AppVersionStrMajor" ]; then
+  mkdir "/z/TBuild/tother/tsetup/$AppVersionStrMajor"
+fi
+
+if [ ! -d "/z/TBuild/tother/tsetup/$AppVersionStrMajor/$AppVersionStr$DevPostfix" ]; then
+  mkdir "/z/TBuild/tother/tsetup/$AppVersionStrMajor/$AppVersionStr$DevPostfix"
+fi
+
+cp -v ./../Win32/Deploy/deploy/$AppVersionStrMajor/$AppVersionStr$DevPostfix/tupdate$AppVersion /z/TBuild/tother/tsetup/$AppVersionStrMajor/$AppVersionStr$DevPostfix/
+cp -v ./../Win32/Deploy/deploy/$AppVersionStrMajor/$AppVersionStr$DevPostfix/tportable.$AppVersionStr$DevPostfix.zip /z/TBuild/tother/tsetup/$AppVersionStrMajor/$AppVersionStr$DevPostfix/
+cp -v ./../Win32/Deploy/deploy/$AppVersionStrMajor/$AppVersionStr$DevPostfix/tsetup.$AppVersionStr$DevPostfix.exe /z/TBuild/tother/tsetup/$AppVersionStrMajor/$AppVersionStr$DevPostfix/
+cp -v ./../Win32/Deploy/deploy/$AppVersionStrMajor/$AppVersionStr$DevPostfix/Telegram.pdb /z/TBuild/tother/tsetup/$AppVersionStrMajor/$AppVersionStr$DevPostfix/
+cp -v ./../Win32/Deploy/deploy/$AppVersionStrMajor/$AppVersionStr$DevPostfix/Updater.exe /z/TBuild/tother/tsetup/$AppVersionStrMajor/$AppVersionStr$DevPostfix/
+cp -v ./../Win32/Deploy/deploy/$AppVersionStrMajor/$AppVersionStr$DevPostfix/Updater.pdb /z/TBuild/tother/tsetup/$AppVersionStrMajor/$AppVersionStr$DevPostfix/
+
diff --git a/Telegram/PrepareLinux.sh b/Telegram/PrepareLinux.sh
index 530fe2885..053d7092b 100755
--- a/Telegram/PrepareLinux.sh
+++ b/Telegram/PrepareLinux.sh
@@ -1,6 +1,7 @@
-AppVersion=`./Version.sh | awk -F " " '{print $1}'`
-AppVersionStr=`./Version.sh | awk -F " " '{print $2}'`
-DevChannel=`./Version.sh | awk -F " " '{print $3}'`
+AppVersionStrMajor=`./Version.sh | awk -F " " '{print $1}'`
+AppVersion=`./Version.sh | awk -F " " '{print $2}'`
+AppVersionStr=`./Version.sh | awk -F " " '{print $3}'`
+DevChannel=`./Version.sh | awk -F " " '{print $4}'`
 DevPostfix=''
 DevParam=''
 if [ "$DevChannel" != "0" ]; then
@@ -8,12 +9,12 @@ if [ "$DevChannel" != "0" ]; then
   DevParam='-dev'
 fi
 
-if [ -d "./../Linux/Release/deploy/$AppVersionStr.dev" ]; then
+if [ -d "./../Linux/Release/deploy/$AppVersionStrMajor/$AppVersionStr.dev" ]; then
   echo "Deploy folder for version $AppVersionStr.dev already exists!"
   exit 1
 fi
 
-if [ -d "./../Linux/Release/deploy/$AppVersionStr" ]; then
+if [ -d "./../Linux/Release/deploy/$AppVersionStrMajor/$AppVersionStr" ]; then
   echo "Deploy folder for version $AppVersionStr already exists!"
   exit 1
 fi
@@ -40,12 +41,17 @@ echo "Packer done!"
 if [ ! -d "./../Linux/Release/deploy" ]; then
   mkdir "./../Linux/Release/deploy"
 fi
+
+if [ ! -d "./../Linux/Release/deploy/$AppVersionStrMajor" ]; then
+  mkdir "./../Linux/Release/deploy/$AppVersionStrMajor"
+fi
+
 echo "Copying Telegram, Updater and tlinuxupd$AppVersion to deploy/$AppVersionStr$DevPostfix..";
-mkdir "./../Linux/Release/deploy/$AppVersionStr$DevPostfix"
-mkdir "./../Linux/Release/deploy/$AppVersionStr$DevPostfix/Telegram"
-mv ./../Linux/Release/Telegram ./../Linux/Release/deploy/$AppVersionStr$DevPostfix/Telegram/
-mv ./../Linux/Release/Updater ./../Linux/Release/deploy/$AppVersionStr$DevPostfix/Telegram/
-mv ./../Linux/Release/tlinuxupd$AppVersion ./../Linux/Release/deploy/$AppVersionStr$DevPostfix/
-cd ./../Linux/Release/deploy/$AppVersionStr$DevPostfix && tar -cJvf tsetup.$AppVersionStr$DevPostfix.tar.xz Telegram/ && cd ./../../../../Telegram
+mkdir "./../Linux/Release/deploy/$AppVersionStrMajor/$AppVersionStr$DevPostfix"
+mkdir "./../Linux/Release/deploy/$AppVersionStrMajor/$AppVersionStr$DevPostfix/Telegram"
+mv ./../Linux/Release/Telegram ./../Linux/Release/deploy/$AppVersionStrMajor/$AppVersionStr$DevPostfix/Telegram/
+mv ./../Linux/Release/Updater ./../Linux/Release/deploy/$AppVersionStrMajor/$AppVersionStr$DevPostfix/Telegram/
+mv ./../Linux/Release/tlinuxupd$AppVersion ./../Linux/Release/deploy/$AppVersionStrMajor/$AppVersionStr$DevPostfix/
+cd ./../Linux/Release/deploy/$AppVersionStrMajor/$AppVersionStr$DevPostfix && tar -cJvf tsetup.$AppVersionStr$DevPostfix.tar.xz Telegram/ && cd ./../../../../../Telegram
 echo "Version $AppVersionStr$DevPostfix prepared!";
 
diff --git a/Telegram/PrepareLinux32.sh b/Telegram/PrepareLinux32.sh
index ead20e14f..e0165bda6 100755
--- a/Telegram/PrepareLinux32.sh
+++ b/Telegram/PrepareLinux32.sh
@@ -1,6 +1,7 @@
-AppVersion=`./Version.sh | awk -F " " '{print $1}'`
-AppVersionStr=`./Version.sh | awk -F " " '{print $2}'`
-DevChannel=`./Version.sh | awk -F " " '{print $3}'`
+AppVersionStrMajor=`./Version.sh | awk -F " " '{print $1}'`
+AppVersion=`./Version.sh | awk -F " " '{print $2}'`
+AppVersionStr=`./Version.sh | awk -F " " '{print $3}'`
+DevChannel=`./Version.sh | awk -F " " '{print $4}'`
 DevPostfix=''
 DevParam=''
 if [ "$DevChannel" != "0" ]; then
@@ -8,12 +9,12 @@ if [ "$DevChannel" != "0" ]; then
   DevParam='-dev'
 fi
 
-if [ -d "./../Linux/Release/deploy/$AppVersionStr.dev" ]; then
+if [ -d "./../Linux/Release/deploy/$AppVersionStrMajor/$AppVersionStr.dev" ]; then
   echo "Deploy folder for version $AppVersionStr.dev already exists!"
   exit 1
 fi
 
-if [ -d "./../Linux/Release/deploy/$AppVersionStr" ]; then
+if [ -d "./../Linux/Release/deploy/$AppVersionStrMajor/$AppVersionStr" ]; then
   echo "Deploy folder for version $AppVersionStr already exists!"
   exit 1
 fi
@@ -40,12 +41,17 @@ echo "Packer done!"
 if [ ! -d "./../Linux/Release/deploy" ]; then
   mkdir "./../Linux/Release/deploy"
 fi
+
+if [ ! -d "./../Linux/Release/deploy/$AppVersionStrMajor" ]; then
+  mkdir "./../Linux/Release/deploy/$AppVersionStrMajor"
+fi
+
 echo "Copying Telegram, Updater and tlinux32upd$AppVersion to deploy/$AppVersionStr$DevPostfix..";
-mkdir "./../Linux/Release/deploy/$AppVersionStr$DevPostfix"
-mkdir "./../Linux/Release/deploy/$AppVersionStr$DevPostfix/Telegram"
-mv ./../Linux/Release/Telegram ./../Linux/Release/deploy/$AppVersionStr$DevPostfix/Telegram/
-mv ./../Linux/Release/Updater ./../Linux/Release/deploy/$AppVersionStr$DevPostfix/Telegram/
-mv ./../Linux/Release/tlinux32upd$AppVersion ./../Linux/Release/deploy/$AppVersionStr$DevPostfix/
-cd ./../Linux/Release/deploy/$AppVersionStr$DevPostfix && tar -cJvf tsetup32.$AppVersionStr$DevPostfix.tar.xz Telegram/ && cd ./../../../../Telegram
+mkdir "./../Linux/Release/deploy/$AppVersionStrMajor/$AppVersionStr$DevPostfix"
+mkdir "./../Linux/Release/deploy/$AppVersionStrMajor/$AppVersionStr$DevPostfix/Telegram"
+mv ./../Linux/Release/Telegram ./../Linux/Release/deploy/$AppVersionStrMajor/$AppVersionStr$DevPostfix/Telegram/
+mv ./../Linux/Release/Updater ./../Linux/Release/deploy/$AppVersionStrMajor/$AppVersionStr$DevPostfix/Telegram/
+mv ./../Linux/Release/tlinux32upd$AppVersion ./../Linux/Release/deploy/$AppVersionStrMajor/$AppVersionStr$DevPostfix/
+cd ./../Linux/Release/deploy/$AppVersionStrMajor/$AppVersionStr$DevPostfix && tar -cJvf tsetup32.$AppVersionStr$DevPostfix.tar.xz Telegram/ && cd ./../../../../../Telegram
 echo "Version $AppVersionStr$DevPostfix prepared!";
 
diff --git a/Telegram/PrepareMac.sh b/Telegram/PrepareMac.sh
index e641309c6..97ab64414 100755
--- a/Telegram/PrepareMac.sh
+++ b/Telegram/PrepareMac.sh
@@ -1,6 +1,7 @@
-AppVersion=`./Version.sh | awk -F " " '{print $1}'`
-AppVersionStr=`./Version.sh | awk -F " " '{print $2}'`
-DevChannel=`./Version.sh | awk -F " " '{print $3}'`
+AppVersionStrMajor=`./Version.sh | awk -F " " '{print $1}'`
+AppVersion=`./Version.sh | awk -F " " '{print $2}'`
+AppVersionStr=`./Version.sh | awk -F " " '{print $3}'`
+DevChannel=`./Version.sh | awk -F " " '{print $4}'`
 DevPostfix=''
 DevParam=''
 if [ "$DevChannel" != "0" ]; then
@@ -12,12 +13,12 @@ echo ""
 echo "Preparing version $AppVersionStr$DevPostfix.."
 echo ""
 
-if [ -d "./../Mac/Release/deploy/$AppVersionStr.dev" ]; then
+if [ -d "./../Mac/Release/deploy/$AppVersionStrMajor/$AppVersionStr.dev" ]; then
   echo "Deploy folder for version $AppVersionStr.dev already exists!"
   exit 1
 fi
 
-if [ -d "./../Mac/Release/deploy/$AppVersionStr" ]; then
+if [ -d "./../Mac/Release/deploy/$AppVersionStrMajor/$AppVersionStr" ]; then
   echo "Deploy folder for version $AppVersionStr already exists!"
   exit 1
 fi
@@ -73,19 +74,23 @@ hdiutil convert tsetup.dmg -format UDZO -imagekey zlib-level=9 -ov -o tsetup.$Ap
 cd ./../../Telegram
 cd ./../Mac/Release && ./Packer.app/Contents/MacOS/Packer -path Telegram.app -version $AppVersion $DevParam && cd ./../../Telegram
 
-if [ ! -d "./../Mac/Release/deploy/" ]; then
+if [ ! -d "./../Mac/Release/deploy" ]; then
   mkdir "./../Mac/Release/deploy"
 fi
 
-echo "Copying Telegram.app and tmacupd$AppVersion to deploy/$AppVersionStr..";
-mkdir "./../Mac/Release/deploy/$AppVersionStr$DevPostfix"
-mkdir "./../Mac/Release/deploy/$AppVersionStr$DevPostfix/Telegram"
-cp -r ./../Mac/Release/Telegram.app ./../Mac/Release/deploy/$AppVersionStr$DevPostfix/Telegram/
-mv ./../Mac/Release/Telegram.app.dSYM ./../Mac/Release/deploy/$AppVersionStr$DevPostfix/
+if [ ! -d "./../Mac/Release/deploy/$AppVersionStrMajor" ]; then
+  mkdir "./../Mac/Release/deploy/$AppVersionStrMajor"
+fi
+
+echo "Copying Telegram.app and tmacupd$AppVersion to deploy/$AppVersionStrMajor/$AppVersionStr..";
+mkdir "./../Mac/Release/deploy/$AppVersionStrMajor/$AppVersionStr$DevPostfix"
+mkdir "./../Mac/Release/deploy/$AppVersionStrMajor/$AppVersionStr$DevPostfix/Telegram"
+cp -r ./../Mac/Release/Telegram.app ./../Mac/Release/deploy/$AppVersionStrMajor/$AppVersionStr$DevPostfix/Telegram/
+mv ./../Mac/Release/Telegram.app.dSYM ./../Mac/Release/deploy/$AppVersionStrMajor/$AppVersionStr$DevPostfix/
 rm ./../Mac/Release/Telegram.app/Contents/MacOS/Telegram
 rm ./../Mac/Release/Telegram.app/Contents/Frameworks/Updater
 rm -rf ./../Mac/Release/Telegram.app/Contents/_CodeSignature
-mv ./../Mac/Release/tmacupd$AppVersion ./../Mac/Release/deploy/$AppVersionStr$DevPostfix/
-mv ./../Mac/Release/tsetup.$AppVersionStr$DevPostfix.dmg ./../Mac/Release/deploy/$AppVersionStr$DevPostfix/tsetup.$AppVersionStr$DevPostfix.dmg
+mv ./../Mac/Release/tmacupd$AppVersion ./../Mac/Release/deploy/$AppVersionStrMajor/$AppVersionStr$DevPostfix/
+mv ./../Mac/Release/tsetup.$AppVersionStr$DevPostfix.dmg ./../Mac/Release/deploy/$AppVersionStrMajor/$AppVersionStr$DevPostfix/tsetup.$AppVersionStr$DevPostfix.dmg
 echo "Version $AppVersionStr$DevPostfix prepared!";
 
diff --git a/Telegram/PrepareWin.bat b/Telegram/PrepareWin.bat
index 997f54058..f2b7a03c1 100644
--- a/Telegram/PrepareWin.bat
+++ b/Telegram/PrepareWin.bat
@@ -1,10 +1,11 @@
 @echo OFF
 
-set "AppVersion=8032"
-set "AppVersionStrSmall=0.8.32"
-set "AppVersionStr=0.8.32"
-set "AppVersionStrFull=0.8.32.0"
-set "DevChannel=0"
+set "AppVersionStrMajor=0.8"
+set "AppVersion=8033"
+set "AppVersionStrSmall=0.8.33"
+set "AppVersionStr=0.8.33"
+set "AppVersionStrFull=0.8.33.0"
+set "DevChannel=1"
 
 if %DevChannel% neq 0 goto preparedev
 
@@ -23,8 +24,8 @@ echo.
 echo Preparing version %AppVersionStr%%DevPostfix%..
 echo.
 
-if exist ..\Win32\Deploy\deploy\%AppVersionStr%\ goto error_exist1
-if exist ..\Win32\Deploy\deploy\%AppVersionStr%.dev\ goto error_exist2
+if exist ..\Win32\Deploy\deploy\%AppVersionStrMajor%\%AppVersionStr%\ goto error_exist1
+if exist ..\Win32\Deploy\deploy\%AppVersionStrMajor%\%AppVersionStr%.dev\ goto error_exist2
 if exist ..\Win32\Deploy\tupdate%AppVersion% goto error_exist3
 
 set "PATH=%PATH%;C:\Program Files\7-Zip;C:\Program Files (x86)\Inno Setup 5"
@@ -46,17 +47,18 @@ call Packer.exe -version %AppVersion% -path Telegram.exe -path Updater.exe %DevP
 if %errorlevel% neq 0 goto error1
 
 if not exist deploy mkdir deploy
-mkdir deploy\%AppVersionStr%%DevPostfix%
-mkdir deploy\%AppVersionStr%%DevPostfix%\Telegram
+if not exist deploy\%AppVersionStrMajor% mkdir deploy\%AppVersionStrMajor%
+mkdir deploy\%AppVersionStrMajor%\%AppVersionStr%%DevPostfix%
+mkdir deploy\%AppVersionStrMajor%\%AppVersionStr%%DevPostfix%\Telegram
 
-move Telegram.exe deploy\%AppVersionStr%%DevPostfix%\Telegram\
-move Updater.exe deploy\%AppVersionStr%%DevPostfix%\
-move Telegram.pdb deploy\%AppVersionStr%%DevPostfix%\
-move Updater.pdb deploy\%AppVersionStr%%DevPostfix%\
-move tsetup.%AppVersionStr%%DevPostfix%.exe deploy\%AppVersionStr%%DevPostfix%\
-move tupdate%AppVersion% deploy\%AppVersionStr%%DevPostfix%\
+move Telegram.exe deploy\%AppVersionStrMajor%\%AppVersionStr%%DevPostfix%\Telegram\
+move Updater.exe deploy\%AppVersionStrMajor%\%AppVersionStr%%DevPostfix%\
+move Telegram.pdb deploy\%AppVersionStrMajor%\%AppVersionStr%%DevPostfix%\
+move Updater.pdb deploy\%AppVersionStrMajor%\%AppVersionStr%%DevPostfix%\
+move tsetup.%AppVersionStr%%DevPostfix%.exe deploy\%AppVersionStrMajor%\%AppVersionStr%%DevPostfix%\
+move tupdate%AppVersion% deploy\%AppVersionStrMajor%\%AppVersionStr%%DevPostfix%\
 
-cd deploy\%AppVersionStr%%DevPostfix%
+cd deploy\%AppVersionStrMajor%\%AppVersionStr%%DevPostfix%
 7z a -mx9 tportable.%AppVersionStr%%DevPostfix%.zip Telegram\
 if %errorlevel% neq 0 goto error2
 
@@ -64,11 +66,11 @@ echo .
 echo Version %AppVersionStr%%DevPostfix% is ready for deploy!
 echo .
 
-cd ..\..\..\..\Telegram
+cd ..\..\..\..\..\Telegram
 goto eof
 
 :error2
-cd ..\..
+cd ..\..\..
 :error1
 cd ..\..\Telegram
 echo ERROR occured!
diff --git a/Telegram/Resources/lang.strings b/Telegram/Resources/lang.strings
index 6a064f23f..377de19c8 100644
--- a/Telegram/Resources/lang.strings
+++ b/Telegram/Resources/lang.strings
@@ -301,13 +301,14 @@ Copyright (c) 2014 John Preston, https://desktop.telegram.org
 
 "lng_connection_type" = "Connection type:";
 "lng_connection_auto_connecting" = "Default (connecting..)";
-"lng_connection_auto" = "Default ({type} used)";
-"lng_connection_http_proxy" = "HTTP with proxy";
-"lng_connection_tcp_proxy" = "TCP with proxy";
+"lng_connection_auto" = "Default ({transport} used)";
+"lng_connection_proxy_connecting" = "Connecting through proxy..";
+"lng_connection_proxy" = "{transport} with proxy";
 "lng_connection_header" = "Connection type";
 "lng_connection_auto_rb" = "Auto (TCP if available or HTTP)";
 "lng_connection_http_proxy_rb" = "HTTP with custom http-proxy";
 "lng_connection_tcp_proxy_rb" = "TCP with custom socks5-proxy";
+"lng_connection_try_ipv6" = "Try connecting through IPv6";
 "lng_connection_host_ph" = "Hostname";
 "lng_connection_port_ph" = "Port";
 "lng_connection_user_ph" = "Username";
diff --git a/Telegram/SourceFiles/boxes/connectionbox.cpp b/Telegram/SourceFiles/boxes/connectionbox.cpp
index 76a9c130b..07e2f8845 100644
--- a/Telegram/SourceFiles/boxes/connectionbox.cpp
+++ b/Telegram/SourceFiles/boxes/connectionbox.cpp
@@ -33,7 +33,8 @@ ConnectionBox::ConnectionBox() :
 	_passwordInput(this, st::inpConnectionPassword, lang(lng_connection_password_ph), cConnectionProxy().password),
 	_autoRadio(this, qsl("conn_type"), dbictAuto, lang(lng_connection_auto_rb), (cConnectionType() == dbictAuto)),
 	_httpProxyRadio(this, qsl("conn_type"), dbictHttpProxy, lang(lng_connection_http_proxy_rb), (cConnectionType() == dbictHttpProxy)),
-	_tcpProxyRadio(this, qsl("conn_type"), dbictTcpProxy, lang(lng_connection_tcp_proxy_rb), (cConnectionType() == dbictTcpProxy)) {
+	_tcpProxyRadio(this, qsl("conn_type"), dbictTcpProxy, lang(lng_connection_tcp_proxy_rb), (cConnectionType() == dbictTcpProxy)),
+	_tryIPv6(this, lang(lng_connection_try_ipv6), cTryIPv6()) {
 
 	connect(&_saveButton, SIGNAL(clicked()), this, SLOT(onSave()));
 	connect(&_cancelButton, SIGNAL(clicked()), this, SLOT(onClose()));
@@ -51,6 +52,7 @@ void ConnectionBox::hideAll() {
 	_autoRadio.hide();
 	_httpProxyRadio.hide();
 	_tcpProxyRadio.hide();
+	_tryIPv6.hide();
 
 	_hostInput.hide();
 	_portInput.hide();
@@ -65,8 +67,9 @@ void ConnectionBox::showAll() {
 	_autoRadio.show();
 	_httpProxyRadio.show();
 	_tcpProxyRadio.show();
+	_tryIPv6.show();
 
-	int32 h = st::boxTitleHeight + st::connectionSkip + _autoRadio.height() + st::connectionSkip + _httpProxyRadio.height() + st::connectionSkip + _tcpProxyRadio.height() + st::connectionSkip;
+	int32 h = st::boxTitleHeight + st::connectionSkip + _autoRadio.height() + st::connectionSkip + _httpProxyRadio.height() + st::connectionSkip + _tcpProxyRadio.height() + st::connectionSkip + st::lineWidth + st::connectionSkip + _tryIPv6.height() + st::connectionSkip;
 	if (_httpProxyRadio.checked() || _tcpProxyRadio.checked()) {
 		h += 2 * st::boxPadding.top() + 2 * _hostInput.height();
 		_hostInput.show();
@@ -99,6 +102,9 @@ void ConnectionBox::paintEvent(QPaintEvent *e) {
 
 	paintTitle(p, lang(lng_connection_header), true);
 
+	// paint separator
+	p.fillRect(st::boxPadding.left(), _tryIPv6.y() - st::connectionSkip - st::lineWidth, width() - st::boxPadding.left() - st::boxPadding.right(), st::lineWidth, st::scrollDef.shColor->b);
+
 	// paint shadow
 	p.fillRect(0, height() - st::btnSelectCancel.height - st::scrollDef.bottomsh, width(), st::scrollDef.bottomsh, st::scrollDef.shColor->b);
 
@@ -128,10 +134,11 @@ void ConnectionBox::resizeEvent(QResizeEvent *e) {
 		_passwordInput.move(width() - st::boxPadding.right() - _passwordInput.width(), _userInput.y());
 	}
 
-	int32 buttony = (_tcpProxyRadio.checked() ? (_userInput.y() + _userInput.height()) : (_tcpProxyRadio.y() + _tcpProxyRadio.height())) + st::connectionSkip;
+	int32 tryipv6y = (_tcpProxyRadio.checked() ? (_userInput.y() + _userInput.height()) : (_tcpProxyRadio.y() + _tcpProxyRadio.height())) + st::connectionSkip + st::lineWidth + st::connectionSkip;
+	_tryIPv6.move(st::boxPadding.left(), tryipv6y);
 
-	_saveButton.move(width() - _saveButton.width(), buttony);
-	_cancelButton.move(0, buttony);
+	_saveButton.move(width() - _saveButton.width(), _tryIPv6.y() + _tryIPv6.height() + st::connectionSkip);
+	_cancelButton.move(0, _saveButton.y());
 }
 
 void ConnectionBox::onChange() {
@@ -172,8 +179,16 @@ void ConnectionBox::onSave() {
 		QNetworkProxyFactory::setUseSystemConfiguration(false);
 		QNetworkProxyFactory::setUseSystemConfiguration(true);
 	}
-	Local::writeSettings();
-	MTP::restart();
-	reinitImageLinkManager();
-	emit closed();
+	if (cPlatform() == dbipWindows && cTryIPv6() != _tryIPv6.checked()) {
+		cSetTryIPv6(_tryIPv6.checked());
+		Local::writeSettings();
+		cSetRestarting(true);
+		cSetRestartingToSettings(true);
+		App::quit();
+	} else {
+		Local::writeSettings();
+		MTP::restart();
+		reinitImageLinkManager();
+		emit closed();
+	}
 }
diff --git a/Telegram/SourceFiles/boxes/connectionbox.h b/Telegram/SourceFiles/boxes/connectionbox.h
index 1550ace95..0f5168620 100644
--- a/Telegram/SourceFiles/boxes/connectionbox.h
+++ b/Telegram/SourceFiles/boxes/connectionbox.h
@@ -47,4 +47,5 @@ private:
 	PortInput _portInput;
 	FlatInput _userInput, _passwordInput;
 	FlatRadiobutton _autoRadio, _httpProxyRadio, _tcpProxyRadio;
+	FlatCheckbox _tryIPv6;
 };
diff --git a/Telegram/SourceFiles/config.h b/Telegram/SourceFiles/config.h
index 767eba9eb..e93ad0206 100644
--- a/Telegram/SourceFiles/config.h
+++ b/Telegram/SourceFiles/config.h
@@ -17,9 +17,9 @@ Copyright (c) 2014 John Preston, https://desktop.telegram.org
 */
 #pragma once
 
-static const int32 AppVersion = 8032;
-static const wchar_t *AppVersionStr = L"0.8.32";
-static const bool DevChannel = false;
+static const int32 AppVersion = 8033;
+static const wchar_t *AppVersionStr = L"0.8.33";
+static const bool DevChannel = true;
 
 static const wchar_t *AppNameOld = L"Telegram Win (Unofficial)";
 static const wchar_t *AppName = L"Telegram Desktop";
diff --git a/Telegram/SourceFiles/dropdown.cpp b/Telegram/SourceFiles/dropdown.cpp
index cf7dbc30b..9be6f8c1a 100644
--- a/Telegram/SourceFiles/dropdown.cpp
+++ b/Telegram/SourceFiles/dropdown.cpp
@@ -2857,13 +2857,13 @@ void MentionsDropdown::recount(bool toDown) {
 	int32 h = (_rows.isEmpty() ? (_hrows.isEmpty() ? _crows.size() : _hrows.size()) : _rows.size()) * st::mentionHeight, oldst = _scroll.scrollTop(), st = oldst;
 	
 	if (_inner.height() != h) {
-		st += h - _inner.height();
+//		st += h - _inner.height();
 		_inner.resize(width(), h);
 	}
 	if (h > _boundings.height()) h = _boundings.height();
 	if (h > 4.5 * st::mentionHeight) h = 4.5 * st::mentionHeight;
 	if (height() != h) {
-		st += _scroll.height() - h;
+//		st += _scroll.height() - h;
 		setGeometry(0, _boundings.height() - h, width(), h);
 		_scroll.resize(width(), h);
 	} else if (y() != _boundings.height() - h) {
diff --git a/Telegram/SourceFiles/historywidget.cpp b/Telegram/SourceFiles/historywidget.cpp
index 5a09d0955..480c84563 100644
--- a/Telegram/SourceFiles/historywidget.cpp
+++ b/Telegram/SourceFiles/historywidget.cpp
@@ -1670,7 +1670,7 @@ bool BotKeyboard::updateMarkup(HistoryItem *to) {
 
 		const ReplyMarkup::Commands &commands(markup.commands);
 		if (!commands.isEmpty()) {
-			int32 i = 0, l = qMin(commands.size(), 32);
+			int32 i = 0, l = qMin(commands.size(), 512);
 			_btns.reserve(l);
 			for (; i != l; ++i) {
 				const QList<QString> &row(commands.at(i));
diff --git a/Telegram/SourceFiles/localstorage.cpp b/Telegram/SourceFiles/localstorage.cpp
index 9745126ba..60bac4642 100644
--- a/Telegram/SourceFiles/localstorage.cpp
+++ b/Telegram/SourceFiles/localstorage.cpp
@@ -736,6 +736,14 @@ namespace {
 			};
 		} break;
 
+		case dbiTryIPv6: {
+			qint32 v;
+			stream >> v;
+			if (!_checkStreamStatus(stream)) return false;
+
+			cSetTryIPv6(v == 1);
+		} break;
+
 		case dbiSeenTrayTooltip: {
 			qint32 v;
 			stream >> v;
@@ -1789,7 +1797,7 @@ namespace Local {
 			cSetDcOptions(dcOpts);
 		}
 
-		quint32 size = 10 * (sizeof(quint32) + sizeof(qint32));
+		quint32 size = 11 * (sizeof(quint32) + sizeof(qint32));
 		for (mtpDcOptions::const_iterator i = dcOpts.cbegin(), e = dcOpts.cend(); i != e; ++i) {
 			size += sizeof(quint32) + sizeof(quint32) + sizeof(quint32);
 			size += sizeof(quint32) + _stringSize(QString::fromUtf8(i->ip.data(), i->ip.size()));
@@ -1827,6 +1835,7 @@ namespace Local {
 			const ConnectionProxy &proxy(cConnectionProxy());
 			data.stream << proxy.host << qint32(proxy.port) << proxy.user << proxy.password;
 		}
+		data.stream << quint32(dbiTryIPv6) << qint32(cTryIPv6());
 
 		TWindowPos pos(cWindowPos());
 		data.stream << quint32(dbiWindowPosition) << qint32(pos.x) << qint32(pos.y) << qint32(pos.w) << qint32(pos.h) << qint32(pos.moncrc) << qint32(pos.maximized);
diff --git a/Telegram/SourceFiles/mtproto/mtpConnection.cpp b/Telegram/SourceFiles/mtproto/mtpConnection.cpp
index 7b85e6732..413c04dc0 100644
--- a/Telegram/SourceFiles/mtproto/mtpConnection.cpp
+++ b/Telegram/SourceFiles/mtproto/mtpConnection.cpp
@@ -606,7 +606,7 @@ void MTPabstractTcpConnection::socketRead() {
 }
 
 MTPautoConnection::MTPautoConnection(QThread *thread) : status(WaitingBoth),
-tcpNonce(MTP::nonce<MTPint128>()), httpNonce(MTP::nonce<MTPint128>()), _tcpTimeout(MTPMinReceiveDelay) {
+tcpNonce(MTP::nonce<MTPint128>()), httpNonce(MTP::nonce<MTPint128>()), _tcpTimeout(MTPMinReceiveDelay), _flags(0) {
 	moveToThread(thread);
 
 	manager.moveToThread(thread);
@@ -615,6 +615,7 @@ tcpNonce(MTP::nonce<MTPint128>()), httpNonce(MTP::nonce<MTPint128>()), _tcpTimeo
 	httpStartTimer.moveToThread(thread);
 	httpStartTimer.setSingleShot(true);
 	connect(&httpStartTimer, SIGNAL(timeout()), this, SLOT(onHttpStart()));
+
 	tcpTimeoutTimer.moveToThread(thread);
 	tcpTimeoutTimer.setSingleShot(true);
 	connect(&tcpTimeoutTimer, SIGNAL(timeout()), this, SLOT(onTcpTimeoutTimer()));
@@ -628,7 +629,7 @@ tcpNonce(MTP::nonce<MTPint128>()), httpNonce(MTP::nonce<MTPint128>()), _tcpTimeo
 
 void MTPautoConnection::onHttpStart() {
 	if (status == HttpReady) {
-		DEBUG_LOG(("Connection Info: Http-transport chosen by timer"));
+		DEBUG_LOG(("Connection Info: HTTP/%1-transport chosen by timer").arg((_flags & MTPDdcOption_flag_ipv6) ? "IPv6" : "IPv4"));
 		status = UsingHttp;
 		sock.disconnectFromHost();
 		emit connected();
@@ -639,7 +640,7 @@ void MTPautoConnection::onSocketConnected() {
 	if (status == HttpReady || status == WaitingBoth || status == WaitingTcp) {
 		mtpBuffer buffer(_preparePQFake(tcpNonce));
 
-		DEBUG_LOG(("Connection Info: sending fake req_pq through tcp transport"));
+		DEBUG_LOG(("Connection Info: sending fake req_pq through TCP/%1 transport").arg((_flags & MTPDdcOption_flag_ipv6) ? "IPv6" : "IPv4"));
 
 		if (_tcpTimeout < 0) _tcpTimeout = -_tcpTimeout;
 		tcpTimeoutTimer.start(_tcpTimeout);
@@ -677,7 +678,7 @@ void MTPautoConnection::onSocketDisconnected() {
 	} else if (status == WaitingTcp || status == UsingTcp) {
 		emit disconnected();
 	} else if (status == HttpReady) {
-		DEBUG_LOG(("Connection Info: Http-transport chosen by socket disconnect"));
+		DEBUG_LOG(("Connection Info: HTTP/%1-transport chosen by socket disconnect").arg((_flags & MTPDdcOption_flag_ipv6) ? "IPv6" : "IPv4"));
 		status = UsingHttp;
 		emit connected();
 	}
@@ -750,19 +751,20 @@ void MTPautoConnection::connectToServer(const QString &addr, int32 port, int32 f
 
 	_addr = addr;
 	_port = port;
+	_flags = flags;
 
 	connect(&sock, SIGNAL(readyRead()), this, SLOT(socketRead()));
 	sock.connectToHost(QHostAddress(_addr), _port);
 
 	mtpBuffer buffer(_preparePQFake(httpNonce));
 
-	DEBUG_LOG(("Connection Info: sending fake req_pq through http transport"));
+	DEBUG_LOG(("Connection Info: sending fake req_pq through HTTP/%1 transport").arg((_flags & MTPDdcOption_flag_ipv6) ? "IPv6" : "IPv4"));
 
 	httpSend(buffer);
 }
 
-bool MTPautoConnection::isConnected() {
-	return status != FinishedWork && !address.isEmpty();
+bool MTPautoConnection::isConnected() const {
+	return (status == UsingTcp) || (status == UsingHttp);
 }
 
 void MTPautoConnection::requestFinished(QNetworkReply *reply) {
@@ -792,13 +794,14 @@ void MTPautoConnection::requestFinished(QNetworkReply *reply) {
 							status = HttpReady;
 							httpStartTimer.start(MTPTcpConnectionWaitTimeout);
 						} else {
-							DEBUG_LOG(("Connection Info: Http-transport chosen by pq-response, awaited"));
+							DEBUG_LOG(("Connection Info: HTTP/%1-transport chosen by pq-response, awaited").arg((_flags & MTPDdcOption_flag_ipv6) ? "IPv6" : "IPv4"));
 							status = UsingHttp;
 							sock.disconnectFromHost();
 							emit connected();
 						}
 					}
 				} catch (Exception &e) {
+					DEBUG_LOG(("Connection Error: exception in parsing HTTP fake pq-responce, %1").arg(e.what()));
 					if (status == WaitingBoth) {
 						status = WaitingTcp;
 					} else {
@@ -834,7 +837,7 @@ void MTPautoConnection::socketPacket(mtpPrime *packet, uint32 size) {
 			status = WaitingHttp;
 			sock.disconnectFromHost();
 		} else if (status == HttpReady) {
-			DEBUG_LOG(("Connection Info: Http-transport chosen by bad tcp response, ready"));
+			DEBUG_LOG(("Connection Info: HTTP/%1-transport chosen by bad tcp response, ready").arg((_flags & MTPDdcOption_flag_ipv6) ? "IPv6" : "IPv4"));
 			status = UsingHttp;
 			sock.disconnectFromHost();
 			emit connected();
@@ -853,16 +856,17 @@ void MTPautoConnection::socketPacket(mtpPrime *packet, uint32 size) {
 			MTPResPQ res_pq = _readPQFakeReply(data);
 			const MTPDresPQ &res_pq_data(res_pq.c_resPQ());
 			if (res_pq_data.vnonce == tcpNonce) {
-				DEBUG_LOG(("Connection Info: Tcp-transport chosen by pq-response"));
+				DEBUG_LOG(("Connection Info: TCP/%1-transport chosen by pq-response").arg((_flags & MTPDdcOption_flag_ipv6) ? "IPv6" : "IPv4"));
 				status = UsingTcp;
 				emit connected();
 			}
 		} catch (Exception &e) {
+			DEBUG_LOG(("Connection Error: exception in parsing TCP fake pq-responce, %1").arg(e.what()));
 			if (status == WaitingBoth) {
 				status = WaitingHttp;
 				sock.disconnectFromHost();
 			} else if (status == HttpReady) {
-				DEBUG_LOG(("Connection Info: Http-transport chosen by bad tcp response, awaited"));
+				DEBUG_LOG(("Connection Info: HTTP/%1-transport chosen by bad tcp response, awaited").arg((_flags & MTPDdcOption_flag_ipv6) ? "IPv6" : "IPv4"));
 				status = UsingHttp;
 				sock.disconnectFromHost();
 				emit connected();
@@ -902,7 +906,7 @@ void MTPautoConnection::socketError(QAbstractSocket::SocketError e) {
 	if (status == WaitingBoth) {
 		status = WaitingHttp;
 	} else if (status == HttpReady) {
-		DEBUG_LOG(("Connection Info: Http-transport chosen by tcp error, ready"));
+		DEBUG_LOG(("Connection Info: HTTP/%1-transport chosen by tcp error, ready").arg((_flags & MTPDdcOption_flag_ipv6) ? "IPv6" : "IPv4"));
 		status = UsingHttp;
 		emit connected();
 	} else if (status == WaitingTcp || status == UsingTcp) {
@@ -912,13 +916,59 @@ void MTPautoConnection::socketError(QAbstractSocket::SocketError e) {
 	}
 }
 
-MTPtcpConnection::MTPtcpConnection(QThread *thread) {
+MTPtcpConnection::MTPtcpConnection(QThread *thread) : status(WaitingTcp),
+tcpNonce(MTP::nonce<MTPint128>()), _tcpTimeout(MTPMinReceiveDelay), _flags(0) {
 	moveToThread(thread);
+
+	tcpTimeoutTimer.moveToThread(thread);
+	tcpTimeoutTimer.setSingleShot(true);
+	connect(&tcpTimeoutTimer, SIGNAL(timeout()), this, SLOT(onTcpTimeoutTimer()));
+
 	sock.moveToThread(thread);
 	App::setProxySettings(sock);
 	connect(&sock, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(socketError(QAbstractSocket::SocketError)));
-	connect(&sock, SIGNAL(connected()), this, SIGNAL(connected()));
-	connect(&sock, SIGNAL(disconnected()), this, SIGNAL(disconnected()));
+	connect(&sock, SIGNAL(connected()), this, SLOT(onSocketConnected()));
+	connect(&sock, SIGNAL(disconnected()), this, SLOT(onSocketDisconnected()));
+}
+
+void MTPtcpConnection::onSocketConnected() {
+	if (status == WaitingTcp) {
+		mtpBuffer buffer(_preparePQFake(tcpNonce));
+
+		DEBUG_LOG(("Connection Info: sending fake req_pq through TCP/%1 transport").arg((_flags & MTPDdcOption_flag_ipv6) ? "IPv6" : "IPv4"));
+
+		if (_tcpTimeout < 0) _tcpTimeout = -_tcpTimeout;
+		tcpTimeoutTimer.start(_tcpTimeout);
+
+		sendData(buffer);
+	}
+}
+
+void MTPtcpConnection::onTcpTimeoutTimer() {
+	if (status == WaitingTcp) {
+		if (_tcpTimeout < MTPMaxReceiveDelay) _tcpTimeout *= 2;
+		_tcpTimeout = -_tcpTimeout;
+
+		QAbstractSocket::SocketState state = sock.state();
+		if (state == QAbstractSocket::ConnectedState || state == QAbstractSocket::ConnectingState || state == QAbstractSocket::HostLookupState) {
+			sock.disconnectFromHost();
+		} else if (state != QAbstractSocket::ClosingState) {
+			sock.connectToHost(QHostAddress(_addr), _port);
+		}
+	}
+}
+
+void MTPtcpConnection::onSocketDisconnected() {
+	if (_tcpTimeout < 0) {
+		_tcpTimeout = -_tcpTimeout;
+		if (status == WaitingTcp) {
+			sock.connectToHost(QHostAddress(_addr), _port);
+			return;
+		}
+	}
+	if (status == WaitingTcp || status == UsingTcp) {
+		emit disconnected();
+	}
 }
 
 void MTPtcpConnection::sendData(mtpBuffer &buffer) {
@@ -945,23 +995,43 @@ void MTPtcpConnection::disconnectFromServer() {
 }
 
 void MTPtcpConnection::connectToServer(const QString &addr, int32 port, int32 flags) {
+	_addr = addr;
+	_port = port;
+	_flags = flags;
+
 	connect(&sock, SIGNAL(readyRead()), this, SLOT(socketRead()));
-	sock.connectToHost(QHostAddress(addr), port);
+	sock.connectToHost(QHostAddress(_addr), _port);
 }
 
 void MTPtcpConnection::socketPacket(mtpPrime *packet, uint32 size) {
+	if (status == FinishedWork) return;
+
 	mtpBuffer data = _handleTcpResponse(packet, size);
 	if (data.size() == 1) {
 		bool mayBeBadKey = (data[0] == -404) && _sentEncrypted;
 		emit error(mayBeBadKey);
+	} else if (status == UsingTcp) {
+		receivedQueue.push_back(data);
+		emit receivedData();
+	} else if (status == WaitingTcp) {
+		tcpTimeoutTimer.stop();
+		try {
+			MTPResPQ res_pq = _readPQFakeReply(data);
+			const MTPDresPQ &res_pq_data(res_pq.c_resPQ());
+			if (res_pq_data.vnonce == tcpNonce) {
+				DEBUG_LOG(("Connection Info: TCP/%1-transport chosen by pq-response").arg((_flags & MTPDdcOption_flag_ipv6) ? "IPv6" : "IPv4"));
+				status = UsingTcp;
+				emit connected();
+			}
+		} catch (Exception &e) {
+			DEBUG_LOG(("Connection Error: exception in parsing TCP fake pq-responce, %1").arg(e.what()));
+			emit error();
+		}
 	}
-
-	receivedQueue.push_back(data);
-	emit receivedData();
 }
 
-bool MTPtcpConnection::isConnected() {
-	return sock.state() == QAbstractSocket::ConnectedState;
+bool MTPtcpConnection::isConnected() const {
+	return (status == UsingTcp);
 }
 
 int32 MTPtcpConnection::debugState() const {
@@ -969,7 +1039,7 @@ int32 MTPtcpConnection::debugState() const {
 }
 
 QString MTPtcpConnection::transport() const {
-	return qsl("TCP");
+	return isConnected() ? qsl("TCP") : QString();
 }
 
 void MTPtcpConnection::socketError(QAbstractSocket::SocketError e) {
@@ -977,7 +1047,7 @@ void MTPtcpConnection::socketError(QAbstractSocket::SocketError e) {
 	emit error();
 }
 
-MTPhttpConnection::MTPhttpConnection(QThread *thread) {
+MTPhttpConnection::MTPhttpConnection(QThread *thread) : status(WaitingHttp), httpNonce(MTP::nonce<MTPint128>()), _flags(0) {
 	moveToThread(thread);
 	manager.moveToThread(thread);
 	App::setProxySettings(manager);
@@ -1018,14 +1088,23 @@ void MTPhttpConnection::connectToServer(const QString &addr, int32 p, int32 flag
 	address = QUrl(((flags & MTPDdcOption_flag_ipv6) ? qsl("http://[%1]:%2/api") : qsl("http://%1:%2/api")).arg(addr).arg(80));//not p - always 80 port for http transport
 	TCP_LOG(("HTTP Info: address is %1").arg(address.toDisplayString()));
 	connect(&manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(requestFinished(QNetworkReply*)));
-	emit connected();
+
+	_flags = flags;
+
+	mtpBuffer buffer(_preparePQFake(httpNonce));
+
+	DEBUG_LOG(("Connection Info: sending fake req_pq through HTTP/%1 transport").arg((flags & MTPDdcOption_flag_ipv6) ? "IPv6" : "IPv4"));
+
+	sendData(buffer);
 }
 
-bool MTPhttpConnection::isConnected() {
-	return !address.isEmpty();
+bool MTPhttpConnection::isConnected() const {
+	return (status == UsingHttp);
 }
 
 void MTPhttpConnection::requestFinished(QNetworkReply *reply) {
+	if (status == FinishedWork) return;
+
 	reply->deleteLater();
 	if (reply->error() == QNetworkReply::NoError) {
 		requests.remove(reply);
@@ -1034,8 +1113,23 @@ void MTPhttpConnection::requestFinished(QNetworkReply *reply) {
 		if (data.size() == 1) {
 			emit error();
 		} else if (!data.isEmpty()) {
-			receivedQueue.push_back(data);
-			emit receivedData();
+			if (status == UsingHttp) {
+				receivedQueue.push_back(data);
+				emit receivedData();
+			} else {
+				try {
+					MTPResPQ res_pq = _readPQFakeReply(data);
+					const MTPDresPQ &res_pq_data(res_pq.c_resPQ());
+					if (res_pq_data.vnonce == httpNonce) {
+						DEBUG_LOG(("Connection Info: HTTP/%1-transport connected by pq-response").arg((_flags & MTPDdcOption_flag_ipv6) ? "IPv6" : "IPv4"));
+						status = UsingHttp;
+						emit connected();
+					}
+				} catch (Exception &e) {
+					DEBUG_LOG(("Connection Error: exception in parsing HTTP fake pq-responce, %1").arg(e.what()));
+					emit error();
+				}
+			}
 		}
 	} else {
 		if (!requests.remove(reply)) {
@@ -1061,12 +1155,17 @@ int32 MTPhttpConnection::debugState() const {
 }
 
 QString MTPhttpConnection::transport() const {
-	return qsl("HTTP");
+	if (status == UsingHttp) {
+		return qsl("HTTP");
+	} else {
+		return QString();
+	}
 }
 
 void MTProtoConnectionPrivate::createConn(bool createIPv4, bool createIPv6) {
 	destroyConn();
 	if (createIPv4) {
+		QWriteLocker lock(&stateConnMutex);
 		if (cConnectionType() == dbictAuto) {
 			_conn4 = new MTPautoConnection(thread());
 		} else if (cConnectionType() == dbictTcpProxy) {
@@ -1078,6 +1177,7 @@ void MTProtoConnectionPrivate::createConn(bool createIPv4, bool createIPv6) {
 		connect(_conn4, SIGNAL(receivedSome()), this, SLOT(onReceivedSome()));
 	}
 	if (createIPv6) {
+		QWriteLocker lock(&stateConnMutex);
 		if (cConnectionType() == dbictAuto) {
 			_conn6 = new MTPautoConnection(thread());
 		} else if (cConnectionType() == dbictTcpProxy) {
@@ -1098,6 +1198,7 @@ void MTProtoConnectionPrivate::createConn(bool createIPv4, bool createIPv6) {
 
 void MTProtoConnectionPrivate::destroyConn(MTPabstractConnection **conn) {
 	if (conn) {
+		QWriteLocker lock(&stateConnMutex);
 		if (*conn) {
 			disconnect(*conn, SIGNAL(disconnected()), 0, 0);
 			disconnect(*conn, SIGNAL(receivedData()), 0, 0);
@@ -1200,7 +1301,7 @@ int32 MTProtoConnectionPrivate::getDC() const {
 }
 
 int32 MTProtoConnectionPrivate::getState() const {
-	QReadLocker lock(&stateMutex);
+	QReadLocker lock(&stateConnMutex);
 	int32 result = _state;
 	if (_state < 0) {
 		if (retryTimer.isActive()) {
@@ -1214,18 +1315,21 @@ int32 MTProtoConnectionPrivate::getState() const {
 }
 
 QString MTProtoConnectionPrivate::transport() const {
-	if ((!_conn4 && !_conn6) || _state < 0) {
+	QReadLocker lock(&stateConnMutex);
+	if ((!_conn4 && !_conn6) || (_conn4 && _conn6) || (_state < 0)) {
 		return QString();
 	}
-	return (_conn4 ? _conn4 : _conn6)->transport();
+	QString result = (_conn4 ? _conn4 : _conn6)->transport();
+	if (!result.isEmpty() && cTryIPv6()) result += (_conn4 ? "/IPv4" : "/IPv6");
+	return result;
 }
 
 bool MTProtoConnectionPrivate::setState(int32 state, int32 ifState) {
 	if (ifState != MTProtoConnection::UpdateAlways) {
-		QReadLocker lock(&stateMutex);
+		QReadLocker lock(&stateConnMutex);
 		if (_state != ifState) return false;
 	}
-	QWriteLocker lock(&stateMutex);
+	QWriteLocker lock(&stateConnMutex);
 	if (_state == state) return false;
 	_state = state;
 	if (state < 0) {
@@ -1784,15 +1888,15 @@ void MTProtoConnectionPrivate::socketStart(bool afterConfig) {
 			port6 = dcIndex6->port;
 		}
 	}
-	bool noIPv4 = (!port4 || ip4.empty()), noIPv6 = (!port6 || ip6.empty());
+	bool noIPv4 = (!port4 || ip4.empty()), noIPv6 = (!cTryIPv6() || !port6 || ip6.empty());
 	if (noIPv4 && noIPv6) {
 		if (afterConfig) {
 			if (noIPv4) LOG(("MTP Error: DC %1 options for IPv4 not found right after config load!").arg(dc));
-			if (noIPv6) LOG(("MTP Error: DC %1 options for IPv6 not found right after config load!").arg(dc));
+			if (cTryIPv6() && noIPv6) LOG(("MTP Error: DC %1 options for IPv6 not found right after config load!").arg(dc));
 			return restart();
 		}
 		if (noIPv4) DEBUG_LOG(("MTP Info: DC %1 options for IPv4 not found, waiting for config").arg(dc));
-		if (noIPv6) DEBUG_LOG(("MTP Info: DC %1 options for IPv6 not found, waiting for config").arg(dc));
+		if (cTryIPv6() && noIPv6) DEBUG_LOG(("MTP Info: DC %1 options for IPv6 not found, waiting for config").arg(dc));
 		connect(mtpConfigLoader(), SIGNAL(loaded()), this, SLOT(onConfigLoaded()));
 		mtpConfigLoader()->load();
 		return;
@@ -1800,7 +1904,7 @@ void MTProtoConnectionPrivate::socketStart(bool afterConfig) {
 
 	if (afterConfig && (_conn4 || _conn6)) return;
 
-	createConn(!noIPv4, false/*!noIPv6*/);
+	createConn(!noIPv4, !noIPv6);
 	retryTimer.stop();
 	_waitForConnectedTimer.stop();
 
@@ -3479,7 +3583,7 @@ void MTProtoConnectionPrivate::sendRequestNotSecure(const TRequest &request) {
 
 		onSentSome(buffer.size() * sizeof(mtpPrime));
 
-	} catch(Exception &e) {
+	} catch (Exception &e) {
 		return restart();
 	}
 }
@@ -3516,7 +3620,7 @@ bool MTProtoConnectionPrivate::readResponseNotSecure(TResponse &response) {
 		}
 		const mtpPrime *from(answer + 5), *end(from + len - 5);
 		response.read(from, end);
-	} catch(Exception &e) {
+	} catch (Exception &e) {
 		return false;
 	}
 	return true;
diff --git a/Telegram/SourceFiles/mtproto/mtpConnection.h b/Telegram/SourceFiles/mtproto/mtpConnection.h
index ac41f9f73..c5268589f 100644
--- a/Telegram/SourceFiles/mtproto/mtpConnection.h
+++ b/Telegram/SourceFiles/mtproto/mtpConnection.h
@@ -141,7 +141,7 @@ public:
 	virtual void sendData(mtpBuffer &buffer) = 0; // has size + 3, buffer[0] = len, buffer[1] = packetnum, buffer[last] = crc32
 	virtual void disconnectFromServer() = 0;
 	virtual void connectToServer(const QString &addr, int32 port, int32 flags) = 0;
-	virtual bool isConnected() = 0;
+	virtual bool isConnected() const = 0;
 	virtual bool usingHttpWait() {
 		return false;
 	}
@@ -209,7 +209,7 @@ public:
 	void sendData(mtpBuffer &buffer);
 	void disconnectFromServer();
 	void connectToServer(const QString &addr, int32 port, int32 flags);
-	bool isConnected();
+	bool isConnected() const;
 	bool usingHttpWait();
 	bool needHttpWait();
 
@@ -256,7 +256,7 @@ private:
 	Requests requests;
 
 	QString _addr;
-	int32 _port, _tcpTimeout;
+	int32 _port, _tcpTimeout, _flags;
 	QTimer tcpTimeoutTimer;
 
 };
@@ -271,7 +271,7 @@ public:
 	void sendData(mtpBuffer &buffer);
 	void disconnectFromServer();
 	void connectToServer(const QString &addr, int32 port, int32 flags);
-	bool isConnected();
+	bool isConnected() const;
 
 	int32 debugState() const;
 
@@ -281,10 +281,29 @@ public slots:
 
 	void socketError(QAbstractSocket::SocketError e);
 
+	void onSocketConnected();
+	void onSocketDisconnected();
+
+	void onTcpTimeoutTimer();
+
 protected:
 
 	void socketPacket(mtpPrime *packet, uint32 packetSize);
 
+private:
+
+	enum Status {
+		WaitingTcp = 0,
+		UsingTcp,
+		FinishedWork
+	};
+	Status status;
+	MTPint128 tcpNonce;
+
+	QString _addr;
+	int32 _port, _tcpTimeout, _flags;
+	QTimer tcpTimeoutTimer;
+
 };
 
 class MTPhttpConnection : public MTPabstractConnection {
@@ -297,7 +316,7 @@ public:
 	void sendData(mtpBuffer &buffer);
 	void disconnectFromServer();
 	void connectToServer(const QString &addr, int32 port, int32 flags);
-	bool isConnected();
+	bool isConnected() const;
 	bool usingHttpWait();
 	bool needHttpWait();
 
@@ -311,6 +330,15 @@ public slots:
 
 private:
 
+	enum Status {
+		WaitingHttp = 0,
+		UsingHttp,
+		FinishedWork
+	};
+	Status status;
+	MTPint128 httpNonce;
+	int32 _flags;
+
 	QNetworkAccessManager manager;
 	QUrl address;
 
@@ -414,7 +442,7 @@ private:
 	void clearMessages();
 
 	bool setState(int32 state, int32 ifState = MTProtoConnection::UpdateAlways);
-	mutable QReadWriteLock stateMutex;
+	mutable QReadWriteLock stateConnMutex;
 	int32 _state;
 
 	bool _needSessionReset;
diff --git a/Telegram/SourceFiles/settings.cpp b/Telegram/SourceFiles/settings.cpp
index 51dfa9759..f9bc2de62 100644
--- a/Telegram/SourceFiles/settings.cpp
+++ b/Telegram/SourceFiles/settings.cpp
@@ -52,6 +52,11 @@ bool gSupportTray = true;
 DBIWorkMode gWorkMode = dbiwmWindowAndTray;
 DBIConnectionType gConnectionType = dbictAuto;
 ConnectionProxy gConnectionProxy;
+#ifdef Q_OS_WIN
+bool gTryIPv6 = false;
+#else
+bool gTryIPv6 = true;
+#endif
 bool gSeenTrayTooltip = false;
 bool gRestartingUpdate = false, gRestarting = false, gRestartingToSettings = false, gWriteProtected = false;
 int32 gLastUpdateCheck = 0;
diff --git a/Telegram/SourceFiles/settings.h b/Telegram/SourceFiles/settings.h
index ed0a588e0..e6fc81913 100644
--- a/Telegram/SourceFiles/settings.h
+++ b/Telegram/SourceFiles/settings.h
@@ -109,6 +109,7 @@ DeclareSetting(TWindowPos, WindowPos);
 DeclareSetting(bool, SupportTray);
 DeclareSetting(DBIWorkMode, WorkMode);
 DeclareSetting(DBIConnectionType, ConnectionType);
+DeclareSetting(bool, TryIPv6);
 DeclareSetting(DBIDefaultAttach, DefaultAttach);
 DeclareSetting(ConnectionProxy, ConnectionProxy);
 DeclareSetting(bool, SeenTrayTooltip);
diff --git a/Telegram/SourceFiles/settingswidget.cpp b/Telegram/SourceFiles/settingswidget.cpp
index 17e3c62bb..3089325d7 100644
--- a/Telegram/SourceFiles/settingswidget.cpp
+++ b/Telegram/SourceFiles/settingswidget.cpp
@@ -182,7 +182,7 @@ SettingsInner::SettingsInner(SettingsWidget *parent) : QWidget(parent),
 	_passwordEdit(this, lang(lng_cloud_password_set)),
 	_passwordTurnOff(this, lang(lng_passcode_turn_off)),
 	_hasPasswordRecovery(false),
-	_connectionType(this, lng_connection_auto(lt_type, QString())),
+	_connectionType(this, lang(lng_connection_auto_connecting)),
 	_connectionTypeText(lang(lng_connection_type) + ' '),
 	_connectionTypeWidth(st::linkFont->m.width(_connectionTypeText)),
 	_showSessions(this, lang(lng_settings_show_sessions)),
@@ -820,18 +820,19 @@ void SettingsInner::updateOnlineDisplay() {
 }
 
 void SettingsInner::updateConnectionType() {
+	QString connection;
 	switch (cConnectionType()) {
 	case dbictAuto: {
 		QString transport = MTP::dctransport();
-		if (transport.isEmpty()) {
-			_connectionType.setText(lang(lng_connection_auto_connecting));
-		} else {
-			_connectionType.setText(lng_connection_auto(lt_type, transport));
-		}
+		connection = transport.isEmpty() ? lang(lng_connection_auto_connecting) : lng_connection_auto(lt_transport, transport);
+	} break;
+	case dbictHttpProxy:
+	case dbictTcpProxy: {
+		QString transport = MTP::dctransport();
+		connection = transport.isEmpty() ? lang(lng_connection_proxy_connecting) : lng_connection_proxy(lt_transport, transport);
 	} break;
-	case dbictHttpProxy: _connectionType.setText(lang(lng_connection_http_proxy)); break;
-	case dbictTcpProxy: _connectionType.setText(lang(lng_connection_tcp_proxy)); break;
 	}
+	_connectionType.setText(connection);
 }
 
 void SettingsInner::passcodeChanged() {
diff --git a/Telegram/SourceFiles/types.h b/Telegram/SourceFiles/types.h
index 1fed10b7b..e7f64078d 100644
--- a/Telegram/SourceFiles/types.h
+++ b/Telegram/SourceFiles/types.h
@@ -247,7 +247,7 @@ enum DataBlockId {
 	dbiLastUpdateCheck     = 0x0d,
 	dbiWindowPosition      = 0x0e,
 	dbiConnectionType      = 0x0f,
-// 16 reserved
+// 0x10 reserved
 	dbiDefaultAttach       = 0x11,
 	dbiCatsAndDogs         = 0x12,
 	dbiReplaceEmojis       = 0x13,
@@ -258,7 +258,7 @@ enum DataBlockId {
 	dbiRecentEmojisOld     = 0x18,
 	dbiLoggedPhoneNumber   = 0x19,
 	dbiMutedPeers          = 0x1a,
-// 27 reserved
+// 0x1b reserved
 	dbiNotifyView          = 0x1c,
 	dbiSendToMenu          = 0x1d,
 	dbiCompressPastedImage = 0x1e,
@@ -271,6 +271,7 @@ enum DataBlockId {
 	dbiEmojiVariants       = 0x25,
 	dbiRecentStickers      = 0x26,
 	dbiDcOption            = 0x27,
+	dbiTryIPv6             = 0x28,
 
 	dbiEncryptedWithSalt   = 333,
 	dbiEncrypted           = 444,
diff --git a/Telegram/Telegram.plist b/Telegram/Telegram.plist
index 5b11e71ea..5ee755bee 100644
--- a/Telegram/Telegram.plist
+++ b/Telegram/Telegram.plist
@@ -11,7 +11,7 @@
 	<key>CFBundlePackageType</key>
 	<string>APPL</string>
 	<key>CFBundleShortVersionString</key>
-	<string>0.8.32</string>
+	<string>0.8.33</string>
         <key>LSMinimumSystemVersion</key>
         <string>$(MACOSX_DEPLOYMENT_TARGET)</string>
 	<key>CFBundleSignature</key>
diff --git a/Telegram/Telegram.rc b/Telegram/Telegram.rc
index 94fdb429a469515c3d324e5344f695d1bbb2b008..ce540572a90fbd187d52b57c1dcd46d951588ab1 100644
GIT binary patch
delta 53
zcmZ3Yy+nIM5ig_h<YHc9M&r%Pc_%Wl8Z+oI7);(Mpu0IsfQJ#z6`#CBP-yWIK^6d+
CybgW<

delta 53
zcmZ3Yy+nIM5ig_B<YHc9Mx)Kkc_%Wl8ZqcG7);(Mpu0IsfQJ#z6`#CBP-yWIK^6d+
CHx7CL

diff --git a/Telegram/Telegram.xcodeproj/project.pbxproj b/Telegram/Telegram.xcodeproj/project.pbxproj
index fcd8e9bbb..426f04acc 100644
--- a/Telegram/Telegram.xcodeproj/project.pbxproj
+++ b/Telegram/Telegram.xcodeproj/project.pbxproj
@@ -1701,7 +1701,7 @@
 			buildSettings = {
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
 				COPY_PHASE_STRIP = NO;
-				CURRENT_PROJECT_VERSION = 0.8.32;
+				CURRENT_PROJECT_VERSION = 0.8.33;
 				DEBUG_INFORMATION_FORMAT = dwarf;
 				GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
 				GCC_OPTIMIZATION_LEVEL = 0;
@@ -1719,7 +1719,7 @@
 			buildSettings = {
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
 				COPY_PHASE_STRIP = YES;
-				CURRENT_PROJECT_VERSION = 0.8.32;
+				CURRENT_PROJECT_VERSION = 0.8.33;
 				GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
 				GCC_OPTIMIZATION_LEVEL = fast;
 				GCC_PREFIX_HEADER = ./SourceFiles/stdafx.h;
@@ -1745,10 +1745,10 @@
 				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
 				CODE_SIGN_IDENTITY = "";
 				COPY_PHASE_STRIP = NO;
-				CURRENT_PROJECT_VERSION = 0.8.32;
+				CURRENT_PROJECT_VERSION = 0.8.33;
 				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
 				DYLIB_COMPATIBILITY_VERSION = 0.8;
-				DYLIB_CURRENT_VERSION = 0.8.32;
+				DYLIB_CURRENT_VERSION = 0.8.33;
 				ENABLE_STRICT_OBJC_MSGSEND = YES;
 				FRAMEWORK_SEARCH_PATHS = "";
 				GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
@@ -1888,10 +1888,10 @@
 				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
 				CODE_SIGN_IDENTITY = "";
 				COPY_PHASE_STRIP = NO;
-				CURRENT_PROJECT_VERSION = 0.8.32;
+				CURRENT_PROJECT_VERSION = 0.8.33;
 				DEBUG_INFORMATION_FORMAT = dwarf;
 				DYLIB_COMPATIBILITY_VERSION = 0.8;
-				DYLIB_CURRENT_VERSION = 0.8.32;
+				DYLIB_CURRENT_VERSION = 0.8.33;
 				ENABLE_STRICT_OBJC_MSGSEND = YES;
 				FRAMEWORK_SEARCH_PATHS = "";
 				GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
diff --git a/Telegram/Version.sh b/Telegram/Version.sh
index fea715868..07cd3ba38 100755
--- a/Telegram/Version.sh
+++ b/Telegram/Version.sh
@@ -1,2 +1,2 @@
-echo 8032 0.8.32 0
-# AppVersion AppVersionStr DevChannel
+echo 0.8 8033 0.8.33 1
+# AppVersionStrMajor AppVersion AppVersionStr DevChannel