index.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. <!DOCTYPE html>
  2. <!--
  3. Copyright © 2016-2017 Threema GmbH (https://threema.ch/).
  4. This file is part of Threema Web.
  5. Threema Web is free software: you can redistribute it and/or modify it
  6. under the terms of the GNU Affero General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or (at
  8. your option) any later version.
  9. This program is distributed in the hope that it will be useful, but
  10. WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
  12. General Public License for more details.
  13. You should have received a copy of the GNU Affero General Public License
  14. along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
  15. -->
  16. <html>
  17. <head>
  18. <meta charset="utf-8">
  19. <meta name="viewport" content="width=device-width, initial-scale=1">
  20. <meta name="referrer" content="no-referrer">
  21. <meta name="robots" content="noindex" />
  22. <title>Threema Web Diagnostics</title>
  23. <!-- Favicon -->
  24. <link rel="icon" href="../img/favicon.ico?v=[[VERSION]]" type="image/x-icon"/>
  25. <link rel="shortcut icon" href="../img/favicon.ico?v=[[VERSION]]" type="image/x-icon"/>
  26. <!-- Fonts -->
  27. <link rel="stylesheet" href="../fonts/roboto.css?v=[[VERSION]]" type="text/css">
  28. <link rel="stylesheet" href="../fonts/material.css?v=[[VERSION]]" type="text/css">
  29. <!-- Styling -->
  30. <style>
  31. body {
  32. padding: 16px;
  33. font-family: 'Roboto';
  34. }
  35. #background-image {
  36. min-height: 100%;
  37. min-width: 1024px;
  38. width: 100%;
  39. height: auto;
  40. position: fixed;
  41. top: 0;
  42. left: 0;
  43. z-index: -1;
  44. -moz-user-select: none;
  45. -webkit-user-select: none;
  46. user-select: none;
  47. }
  48. #wrapper {
  49. background-color: white;
  50. margin: 0 auto;
  51. padding: 16px 32px 32px;
  52. min-width: 400px;
  53. max-width: 500px;
  54. text-align: center;
  55. }
  56. #logo {
  57. width: 300px;
  58. color: white;
  59. margin: 0px auto 16px;
  60. }
  61. h1 { margin-top: 0; font-weight: 500; }
  62. h2 { font-weight: 300; }
  63. p { font-weight: 300; }
  64. .status span {
  65. display: inline-block;
  66. line-height: 36px;
  67. vertical-align: top;
  68. }
  69. .status-yes i { color: #4caf50; }
  70. .status-no i { color: #f44336; }
  71. .status-unknown i { color: #0277BD; }
  72. .hidden { display: none; }
  73. .small { font-size: 0.8em; font-weight: 300; }
  74. footer {
  75. color: white;
  76. font-weight: 300;
  77. text-align: center;
  78. padding-top: 16px;
  79. }
  80. </style>
  81. <!-- JS -->
  82. <script src="../node_modules/webrtc-adapter/out/adapter.js?v=[[VERSION]]"></script>
  83. <script src="../node_modules/sdp/sdp.js?v=[[VERSION]]"></script>
  84. <script>
  85. function switchTo(type, newStatus) {
  86. var unknown = document.querySelector('#status-' + type + ' .status-unknown');
  87. if (unknown) {
  88. unknown.classList.add('hidden');
  89. }
  90. var test = document.querySelector('#status-' + type + ' .status-test')
  91. if (test) {
  92. test.classList.add('hidden');
  93. }
  94. document.querySelector('#status-' + type + ' .status-no').classList.add('hidden');
  95. document.querySelector('#status-' + type + ' .status-yes').classList.add('hidden');
  96. document.querySelector('#status-' + type + ' .status-' + newStatus).classList.remove('hidden');
  97. }
  98. function doChecks() {
  99. // Check for JS
  100. switchTo('js', 'yes');
  101. // Check for RTCPeerConnection
  102. if (window.RTCPeerConnection) {
  103. switchTo('pc', 'yes');
  104. } else {
  105. switchTo('pc', 'no');
  106. }
  107. // Check for RTCDataChannel
  108. if (window.RTCPeerConnection && (new RTCPeerConnection()).createDataChannel) {
  109. switchTo('dc', 'yes');
  110. switchTo('turn', 'test');
  111. } else {
  112. switchTo('dc', 'no');
  113. switchTo('turn', 'no');
  114. }
  115. // Check for LocalStorage
  116. function localStorageAvailable(){
  117. var test = 'test';
  118. try {
  119. localStorage.setItem(test, test);
  120. localStorage.removeItem(test);
  121. return true;
  122. } catch(e) {
  123. return false;
  124. }
  125. }
  126. if (localStorageAvailable()) {
  127. switchTo('ls', 'yes');
  128. } else {
  129. switchTo('ls', 'no');
  130. }
  131. // Check for TURN connectivity
  132. var timeout = null;
  133. function turnSuccess() {
  134. switchTo('turn', 'yes');
  135. clearTimeout(timeout);
  136. }
  137. function turnFail() {
  138. switchTo('turn', 'no');
  139. document.querySelector('#status-turn .results').classList.add('hidden');
  140. document.querySelector('#status-turn .status-no .small').classList.remove('hidden');
  141. }
  142. var button = document.querySelector('#status-turn button');
  143. button.addEventListener('click', function(e) {
  144. button.outerHTML = '<img src="loading.gif" alt="Loading...">';
  145. timeout = setTimeout(function() {
  146. turnFail();
  147. }, 10000);
  148. var noop = function() {};
  149. var pc = new RTCPeerConnection({iceServers: [{
  150. urls: [
  151. 'turn:turn.threema.ch:443?transport=udp',
  152. 'turn:turn.threema.ch:443?transport=tcp',
  153. 'turns:turn.threema.ch:443',
  154. ],
  155. username: 'threema-angular-test',
  156. credential: 'VaoVnhxKGt2wD20F9bTOgiew6yHQmj4P7y7SE4lrahAjTQC0dpnG32FR4fnrlpKa',
  157. }]});
  158. document.querySelector('#status-turn .results').classList.remove('hidden');
  159. var resultData = document.querySelector('#status-turn .result-data');
  160. pc.createDataChannel('test');
  161. console.info('Creating offer...');
  162. pc.createOffer(function(sdp) { pc.setLocalDescription(sdp, noop, noop) }, noop);
  163. pc.onicecandidate = function(ice) {
  164. if (ice.candidate === null) {
  165. console.info('Done collecting candidates.');
  166. } else if (ice.candidate.candidate) {
  167. var candidate = SDPUtils.parseCandidate(ice.candidate.candidate);
  168. console.debug(candidate);
  169. if (candidate.type === 'relay') {
  170. var info = '[' + candidate.type + '] ' + candidate.ip + ':' + candidate.port + ' (' + candidate.protocol + ')';
  171. if (candidate.relatedAddress.indexOf(':') !== -1) {
  172. info += ' (ipv6)';
  173. } else if (candidate.relatedAddress.indexOf('.') !== -1) {
  174. info += ' (ipv4)';
  175. } else {
  176. info += ' (?)';
  177. }
  178. resultData.innerHTML += info + '<br>';
  179. turnSuccess();
  180. }
  181. } else {
  182. console.warn('Invalid candidate:', ice.candidate.candidate);
  183. }
  184. }
  185. });
  186. }
  187. if (document.readyState != 'loading') {
  188. doChecks();
  189. } else {
  190. document.addEventListener('DOMContentLoaded', doChecks);
  191. }
  192. </script>
  193. </head>
  194. <body>
  195. <img src="../img/bg1.jpg?v=[[VERSION]]" id="background-image" draggable="false" alt="" />
  196. <header>
  197. <div id="title">
  198. <div id="logo">
  199. <img src="../img/logo.svg?v=[[VERSION]]" alt="Logo">
  200. </div>
  201. </div>
  202. </header>
  203. <div id="wrapper">
  204. <h1>Threema Web Diagnostics</h1>
  205. <h2>Is JavaScript enabled?</h2>
  206. <div id="status-js">
  207. <div class="status status-no">
  208. <i class="material-icons md-36">error</i> <span class="text">No</span>
  209. </div>
  210. <div class="status status-yes hidden">
  211. <i class="material-icons md-36">check_circle</i> <span class="text">Yes</span>
  212. </div>
  213. </div>
  214. <h2>Is WebRTC available?</h2>
  215. <div id="status-pc">
  216. <div class="status status-unknown">
  217. <i class="material-icons md-36">help</i> <span class="text">Unknown</span>
  218. </div>
  219. <div class="status status-no hidden">
  220. <i class="material-icons md-36">error</i> <span class="text">No</span>
  221. <p class="small">RTCPeerConnection is a part of WebRTC.<br>Threema Web cannot work without it.</p>
  222. </div>
  223. <div class="status status-yes hidden">
  224. <i class="material-icons md-36">check_circle</i> <span class="text">Yes</span>
  225. </div>
  226. </div>
  227. <h2>Are WebRTC DataChannels available?</h2>
  228. <div id="status-dc">
  229. <div class="status status-unknown">
  230. <i class="material-icons md-36">help</i> <span class="text">Unknown</span>
  231. </div>
  232. <div class="status status-no hidden">
  233. <i class="material-icons md-36">error</i> <span class="text">No</span>
  234. <p class="small">RTCDataChannel is a part of WebRTC.<br>Threema Web cannot work without it.</p>
  235. </div>
  236. <div class="status status-yes hidden">
  237. <i class="material-icons md-36">check_circle</i> <span class="text">Yes</span>
  238. </div>
  239. </div>
  240. <h2>Is LocalStorage available?</h2>
  241. <div id="status-ls">
  242. <div class="status status-unknown">
  243. <i class="material-icons md-36">help</i> <span class="text">Unknown</span>
  244. </div>
  245. <div class="status status-no hidden">
  246. <i class="material-icons md-36">error</i> <span class="text">No</span>
  247. <p class="small">Without LocalStorage, persistent sessions and settings<br>cannot be stored in the browser.<br>
  248. See the <a href="https://threema.ch/faq/web_browser_settings">FAQ</a> for information on how to fix this.</p>
  249. </div>
  250. <div class="status status-yes hidden">
  251. <i class="material-icons md-36">check_circle</i> <span class="text">Yes</span>
  252. </div>
  253. </div>
  254. <h2>Does TURN work?</h2>
  255. <div id="status-turn">
  256. <div class="status status-unknown">
  257. <i class="material-icons md-36">help</i> <span class="text">Unknown</span>
  258. </div>
  259. <div class="status status-no hidden">
  260. <i class="material-icons md-36">error</i> <span class="text">No</span>
  261. <p class="small hidden">It looks like TURN traffic is being blocked by your firewall.<br>
  262. Without TURN, connections can only be established if your computer<br>
  263. and your phone are in the same network.</p>
  264. </div>
  265. <div class="status status-yes hidden">
  266. <i class="material-icons md-36">check_circle</i> <span class="text">Yes</span>
  267. </div>
  268. <div class="status status-test hidden">
  269. <button>Click to test</button>
  270. </div>
  271. <div class="results hidden">
  272. <p>Results:</p>
  273. <p class="result-data"></p>
  274. </div>
  275. </div>
  276. </div>
  277. <footer>
  278. &copy; 2017 Threema GmbH
  279. </footer>
  280. </body>
  281. </html>