commit 5c80572264500666250a05b671c0e0811661aa71 Merge: 7c303f1 1464901 Author: Nathan Freitas nathan@freitas.net Date: Mon Feb 2 13:42:56 2015 -0500
Merge branch 'master' of https://github.com/SuppSandroB/Ony into ony-dev
Conflicts: AndroidManifest.xml jni/Android.mk res/menu/main.xml src/org/torproject/android/OrbotMainActivity.java src/org/torproject/android/service/TorService.java src/org/torproject/android/ui/TipsAndTricks.java src/org/torproject/android/vpn/OrbotVpnService.java src/org/torproject/android/wizard/ConfigureTransProxy.java src/org/torproject/android/wizard/Permissions.java
.project | 16 + AndroidManifest.KITKAT_AND_LOWER.xml | 98 +- AndroidManifest.LOLLIPOP.xml | 96 +- AndroidManifest.xml | 12 +- bcdroid.manifest | 6 +- external/Makefile | 6 +- external/appcompat/.classpath | 4 +- external/badvpn_dns/Android.mk | 75 + external/badvpn_dns/CMakeLists.txt | 408 ++ external/badvpn_dns/COPYING | 24 + external/badvpn_dns/ChangeLog | 216 + external/badvpn_dns/INSTALL | 76 + external/badvpn_dns/INSTALL-WINDOWS | 72 + external/badvpn_dns/arpprobe/BArpProbe.c | 359 ++ external/badvpn_dns/arpprobe/BArpProbe.h | 80 + external/badvpn_dns/arpprobe/CMakeLists.txt | 1 + external/badvpn_dns/badvpn.7 | 324 ++ external/badvpn_dns/base/BLog.c | 96 + external/badvpn_dns/base/BLog.h | 402 ++ external/badvpn_dns/base/BLog_syslog.c | 150 + external/badvpn_dns/base/BLog_syslog.h | 42 + external/badvpn_dns/base/BMutex.h | 101 + external/badvpn_dns/base/BPending.c | 205 + external/badvpn_dns/base/BPending.h | 250 + external/badvpn_dns/base/BPending_list.h | 4 + external/badvpn_dns/base/CMakeLists.txt | 13 + external/badvpn_dns/base/DebugObject.c | 39 + external/badvpn_dns/base/DebugObject.h | 147 + external/badvpn_dns/blog_channels.txt | 145 + external/badvpn_dns/blog_generator/blog.php | 121 + .../badvpn_dns/blog_generator/blog_functions.php | 35 + external/badvpn_dns/bproto/BProto.h | 85 + .../badvpn_dns/bproto_generator/ProtoParser.lime | 99 + .../badvpn_dns/bproto_generator/ProtoParser.php | 560 +++ external/badvpn_dns/bproto_generator/bproto.php | 115 + .../bproto_generator/bproto_functions.php | 777 ++++ external/badvpn_dns/client/CMakeLists.txt | 30 + external/badvpn_dns/client/DPReceive.c | 324 ++ external/badvpn_dns/client/DPReceive.h | 98 + external/badvpn_dns/client/DPRelay.c | 307 ++ external/badvpn_dns/client/DPRelay.h | 89 + external/badvpn_dns/client/DataProto.c | 566 +++ external/badvpn_dns/client/DataProto.h | 237 + .../badvpn_dns/client/DataProtoKeepaliveSource.c | 72 + .../badvpn_dns/client/DataProtoKeepaliveSource.h | 73 + external/badvpn_dns/client/DatagramPeerIO.c | 425 ++ external/badvpn_dns/client/DatagramPeerIO.h | 271 ++ .../badvpn_dns/client/FragmentProtoAssembler.c | 469 ++ .../badvpn_dns/client/FragmentProtoAssembler.h | 134 + .../client/FragmentProtoAssembler_tree.h | 9 + .../badvpn_dns/client/FragmentProtoDisassembler.c | 229 + .../badvpn_dns/client/FragmentProtoDisassembler.h | 109 + external/badvpn_dns/client/FrameDecider.c | 795 ++++ external/badvpn_dns/client/FrameDecider.h | 196 + .../badvpn_dns/client/FrameDecider_groups_tree.h | 9 + .../badvpn_dns/client/FrameDecider_macs_tree.h | 9 + .../client/FrameDecider_multicast_tree.h | 9 + external/badvpn_dns/client/PasswordListener.c | 374 ++ external/badvpn_dns/client/PasswordListener.h | 156 + external/badvpn_dns/client/PeerChat.c | 433 ++ external/badvpn_dns/client/PeerChat.h | 123 + external/badvpn_dns/client/SCOutmsgEncoder.c | 104 + external/badvpn_dns/client/SCOutmsgEncoder.h | 76 + external/badvpn_dns/client/SPProtoDecoder.c | 398 ++ external/badvpn_dns/client/SPProtoDecoder.h | 171 + external/badvpn_dns/client/SPProtoEncoder.c | 436 ++ external/badvpn_dns/client/SPProtoEncoder.h | 172 + external/badvpn_dns/client/SimpleStreamBuffer.c | 144 + external/badvpn_dns/client/SimpleStreamBuffer.h | 52 + external/badvpn_dns/client/SinglePacketSource.c | 85 + external/badvpn_dns/client/SinglePacketSource.h | 73 + external/badvpn_dns/client/StreamPeerIO.c | 712 +++ external/badvpn_dns/client/StreamPeerIO.h | 222 + external/badvpn_dns/client/badvpn-client.8 | 316 ++ external/badvpn_dns/client/client.c | 2997 ++++++++++++ external/badvpn_dns/client/client.h | 193 + .../badvpn_dns/cmake/modules/COPYING-CMAKE-SCRIPTS | 22 + external/badvpn_dns/cmake/modules/FindGLIB2.cmake | 52 + .../cmake/modules/FindLibraryWithDebug.cmake | 113 + external/badvpn_dns/cmake/modules/FindNSPR.cmake | 57 + external/badvpn_dns/cmake/modules/FindNSS.cmake | 57 + .../badvpn_dns/cmake/modules/FindOpenSSL.cmake | 72 + external/badvpn_dns/compile-tun2sock.sh | 112 + external/badvpn_dns/compile-udpgw.sh | 84 + external/badvpn_dns/dhcpclient/BDHCPClient.c | 340 ++ external/badvpn_dns/dhcpclient/BDHCPClient.h | 87 + external/badvpn_dns/dhcpclient/BDHCPClientCore.c | 860 ++++ external/badvpn_dns/dhcpclient/BDHCPClientCore.h | 114 + external/badvpn_dns/dhcpclient/CMakeLists.txt | 10 + external/badvpn_dns/dhcpclient/DHCPIpUdpDecoder.c | 137 + external/badvpn_dns/dhcpclient/DHCPIpUdpDecoder.h | 49 + external/badvpn_dns/dhcpclient/DHCPIpUdpEncoder.c | 119 + external/badvpn_dns/dhcpclient/DHCPIpUdpEncoder.h | 49 + external/badvpn_dns/dostest/CMakeLists.txt | 10 + external/badvpn_dns/dostest/StreamBuffer.c | 147 + external/badvpn_dns/dostest/StreamBuffer.h | 70 + external/badvpn_dns/dostest/dostest-attacker.c | 512 ++ external/badvpn_dns/dostest/dostest-server.c | 567 +++ external/badvpn_dns/examples/CMakeLists.txt | 97 + external/badvpn_dns/examples/FastPacketSource.h | 79 + external/badvpn_dns/examples/RandomPacketSink.h | 116 + external/badvpn_dns/examples/TimerPacketSink.h | 97 + external/badvpn_dns/examples/arpprobe_test.c | 131 + external/badvpn_dns/examples/bavl_test.c | 129 + external/badvpn_dns/examples/bencryption_bench.c | 146 + external/badvpn_dns/examples/bprocess_example.c | 140 + external/badvpn_dns/examples/brandom2_test.c | 65 + external/badvpn_dns/examples/btimer_example.c | 84 + external/badvpn_dns/examples/cavl_test.c | 285 ++ external/badvpn_dns/examples/cavl_test_tree.h | 23 + external/badvpn_dns/examples/dhcpclient_test.c | 159 + external/badvpn_dns/examples/emscripten_test.c | 71 + external/badvpn_dns/examples/fairqueue_test.c | 145 + external/badvpn_dns/examples/fairqueue_test2.c | 93 + external/badvpn_dns/examples/indexedlist_test.c | 95 + external/badvpn_dns/examples/ipaddr6_test.c | 169 + external/badvpn_dns/examples/ncd_parser_test.c | 294 ++ external/badvpn_dns/examples/ncd_tokenizer_test.c | 149 + .../badvpn_dns/examples/ncd_value_parser_test.c | 78 + .../badvpn_dns/examples/ncdinterfacemonitor_test.c | 150 + external/badvpn_dns/examples/ncdudevmanager_test.c | 161 + external/badvpn_dns/examples/ncdudevmonitor_test.c | 152 + external/badvpn_dns/examples/ncdval_test.c | 380 ++ external/badvpn_dns/examples/ncdvalcons_test.c | 111 + external/badvpn_dns/examples/parse_number_test.c | 130 + external/badvpn_dns/examples/predicate_test.c | 116 + external/badvpn_dns/examples/savl_test.c | 135 + external/badvpn_dns/examples/savl_test_tree.h | 9 + external/badvpn_dns/examples/stdin_input.c | 138 + external/badvpn_dns/examples/substring_test.c | 204 + external/badvpn_dns/fix_flex.php | 10 + external/badvpn_dns/flooder/CMakeLists.txt | 7 + external/badvpn_dns/flooder/flooder.c | 671 +++ external/badvpn_dns/flooder/flooder.h | 37 + external/badvpn_dns/flow/BufferWriter.c | 112 + external/badvpn_dns/flow/BufferWriter.h | 107 + external/badvpn_dns/flow/CMakeLists.txt | 31 + external/badvpn_dns/flow/LineBuffer.c | 140 + external/badvpn_dns/flow/LineBuffer.h | 54 + external/badvpn_dns/flow/PacketBuffer.c | 131 + external/badvpn_dns/flow/PacketBuffer.h | 77 + external/badvpn_dns/flow/PacketCopier.c | 136 + external/badvpn_dns/flow/PacketCopier.h | 90 + external/badvpn_dns/flow/PacketPassConnector.c | 125 + external/badvpn_dns/flow/PacketPassConnector.h | 102 + external/badvpn_dns/flow/PacketPassFairQueue.c | 405 ++ external/badvpn_dns/flow/PacketPassFairQueue.h | 204 + .../badvpn_dns/flow/PacketPassFairQueue_tree.h | 7 + external/badvpn_dns/flow/PacketPassFifoQueue.c | 241 + external/badvpn_dns/flow/PacketPassFifoQueue.h | 76 + external/badvpn_dns/flow/PacketPassInterface.c | 68 + external/badvpn_dns/flow/PacketPassInterface.h | 236 + external/badvpn_dns/flow/PacketPassNotifier.c | 103 + external/badvpn_dns/flow/PacketPassNotifier.h | 99 + external/badvpn_dns/flow/PacketPassPriorityQueue.c | 283 ++ external/badvpn_dns/flow/PacketPassPriorityQueue.h | 192 + .../badvpn_dns/flow/PacketPassPriorityQueue_tree.h | 7 + external/badvpn_dns/flow/PacketProtoDecoder.c | 182 + external/badvpn_dns/flow/PacketProtoDecoder.h | 96 + external/badvpn_dns/flow/PacketProtoEncoder.c | 101 + external/badvpn_dns/flow/PacketProtoEncoder.h | 80 + external/badvpn_dns/flow/PacketProtoFlow.c | 82 + external/badvpn_dns/flow/PacketProtoFlow.h | 83 + external/badvpn_dns/flow/PacketRecvBlocker.c | 99 + external/badvpn_dns/flow/PacketRecvBlocker.h | 90 + external/badvpn_dns/flow/PacketRecvConnector.c | 123 + external/badvpn_dns/flow/PacketRecvConnector.h | 102 + external/badvpn_dns/flow/PacketRecvInterface.c | 56 + external/badvpn_dns/flow/PacketRecvInterface.h | 170 + external/badvpn_dns/flow/PacketRouter.c | 129 + external/badvpn_dns/flow/PacketRouter.h | 126 + external/badvpn_dns/flow/PacketStreamSender.c | 111 + external/badvpn_dns/flow/PacketStreamSender.h | 83 + external/badvpn_dns/flow/RouteBuffer.c | 256 + external/badvpn_dns/flow/RouteBuffer.h | 139 + external/badvpn_dns/flow/SinglePacketBuffer.c | 87 + external/badvpn_dns/flow/SinglePacketBuffer.h | 75 + external/badvpn_dns/flow/SinglePacketSender.c | 72 + external/badvpn_dns/flow/SinglePacketSender.h | 82 + external/badvpn_dns/flow/SingleStreamReceiver.c | 82 + external/badvpn_dns/flow/SingleStreamReceiver.h | 53 + external/badvpn_dns/flow/SingleStreamSender.c | 82 + external/badvpn_dns/flow/SingleStreamSender.h | 53 + external/badvpn_dns/flow/StreamPacketSender.c | 90 + external/badvpn_dns/flow/StreamPacketSender.h | 77 + external/badvpn_dns/flow/StreamPassConnector.c | 120 + external/badvpn_dns/flow/StreamPassConnector.h | 98 + external/badvpn_dns/flow/StreamPassInterface.c | 56 + external/badvpn_dns/flow/StreamPassInterface.h | 165 + external/badvpn_dns/flow/StreamRecvConnector.c | 120 + external/badvpn_dns/flow/StreamRecvConnector.h | 98 + external/badvpn_dns/flow/StreamRecvInterface.c | 56 + external/badvpn_dns/flow/StreamRecvInterface.h | 165 + external/badvpn_dns/flowextra/CMakeLists.txt | 5 + external/badvpn_dns/flowextra/KeepaliveIO.c | 112 + external/badvpn_dns/flowextra/KeepaliveIO.h | 88 + .../flowextra/PacketPassInactivityMonitor.c | 131 + .../flowextra/PacketPassInactivityMonitor.h | 124 + external/badvpn_dns/generate_files | 51 + .../badvpn_dns/generated/NCDConfigParser_parse.c | 1890 ++++++++ .../badvpn_dns/generated/NCDConfigParser_parse.h | 22 + .../badvpn_dns/generated/NCDConfigParser_parse.out | 950 ++++ .../badvpn_dns/generated/NCDConfigParser_parse.y | 718 +++ external/badvpn_dns/generated/NCDValParser_parse.c | 1119 +++++ external/badvpn_dns/generated/NCDValParser_parse.h | 7 + .../badvpn_dns/generated/NCDValParser_parse.out | 217 + external/badvpn_dns/generated/NCDValParser_parse.y | 202 + external/badvpn_dns/generated/bison_BPredicate.c | 2168 +++++++++ external/badvpn_dns/generated/bison_BPredicate.h | 114 + .../badvpn_dns/generated/blog_channel_BArpProbe.h | 4 + .../generated/blog_channel_BConnection.h | 4 + .../generated/blog_channel_BDHCPClient.h | 4 + .../generated/blog_channel_BDHCPClientCore.h | 4 + .../badvpn_dns/generated/blog_channel_BDatagram.h | 4 + .../generated/blog_channel_BEncryption.h | 4 + .../generated/blog_channel_BInputProcess.h | 4 + .../generated/blog_channel_BLockReactor.h | 4 + .../badvpn_dns/generated/blog_channel_BNetwork.h | 4 + .../badvpn_dns/generated/blog_channel_BPredicate.h | 4 + .../badvpn_dns/generated/blog_channel_BProcess.h | 4 + .../badvpn_dns/generated/blog_channel_BReactor.h | 4 + .../generated/blog_channel_BSSLConnection.h | 4 + .../badvpn_dns/generated/blog_channel_BSignal.h | 4 + .../generated/blog_channel_BSocksClient.h | 4 + external/badvpn_dns/generated/blog_channel_BTap.h | 4 + .../generated/blog_channel_BThreadSignal.h | 4 + .../generated/blog_channel_BThreadWork.h | 4 + external/badvpn_dns/generated/blog_channel_BTime.h | 4 + .../generated/blog_channel_BUnixSignal.h | 4 + .../badvpn_dns/generated/blog_channel_DPReceive.h | 4 + .../badvpn_dns/generated/blog_channel_DPRelay.h | 4 + .../badvpn_dns/generated/blog_channel_DataProto.h | 4 + .../generated/blog_channel_DatagramPeerIO.h | 4 + .../blog_channel_FragmentProtoAssembler.h | 4 + .../generated/blog_channel_FrameDecider.h | 4 + .../badvpn_dns/generated/blog_channel_LineBuffer.h | 4 + .../badvpn_dns/generated/blog_channel_Listener.h | 4 + .../generated/blog_channel_NCDBuildProgram.h | 4 + .../generated/blog_channel_NCDConfigParser.h | 4 + .../generated/blog_channel_NCDConfigTokenizer.h | 4 + .../generated/blog_channel_NCDIfConfig.h | 4 + .../generated/blog_channel_NCDInterfaceMonitor.h | 4 + .../generated/blog_channel_NCDModuleIndex.h | 4 + .../generated/blog_channel_NCDModuleProcess.h | 4 + .../generated/blog_channel_NCDPlaceholderDb.h | 4 + .../badvpn_dns/generated/blog_channel_NCDRequest.h | 4 + .../generated/blog_channel_NCDRequestClient.h | 4 + .../generated/blog_channel_NCDRfkillMonitor.h | 4 + .../generated/blog_channel_NCDUdevCache.h | 4 + .../generated/blog_channel_NCDUdevManager.h | 4 + .../generated/blog_channel_NCDUdevMonitor.h | 4 + .../generated/blog_channel_NCDUdevMonitorParser.h | 4 + .../badvpn_dns/generated/blog_channel_NCDVal.h | 4 + .../generated/blog_channel_NCDValGenerator.h | 4 + .../generated/blog_channel_NCDValParser.h | 4 + .../generated/blog_channel_PRStreamSink.h | 4 + .../generated/blog_channel_PRStreamSource.h | 4 + .../generated/blog_channel_PacketProtoDecoder.h | 4 + .../generated/blog_channel_PasswordListener.h | 4 + .../badvpn_dns/generated/blog_channel_PeerChat.h | 4 + .../generated/blog_channel_SPProtoDecoder.h | 4 + .../generated/blog_channel_ServerConnection.h | 4 + .../generated/blog_channel_SocksUdpGwClient.h | 4 + .../generated/blog_channel_StreamPeerIO.h | 4 + .../generated/blog_channel_UdpGwClient.h | 4 + external/badvpn_dns/generated/blog_channel_addr.h | 4 + .../badvpn_dns/generated/blog_channel_client.h | 4 + .../generated/blog_channel_dostest_attacker.h | 4 + .../generated/blog_channel_dostest_server.h | 4 + .../badvpn_dns/generated/blog_channel_flooder.h | 4 + external/badvpn_dns/generated/blog_channel_lwip.h | 4 + external/badvpn_dns/generated/blog_channel_ncd.h | 4 + .../badvpn_dns/generated/blog_channel_ncd_alias.h | 4 + .../generated/blog_channel_ncd_arithmetic.h | 4 + .../badvpn_dns/generated/blog_channel_ncd_assert.h | 4 + .../generated/blog_channel_ncd_backtrack.h | 4 + .../generated/blog_channel_ncd_blocker.h | 4 + .../badvpn_dns/generated/blog_channel_ncd_buffer.h | 4 + .../badvpn_dns/generated/blog_channel_ncd_call2.h | 4 + .../badvpn_dns/generated/blog_channel_ncd_choose.h | 4 + .../badvpn_dns/generated/blog_channel_ncd_concat.h | 4 + .../badvpn_dns/generated/blog_channel_ncd_daemon.h | 4 + .../badvpn_dns/generated/blog_channel_ncd_depend.h | 4 + .../generated/blog_channel_ncd_depend_scope.h | 4 + .../generated/blog_channel_ncd_dynamic_depend.h | 4 + .../badvpn_dns/generated/blog_channel_ncd_exit.h | 4 + .../generated/blog_channel_ncd_explode.h | 4 + .../badvpn_dns/generated/blog_channel_ncd_file.h | 4 + .../generated/blog_channel_ncd_file_open.h | 4 + .../generated/blog_channel_ncd_foreach.h | 4 + .../generated/blog_channel_ncd_from_string.h | 4 + .../generated/blog_channel_ncd_getargs.h | 4 + .../badvpn_dns/generated/blog_channel_ncd_getenv.h | 4 + .../badvpn_dns/generated/blog_channel_ncd_if.h | 4 + .../generated/blog_channel_ncd_imperative.h | 4 + .../generated/blog_channel_ncd_implode.h | 4 + .../badvpn_dns/generated/blog_channel_ncd_index.h | 4 + .../badvpn_dns/generated/blog_channel_ncd_list.h | 4 + .../generated/blog_channel_ncd_load_module.h | 4 + .../badvpn_dns/generated/blog_channel_ncd_log.h | 4 + .../generated/blog_channel_ncd_log_msg.h | 4 + .../generated/blog_channel_ncd_logical.h | 4 + .../generated/blog_channel_ncd_multidepend.h | 4 + .../blog_channel_ncd_net_backend_badvpn.h | 4 + .../blog_channel_ncd_net_backend_rfkill.h | 4 + .../blog_channel_ncd_net_backend_waitdevice.h | 4 + .../blog_channel_ncd_net_backend_waitlink.h | 4 + .../blog_channel_ncd_net_backend_wpa_supplicant.h | 4 + .../generated/blog_channel_ncd_net_dns.h | 4 + .../generated/blog_channel_ncd_net_iptables.h | 4 + .../generated/blog_channel_ncd_net_ipv4_addr.h | 4 + .../blog_channel_ncd_net_ipv4_addr_in_network.h | 4 + .../blog_channel_ncd_net_ipv4_arp_probe.h | 4 + .../generated/blog_channel_ncd_net_ipv4_dhcp.h | 4 + .../generated/blog_channel_ncd_net_ipv4_route.h | 4 + .../generated/blog_channel_ncd_net_ipv6_addr.h | 4 + .../blog_channel_ncd_net_ipv6_addr_in_network.h | 4 + .../generated/blog_channel_ncd_net_ipv6_route.h | 4 + .../blog_channel_ncd_net_ipv6_wait_dynamic_addr.h | 4 + .../badvpn_dns/generated/blog_channel_ncd_net_up.h | 4 + .../blog_channel_ncd_net_watch_interfaces.h | 4 + .../generated/blog_channel_ncd_netmask.h | 4 + .../generated/blog_channel_ncd_ondemand.h | 4 + .../badvpn_dns/generated/blog_channel_ncd_parse.h | 4 + .../badvpn_dns/generated/blog_channel_ncd_print.h | 4 + .../generated/blog_channel_ncd_process_manager.h | 4 + .../badvpn_dns/generated/blog_channel_ncd_reboot.h | 4 + .../badvpn_dns/generated/blog_channel_ncd_ref.h | 4 + .../generated/blog_channel_ncd_regex_match.h | 4 + .../generated/blog_channel_ncd_request.h | 4 + .../badvpn_dns/generated/blog_channel_ncd_run.h | 4 + .../generated/blog_channel_ncd_runonce.h | 4 + .../badvpn_dns/generated/blog_channel_ncd_sleep.h | 4 + .../badvpn_dns/generated/blog_channel_ncd_socket.h | 4 + .../badvpn_dns/generated/blog_channel_ncd_spawn.h | 4 + .../badvpn_dns/generated/blog_channel_ncd_strcmp.h | 4 + .../badvpn_dns/generated/blog_channel_ncd_substr.h | 4 + .../generated/blog_channel_ncd_sys_evdev.h | 4 + .../blog_channel_ncd_sys_request_client.h | 4 + .../blog_channel_ncd_sys_request_server.h | 4 + .../generated/blog_channel_ncd_sys_start_process.h | 4 + .../blog_channel_ncd_sys_watch_directory.h | 4 + .../generated/blog_channel_ncd_sys_watch_input.h | 4 + .../generated/blog_channel_ncd_sys_watch_usb.h | 4 + .../badvpn_dns/generated/blog_channel_ncd_timer.h | 4 + .../generated/blog_channel_ncd_to_string.h | 4 + .../badvpn_dns/generated/blog_channel_ncd_try.h | 4 + .../badvpn_dns/generated/blog_channel_ncd_value.h | 4 + .../generated/blog_channel_ncd_valuemetic.h | 4 + .../badvpn_dns/generated/blog_channel_ncd_var.h | 4 + .../badvpn_dns/generated/blog_channel_nsskey.h | 4 + .../badvpn_dns/generated/blog_channel_server.h | 4 + .../badvpn_dns/generated/blog_channel_tun2socks.h | 4 + external/badvpn_dns/generated/blog_channel_udpgw.h | 4 + .../badvpn_dns/generated/blog_channels_defines.h | 146 + external/badvpn_dns/generated/blog_channels_list.h | 145 + external/badvpn_dns/generated/bproto_addr.h | 675 +++ external/badvpn_dns/generated/bproto_bproto_test.h | 1029 ++++ external/badvpn_dns/generated/bproto_msgproto.h | 2122 +++++++++ external/badvpn_dns/generated/flex_BPredicate.c | 2143 +++++++++ external/badvpn_dns/generated/flex_BPredicate.h | 350 ++ external/badvpn_dns/lemon/lemon.c | 4889 ++++++++++++++++++++ external/badvpn_dns/lemon/lempar.c | 842 ++++ external/badvpn_dns/lime/HOWTO | 70 + external/badvpn_dns/lime/flex_token_stream.php | 34 + external/badvpn_dns/lime/lemon.c | 4588 ++++++++++++++++++ external/badvpn_dns/lime/lime.bootstrap | 31 + external/badvpn_dns/lime/lime.php | 910 ++++ external/badvpn_dns/lime/lime_scan_tokens.l | 121 + external/badvpn_dns/lime/metagrammar | 58 + external/badvpn_dns/lime/parse_engine.php | 252 + external/badvpn_dns/lime/set.so.php | 29 + external/badvpn_dns/lwip/CHANGELOG | 3396 ++++++++++++++ external/badvpn_dns/lwip/CMakeLists.txt | 27 + external/badvpn_dns/lwip/COPYING | 33 + external/badvpn_dns/lwip/FILES | 4 + external/badvpn_dns/lwip/README | 89 + external/badvpn_dns/lwip/UPGRADING | 144 + external/badvpn_dns/lwip/custom/arch/cc.h | 96 + external/badvpn_dns/lwip/custom/arch/perf.h | 36 + external/badvpn_dns/lwip/custom/lwipopts.h | 70 + external/badvpn_dns/lwip/custom/sys.c | 37 + external/badvpn_dns/lwip/doc/FILES | 6 + external/badvpn_dns/lwip/doc/contrib.txt | 63 + external/badvpn_dns/lwip/doc/rawapi.txt | 511 ++ external/badvpn_dns/lwip/doc/savannah.txt | 135 + external/badvpn_dns/lwip/doc/snmp_agent.txt | 181 + external/badvpn_dns/lwip/doc/sys_arch.txt | 267 ++ external/badvpn_dns/lwip/lwip-base-version | 1 + external/badvpn_dns/lwip/src/FILES | 13 + external/badvpn_dns/lwip/src/api/api_lib.c | 788 ++++ external/badvpn_dns/lwip/src/api/api_msg.c | 1610 +++++++ external/badvpn_dns/lwip/src/api/err.c | 75 + external/badvpn_dns/lwip/src/api/netbuf.c | 245 + external/badvpn_dns/lwip/src/api/netdb.c | 353 ++ external/badvpn_dns/lwip/src/api/netifapi.c | 160 + external/badvpn_dns/lwip/src/api/sockets.c | 2555 ++++++++++ external/badvpn_dns/lwip/src/api/tcpip.c | 492 ++ external/badvpn_dns/lwip/src/core/def.c | 108 + external/badvpn_dns/lwip/src/core/dhcp.c | 1771 +++++++ external/badvpn_dns/lwip/src/core/dns.c | 988 ++++ external/badvpn_dns/lwip/src/core/inet_chksum.c | 545 +++ external/badvpn_dns/lwip/src/core/init.c | 345 ++ external/badvpn_dns/lwip/src/core/ipv4/autoip.c | 528 +++ external/badvpn_dns/lwip/src/core/ipv4/icmp.c | 338 ++ external/badvpn_dns/lwip/src/core/ipv4/igmp.c | 805 ++++ external/badvpn_dns/lwip/src/core/ipv4/ip4.c | 924 ++++ external/badvpn_dns/lwip/src/core/ipv4/ip4_addr.c | 312 ++ external/badvpn_dns/lwip/src/core/ipv4/ip_frag.c | 863 ++++ external/badvpn_dns/lwip/src/core/ipv6/README | 1 + external/badvpn_dns/lwip/src/core/ipv6/dhcp6.c | 50 + external/badvpn_dns/lwip/src/core/ipv6/ethip6.c | 193 + external/badvpn_dns/lwip/src/core/ipv6/icmp6.c | 337 ++ external/badvpn_dns/lwip/src/core/ipv6/inet6.c | 51 + external/badvpn_dns/lwip/src/core/ipv6/ip6.c | 1034 +++++ external/badvpn_dns/lwip/src/core/ipv6/ip6_addr.c | 251 + external/badvpn_dns/lwip/src/core/ipv6/ip6_frag.c | 697 +++ external/badvpn_dns/lwip/src/core/ipv6/mld6.c | 580 +++ external/badvpn_dns/lwip/src/core/ipv6/nd6.c | 1787 +++++++ external/badvpn_dns/lwip/src/core/mem.c | 659 +++ external/badvpn_dns/lwip/src/core/memp.c | 485 ++ external/badvpn_dns/lwip/src/core/netif.c | 918 ++++ external/badvpn_dns/lwip/src/core/pbuf.c | 1179 +++++ external/badvpn_dns/lwip/src/core/raw.c | 422 ++ external/badvpn_dns/lwip/src/core/snmp/asn1_dec.c | 657 +++ external/badvpn_dns/lwip/src/core/snmp/asn1_enc.c | 611 +++ external/badvpn_dns/lwip/src/core/snmp/mib2.c | 4146 +++++++++++++++++ .../badvpn_dns/lwip/src/core/snmp/mib_structs.c | 1174 +++++ external/badvpn_dns/lwip/src/core/snmp/msg_in.c | 1453 ++++++ external/badvpn_dns/lwip/src/core/snmp/msg_out.c | 678 +++ external/badvpn_dns/lwip/src/core/stats.c | 181 + external/badvpn_dns/lwip/src/core/sys.c | 68 + external/badvpn_dns/lwip/src/core/tcp.c | 1852 ++++++++ external/badvpn_dns/lwip/src/core/tcp_in.c | 1666 +++++++ external/badvpn_dns/lwip/src/core/tcp_out.c | 1499 ++++++ external/badvpn_dns/lwip/src/core/timers.c | 546 +++ external/badvpn_dns/lwip/src/core/udp.c | 1151 +++++ .../badvpn_dns/lwip/src/include/ipv4/lwip/autoip.h | 118 + .../badvpn_dns/lwip/src/include/ipv4/lwip/icmp.h | 125 + .../badvpn_dns/lwip/src/include/ipv4/lwip/igmp.h | 106 + .../badvpn_dns/lwip/src/include/ipv4/lwip/inet.h | 107 + .../badvpn_dns/lwip/src/include/ipv4/lwip/ip4.h | 146 + .../lwip/src/include/ipv4/lwip/ip4_addr.h | 244 + .../lwip/src/include/ipv4/lwip/ip_frag.h | 91 + .../badvpn_dns/lwip/src/include/ipv6/lwip/dhcp6.h | 58 + .../badvpn_dns/lwip/src/include/ipv6/lwip/ethip6.h | 68 + .../badvpn_dns/lwip/src/include/ipv6/lwip/icmp6.h | 152 + .../badvpn_dns/lwip/src/include/ipv6/lwip/inet6.h | 92 + .../badvpn_dns/lwip/src/include/ipv6/lwip/ip6.h | 197 + .../lwip/src/include/ipv6/lwip/ip6_addr.h | 286 ++ .../lwip/src/include/ipv6/lwip/ip6_frag.h | 102 + .../badvpn_dns/lwip/src/include/ipv6/lwip/mld6.h | 118 + .../badvpn_dns/lwip/src/include/ipv6/lwip/nd6.h | 369 ++ external/badvpn_dns/lwip/src/include/lwip/api.h | 338 ++ .../badvpn_dns/lwip/src/include/lwip/api_msg.h | 177 + external/badvpn_dns/lwip/src/include/lwip/arch.h | 217 + external/badvpn_dns/lwip/src/include/lwip/debug.h | 99 + external/badvpn_dns/lwip/src/include/lwip/def.h | 123 + external/badvpn_dns/lwip/src/include/lwip/dhcp.h | 242 + external/badvpn_dns/lwip/src/include/lwip/dns.h | 124 + external/badvpn_dns/lwip/src/include/lwip/err.h | 85 + .../badvpn_dns/lwip/src/include/lwip/inet_chksum.h | 112 + external/badvpn_dns/lwip/src/include/lwip/init.h | 72 + external/badvpn_dns/lwip/src/include/lwip/ip.h | 254 + .../badvpn_dns/lwip/src/include/lwip/ip_addr.h | 130 + external/badvpn_dns/lwip/src/include/lwip/mem.h | 123 + external/badvpn_dns/lwip/src/include/lwip/memp.h | 116 + .../badvpn_dns/lwip/src/include/lwip/memp_std.h | 135 + external/badvpn_dns/lwip/src/include/lwip/netbuf.h | 112 + external/badvpn_dns/lwip/src/include/lwip/netdb.h | 124 + external/badvpn_dns/lwip/src/include/lwip/netif.h | 393 ++ .../badvpn_dns/lwip/src/include/lwip/netifapi.h | 108 + external/badvpn_dns/lwip/src/include/lwip/opt.h | 2417 ++++++++++ external/badvpn_dns/lwip/src/include/lwip/pbuf.h | 185 + external/badvpn_dns/lwip/src/include/lwip/raw.h | 131 + external/badvpn_dns/lwip/src/include/lwip/sio.h | 141 + external/badvpn_dns/lwip/src/include/lwip/snmp.h | 367 ++ .../badvpn_dns/lwip/src/include/lwip/snmp_asn1.h | 101 + .../badvpn_dns/lwip/src/include/lwip/snmp_msg.h | 315 ++ .../lwip/src/include/lwip/snmp_structs.h | 268 ++ .../badvpn_dns/lwip/src/include/lwip/sockets.h | 411 ++ external/badvpn_dns/lwip/src/include/lwip/stats.h | 347 ++ external/badvpn_dns/lwip/src/include/lwip/sys.h | 336 ++ external/badvpn_dns/lwip/src/include/lwip/tcp.h | 400 ++ .../badvpn_dns/lwip/src/include/lwip/tcp_impl.h | 508 ++ external/badvpn_dns/lwip/src/include/lwip/tcpip.h | 179 + external/badvpn_dns/lwip/src/include/lwip/timers.h | 100 + external/badvpn_dns/lwip/src/include/lwip/udp.h | 215 + .../badvpn_dns/lwip/src/include/netif/etharp.h | 223 + .../badvpn_dns/lwip/src/include/netif/ppp_oe.h | 190 + .../badvpn_dns/lwip/src/include/netif/slipif.h | 81 + external/badvpn_dns/lwip/src/include/posix/netdb.h | 33 + .../badvpn_dns/lwip/src/include/posix/sys/socket.h | 33 + external/badvpn_dns/lwip/src/netif/FILES | 29 + external/badvpn_dns/lwip/src/netif/etharp.c | 1413 ++++++ external/badvpn_dns/lwip/src/netif/ethernetif.c | 322 ++ external/badvpn_dns/lwip/src/netif/ppp/auth.c | 1334 ++++++ external/badvpn_dns/lwip/src/netif/ppp/auth.h | 111 + external/badvpn_dns/lwip/src/netif/ppp/chap.c | 908 ++++ external/badvpn_dns/lwip/src/netif/ppp/chap.h | 150 + external/badvpn_dns/lwip/src/netif/ppp/chpms.c | 396 ++ external/badvpn_dns/lwip/src/netif/ppp/chpms.h | 64 + external/badvpn_dns/lwip/src/netif/ppp/fsm.c | 890 ++++ external/badvpn_dns/lwip/src/netif/ppp/fsm.h | 157 + external/badvpn_dns/lwip/src/netif/ppp/ipcp.c | 1411 ++++++ external/badvpn_dns/lwip/src/netif/ppp/ipcp.h | 106 + external/badvpn_dns/lwip/src/netif/ppp/lcp.c | 2066 +++++++++ external/badvpn_dns/lwip/src/netif/ppp/lcp.h | 151 + external/badvpn_dns/lwip/src/netif/ppp/magic.c | 80 + external/badvpn_dns/lwip/src/netif/ppp/magic.h | 63 + external/badvpn_dns/lwip/src/netif/ppp/md5.c | 320 ++ external/badvpn_dns/lwip/src/netif/ppp/md5.h | 55 + external/badvpn_dns/lwip/src/netif/ppp/pap.c | 628 +++ external/badvpn_dns/lwip/src/netif/ppp/pap.h | 118 + external/badvpn_dns/lwip/src/netif/ppp/ppp.c | 2052 ++++++++ external/badvpn_dns/lwip/src/netif/ppp/ppp.h | 201 + external/badvpn_dns/lwip/src/netif/ppp/ppp_impl.h | 363 ++ external/badvpn_dns/lwip/src/netif/ppp/ppp_oe.c | 1132 +++++ external/badvpn_dns/lwip/src/netif/ppp/pppdebug.h | 73 + external/badvpn_dns/lwip/src/netif/ppp/randm.c | 249 + external/badvpn_dns/lwip/src/netif/ppp/randm.h | 81 + external/badvpn_dns/lwip/src/netif/ppp/readme.txt | 21 + external/badvpn_dns/lwip/src/netif/ppp/vj.c | 652 +++ external/badvpn_dns/lwip/src/netif/ppp/vj.h | 156 + external/badvpn_dns/lwip/src/netif/slipif.c | 546 +++ external/badvpn_dns/lwip/test/unit/core/test_mem.c | 73 + external/badvpn_dns/lwip/test/unit/core/test_mem.h | 8 + .../badvpn_dns/lwip/test/unit/core/test_pbuf.c | 73 + .../badvpn_dns/lwip/test/unit/core/test_pbuf.h | 8 + .../badvpn_dns/lwip/test/unit/dhcp/test_dhcp.c | 916 ++++ .../badvpn_dns/lwip/test/unit/dhcp/test_dhcp.h | 8 + .../badvpn_dns/lwip/test/unit/etharp/test_etharp.c | 262 ++ .../badvpn_dns/lwip/test/unit/etharp/test_etharp.h | 8 + external/badvpn_dns/lwip/test/unit/lwip_check.h | 37 + .../badvpn_dns/lwip/test/unit/lwip_unittests.c | 49 + external/badvpn_dns/lwip/test/unit/lwipopts.h | 53 + .../badvpn_dns/lwip/test/unit/tcp/tcp_helper.c | 303 ++ .../badvpn_dns/lwip/test/unit/tcp/tcp_helper.h | 52 + external/badvpn_dns/lwip/test/unit/tcp/test_tcp.c | 671 +++ external/badvpn_dns/lwip/test/unit/tcp/test_tcp.h | 8 + .../badvpn_dns/lwip/test/unit/tcp/test_tcp_oos.c | 958 ++++ .../badvpn_dns/lwip/test/unit/tcp/test_tcp_oos.h | 8 + external/badvpn_dns/lwip/test/unit/udp/test_udp.c | 68 + external/badvpn_dns/lwip/test/unit/udp/test_udp.h | 8 + external/badvpn_dns/misc/BRefTarget.h | 114 + external/badvpn_dns/misc/Utf16Decoder.h | 113 + external/badvpn_dns/misc/Utf16Encoder.h | 67 + external/badvpn_dns/misc/Utf8Decoder.h | 143 + external/badvpn_dns/misc/Utf8Encoder.h | 81 + external/badvpn_dns/misc/arp_proto.h | 60 + external/badvpn_dns/misc/array_length.h | 35 + external/badvpn_dns/misc/balign.h | 76 + external/badvpn_dns/misc/balloc.h | 248 + external/badvpn_dns/misc/blimits.h | 60 + external/badvpn_dns/misc/bsize.h | 117 + external/badvpn_dns/misc/bsort.h | 69 + external/badvpn_dns/misc/bstring.h | 140 + external/badvpn_dns/misc/byteorder.h | 196 + external/badvpn_dns/misc/cmdline.h | 181 + external/badvpn_dns/misc/compare.h | 37 + external/badvpn_dns/misc/concat_strings.h | 85 + external/badvpn_dns/misc/cstring.h | 347 ++ external/badvpn_dns/misc/dead.h | 134 + external/badvpn_dns/misc/debug.h | 142 + external/badvpn_dns/misc/debugcounter.h | 118 + external/badvpn_dns/misc/debugerror.h | 90 + external/badvpn_dns/misc/dhcp_proto.h | 131 + external/badvpn_dns/misc/ethernet_proto.h | 52 + external/badvpn_dns/misc/exparray.h | 101 + external/badvpn_dns/misc/expstring.h | 161 + external/badvpn_dns/misc/find_char.h | 58 + external/badvpn_dns/misc/find_program.h | 103 + external/badvpn_dns/misc/get_iface_info.h | 110 + external/badvpn_dns/misc/grow_array.h | 139 + external/badvpn_dns/misc/hashfun.h | 60 + external/badvpn_dns/misc/igmp_proto.h | 97 + external/badvpn_dns/misc/ipaddr.h | 218 + external/badvpn_dns/misc/ipaddr6.h | 400 ++ external/badvpn_dns/misc/ipv4_proto.h | 145 + external/badvpn_dns/misc/ipv6_proto.h | 86 + external/badvpn_dns/misc/loggers_string.h | 43 + external/badvpn_dns/misc/loglevel.h | 80 + external/badvpn_dns/misc/maxalign.h | 53 + external/badvpn_dns/misc/merge.h | 36 + external/badvpn_dns/misc/minmax.h | 56 + external/badvpn_dns/misc/modadd.h | 59 + external/badvpn_dns/misc/mswsock.h | 229 + external/badvpn_dns/misc/nonblocking.h | 51 + external/badvpn_dns/misc/nsskey.h | 118 + external/badvpn_dns/misc/offset.h | 51 + external/badvpn_dns/misc/open_standard_streams.h | 54 + external/badvpn_dns/misc/overflow.h | 66 + external/badvpn_dns/misc/packed.h | 51 + external/badvpn_dns/misc/parse_number.h | 304 ++ external/badvpn_dns/misc/print_macros.h | 98 + external/badvpn_dns/misc/read_file.h | 98 + external/badvpn_dns/misc/read_write_int.h | 181 + external/badvpn_dns/misc/socks_proto.h | 118 + external/badvpn_dns/misc/sslsocket.h | 48 + external/badvpn_dns/misc/stdbuf_cmdline.h | 92 + external/badvpn_dns/misc/strdup.h | 86 + external/badvpn_dns/misc/string_begins_with.h | 96 + external/badvpn_dns/misc/substring.h | 81 + external/badvpn_dns/misc/udp_proto.h | 170 + external/badvpn_dns/misc/unicode_funcs.h | 232 + external/badvpn_dns/misc/version.h | 41 + external/badvpn_dns/misc/write_file.h | 104 + external/badvpn_dns/ncd-request/CMakeLists.txt | 9 + external/badvpn_dns/ncd-request/ncd-request.c | 224 + external/badvpn_dns/ncd/CMakeLists.txt | 211 + external/badvpn_dns/ncd/NCDAst.c | 1022 ++++ external/badvpn_dns/ncd/NCDAst.h | 237 + external/badvpn_dns/ncd/NCDBuildProgram.c | 316 ++ external/badvpn_dns/ncd/NCDBuildProgram.h | 49 + external/badvpn_dns/ncd/NCDConfigParser.c | 214 + external/badvpn_dns/ncd/NCDConfigParser.h | 40 + external/badvpn_dns/ncd/NCDConfigParser_parse.y | 718 +++ external/badvpn_dns/ncd/NCDConfigTokenizer.c | 321 ++ external/badvpn_dns/ncd/NCDConfigTokenizer.h | 64 + external/badvpn_dns/ncd/NCDInterpProcess.c | 497 ++ external/badvpn_dns/ncd/NCDInterpProcess.h | 100 + external/badvpn_dns/ncd/NCDInterpProg.c | 140 + external/badvpn_dns/ncd/NCDInterpProg.h | 63 + external/badvpn_dns/ncd/NCDInterpProg_hash.h | 12 + external/badvpn_dns/ncd/NCDInterpreter.c | 1356 ++++++ external/badvpn_dns/ncd/NCDInterpreter.h | 156 + external/badvpn_dns/ncd/NCDMethodIndex.c | 272 ++ external/badvpn_dns/ncd/NCDMethodIndex.h | 135 + external/badvpn_dns/ncd/NCDMethodIndex_hash.h | 12 + external/badvpn_dns/ncd/NCDModule.c | 625 +++ external/badvpn_dns/ncd/NCDModule.h | 1011 ++++ external/badvpn_dns/ncd/NCDModuleIndex.c | 372 ++ external/badvpn_dns/ncd/NCDModuleIndex.h | 86 + external/badvpn_dns/ncd/NCDModuleIndex_mhash.h | 12 + external/badvpn_dns/ncd/NCDObject.c | 40 + external/badvpn_dns/ncd/NCDObject.h | 356 ++ external/badvpn_dns/ncd/NCDPlaceholderDb.c | 127 + external/badvpn_dns/ncd/NCDPlaceholderDb.h | 95 + external/badvpn_dns/ncd/NCDStringIndex.c | 262 ++ external/badvpn_dns/ncd/NCDStringIndex.h | 83 + external/badvpn_dns/ncd/NCDStringIndex_hash.h | 13 + external/badvpn_dns/ncd/NCDSugar.c | 253 + external/badvpn_dns/ncd/NCDSugar.h | 38 + external/badvpn_dns/ncd/NCDVal.c | 2065 +++++++++ external/badvpn_dns/ncd/NCDVal.h | 857 ++++ external/badvpn_dns/ncd/NCDValCons.c | 283 ++ external/badvpn_dns/ncd/NCDValCons.h | 176 + external/badvpn_dns/ncd/NCDValGenerator.c | 193 + external/badvpn_dns/ncd/NCDValGenerator.h | 40 + external/badvpn_dns/ncd/NCDValParser.c | 225 + external/badvpn_dns/ncd/NCDValParser.h | 50 + external/badvpn_dns/ncd/NCDValParser_parse.y | 202 + external/badvpn_dns/ncd/NCDVal_maptree.h | 15 + external/badvpn_dns/ncd/README | 386 ++ external/badvpn_dns/ncd/emncd.c | 137 + external/badvpn_dns/ncd/emncd.html | 320 ++ external/badvpn_dns/ncd/examples/dbus_start.ncd | 82 + .../badvpn_dns/ncd/examples/dhcpd.conf.template | 11 + .../badvpn_dns/ncd/examples/directory_updater.ncd | 72 + external/badvpn_dns/ncd/examples/events.ncd | 101 + .../ncd/examples/igmpproxy.conf.template | 10 + .../badvpn_dns/ncd/examples/make_dhcp_config.ncd | 27 + .../ncd/examples/make_igmpproxy_config.ncd | 53 + external/badvpn_dns/ncd/examples/network.ncd | 123 + external/badvpn_dns/ncd/examples/onoff_server.ncdi | 82 + .../badvpn_dns/ncd/examples/onoff_server_test.ncd | 20 + external/badvpn_dns/ncd/examples/router/README | 36 + .../ncd/examples/router/add-port-forwarding | 43 + .../ncd/examples/router/dhcp_server.ncdi | 60 + .../ncd/examples/router/list-port-forwardings | 61 + external/badvpn_dns/ncd/examples/router/ncd.conf | 6 + .../badvpn_dns/ncd/examples/router/network.ncdi | 356 ++ .../examples/router/network_control_server.ncdi | 96 + .../ncd/examples/router/port_forwarding.ncdi | 170 + external/badvpn_dns/ncd/examples/router/pppoe.ncdi | 296 ++ .../ncd/examples/router/remove-port-forwarding | 43 + .../badvpn_dns/ncd/examples/router/unbound.ncdi | 42 + .../badvpn_dns/ncd/examples/tcp_echo_client.ncd | 35 + .../badvpn_dns/ncd/examples/tcp_echo_server.ncd | 40 + external/badvpn_dns/ncd/extra/BEventLock.c | 146 + external/badvpn_dns/ncd/extra/BEventLock.h | 127 + external/badvpn_dns/ncd/extra/NCDBProcessOpts.c | 154 + external/badvpn_dns/ncd/extra/NCDBProcessOpts.h | 54 + external/badvpn_dns/ncd/extra/NCDBuf.c | 123 + external/badvpn_dns/ncd/extra/NCDBuf.h | 61 + external/badvpn_dns/ncd/extra/NCDIfConfig.c | 483 ++ external/badvpn_dns/ncd/extra/NCDIfConfig.h | 70 + .../badvpn_dns/ncd/extra/NCDInterfaceMonitor.c | 446 ++ .../badvpn_dns/ncd/extra/NCDInterfaceMonitor.h | 160 + external/badvpn_dns/ncd/extra/NCDRequestClient.c | 647 +++ external/badvpn_dns/ncd/extra/NCDRequestClient.h | 111 + external/badvpn_dns/ncd/extra/NCDRfkillMonitor.c | 117 + external/badvpn_dns/ncd/extra/NCDRfkillMonitor.h | 53 + external/badvpn_dns/ncd/extra/address_utils.h | 280 ++ external/badvpn_dns/ncd/extra/build_cmdline.c | 111 + external/badvpn_dns/ncd/extra/build_cmdline.h | 38 + external/badvpn_dns/ncd/extra/make_fast_names.h | 154 + external/badvpn_dns/ncd/extra/value_utils.h | 174 + external/badvpn_dns/ncd/include_linux_input.c | 1 + external/badvpn_dns/ncd/make_name_indices.h | 104 + external/badvpn_dns/ncd/modules/alias.c | 148 + external/badvpn_dns/ncd/modules/arithmetic.c | 404 ++ external/badvpn_dns/ncd/modules/assert.c | 105 + external/badvpn_dns/ncd/modules/backtrack.c | 103 + external/badvpn_dns/ncd/modules/blocker.c | 353 ++ external/badvpn_dns/ncd/modules/buffer.c | 619 +++ .../badvpn_dns/ncd/modules/buffer_chunks_tree.h | 9 + external/badvpn_dns/ncd/modules/call2.c | 498 ++ external/badvpn_dns/ncd/modules/choose.c | 145 + external/badvpn_dns/ncd/modules/command_template.c | 218 + external/badvpn_dns/ncd/modules/command_template.h | 62 + external/badvpn_dns/ncd/modules/concat.c | 189 + external/badvpn_dns/ncd/modules/daemon.c | 296 ++ external/badvpn_dns/ncd/modules/depend.c | 452 ++ external/badvpn_dns/ncd/modules/depend_scope.c | 466 ++ external/badvpn_dns/ncd/modules/dynamic_depend.c | 548 +++ external/badvpn_dns/ncd/modules/event_template.c | 184 + external/badvpn_dns/ncd/modules/event_template.h | 64 + external/badvpn_dns/ncd/modules/exit.c | 91 + external/badvpn_dns/ncd/modules/explode.c | 232 + external/badvpn_dns/ncd/modules/file.c | 350 ++ external/badvpn_dns/ncd/modules/file_open.c | 585 +++ external/badvpn_dns/ncd/modules/foreach.c | 715 +++ external/badvpn_dns/ncd/modules/from_string.c | 125 + external/badvpn_dns/ncd/modules/getargs.c | 98 + external/badvpn_dns/ncd/modules/getenv.c | 153 + external/badvpn_dns/ncd/modules/if.c | 103 + external/badvpn_dns/ncd/modules/imperative.c | 324 ++ external/badvpn_dns/ncd/modules/implode.c | 155 + external/badvpn_dns/ncd/modules/index.c | 164 + external/badvpn_dns/ncd/modules/list.c | 871 ++++ external/badvpn_dns/ncd/modules/load_module.c | 313 ++ external/badvpn_dns/ncd/modules/log.c | 285 ++ external/badvpn_dns/ncd/modules/logical.c | 160 + external/badvpn_dns/ncd/modules/modules.h | 210 + external/badvpn_dns/ncd/modules/multidepend.c | 401 ++ .../badvpn_dns/ncd/modules/net_backend_badvpn.c | 281 ++ .../badvpn_dns/ncd/modules/net_backend_rfkill.c | 216 + .../ncd/modules/net_backend_waitdevice.c | 187 + .../badvpn_dns/ncd/modules/net_backend_waitlink.c | 155 + .../ncd/modules/net_backend_wpa_supplicant.c | 573 +++ external/badvpn_dns/ncd/modules/net_dns.c | 434 ++ external/badvpn_dns/ncd/modules/net_iptables.c | 749 +++ external/badvpn_dns/ncd/modules/net_ipv4_addr.c | 148 + .../ncd/modules/net_ipv4_addr_in_network.c | 173 + .../badvpn_dns/ncd/modules/net_ipv4_arp_probe.c | 212 + external/badvpn_dns/ncd/modules/net_ipv4_dhcp.c | 351 ++ external/badvpn_dns/ncd/modules/net_ipv4_route.c | 211 + external/badvpn_dns/ncd/modules/net_ipv6_addr.c | 148 + .../ncd/modules/net_ipv6_addr_in_network.c | 168 + external/badvpn_dns/ncd/modules/net_ipv6_route.c | 213 + .../ncd/modules/net_ipv6_wait_dynamic_addr.c | 201 + external/badvpn_dns/ncd/modules/net_up.c | 119 + .../badvpn_dns/ncd/modules/net_watch_interfaces.c | 474 ++ external/badvpn_dns/ncd/modules/netmask.c | 263 ++ external/badvpn_dns/ncd/modules/ondemand.c | 372 ++ external/badvpn_dns/ncd/modules/parse.c | 392 ++ external/badvpn_dns/ncd/modules/print.c | 207 + external/badvpn_dns/ncd/modules/process_manager.c | 538 +++ external/badvpn_dns/ncd/modules/reboot.c | 103 + external/badvpn_dns/ncd/modules/ref.c | 215 + external/badvpn_dns/ncd/modules/regex_match.c | 369 ++ external/badvpn_dns/ncd/modules/run.c | 187 + external/badvpn_dns/ncd/modules/runonce.c | 331 ++ external/badvpn_dns/ncd/modules/sleep.c | 178 + external/badvpn_dns/ncd/modules/socket.c | 1057 +++++ external/badvpn_dns/ncd/modules/spawn.c | 410 ++ external/badvpn_dns/ncd/modules/strcmp.c | 107 + external/badvpn_dns/ncd/modules/substr.c | 167 + external/badvpn_dns/ncd/modules/sys_evdev.c | 348 ++ .../badvpn_dns/ncd/modules/sys_request_client.c | 646 +++ .../badvpn_dns/ncd/modules/sys_request_server.c | 792 ++++ .../badvpn_dns/ncd/modules/sys_start_process.c | 1266 +++++ .../badvpn_dns/ncd/modules/sys_watch_directory.c | 425 ++ external/badvpn_dns/ncd/modules/sys_watch_input.c | 455 ++ external/badvpn_dns/ncd/modules/sys_watch_usb.c | 421 ++ external/badvpn_dns/ncd/modules/timer.c | 146 + external/badvpn_dns/ncd/modules/to_string.c | 116 + external/badvpn_dns/ncd/modules/try.c | 302 ++ external/badvpn_dns/ncd/modules/value.c | 2102 +++++++++ external/badvpn_dns/ncd/modules/value_maptree.h | 11 + external/badvpn_dns/ncd/modules/valuemetic.c | 219 + external/badvpn_dns/ncd/modules/var.c | 163 + external/badvpn_dns/ncd/ncd.c | 463 ++ external/badvpn_dns/ncd/ncd.h | 37 + external/badvpn_dns/ncd/parse_linux_input.sh | 94 + external/badvpn_dns/ncd/static_strings.h | 70 + external/badvpn_dns/ncd/tests/addr_in_network.ncd | 60 + external/badvpn_dns/ncd/tests/alias.ncd | 48 + external/badvpn_dns/ncd/tests/arithmetic.ncd | 69 + external/badvpn_dns/ncd/tests/backtracking.ncd | 31 + external/badvpn_dns/ncd/tests/buffer.ncd | 54 + external/badvpn_dns/ncd/tests/call.ncd | 18 + external/badvpn_dns/ncd/tests/concat.ncd | 19 + external/badvpn_dns/ncd/tests/depend.ncd | 64 + external/badvpn_dns/ncd/tests/depend_scope.ncd | 31 + external/badvpn_dns/ncd/tests/escape_and_nulls.ncd | 38 + external/badvpn_dns/ncd/tests/explode.ncd | 23 + external/badvpn_dns/ncd/tests/foreach.ncd | 35 + external/badvpn_dns/ncd/tests/if.ncd | 38 + external/badvpn_dns/ncd/tests/implode.ncd | 15 + external/badvpn_dns/ncd/tests/include.ncd | 16 + .../badvpn_dns/ncd/tests/include_included.ncdi | 5 + .../badvpn_dns/ncd/tests/include_included2.ncdi | 5 + external/badvpn_dns/ncd/tests/logical.ncd | 46 + external/badvpn_dns/ncd/tests/multidepend.ncd | 30 + external/badvpn_dns/ncd/tests/netmask.ncd | 15 + external/badvpn_dns/ncd/tests/parse.ncd | 85 + external/badvpn_dns/ncd/tests/process_manager.ncd | 112 + external/badvpn_dns/ncd/tests/regex.ncd | 48 + external/badvpn_dns/ncd/tests/run_tests | 38 + external/badvpn_dns/ncd/tests/strings.ncd | 47 + external/badvpn_dns/ncd/tests/substr.ncd | 37 + external/badvpn_dns/ncd/tests/turing.ncd | 138 + external/badvpn_dns/ncd/tests/value.ncd | 258 ++ external/badvpn_dns/ncd/tests/value_substr.ncd | 25 + external/badvpn_dns/nspr_support/BSSLConnection.c | 1024 ++++ external/badvpn_dns/nspr_support/BSSLConnection.h | 116 + external/badvpn_dns/nspr_support/CMakeLists.txt | 5 + external/badvpn_dns/nspr_support/DummyPRFileDesc.c | 176 + external/badvpn_dns/nspr_support/DummyPRFileDesc.h | 61 + external/badvpn_dns/predicate/BPredicate.c | 284 ++ external/badvpn_dns/predicate/BPredicate.h | 177 + external/badvpn_dns/predicate/BPredicate.l | 83 + external/badvpn_dns/predicate/BPredicate.y | 345 ++ .../badvpn_dns/predicate/BPredicate_internal.h | 154 + external/badvpn_dns/predicate/BPredicate_parser.h | 47 + external/badvpn_dns/predicate/CMakeLists.txt | 6 + .../badvpn_dns/predicate/LexMemoryBufferInput.h | 86 + external/badvpn_dns/protocol/addr.bproto | 11 + external/badvpn_dns/protocol/addr.h | 207 + external/badvpn_dns/protocol/dataproto.h | 91 + external/badvpn_dns/protocol/fragmentproto.h | 100 + external/badvpn_dns/protocol/msgproto.bproto | 43 + external/badvpn_dns/protocol/msgproto.h | 76 + external/badvpn_dns/protocol/packetproto.h | 68 + external/badvpn_dns/protocol/requestproto.h | 50 + external/badvpn_dns/protocol/scproto.h | 266 ++ external/badvpn_dns/protocol/spproto.h | 195 + external/badvpn_dns/protocol/udpgw_proto.h | 84 + external/badvpn_dns/random/BRandom2.c | 90 + external/badvpn_dns/random/BRandom2.h | 50 + external/badvpn_dns/random/CMakeLists.txt | 1 + external/badvpn_dns/scripts/cmake | 8 + external/badvpn_dns/scripts/copy_nss | 23 + external/badvpn_dns/scripts/toolchain.cmake | 6 + external/badvpn_dns/security/BEncryption.c | 240 + external/badvpn_dns/security/BEncryption.h | 175 + external/badvpn_dns/security/BHash.c | 69 + external/badvpn_dns/security/BHash.h | 80 + external/badvpn_dns/security/BRandom.c | 42 + external/badvpn_dns/security/BRandom.h | 49 + external/badvpn_dns/security/BSecurity.c | 149 + external/badvpn_dns/security/BSecurity.h | 60 + external/badvpn_dns/security/CMakeLists.txt | 10 + external/badvpn_dns/security/OTPCalculator.c | 118 + external/badvpn_dns/security/OTPCalculator.h | 96 + external/badvpn_dns/security/OTPChecker.c | 297 ++ external/badvpn_dns/security/OTPChecker.h | 148 + external/badvpn_dns/security/OTPGenerator.c | 159 + external/badvpn_dns/security/OTPGenerator.h | 134 + external/badvpn_dns/server/CMakeLists.txt | 12 + external/badvpn_dns/server/badvpn-server.8 | 190 + external/badvpn_dns/server/server.c | 2394 ++++++++++ external/badvpn_dns/server/server.h | 186 + .../badvpn_dns/server_connection/CMakeLists.txt | 5 + .../server_connection/SCKeepaliveSource.c | 69 + .../server_connection/SCKeepaliveSource.h | 72 + .../server_connection/ServerConnection.c | 669 +++ .../server_connection/ServerConnection.h | 289 ++ external/badvpn_dns/socksclient/BSocksClient.c | 608 +++ external/badvpn_dns/socksclient/BSocksClient.h | 147 + external/badvpn_dns/socksclient/CMakeLists.txt | 1 + external/badvpn_dns/stringmap/BStringMap.c | 198 + external/badvpn_dns/stringmap/BStringMap.h | 57 + external/badvpn_dns/stringmap/CMakeLists.txt | 1 + external/badvpn_dns/structure/BAVL.h | 797 ++++ external/badvpn_dns/structure/CAvl.h | 36 + external/badvpn_dns/structure/CAvl_decl.h | 77 + external/badvpn_dns/structure/CAvl_footer.h | 113 + external/badvpn_dns/structure/CAvl_header.h | 141 + external/badvpn_dns/structure/CAvl_impl.h | 949 ++++ external/badvpn_dns/structure/CHash.h | 39 + external/badvpn_dns/structure/CHash_decl.h | 59 + external/badvpn_dns/structure/CHash_footer.h | 74 + external/badvpn_dns/structure/CHash_header.h | 78 + external/badvpn_dns/structure/CHash_impl.h | 312 ++ external/badvpn_dns/structure/ChunkBuffer2.h | 317 ++ external/badvpn_dns/structure/IndexedList.h | 225 + external/badvpn_dns/structure/IndexedList_tree.h | 15 + external/badvpn_dns/structure/LinkedList0.h | 202 + external/badvpn_dns/structure/LinkedList1.h | 275 ++ external/badvpn_dns/structure/LinkedList3.h | 362 ++ external/badvpn_dns/structure/SAvl.h | 40 + external/badvpn_dns/structure/SAvl_decl.h | 73 + external/badvpn_dns/structure/SAvl_footer.h | 89 + external/badvpn_dns/structure/SAvl_header.h | 93 + external/badvpn_dns/structure/SAvl_impl.h | 164 + external/badvpn_dns/structure/SAvl_tree.h | 18 + external/badvpn_dns/structure/SLinkedList.h | 38 + external/badvpn_dns/structure/SLinkedList_decl.h | 67 + external/badvpn_dns/structure/SLinkedList_footer.h | 57 + external/badvpn_dns/structure/SLinkedList_header.h | 62 + external/badvpn_dns/structure/SLinkedList_impl.h | 182 + external/badvpn_dns/system/BAddr.h | 808 ++++ external/badvpn_dns/system/BConnection.h | 369 ++ external/badvpn_dns/system/BConnectionGeneric.h | 144 + external/badvpn_dns/system/BConnection_unix.c | 1057 +++++ external/badvpn_dns/system/BConnection_unix.h | 87 + external/badvpn_dns/system/BConnection_win.c | 875 ++++ external/badvpn_dns/system/BConnection_win.h | 101 + external/badvpn_dns/system/BDatagram.h | 209 + external/badvpn_dns/system/BDatagram_unix.c | 855 ++++ external/badvpn_dns/system/BDatagram_unix.h | 71 + external/badvpn_dns/system/BDatagram_win.c | 755 +++ external/badvpn_dns/system/BDatagram_win.h | 99 + external/badvpn_dns/system/BInputProcess.c | 211 + external/badvpn_dns/system/BInputProcess.h | 65 + external/badvpn_dns/system/BLockReactor.c | 131 + external/badvpn_dns/system/BLockReactor.h | 58 + external/badvpn_dns/system/BNetwork.c | 99 + external/badvpn_dns/system/BNetwork.h | 36 + external/badvpn_dns/system/BProcess.c | 400 ++ external/badvpn_dns/system/BProcess.h | 200 + external/badvpn_dns/system/BReactor.h | 11 + external/badvpn_dns/system/BReactor_badvpn.c | 1430 ++++++ external/badvpn_dns/system/BReactor_badvpn.h | 572 +++ .../badvpn_dns/system/BReactor_badvpn_timerstree.h | 13 + external/badvpn_dns/system/BReactor_emscripten.c | 176 + external/badvpn_dns/system/BReactor_emscripten.h | 87 + external/badvpn_dns/system/BReactor_glib.c | 524 +++ external/badvpn_dns/system/BReactor_glib.h | 148 + external/badvpn_dns/system/BSignal.c | 188 + external/badvpn_dns/system/BSignal.h | 64 + external/badvpn_dns/system/BThreadSignal.c | 136 + external/badvpn_dns/system/BThreadSignal.h | 53 + external/badvpn_dns/system/BTime.c | 38 + external/badvpn_dns/system/BTime.h | 163 + external/badvpn_dns/system/BUnixSignal.c | 406 ++ external/badvpn_dns/system/BUnixSignal.h | 132 + external/badvpn_dns/system/CMakeLists.txt | 44 + external/badvpn_dns/tests/CMakeLists.txt | 8 + external/badvpn_dns/tests/bproto_test.bproto | 9 + external/badvpn_dns/tests/bproto_test.c | 76 + external/badvpn_dns/tests/chunkbuffer2_test.c | 86 + external/badvpn_dns/tests/threadwork_test.c | 87 + external/badvpn_dns/threadwork/BThreadWork.c | 451 ++ external/badvpn_dns/threadwork/BThreadWork.h | 171 + external/badvpn_dns/threadwork/CMakeLists.txt | 6 + external/badvpn_dns/tun2socks/CMakeLists.txt | 15 + external/badvpn_dns/tun2socks/SocksUdpGwClient.c | 228 + external/badvpn_dns/tun2socks/SocksUdpGwClient.h | 64 + external/badvpn_dns/tun2socks/badvpn-tun2socks.8 | 126 + external/badvpn_dns/tun2socks/tun2socks.c | 2138 +++++++++ external/badvpn_dns/tun2socks/tun2socks.h | 46 + external/badvpn_dns/tunctl/CMakeLists.txt | 6 + external/badvpn_dns/tunctl/tunctl.c | 352 ++ external/badvpn_dns/tuntap/BTap.c | 631 +++ external/badvpn_dns/tuntap/BTap.h | 199 + external/badvpn_dns/tuntap/CMakeLists.txt | 10 + external/badvpn_dns/tuntap/tapwin32-funcs.c | 227 + external/badvpn_dns/tuntap/tapwin32-funcs.h | 42 + external/badvpn_dns/tuntap/wintap-common.h | 39 + external/badvpn_dns/udevmonitor/CMakeLists.txt | 7 + external/badvpn_dns/udevmonitor/NCDUdevCache.c | 417 ++ external/badvpn_dns/udevmonitor/NCDUdevCache.h | 66 + external/badvpn_dns/udevmonitor/NCDUdevManager.c | 547 +++ external/badvpn_dns/udevmonitor/NCDUdevManager.h | 84 + external/badvpn_dns/udevmonitor/NCDUdevMonitor.c | 250 + external/badvpn_dns/udevmonitor/NCDUdevMonitor.h | 71 + .../badvpn_dns/udevmonitor/NCDUdevMonitorParser.c | 358 ++ .../badvpn_dns/udevmonitor/NCDUdevMonitorParser.h | 76 + external/badvpn_dns/udpgw/CMakeLists.txt | 9 + external/badvpn_dns/udpgw/udpgw.c | 1473 ++++++ external/badvpn_dns/udpgw/udpgw.h | 52 + external/badvpn_dns/udpgw_client/CMakeLists.txt | 1 + external/badvpn_dns/udpgw_client/UdpGwClient.c | 597 +++ external/badvpn_dns/udpgw_client/UdpGwClient.h | 118 + jni/Android.mk | 5 +- jni/Application.mk | 3 + res/menu/main.xml | 79 + res/values/strings.xml | 2 +- src/com/runjva/sourceforge/jsocks/main/SOCKS.java | 269 ++ .../runjva/sourceforge/jsocks/main/SocksEcho.gif | Bin 0 -> 926 bytes .../jsocks/protocol/Authentication.java | 35 + .../jsocks/protocol/AuthenticationNone.java | 22 + .../sourceforge/jsocks/protocol/InetRange.java | 492 ++ .../sourceforge/jsocks/protocol/ProxyMessage.java | 118 + .../sourceforge/jsocks/protocol/ProxyServer.java | 669 +++ .../sourceforge/jsocks/protocol/Socks4Message.java | 167 + .../sourceforge/jsocks/protocol/Socks4Proxy.java | 144 + .../jsocks/protocol/Socks5DatagramSocket.java | 485 ++ .../sourceforge/jsocks/protocol/Socks5Message.java | 330 ++ .../sourceforge/jsocks/protocol/Socks5Proxy.java | 295 ++ .../jsocks/protocol/SocksException.java | 111 + .../jsocks/protocol/SocksProxyBase.java | 543 +++ .../jsocks/protocol/SocksServerSocket.java | 238 + .../sourceforge/jsocks/protocol/SocksSocket.java | 389 ++ .../jsocks/protocol/UDPEncapsulation.java | 33 + .../jsocks/protocol/UDPRelayServer.java | 231 + .../protocol/UserPasswordAuthentication.java | 91 + .../runjva/sourceforge/jsocks/server/Ident.java | 176 + .../jsocks/server/IdentAuthenticator.java | 182 + .../jsocks/server/ServerAuthenticator.java | 126 + .../jsocks/server/ServerAuthenticatorBase.java | 187 + .../jsocks/server/ServerAuthenticatorNone.java | 16 + .../jsocks/server/UserPasswordAuthenticator.java | 82 + .../sourceforge/jsocks/server/UserValidation.java | 24 + src/org/sandroproxy/ony/OrbotApp.java | 69 + src/org/torproject/android/OrbotMainActivity.java | 960 +++- .../android/service/TorResourceInstaller.java | 482 +- src/org/torproject/android/service/TorService.java | 4062 ++++++++-------- .../torproject/android/settings/AppManager.java | 5 +- .../android/settings/SettingsPreferences.java | 2 +- .../android/ui/ChooseLocaleWizardActivity.java | 164 +- src/org/torproject/android/ui/LotsaText.java | 2 +- .../android/ui/OrbotDiagnosticsActivity.java | 1 + src/org/torproject/android/ui/TipsAndTricks.java | 184 +- .../torproject/android/vpn/OrbotVpnService.java | 202 +- src/org/torproject/android/vpn/Tun2Socks.java | 49 +- 1020 files changed, 236040 insertions(+), 2967 deletions(-)
diff --cc AndroidManifest.xml index 6681cd4,c8cc1f4..b4cbd42 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@@ -1,23 -1,21 +1,19 @@@ <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="org.sandroproxy.ony" - android:versionName="14.1.4-noPIE" - android:versionCode="132" - android:installLocation="auto" + package="org.torproject.android" + android:versionName="15.0.0-alpha-1" + android:versionCode="15001" + android:installLocation="auto" > - - <uses-sdk android:minSdkVersion="9" android:maxSdkVersion="20" android:targetSdkVersion="19"/> - <permission android:name="org.torproject.android.MANAGE_TOR" android:label="@string/permission_manage_tor_label" android:description="@string/permission_manage_tor_description" android:protectionLevel="signature"></permission> - - <uses-permission android:name="android.permission.INTERNET" /> - <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/> - <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> - <uses-permission android:name="android.permission.ACCESS_SUPERUSER"/> - <uses-permission android:name="org.torproject.android.MANAGE_TOR"/> + + <uses-sdk android:minSdkVersion="9" android:maxSdkVersion="22" android:targetSdkVersion="22"/> + <permission android:name="org.torproject.android.MANAGE_TOR" android:label="@string/permission_manage_tor_label" android:description="@string/permission_manage_tor_description" android:protectionLevel="signature"></permission> - - <uses-permission android:name="android.permission.INTERNET" /> - <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/> - <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> + <uses-permission android:name="android.permission.ACCESS_SUPERUSER"/> + <uses-permission android:name="org.torproject.android.MANAGE_TOR"/> + <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> +
- <application android:name=".OrbotApp" android:icon="@drawable/ic_launcher" + <application android:name="org.sandroproxy.ony.OrbotApp" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:description="@string/app_description" android:configChanges="locale|orientation|screenSize" @@@ -58,105 -56,69 +54,105 @@@ </intent-filter> <intent-filter> <category android:name="android.intent.category.DEFAULT" /> - <action android:name="org.torproject.android.START_TOR" /> + <action android:name="org.torproject.android.START_TOR" /> </intent-filter>
- <!-- - <intent-filter> - <action android:name="android.intent.action.SEND" /> - - <category android:name="android.intent.category.DEFAULT" /> - <category android:name="android.intent.category.ALTERNATIVE" /> - <category android:name="android.intent.category.SELECTED_ALTERNATIVE" /> - - <data android:mimeType="*/*" /> - </intent-filter> - --> - </activity>
+ + <activity android:name=".ui.OrbotLogActivity" + android:configChanges="orientation|screenSize" + android:exported="false" + /> + <!-- - <activity android:name=".OrbotDiagnosticsActivity" android:label="OrbotDiag"/> + This is for ensuring the background service still runs when/if the app is swiped away --> - <activity - android:name="org.torproject.android.service.DummyActivity" - android:theme="@android:style/Theme.NoDisplay" - android:enabled="true" - android:allowTaskReparenting="true" - android:noHistory="true" - android:excludeFromRecents="true" - android:alwaysRetainTaskState="false" - android:stateNotNeeded="true" - android:clearTaskOnLaunch="true" - android:finishOnTaskLaunch="true" - /> - - - <activity android:name="org.torproject.android.wizard.LotsaText" android:exported="false"/> - <activity android:name="org.torproject.android.wizard.Permissions" android:exported="false"/> - <activity android:name="org.torproject.android.wizard.TipsAndTricks" android:exported="false"/> - <activity android:name="org.torproject.android.wizard.ConfigureTransProxy" android:exported="false"/> - <activity android:name="org.torproject.android.wizard.ChooseLocaleWizardActivity" android:exported="false"/> - - <activity android:name="org.torproject.android.settings.SettingsPreferences" android:label="@string/app_name"/> - <activity android:name="org.torproject.android.settings.AppManager" android:label="@string/app_name"/> + <activity + android:name=".service.DummyActivity" + android:theme="@android:style/Theme.NoDisplay" + android:enabled="true" + android:allowTaskReparenting="true" + android:noHistory="true" + android:excludeFromRecents="true" + android:alwaysRetainTaskState="false" + android:stateNotNeeded="true" + android:clearTaskOnLaunch="true" + android:finishOnTaskLaunch="true" + + /> + + + <activity android:name=".ui.LotsaText" android:exported="false"/> + <activity android:name=".ui.TipsAndTricks" android:exported="false"/> + <activity android:name=".ui.ChooseLocaleWizardActivitycaleWizardActivity" android:exported="false"/> + + <activity android:name=".settings.SettingsPreferences" android:label="@string/app_name"/> + <activity android:name=".settings.AppManager" android:label="@string/app_name"/>
- <service android:enabled="true" - android:name="org.torproject.android.service.TorService" - android:permission="org.torproject.android.MANAGE_TOR" - android:stopWithTask="false" - > - <intent-filter> - <action android:name="org.torproject.android.service.ITorService" /> - <action android:name="org.torproject.android.service.TOR_SERVICE" /> + <activity android:name="info.guardianproject.browser.Browser" + android:label="@string/app_name_orweb" + android:icon="@drawable/icon_orweb" + android:configChanges="locale|orientation|screenSize" + > + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> - </service> - - <receiver android:name="org.torproject.android.OnBootReceiver"> <intent-filter> - <action android:name="android.intent.action.BOOT_COMPLETED" /> - <action android:name="android.intent.action.QUICKBOOT_POWERON" /> - <action android:name="android.intent.action.MEDIA_MOUNTED"/> + <action android:name="android.intent.action.SEARCH" /> + <category android:name="android.intent.category.DEFAULT" /> + </intent-filter> + <intent-filter> + <action android:name="android.intent.action.VIEW" /> + + <category android:name="android.intent.category.DEFAULT" /> + <category android:name="android.intent.category.BROWSABLE" /> + <data android:scheme="http" /> + <data android:scheme="https" /> + <data android:scheme="about" /> + </intent-filter> + <!-- For these schemes where any of these particular MIME types + have been supplied, we are a good candidate. --> + <intent-filter> + <action android:name="android.intent.action.VIEW" /> + + <category android:name="android.intent.category.BROWSABLE" /> + <category android:name="android.intent.category.DEFAULT" /> + <data android:scheme="http" /> --> + <data android:scheme="https" /> + <data android:mimeType="text/html"/> + <data android:mimeType="text/plain"/> + <data android:mimeType="application/xhtml+xml"/> + <data android:mimeType="application/vnd.wap.xhtml+xml"/> </intent-filter> - </receiver>
+ <meta-data android:name="android.app.searchable" + android:resource="@xml/searchable"/> + </activity> + <activity android:label="@string/app_name" android:name="info.guardianproject.browser.EditPreferences"></activity> +
+ <service android:enabled="true" + android:name=".service.TorService" + android:permission="org.torproject.android.MANAGE_TOR" + android:stopWithTask="false" + > + <intent-filter> + <action android:name="org.torproject.android.service.ITorService" /> + <action android:name="org.torproject.android.service.TOR_SERVICE" /> + </intent-filter> + </service> + + <receiver android:name="org.torproject.android.service.OnBootReceiver"> + <intent-filter> + <action android:name="android.intent.action.BOOT_COMPLETED" /> + <action android:name="android.intent.action.QUICKBOOT_POWERON" /> + <action android:name="android.intent.action.MEDIA_MOUNTED"/> + </intent-filter> + </receiver> + + <service android:name="org.torproject.android.vpn.OrbotVpnService" android:permission="android.permission.BIND_VPN_SERVICE"> <intent-filter> diff --cc src/org/torproject/android/OrbotMainActivity.java index b3583bc,0000000..99b613e mode 100644,000000..100644 --- a/src/org/torproject/android/OrbotMainActivity.java +++ b/src/org/torproject/android/OrbotMainActivity.java @@@ -1,1196 -1,0 +1,1666 @@@ +/* Copyright (c) 2009, Nathan Freitas, Orbot / The Guardian Project - https://guardianproject.info */ +/* See LICENSE for licensing information */ + +package org.torproject.android; + +import info.guardianproject.browser.Browser; + +import java.net.URLDecoder; +import java.util.Locale; + ++import org.sandroproxy.ony.R; +import org.torproject.android.service.TorService; +import org.torproject.android.service.TorServiceConstants; +import org.torproject.android.service.TorServiceUtils; +import org.torproject.android.settings.SettingsPreferences; +import org.torproject.android.ui.ChooseLocaleWizardActivity; +import org.torproject.android.ui.ImageProgressView; +import org.torproject.android.ui.Rotate3dAnimation; + +import android.annotation.TargetApi; +import android.app.Activity; +import android.app.AlertDialog; +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.DialogInterface; +import android.content.Intent; +import android.content.IntentFilter; +import android.content.SharedPreferences; +import android.content.SharedPreferences.Editor; +import android.content.SharedPreferences.OnSharedPreferenceChangeListener; +import android.content.pm.PackageInfo; +import android.content.pm.PackageManager; +import android.content.pm.PackageManager.NameNotFoundException; +import android.content.res.Configuration; +import android.net.Uri; +import android.net.VpnService; +import android.os.Build; +import android.os.Bundle; +import android.os.Handler; +import android.os.Message; +import android.os.RemoteException; +import android.support.v4.content.LocalBroadcastManager; +import android.support.v4.widget.DrawerLayout; +import android.support.v7.app.ActionBarDrawerToggle; +import android.support.v7.widget.Toolbar; +import android.util.Log; +import android.view.GestureDetector; +import android.view.GestureDetector.SimpleOnGestureListener; +import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; +import android.view.MotionEvent; +import android.view.View; +import android.view.View.OnClickListener; +import android.view.View.OnLongClickListener; +import android.view.View.OnTouchListener; +import android.view.animation.AccelerateInterpolator; +import android.widget.Button; +import android.widget.TextView; +import android.widget.Toast; + + +public class OrbotMainActivity extends Activity implements TorConstants, OnLongClickListener, OnTouchListener, OnSharedPreferenceChangeListener +{ - /* Useful UI bits */ - private TextView lblStatus = null; //the main text display widget - private ImageProgressView imgStatus = null; //the main touchable image for activating Orbot ++ /* Useful UI bits */ ++ private TextView lblStatus = null; //the main text display widget ++ private ImageProgressView imgStatus = null; //the main touchable image for activating Orbot + - private MenuItem mItemOnOff = null; ++ private MenuItem mItemOnOff = null; + private TextView downloadText = null; + private TextView uploadText = null; + + private Button mBtnBrowser = null; + private Button mBtnVPN = null; + - /* Some tracking bits */ - private int torStatus = TorServiceConstants.STATUS_OFF; //latest status reported from the tor service - - private SharedPreferences mPrefs = null; ++ /* Some tracking bits */ ++ private int torStatus = TorServiceConstants.STATUS_OFF; //latest status reported from the tor service ++ ++ private SharedPreferences mPrefs = null; + - private boolean autoStartFromIntent = false; - - private final static long INIT_DELAY = 100; ++ private boolean autoStartFromIntent = false; ++ ++ private final static long INIT_DELAY = 100; + + /** Called when the activity is first created. */ - public void onCreate(Bundle savedInstanceState) { ++ public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + mPrefs = TorServiceUtils.getSharedPrefs(getApplicationContext()); + mPrefs.registerOnSharedPreferenceChangeListener(this); - ++ + setLocale(); + ++<<<<<<< HEAD:src/org/torproject/android/OrbotMainActivity.java + doLayout(); + + // appConflictChecker (); + + + // Register to receive messages. + // We are registering an observer (mMessageReceiver) to receive Intents + // with actions named "custom-event-name". + LocalBroadcastManager.getInstance(this).registerReceiver(mMessageReceiver, + new IntentFilter("status")); + + LocalBroadcastManager.getInstance(this).registerReceiver(mMessageReceiver, + new IntentFilter("log")); + + mHandler.postDelayed(new Runnable () + { + + public void run () + { + startService(TorServiceConstants.CMD_INIT); + } + },INIT_DELAY); + + } + + // Our handler for received Intents. This will be called whenever an Intent + // with an action named "custom-event-name" is broadcasted. + private BroadcastReceiver mMessageReceiver = new BroadcastReceiver() { + + + + @Override + public void onReceive(Context context, Intent intent) { + // Get extra data included in the Intent + + if (intent.hasExtra("log")) + { + String log = intent.getStringExtra("log"); + updateStatus(log); + } + else if (intent.hasExtra("up")) + { + long upload = intent.getLongExtra("up",0); + long download = intent.getLongExtra("down",0); + long written = intent.getLongExtra("written",0); + long read = intent.getLongExtra("read",0); + + Message msg = mHandler.obtainMessage(TorServiceConstants.MESSAGE_TRAFFIC_COUNT); + msg.getData().putLong("download", download); + msg.getData().putLong("upload", upload); + msg.getData().putLong("readTotal", read); + msg.getData().putLong("writeTotal", written); + mHandler.sendMessage(msg); + + } + else if (intent.hasExtra("status")) + { + torStatus = intent.getIntExtra("status", TorServiceConstants.STATUS_OFF); + updateStatus(""); + } + + } + }; + + private void startService (String action) + { + + Intent torService = new Intent(this, TorService.class); + torService.setAction(action); + startService(torService); + + } + + private void stopService () + { + + Intent torService = new Intent(this, TorService.class); + stopService(torService); + + } + + private DrawerLayout mDrawer; + private ActionBarDrawerToggle mDrawerToggle; + private Toolbar mToolbar; + + private void doLayout () + { + setContentView(R.layout.layout_main); + + mToolbar = (Toolbar) findViewById(R.id.toolbar); + mToolbar.inflateMenu(R.menu.orbot_main); + mToolbar.setTitle(R.string.app_name); + + mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout); + mDrawerToggle = new ActionBarDrawerToggle( + this, mDrawer, mToolbar, + android.R.string.ok, android.R.string.cancel + ); + + mDrawer.setDrawerListener(mDrawerToggle); + mDrawerToggle.setDrawerIndicatorEnabled(true); + mDrawerToggle.syncState(); + mDrawerToggle.setToolbarNavigationClickListener(new OnClickListener () + { + + @Override + public void onClick(View v) { + + + + } + + + }); + + + lblStatus = (TextView)findViewById(R.id.lblStatus); + imgStatus = (ImageProgressView)findViewById(R.id.imgStatus); + imgStatus.setOnLongClickListener(this); + + downloadText = (TextView)findViewById(R.id.trafficDown); + uploadText = (TextView)findViewById(R.id.trafficUp); ++======= ++ doLayout(); ++ ++ appConflictChecker (); + - downloadText.setText(formatCount(0) + " / " + formatTotal(0)); - uploadText.setText(formatCount(0) + " / " + formatTotal(0)); - ++ ++ // Register to receive messages. ++ // We are registering an observer (mMessageReceiver) to receive Intents ++ // with actions named "custom-event-name". ++ LocalBroadcastManager.getInstance(this).registerReceiver(mMessageReceiver, ++ new IntentFilter("status")); ++ ++ LocalBroadcastManager.getInstance(this).registerReceiver(mMessageReceiver, ++ new IntentFilter("log")); ++ ++ mHandler.postDelayed(new Runnable () ++ { ++ ++ public void run () ++ { ++ startService(TorServiceConstants.CMD_INIT); ++ } ++ },INIT_DELAY); ++ ++ } ++ ++ // Our handler for received Intents. This will be called whenever an Intent ++ // with an action named "custom-event-name" is broadcasted. ++ private BroadcastReceiver mMessageReceiver = new BroadcastReceiver() { ++ ++ ++ ++ @Override ++ public void onReceive(Context context, Intent intent) { ++ // Get extra data included in the Intent ++ ++ if (intent.hasExtra("log")) ++ { ++ String log = intent.getStringExtra("log"); ++ updateStatus(log); ++ } ++ else if (intent.hasExtra("up")) ++ { ++ long upload = intent.getLongExtra("up",0); ++ long download = intent.getLongExtra("down",0); ++ long written = intent.getLongExtra("written",0); ++ long read = intent.getLongExtra("read",0); ++ ++ Message msg = mHandler.obtainMessage(TorServiceConstants.MESSAGE_TRAFFIC_COUNT); ++ msg.getData().putLong("download", download); ++ msg.getData().putLong("upload", upload); ++ msg.getData().putLong("readTotal", read); ++ msg.getData().putLong("writeTotal", written); ++ mHandler.sendMessage(msg); ++ ++ } ++ else if (intent.hasExtra("status")) ++ { ++ torStatus = intent.getIntExtra("status", TorServiceConstants.STATUS_OFF); ++ updateStatus(""); ++ } ++ ++ } ++ }; ++ ++ ProgressDialog mProgressDialog; ++ ++ private void startService (String action) ++ { ++ ++ Intent torService = new Intent(this, TorService.class); ++ torService.setAction(action); ++ startService(torService); ++ ++ } ++ ++ private void stopService () ++ { ++ ++ Intent torService = new Intent(this, TorService.class); ++ stopService(torService); ++ ++ } ++ ++ private void doLayout () ++ { ++ setContentView(R.layout.layout_main); ++ ++ mViewMain = findViewById(R.id.viewMain); ++ lblStatus = (TextView)findViewById(R.id.lblStatus); ++ lblStatus.setOnLongClickListener(this); ++ imgStatus = (ImageProgressView)findViewById(R.id.imgStatus); ++ imgStatus.setOnLongClickListener(this); ++ imgStatus.setOnTouchListener(this); ++ ++ lblStatus.setText("Initializing the application..."); ++ ++ downloadText = (TextView)findViewById(R.id.trafficDown); ++ uploadText = (TextView)findViewById(R.id.trafficUp); ++ mTxtOrbotLog = (TextView)findViewById(R.id.orbotLog); ++ ++ mDrawer = ((SlidingDrawer)findViewById(R.id.SlidingDrawer)); ++ Button slideButton = (Button)findViewById(R.id.slideButton); ++ if (slideButton != null) ++ { ++ slideButton.setOnTouchListener(new OnTouchListener (){ ++ ++ @Override ++ public boolean onTouch(View v, MotionEvent event) { ++ ++ if (event.equals(MotionEvent.ACTION_DOWN)) ++ { ++ mDrawerOpen = !mDrawerOpen; ++ mTxtOrbotLog.setEnabled(mDrawerOpen); ++ } ++ return false; ++ } ++ ++ }); ++ } ++ ++ ScrollingMovementMethod smm = new ScrollingMovementMethod(); ++ ++ mTxtOrbotLog.setMovementMethod(smm); ++ mTxtOrbotLog.setOnLongClickListener(new View.OnLongClickListener() { ++ ++ ++ @Override ++ public boolean onLongClick(View v) { ++ ClipboardManager cm = (ClipboardManager)getSystemService(Context.CLIPBOARD_SERVICE); ++ cm.setText(mTxtOrbotLog.getText()); ++ Toast.makeText(Orbot.this, "LOG COPIED TO CLIPBOARD", Toast.LENGTH_SHORT).show(); ++ return true; ++ } ++ }); ++ ++ downloadText.setText(formatCount(0) + " / " + formatTotal(0)); ++ uploadText.setText(formatCount(0) + " / " + formatTotal(0)); ++ + // Gesture detection + mGestureDetector = new GestureDetector(this, new MyGestureDetector()); + + mBtnBrowser = (Button)findViewById(R.id.btnBrowser); + mBtnBrowser.setOnClickListener(new View.OnClickListener () + { + + @Override + public void onClick(View v) { + doTorCheck(); + + } + + + }); + + mBtnVPN = (Button)findViewById(R.id.btnVPN); + mBtnVPN.setOnClickListener(new View.OnClickListener () + { + + @Override + public void onClick(View v) { + + startVpnService(); + + } + + + }); + + + } - - GestureDetector mGestureDetector; ++ ++ GestureDetector mGestureDetector; + + - @Override - public boolean onTouch(View v, MotionEvent event) { - return mGestureDetector.onTouchEvent(event); ++ @Override ++ public boolean onTouch(View v, MotionEvent event) { ++ return mGestureDetector.onTouchEvent(event); + + } + ++ private void appendLogTextAndScroll(String text) ++ { ++ if(mTxtOrbotLog != null && text != null && text.length() > 0){ ++ ++ if (mTxtOrbotLog.getText().length() > MAX_LOG_LENGTH) ++ mTxtOrbotLog.setText(""); ++ ++ mTxtOrbotLog.append(text + "\n"); ++ final Layout layout = mTxtOrbotLog.getLayout(); ++ if(layout != null){ ++ int scrollDelta = layout.getLineBottom(mTxtOrbotLog.getLineCount() - 1) ++ - mTxtOrbotLog.getScrollY() - mTxtOrbotLog.getHeight(); ++ if(scrollDelta > 0) ++ mTxtOrbotLog.scrollBy(0, scrollDelta); ++ } ++ } ++ } ++ + /* + * Create the UI Options Menu (non-Javadoc) + * @see android.app.Activity#onCreateOptionsMenu(android.view.Menu) + */ + @Override + public boolean onCreateOptionsMenu(Menu menu) { + super.onCreateOptionsMenu(menu); + MenuInflater inflater = getMenuInflater(); + inflater.inflate(R.menu.orbot_main, menu); + + mItemOnOff = menu.getItem(0); + + return true; + } + + /** + private void appConflictChecker () + { + SharedPreferences sprefs = TorServiceUtils.getSharedPrefs(getApplicationContext()); + + boolean showAppConflict = true;//sprefs.getBoolean("pref_show_conflict",true); + + String[] badApps = {"com.sec.msc.nts.android.proxy:com.sec.msc.nts.android.proxy","com.sec.pcw:Samsung Link"}; + + for (String badApp : badApps) + { + String[] badAppParts = badApp.split(":"); + + if (appInstalledOrNot(badAppParts[0])) + { + String msg = getString(R.string.please_disable_this_app_in_android_settings_apps_if_you_are_having_problems_with_orbot_) + badAppParts[1]; + + if (showAppConflict) + showAlert(getString(R.string.app_conflict),msg,true); + + // appendLogTextAndScroll(msg); + } + } + + sprefs.edit().putBoolean("pref_show_conflict", false).commit(); + + }*/ + - - - + private void showAbout () + { + - LayoutInflater li = LayoutInflater.from(this); - View view = li.inflate(R.layout.layout_about, null); - - String version = ""; - - try { - version = getPackageManager().getPackageInfo(getPackageName(), 0).versionName + " (Tor " + TorServiceConstants.BINARY_TOR_VERSION + ")"; - } catch (NameNotFoundException e) { - version = "Version Not Found"; - } - - TextView versionName = (TextView)view.findViewById(R.id.versionName); - versionName.setText(version); - - new AlertDialog.Builder(this) - .setTitle(getString(R.string.button_about)) - .setView(view) - .show(); ++ LayoutInflater li = LayoutInflater.from(this); ++ View view = li.inflate(R.layout.layout_about, null); ++ ++ String version = ""; ++ ++ try { ++ version = getPackageManager().getPackageInfo(getPackageName(), 0).versionName + " (Tor " + TorServiceConstants.BINARY_TOR_VERSION + ")"; ++ } catch (NameNotFoundException e) { ++ version = "Version Not Found"; ++ } ++ ++ TextView versionName = (TextView)view.findViewById(R.id.versionName); ++ versionName.setText(version); ++ ++ new AlertDialog.Builder(this) ++ .setTitle(getString(R.string.button_about)) ++ .setView(view) ++ .show(); + } + - @Override ++ @Override + public boolean onOptionsItemSelected(MenuItem item) { + + super.onOptionsItemSelected(item); + + if (item.getItemId() == R.id.menu_start) + { + + try + { + + if (torStatus == TorServiceConstants.STATUS_OFF) + { + if (mItemOnOff != null) + mItemOnOff.setTitle(R.string.menu_stop); + startTor(); + + } + else + { + if (mItemOnOff != null) + mItemOnOff.setTitle(R.string.menu_start); + + stopTor(); + stopService (); + + } + + } + catch (RemoteException re) + { + Log.w(TAG, "Unable to start/top Tor from menu UI", re); + } + } + else if (item.getItemId() == R.id.menu_settings) + { + showSettings(); + } + else if (item.getItemId() == R.id.menu_wizard) + { - startActivity(new Intent(this, ChooseLocaleWizardActivity.class)); ++ startActivity(new Intent(this, ChooseLocaleWizardActivity.class)); + + } + else if (item.getItemId() == R.id.menu_exit) + { + //exit app + doExit(); + + + } + else if (item.getItemId() == R.id.menu_about) + { + showAbout(); + + + } + - /** - else if (item.getItemId() == R.id.menu_verify) - { - doTorCheck(); - } - else if (item.getItemId() == R.id.menu_vpn) - { - startVpnService(); - }*/ - + return true; + } + + /** + * This is our attempt to REALLY exit Orbot, and stop the background service + * However, Android doesn't like people "quitting" apps, and/or our code may not + * be quite right b/c no matter what we do, it seems like the TorService still exists + **/ + private void doExit () + { + try { - ++ + //one of the confusing things about all of this code is the multiple + //places where things like "stopTor" are called, both in the Activity and the Service + //not something to tackle in your first iteration, but i thin we can talk about fixing + //terminology but also making sure there are clear distinctions in control + stopTor(); + stopService (); + + + } catch (RemoteException e) { + Log.w(TAG, e); + } + + //Kill all the wizard activities + setResult(RESULT_CLOSE_ALL); + finish(); + + } + + /* (non-Javadoc) ++<<<<<<< HEAD:src/org/torproject/android/OrbotMainActivity.java + * @see android.app.Activity#onPause() + */ + protected void onPause() { + try + { + super.onPause(); + + if (aDialog != null) + aDialog.dismiss(); + } + catch (IllegalStateException ise) + { + //can happen on exit/shutdown + } + } + + private void doTorCheck () + { + + openBrowser(URL_TOR_CHECK); + + + } + + private void enableHiddenServicePort (int hsPort) + { + + Editor pEdit = mPrefs.edit(); + + String hsPortString = mPrefs.getString("pref_hs_ports", ""); + + if (hsPortString.length() > 0 && hsPortString.indexOf(hsPort+"")==-1) + hsPortString += ',' + hsPort; + else + hsPortString = hsPort + ""; + + pEdit.putString("pref_hs_ports", hsPortString); + pEdit.putBoolean("pref_hs_enable", true); + + pEdit.commit(); + + String onionHostname = mPrefs.getString("pref_hs_hostname",""); + + while (onionHostname.length() == 0) + { + //we need to stop and start Tor + try { + stopTor(); + + Thread.sleep(3000); //wait three seconds + + startTor(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + onionHostname = mPrefs.getString("pref_hs_hostname",""); + } + + Intent nResult = new Intent(); + nResult.putExtra("hs_host", onionHostname); + setResult(RESULT_OK, nResult); + + } + + + private synchronized void handleIntents () + { + if (getIntent() == null) + return; + + // Get intent, action and MIME type + Intent intent = getIntent(); + String action = intent.getAction(); + String type = intent.getType(); + + if (action == null) + return; + + if (action.equals("org.torproject.android.REQUEST_HS_PORT")) + { + + DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { + + public void onClick(DialogInterface dialog, int which) { + switch (which){ + case DialogInterface.BUTTON_POSITIVE: + + int hsPort = getIntent().getIntExtra("hs_port", -1); + + enableHiddenServicePort (hsPort); + + finish(); + + + break; + + case DialogInterface.BUTTON_NEGATIVE: + //No button clicked + finish(); + break; + } + } + }; + + int hsPort = getIntent().getIntExtra("hs_port", -1); + + String requestMsg = getString(R.string.hidden_service_request, hsPort); + AlertDialog.Builder builder = new AlertDialog.Builder(this); + builder.setMessage(requestMsg).setPositiveButton("Allow", dialogClickListener) + .setNegativeButton("Deny", dialogClickListener).show(); + + + } + else if (action.equals("org.torproject.android.START_TOR")) + { + autoStartFromIntent = true; + + try { + startTor(); + + Intent nResult = new Intent(); + + //nResult.putExtra("socks", ); //TODO respond with socks, transport, dns, etc + + setResult(RESULT_OK,nResult); + + } catch (RemoteException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + else if (action.equals(Intent.ACTION_VIEW)) + { + String urlString = intent.getDataString(); + + if (urlString != null) + { + + if (urlString.toLowerCase().startsWith("bridge://")) + + { + String newBridgeValue = urlString.substring(9); //remove the bridge protocol piece + newBridgeValue = URLDecoder.decode(newBridgeValue); //decode the value here + + showAlert("Bridges Updated","Restart Orbot to use this bridge: " + newBridgeValue,false); + + String bridges = mPrefs.getString(TorConstants.PREF_BRIDGES_LIST, null); + + Editor pEdit = mPrefs.edit(); + + if (bridges != null && bridges.trim().length() > 0) + { + if (bridges.indexOf('\n')!=-1) + bridges += '\n' + newBridgeValue; + else + bridges += ',' + newBridgeValue; + } + else + bridges = newBridgeValue; + + pEdit.putString(TorConstants.PREF_BRIDGES_LIST,bridges); //set the string to a preference + pEdit.putBoolean(TorConstants.PREF_BRIDGES_ENABLED,true); + + pEdit.commit(); + + setResult(RESULT_OK); + } + } + } + else + { + + showWizard = mPrefs.getBoolean("show_wizard",showWizard); + + if (showWizard) + { + Editor pEdit = mPrefs.edit(); + pEdit.putBoolean("show_wizard",false); + pEdit.commit(); + showWizard = false; + + startActivity(new Intent(this, ChooseLocaleWizardActivity.class)); + + } + + } + + setIntent(null); + + updateStatus (""); + + } + + private boolean showWizard = true; + + + @Override + public void onConfigurationChanged(Configuration newConfig) { + super.onConfigurationChanged(newConfig); + + doLayout(); + updateStatus(""); + } + + + /* + * Launch the system activity for Uri viewing with the provided url + */ + private void openBrowser(final String browserLaunchUrl) + { + //startIntent("info.guardianproject.browser.Browser",Intent.ACTION_VIEW,Uri.parse(browserLaunchUrl)); + + Intent intentBrowser = new Intent(this, Browser.class); + intentBrowser.setAction(Intent.ACTION_VIEW); + intentBrowser.setData(Uri.parse(browserLaunchUrl)); + startActivity(intentBrowser); + + /** + boolean isOrwebInstalled = appInstalledOrNot("info.guardianproject.browser"); + boolean isTransProxy = mPrefs.getBoolean("pref_transparent", false); + + if (isOrwebInstalled) + { + } + else if (isTransProxy) + { + Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(browserLaunchUrl)); + intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP|Intent.FLAG_ACTIVITY_NEW_TASK); + startActivity(intent); + } + else + { + AlertDialog aDialog = new AlertDialog.Builder(Orbot.this) + .setIcon(R.drawable.onion32) + .setTitle(R.string.install_apps_) + .setMessage(R.string.it_doesn_t_seem_like_you_have_orweb_installed_want_help_with_that_or_should_we_just_open_the_browser_) + .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener () + { + + @Override + public void onClick(DialogInterface dialog, int which) { + + //prompt to install Orweb + Intent intent = new Intent(Orbot.this,TipsAndTricks.class); + startActivity(intent); + + } + + }) + .setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener () + { + + @Override + public void onClick(DialogInterface dialog, int which) { + Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(browserLaunchUrl)); + intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP|Intent.FLAG_ACTIVITY_NEW_TASK); + startActivity(intent); + + } + + }) + .show(); + + }*/ + + } + + private void startIntent (String pkg, String action, Uri data) + { + Intent i; + PackageManager manager = getPackageManager(); + try { + i = manager.getLaunchIntentForPackage(pkg); + if (i == null) + throw new PackageManager.NameNotFoundException(); + i.setAction(action); + i.setData(data); + startActivity(i); + } catch (PackageManager.NameNotFoundException e) { + + } + } + + private boolean appInstalledOrNot(String uri) ++======= ++ * @see android.app.Activity#onPause() ++ */ ++ protected void onPause() { ++ try ++ { ++ super.onPause(); ++ ++ if (aDialog != null) ++ aDialog.dismiss(); ++ } ++ catch (IllegalStateException ise) ++ { ++ //can happen on exit/shutdown ++ } ++ } ++ ++ private void doTorCheck () ++ { ++ ++ DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { ++ ++ public void onClick(DialogInterface dialog, int which) { ++ switch (which){ ++ case DialogInterface.BUTTON_POSITIVE: ++ ++ openBrowser(URL_TOR_CHECK); ++ ++ ++ ++ break; ++ ++ case DialogInterface.BUTTON_NEGATIVE: ++ ++ //do nothing ++ break; ++ } ++ } ++ }; ++ ++ AlertDialog.Builder builder = new AlertDialog.Builder(this); ++ builder.setMessage(R.string.tor_check).setPositiveButton(R.string.btn_okay, dialogClickListener) ++ .setNegativeButton(R.string.btn_cancel, dialogClickListener).show(); ++ ++ } ++ ++ private void enableHiddenServicePort (int hsPort) ++ { ++ ++ Editor pEdit = mPrefs.edit(); ++ ++ String hsPortString = mPrefs.getString("pref_hs_ports", ""); ++ ++ if (hsPortString.length() > 0 && hsPortString.indexOf(hsPort+"")==-1) ++ hsPortString += ',' + hsPort; ++ else ++ hsPortString = hsPort + ""; ++ ++ pEdit.putString("pref_hs_ports", hsPortString); ++ pEdit.putBoolean("pref_hs_enable", true); ++ ++ pEdit.commit(); ++ ++ String onionHostname = mPrefs.getString("pref_hs_hostname",""); ++ ++ while (onionHostname.length() == 0) ++ { ++ //we need to stop and start Tor ++ try { ++ stopTor(); ++ ++ Thread.sleep(3000); //wait three seconds ++ ++ startTor(); ++ } catch (Exception e) { ++ // TODO Auto-generated catch block ++ e.printStackTrace(); ++ } ++ ++ onionHostname = mPrefs.getString("pref_hs_hostname",""); ++ } ++ ++ Intent nResult = new Intent(); ++ nResult.putExtra("hs_host", onionHostname); ++ setResult(RESULT_OK, nResult); ++ ++ } ++ ++ ++ private synchronized void handleIntents () ++ { ++ if (getIntent() == null) ++ return; ++ ++ // Get intent, action and MIME type ++ Intent intent = getIntent(); ++ String action = intent.getAction(); ++ String type = intent.getType(); ++ ++ if (action == null) ++ return; ++ ++ if (action.equals("org.torproject.android.REQUEST_HS_PORT")) ++ { ++ ++ DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { ++ ++ public void onClick(DialogInterface dialog, int which) { ++ switch (which){ ++ case DialogInterface.BUTTON_POSITIVE: ++ ++ int hsPort = getIntent().getIntExtra("hs_port", -1); ++ ++ enableHiddenServicePort (hsPort); ++ ++ finish(); ++ ++ ++ break; ++ ++ case DialogInterface.BUTTON_NEGATIVE: ++ //No button clicked ++ finish(); ++ break; ++ } ++ } ++ }; ++ ++ int hsPort = getIntent().getIntExtra("hs_port", -1); ++ ++ String requestMsg = getString(R.string.hidden_service_request, hsPort); ++ AlertDialog.Builder builder = new AlertDialog.Builder(this); ++ builder.setMessage(requestMsg).setPositiveButton("Allow", dialogClickListener) ++ .setNegativeButton("Deny", dialogClickListener).show(); ++ ++ ++ } ++ else if (action.equals("org.torproject.android.START_TOR")) ++ { ++ autoStartFromIntent = true; ++ ++ try { ++ startTor(); ++ ++ Intent nResult = new Intent(); ++ ++ //nResult.putExtra("socks", ); //TODO respond with socks, transport, dns, etc ++ ++ setResult(RESULT_OK,nResult); ++ ++ } catch (RemoteException e) { ++ // TODO Auto-generated catch block ++ e.printStackTrace(); ++ } ++ ++ } ++ else if (action.equals(Intent.ACTION_VIEW)) ++ { ++ String urlString = intent.getDataString(); ++ ++ if (urlString != null) ++ { ++ ++ if (urlString.toLowerCase().startsWith("bridge://")) ++ ++ { ++ String newBridgeValue = urlString.substring(9); //remove the bridge protocol piece ++ newBridgeValue = URLDecoder.decode(newBridgeValue); //decode the value here ++ ++ showAlert("Bridges Updated","Restart Orbot to use this bridge: " + newBridgeValue,false); ++ ++ String bridges = mPrefs.getString(TorConstants.PREF_BRIDGES_LIST, null); ++ ++ Editor pEdit = mPrefs.edit(); ++ ++ if (bridges != null && bridges.trim().length() > 0) ++ { ++ if (bridges.indexOf('\n')!=-1) ++ bridges += '\n' + newBridgeValue; ++ else ++ bridges += ',' + newBridgeValue; ++ } ++ else ++ bridges = newBridgeValue; ++ ++ pEdit.putString(TorConstants.PREF_BRIDGES_LIST,bridges); //set the string to a preference ++ pEdit.putBoolean(TorConstants.PREF_BRIDGES_ENABLED,true); ++ ++ pEdit.commit(); ++ ++ setResult(RESULT_OK); ++ } ++ } ++ } ++ else ++ { ++ ++ showWizard = mPrefs.getBoolean("show_wizard",showWizard); ++ ++ if (showWizard) ++ { ++ Editor pEdit = mPrefs.edit(); ++ pEdit.putBoolean("show_wizard",false); ++ pEdit.commit(); ++ showWizard = false; ++ ++ startActivity(new Intent(this, ChooseLocaleWizardActivity.class)); ++ ++ } ++ ++ } ++ ++ setIntent(null); ++ ++ updateStatus (""); ++ ++ } ++ ++ private boolean showWizard = true; ++ ++ ++ @Override ++ public void onConfigurationChanged(Configuration newConfig) { ++ super.onConfigurationChanged(newConfig); ++ ++ doLayout(); ++ updateStatus(""); ++ } ++ ++ ++ /* ++ * Launch the system activity for Uri viewing with the provided url ++ */ ++ private void openBrowser(final String browserLaunchUrl) ++ { ++ boolean isOrwebInstalled = appInstalledOrNot("info.guardianproject.browser"); ++ boolean isTransProxy = mPrefs.getBoolean("pref_transparent", false); ++ ++ if (isOrwebInstalled) ++ { ++ startIntent("info.guardianproject.browser",Intent.ACTION_VIEW,Uri.parse(browserLaunchUrl)); ++ } ++ else if (isTransProxy) ++ { ++ Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(browserLaunchUrl)); ++ intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP|Intent.FLAG_ACTIVITY_NEW_TASK); ++ startActivity(intent); ++ } ++ else ++ { ++ AlertDialog aDialog = new AlertDialog.Builder(Orbot.this) ++ .setIcon(R.drawable.onion32) ++ .setTitle(R.string.install_apps_) ++ .setMessage(R.string.it_doesn_t_seem_like_you_have_orweb_installed_want_help_with_that_or_should_we_just_open_the_browser_) ++ .setPositiveButton(android.R.string.ok, new OnClickListener () ++ { ++ ++ @Override ++ public void onClick(DialogInterface dialog, int which) { ++ ++ //prompt to install Orweb ++ Intent intent = new Intent(Orbot.this,TipsAndTricks.class); ++ startActivity(intent); ++ ++ } ++ ++ }) ++ .setNegativeButton(android.R.string.no, new OnClickListener () ++ { ++ ++ @Override ++ public void onClick(DialogInterface dialog, int which) { ++ Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(browserLaunchUrl)); ++ intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP|Intent.FLAG_ACTIVITY_NEW_TASK); ++ startActivity(intent); ++ ++ } ++ ++ }) ++ .show(); ++ ++ } ++ ++ } ++ ++ private void startIntent (String pkg, String action, Uri data) ++ { ++ Intent i; ++ PackageManager manager = getPackageManager(); ++ try { ++ i = manager.getLaunchIntentForPackage(pkg); ++ if (i == null) ++ throw new PackageManager.NameNotFoundException(); ++ i.setAction(action); ++ i.setData(data); ++ startActivity(i); ++ } catch (PackageManager.NameNotFoundException e) { ++ ++ } ++ } ++ ++ private boolean appInstalledOrNot(String uri) + { + PackageManager pm = getPackageManager(); + try + { + PackageInfo pi = pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES); + return pi.applicationInfo.enabled; + } + catch (PackageManager.NameNotFoundException e) + { + return false; + } - } - ++ } ++ + /* + * Load the basic settings application to display torrc + */ + private void showSettings () + { + + startActivityForResult(new Intent(this, SettingsPreferences.class), 1); + } + + + @Override - protected void onActivityResult(int request, int response, Intent data) { - super.onActivityResult(request, response, data); - - - if (request == 1 && response == RESULT_OK) - { - if (data != null && data.getBooleanExtra("transproxywipe", false)) - { - - boolean result = flushTransProxy(); - - if (result) - { ++ protected void onActivityResult(int request, int response, Intent data) { ++ super.onActivityResult(request, response, data); ++ ++ ++ if (request == 1 && response == RESULT_OK) ++ { ++ if (data != null && data.getBooleanExtra("transproxywipe", false)) ++ { ++ ++ boolean result = flushTransProxy(); ++ ++ if (result) ++ { + - Toast.makeText(this, R.string.transparent_proxy_rules_flushed_, Toast.LENGTH_SHORT).show(); - - } - else - { ++ Toast.makeText(this, R.string.transparent_proxy_rules_flushed_, Toast.LENGTH_SHORT).show(); ++ ++ } ++ else ++ { + - Toast.makeText(this, R.string.you_do_not_have_root_access_enabled, Toast.LENGTH_SHORT).show(); - - } - - } - else if (torStatus == TorServiceConstants.STATUS_ON) - { - updateSettings(); - Toast.makeText(this, R.string.you_may_need_to_stop_and_start_orbot_for_settings_change_to_be_enabled_, Toast.LENGTH_SHORT).show(); ++ Toast.makeText(this, R.string.you_do_not_have_root_access_enabled, Toast.LENGTH_SHORT).show(); ++ ++ } ++ ++ } ++ else if (torStatus == TorServiceConstants.STATUS_ON) ++ { ++ updateSettings(); ++ Toast.makeText(this, R.string.you_may_need_to_stop_and_start_orbot_for_settings_change_to_be_enabled_, Toast.LENGTH_SHORT).show(); + - } - } - else if (request == REQUEST_VPN && response == RESULT_OK) - { - startService(TorServiceConstants.CMD_VPN); - } - - } ++ } ++ } ++ else if (request == REQUEST_VPN && response == RESULT_OK) ++ { ++ startService(TorServiceConstants.CMD_VPN); ++ } ++ ++ } + + private final static int REQUEST_VPN = 8888; + + @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) - public void startVpnService () ++ public void startVpnService () + { - Intent intent = VpnService.prepare(this); - if (intent != null) { - startActivityForResult(intent,REQUEST_VPN); - } - else - { - startService(TorServiceConstants.CMD_VPN); - - } ++ Intent intent = VpnService.prepare(this); ++ if (intent != null) { ++ startActivityForResult(intent,REQUEST_VPN); ++ } ++ else ++ { ++ startService(TorServiceConstants.CMD_VPN); ++ ++ } + } + + private boolean flushTransProxy () + { - startService(TorServiceConstants.CMD_FLUSH); - return true; ++ startService(TorServiceConstants.CMD_FLUSH); ++ return true; + } + + private boolean updateSettings () + { - //todo send service command - startService(TorServiceConstants.CMD_UPDATE); - return true; ++ //todo send service command ++ startService(TorServiceConstants.CMD_UPDATE); ++ return true; + } + - @Override - protected void onResume() { - super.onResume(); ++ @Override ++ protected void onResume() { ++ super.onResume(); + - mHandler.postDelayed(new Runnable () - { - public void run () - { ++ mHandler.postDelayed(new Runnable () ++ { ++ public void run () ++ { + - setLocale(); - - handleIntents(); ++ setLocale(); ++ ++ handleIntents(); + - } - } - , 500); - - - } ++ } ++ } ++ , 500); ++ ++ ++ } + - AlertDialog aDialog = null; ++ AlertDialog aDialog = null; + + //general alert dialog for mostly Tor warning messages + //sometimes this can go haywire or crazy with too many error + //messages from Tor, and the user cannot stop or exit Orbot + //so need to ensure repeated error messages are not spamming this method + private void showAlert(String title, String msg, boolean button) + { + try + { + if (aDialog != null && aDialog.isShowing()) + aDialog.dismiss(); + } + catch (Exception e){} //swallow any errors + + if (button) + { + aDialog = new AlertDialog.Builder(OrbotMainActivity.this) + .setIcon(R.drawable.onion32) + .setTitle(title) + .setMessage(msg) + .setPositiveButton(android.R.string.ok, null) + .show(); + } + else + { + aDialog = new AlertDialog.Builder(OrbotMainActivity.this) + .setIcon(R.drawable.onion32) + .setTitle(title) + .setMessage(msg) + .show(); + } + + aDialog.setCanceledOnTouchOutside(true); + } + - private void updateStatus (String torServiceMsg) ++ private void updateStatus (String torServiceMsg) + { + + //now update the layout_main UI based on the status + if (imgStatus != null) + { + + if (torStatus == TorServiceConstants.STATUS_ON) + { - ++ + imgStatus.setImageResource(R.drawable.toron); + + mBtnBrowser.setEnabled(true); + mBtnVPN.setEnabled(true); + - lblStatus.setText(""); + + if (mItemOnOff != null) + mItemOnOff.setTitle(R.string.menu_stop); + + + if (torServiceMsg != null && torServiceMsg.length() > 0) + { + // appendLogTextAndScroll(torServiceMsg); + } + + boolean showFirstTime = mPrefs.getBoolean("connect_first_time",true); + + if (showFirstTime) + { + + Editor pEdit = mPrefs.edit(); + + pEdit.putBoolean("connect_first_time",false); + + pEdit.commit(); + + showAlert(getString(R.string.status_activated),getString(R.string.connect_first_time),true); + + } + + + if (autoStartFromIntent) + { - setResult(RESULT_OK); - finish(); ++ setResult(RESULT_OK); ++ finish(); + } + + } + else if (torStatus == TorServiceConstants.STATUS_CONNECTING) + { - ++ + imgStatus.setImageResource(R.drawable.torstarting); + + if (mItemOnOff != null) + mItemOnOff.setTitle(R.string.menu_stop); + + if (lblStatus != null && torServiceMsg != null) + if (torServiceMsg.indexOf('%')!=-1) + lblStatus.setText(torServiceMsg); + - + //appendLogTextAndScroll(torServiceMsg); + + + } + else if (torStatus == TorServiceConstants.STATUS_OFF) + { + imgStatus.setImageResource(R.drawable.toroff); + lblStatus.setText(""); + //lblStatus.setText(getString(R.string.status_disabled) + "\n" + getString(R.string.press_to_start)); + + if (mItemOnOff != null) + mItemOnOff.setTitle(R.string.menu_start); + + mBtnBrowser.setEnabled(false); + mBtnVPN.setEnabled(false); + + } + } + + + } - ++ + + + // guess what? this start's Tor! actually no it just requests via the local ITorService to the remote TorService instance + // to start Tor + private void startTor () throws RemoteException + { + + + startService (TorServiceConstants.CMD_START); + torStatus = TorServiceConstants.STATUS_CONNECTING; + +// mTxtOrbotLog.setText(""); + + //here we update the UI which is a bit sloppy and mixed up code wise + //might be best to just call updateStatus() instead of directly manipulating UI in this method - yep makes sense + imgStatus.setImageResource(R.drawable.torstarting); + // lblStatus.setText(getString(R.string.status_starting_up)); + + //we send a message here to the progressDialog i believe, but we can clarify that shortly + Message msg = mHandler.obtainMessage(TorServiceConstants.ENABLE_TOR_MSG); + msg.getData().putString(HANDLER_TOR_MSG, getString(R.string.status_starting_up)); + mHandler.sendMessage(msg); + + - ++ + } + + //now we stop Tor! amazing! + private void stopTor () throws RemoteException + { + + startService (TorServiceConstants.CMD_STOP); + torStatus = TorServiceConstants.STATUS_OFF; + Message msg = mHandler.obtainMessage(TorServiceConstants.DISABLE_TOR_MSG); + mHandler.sendMessage(msg); + + } + + /* + * (non-Javadoc) + * @see android.view.View.OnClickListener#onClick(android.view.View) + */ + public boolean onLongClick(View view) { + + try + { + + if (torStatus == TorServiceConstants.STATUS_OFF) + { + + startTor(); + } + else + { + + stopTor(); + stopService (); + + } + ++<<<<<<< HEAD:src/org/torproject/android/OrbotMainActivity.java + return true; + + } + catch (Exception e) + { + Log.d(TAG,"error onclick",e); + } + ++======= ++ if (!mDrawerOpen) ++ { ++ try ++ { ++ ++ if (torStatus == TorServiceConstants.STATUS_OFF) ++ { ++ ++ startTor(); ++ } ++ else ++ { ++ ++ stopTor(); ++ stopService (); ++ ++ } ++ ++ return true; ++ ++ } ++ catch (Exception e) ++ { ++ Log.d(TAG,"error onclick",e); ++ } ++ ++ } ++ + return false; + + } + - ++ + + + +// this is what takes messages or values from the callback threads or other non-mainUI threads +//and passes them back into the main UI thread for display to the user + private Handler mHandler = new Handler() { - - private String lastServiceMsg = null; - ++ ++ private String lastServiceMsg = null; ++ + public void handleMessage(Message msg) { + switch (msg.what) { + case TorServiceConstants.STATUS_MSG: + case TorServiceConstants.LOG_MSG: + + String torServiceMsg = (String)msg.getData().getString(HANDLER_TOR_MSG); + + if (lastServiceMsg == null || !lastServiceMsg.equals(torServiceMsg)) + { - updateStatus(torServiceMsg); ++ updateStatus(torServiceMsg); + - lastServiceMsg = torServiceMsg; ++ lastServiceMsg = torServiceMsg; + } + + break; + case TorServiceConstants.ENABLE_TOR_MSG: + + + updateStatus((String)msg.getData().getString(HANDLER_TOR_MSG)); + + break; + case TorServiceConstants.DISABLE_TOR_MSG: - - updateStatus((String)msg.getData().getString(HANDLER_TOR_MSG)); - - break; - ++ ++ updateStatus((String)msg.getData().getString(HANDLER_TOR_MSG)); ++ ++ break; ++ + - case TorServiceConstants.MESSAGE_TRAFFIC_COUNT : ++ case TorServiceConstants.MESSAGE_TRAFFIC_COUNT : ++ ++ Bundle data = msg.getData(); ++ DataCount datacount = new DataCount(data.getLong("upload"),data.getLong("download")); + - Bundle data = msg.getData(); - DataCount datacount = new DataCount(data.getLong("upload"),data.getLong("download")); - - long totalRead = data.getLong("readTotal"); - long totalWrite = data.getLong("writeTotal"); - - downloadText.setText(formatCount(datacount.Download) + " / " + formatTotal(totalRead)); - uploadText.setText(formatCount(datacount.Upload) + " / " + formatTotal(totalWrite)); ++ long totalRead = data.getLong("readTotal"); ++ long totalWrite = data.getLong("writeTotal"); ++ ++ downloadText.setText(formatCount(datacount.Download) + " / " + formatTotal(totalRead)); ++ uploadText.setText(formatCount(datacount.Upload) + " / " + formatTotal(totalWrite)); + - if (torStatus != TorServiceConstants.STATUS_ON) - { - updateStatus(""); - } - ++ if (torStatus != TorServiceConstants.STATUS_ON) ++ { ++ updateStatus(""); ++ } ++ + default: + super.handleMessage(msg); + } + } + + + + }; + + + /** + * Class for interacting with the main interface of the service. + */ + // this is the connection that gets called back when a successfull bind occurs + // we should use this to activity monitor unbind so that we don't have to call + // bindService() a million times + + private void setLocale () + { - ++ + + Configuration config = getResources().getConfiguration(); + String lang = mPrefs.getString(PREF_DEFAULT_LOCALE, ""); + + if (! "".equals(lang) && ! config.locale.getLanguage().equals(lang)) + { - Locale locale = new Locale(lang); ++ Locale locale = new Locale(lang); + Locale.setDefault(locale); + config.locale = locale; + getResources().updateConfiguration(config, getResources().getDisplayMetrics()); + } + } + - @Override - protected void onDestroy() { - super.onDestroy(); - LocalBroadcastManager.getInstance(this).unregisterReceiver(mMessageReceiver); ++ @Override ++ protected void onDestroy() { ++ super.onDestroy(); ++ LocalBroadcastManager.getInstance(this).unregisterReceiver(mMessageReceiver); + - } - - public class DataCount { - // data uploaded - public long Upload; - // data downloaded - public long Download; - - DataCount(long Upload, long Download){ - this.Upload = Upload; - this.Download = Download; - } - } - - private String formatCount(long count) { - // Converts the supplied argument into a string. - // Under 2Mb, returns "xxx.xKb" - // Over 2Mb, returns "xxx.xxMb" - if (count < 1e6) - return ((float)((int)(count*10/1024))/10 + "kbps"); - return ((float)((int)(count*100/1024/1024))/100 + "mbps"); - - //return count+" kB"; - } - - private String formatTotal(long count) { - // Converts the supplied argument into a string. - // Under 2Mb, returns "xxx.xKb" - // Over 2Mb, returns "xxx.xxMb" - if (count < 1e6) - return ((float)((int)(count*10/1024))/10 + "KB"); - return ((float)((int)(count*100/1024/1024))/100 + "MB"); - - //return count+" kB"; - } - - @Override - public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, - String key) { - - - } - - private static final float ROTATE_FROM = 0.0f; - private static final float ROTATE_TO = 360.0f*4f;// 3.141592654f * 32.0f; ++ } + - public void spinOrbot (float direction) - { - startService (TorServiceConstants.CMD_NEWNYM); - - - Toast.makeText(this, R.string.newnym, Toast.LENGTH_SHORT).show(); - - // Rotate3dAnimation rotation = new Rotate3dAnimation(ROTATE_FROM, ROTATE_TO*direction, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); - Rotate3dAnimation rotation = new Rotate3dAnimation(ROTATE_FROM, ROTATE_TO*direction, imgStatus.getWidth()/2f,imgStatus.getWidth()/2f,20f,false); - rotation.setFillAfter(true); - rotation.setInterpolator(new AccelerateInterpolator()); - rotation.setDuration((long) 2*1000); - rotation.setRepeatCount(0); - imgStatus.startAnimation(rotation); - - - } - - class MyGestureDetector extends SimpleOnGestureListener { - @Override - public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { - try { - if (torStatus == TorServiceConstants.STATUS_ON) - { - float direction = 1f; - if (velocityX < 0) - direction = -1f; - spinOrbot (direction); - } - } catch (Exception e) { - // nothing - } - return false; - } - - } ++ public class DataCount { ++ // data uploaded ++ public long Upload; ++ // data downloaded ++ public long Download; ++ ++ DataCount(long Upload, long Download){ ++ this.Upload = Upload; ++ this.Download = Download; ++ } ++ } ++ ++ private String formatCount(long count) { ++ // Converts the supplied argument into a string. ++ // Under 2Mb, returns "xxx.xKb" ++ // Over 2Mb, returns "xxx.xxMb" ++ if (count < 1e6) ++ return ((float)((int)(count*10/1024))/10 + "kbps"); ++ return ((float)((int)(count*100/1024/1024))/100 + "mbps"); ++ ++ //return count+" kB"; ++ } ++ ++ private String formatTotal(long count) { ++ // Converts the supplied argument into a string. ++ // Under 2Mb, returns "xxx.xKb" ++ // Over 2Mb, returns "xxx.xxMb" ++ if (count < 1e6) ++ return ((float)((int)(count*10/1024))/10 + "KB"); ++ return ((float)((int)(count*100/1024/1024))/100 + "MB"); ++ ++ //return count+" kB"; ++ } + ++ @Override ++ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, ++ String key) { ++ ++ ++ } ++ ++ private static final float ROTATE_FROM = 0.0f; ++ private static final float ROTATE_TO = 360.0f*4f;// 3.141592654f * 32.0f; + ++ public void spinOrbot (float direction) ++ { ++ startService (TorServiceConstants.CMD_NEWNYM); ++ ++ ++ Toast.makeText(this, R.string.newnym, Toast.LENGTH_SHORT).show(); ++ ++ // Rotate3dAnimation rotation = new Rotate3dAnimation(ROTATE_FROM, ROTATE_TO*direction, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); ++ Rotate3dAnimation rotation = new Rotate3dAnimation(ROTATE_FROM, ROTATE_TO*direction, imgStatus.getWidth()/2f,imgStatus.getWidth()/2f,20f,false); ++ rotation.setFillAfter(true); ++ rotation.setInterpolator(new AccelerateInterpolator()); ++ rotation.setDuration((long) 2*1000); ++ rotation.setRepeatCount(0); ++ imgStatus.startAnimation(rotation); ++ ++ ++ } ++ ++ class MyGestureDetector extends SimpleOnGestureListener { ++ @Override ++ public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { ++ try { ++ if (torStatus == TorServiceConstants.STATUS_ON) ++ { ++ float direction = 1f; ++ if (velocityX < 0) ++ direction = -1f; ++ spinOrbot (direction); ++ } ++ } catch (Exception e) { ++ // nothing ++ } ++ return false; ++ } ++ } +} diff --cc src/org/torproject/android/service/TorService.java index d9a2fd5,251137f..a13b3b8 --- a/src/org/torproject/android/service/TorService.java +++ b/src/org/torproject/android/service/TorService.java @@@ -45,11 -45,12 +45,12 @@@ import net.freehaven.tor.control.TorCon
import org.json.JSONArray; import org.json.JSONObject; + import org.sandroproxy.ony.R; import org.sufficientlysecure.rootcommands.Shell; import org.sufficientlysecure.rootcommands.command.SimpleCommand; -import org.torproject.android.Orbot; +import org.torproject.android.OrbotMainActivity; +import org.torproject.android.R; import org.torproject.android.TorConstants; -import org.torproject.android.Utils; import org.torproject.android.settings.AppManager; import org.torproject.android.settings.TorifiedApp; import org.torproject.android.vpn.OrbotVpnService; @@@ -206,249 -207,218 +207,238 @@@ public class TorService extends Servic
/* (non-Javadoc) - * @see android.app.Service#onLowMemory() - */ + * @see android.app.Service#onLowMemory() + */ @Override - public void onLowMemory() { - super.onLowMemory(); - - logNotice( "Low Memory Warning!"); - - } + public void onLowMemory() { + super.onLowMemory(); + + logNotice( "Low Memory Warning!"); + + }
- public int getTorStatus () + public int getTorStatus () { - - return mCurrentStatus; - + + return mCurrentStatus; + + } + + private void clearNotifications () + { + if (mNotificationManager != null) + mNotificationManager.cancelAll(); + + + hmBuiltNodes.clear(); + mNotificationShowing = false; + } ++<<<<<<< HEAD + + private void clearNotifications () + { + if (mNotificationManager != null) + mNotificationManager.cancelAll(); + + + hmBuiltNodes.clear(); + mNotificationShowing = false; + + } + + @SuppressLint("NewApi") + private void showToolbarNotification (String notifyMsg, int notifyType, int icon) + { + + //Reusable code. + Intent intent = new Intent(TorService.this, OrbotMainActivity.class); + PendingIntent pendIntent = PendingIntent.getActivity(TorService.this, 0, intent, 0); + + @SuppressLint("NewApi") + private void showToolbarNotification (String notifyMsg, int notifyType, int icon) + { + + //Reusable code. + Intent intent = new Intent(TorService.this, Orbot.class); + PendingIntent pendIntent = PendingIntent.getActivity(TorService.this, 0, intent, 0);
- if (mNotifyBuilder == null) - { - - mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); - - if (mNotifyBuilder == null) - { - mNotifyBuilder = new NotificationCompat.Builder(this) - .setContentTitle(getString(R.string.app_name)) - .setSmallIcon(R.drawable.ic_stat_tor); - - mNotifyBuilder.setContentIntent(pendIntent); - } - - } - - mNotifyBuilder.setContentText(notifyMsg); - mNotifyBuilder.setSmallIcon(icon); - - if (notifyType != NOTIFY_ID) - { - mNotifyBuilder.setTicker(notifyMsg); - // mNotifyBuilder.setLights(Color.GREEN, 1000, 1000); - } - else - { - mNotifyBuilder.setTicker(null); - } - - mNotifyBuilder.setOngoing(prefPersistNotifications); - - mNotification = mNotifyBuilder.build(); - - if (Build.VERSION.SDK_INT >= 16 && mShowExpandedNotifications) { - - - // Create remote view that needs to be set as bigContentView for the notification. - RemoteViews expandedView = new RemoteViews(this.getPackageName(), - R.layout.layout_notification_expanded); - - StringBuffer sbInfo = new StringBuffer(); - - - if (notifyType == NOTIFY_ID) - expandedView.setTextViewText(R.id.text, notifyMsg); - else - { - expandedView.setTextViewText(R.id.info, notifyMsg); - - } - - if (hmBuiltNodes.size() > 0) - { - //sbInfo.append(getString(R.string.your_tor_public_ips_) + '\n'); - - Set<String> itBuiltNodes = hmBuiltNodes.keySet(); - for (String key : itBuiltNodes) - { - Node node = hmBuiltNodes.get(key); - - if (node.ipAddress != null) - { - sbInfo.append(node.ipAddress); - - if (node.country != null) - sbInfo.append(' ').append(node.country); - - if (node.organization != null) - sbInfo.append(" (").append(node.organization).append(')'); - - sbInfo.append('\n'); - } - - } - - expandedView.setTextViewText(R.id.text2, sbInfo.toString()); - } - - expandedView.setTextViewText(R.id.title, getString(R.string.app_name)); - - expandedView.setImageViewResource(R.id.icon, icon); - mNotification.bigContentView = expandedView; - } - - if (prefPersistNotifications && (!mNotificationShowing)) - { - startForeground(NOTIFY_ID, mNotification); - logNotice("Set background service to FOREGROUND"); - } - else - { - mNotificationManager.notify(NOTIFY_ID, mNotification); - } - - mNotificationShowing = true; - } + if (mNotifyBuilder == null) + { + + mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); + + if (mNotifyBuilder == null) + { + mNotifyBuilder = new NotificationCompat.Builder(this) + .setContentTitle(getString(R.string.app_name)) + .setSmallIcon(R.drawable.ic_stat_tor); + + mNotifyBuilder.setContentIntent(pendIntent); + } + + } + + mNotifyBuilder.setContentText(notifyMsg); + mNotifyBuilder.setSmallIcon(icon); + + if (notifyType != NOTIFY_ID) + { + mNotifyBuilder.setTicker(notifyMsg); + // mNotifyBuilder.setLights(Color.GREEN, 1000, 1000); + } + else + { + mNotifyBuilder.setTicker(null); + } + + mNotifyBuilder.setOngoing(prefPersistNotifications); + + mNotification = mNotifyBuilder.build(); + + if (Build.VERSION.SDK_INT >= 16 && mShowExpandedNotifications) { + + + // Create remote view that needs to be set as bigContentView for the notification. + RemoteViews expandedView = new RemoteViews(this.getPackageName(), + R.layout.layout_notification_expanded); + + StringBuffer sbInfo = new StringBuffer(); + + + if (notifyType == NOTIFY_ID) + expandedView.setTextViewText(R.id.text, notifyMsg); + else + { + expandedView.setTextViewText(R.id.info, notifyMsg); + + } + + if (hmBuiltNodes.size() > 0) + { + //sbInfo.append(getString(R.string.your_tor_public_ips_) + '\n'); + + Set<String> itBuiltNodes = hmBuiltNodes.keySet(); + for (String key : itBuiltNodes) + { + Node node = hmBuiltNodes.get(key); + + if (node.ipAddress != null) + { + sbInfo.append(node.ipAddress); + + if (node.country != null) + sbInfo.append(' ').append(node.country); + + if (node.organization != null) + sbInfo.append(" (").append(node.organization).append(')'); + + sbInfo.append('\n'); + } + + } + + expandedView.setTextViewText(R.id.text2, sbInfo.toString()); + } + + expandedView.setTextViewText(R.id.title, getString(R.string.app_name)); + + expandedView.setImageViewResource(R.id.icon, icon); + mNotification.bigContentView = expandedView; + } + + if (prefPersistNotifications && (!mNotificationShowing)) + { + startForeground(NOTIFY_ID, mNotification); + logNotice("Set background service to FOREGROUND"); + } + else + { + mNotificationManager.notify(NOTIFY_ID, mNotification); + } + + mNotificationShowing = true; + }
- /* (non-Javadoc) - * @see android.app.Service#onStart(android.content.Intent, int) - */ - public int onStartCommand(Intent intent, int flags, int startId) { + /* (non-Javadoc) + * @see android.app.Service#onStart(android.content.Intent, int) + */ + public int onStartCommand(Intent intent, int flags, int startId) {
- new Thread (new TorStarter(intent)).start(); - - return START_REDELIVER_INTENT; + new Thread (new TorStarter(intent)).start(); + + return START_REDELIVER_INTENT;
- } - - private class TorStarter implements Runnable - { - Intent mIntent; - - public TorStarter (Intent intent) - { - mIntent = intent; - } - - public void run () - { - try - { - - //if this is a start on boot launch turn tor on - if (mIntent != null) - { - String action = mIntent.getAction(); - - if (action!=null) - { - if(action.equals(Intent.ACTION_BOOT_COMPLETED)||action.equals(CMD_START)) - { - setTorProfile(STATUS_ON); - } - else if (action.equals(CMD_STOP)) - { - setTorProfile(STATUS_OFF); - } - else if (action.equals(CMD_INIT)) - { - initialize(); - sendCallbackStatus(mCurrentStatus); - } - else if (action.equals(CMD_NEWNYM)) - { - newIdentity(); - } - else if (action.equals(CMD_FLUSH)) - { - flushTransparentProxyRules(); - } - else if (action.equals(CMD_UPDATE)) - { - processSettings(); - } - else if (action.equals(CMD_VPN)) - { - startVpnService(); - } - } - } - else - { - Log.d(TAG, "Got null onStartCommand() intent"); - } - - } - catch (Exception e) - { - Log.e(TAG,"error onBind",e); - } - } - } - + } + + private class TorStarter implements Runnable + { + Intent mIntent; + + public TorStarter (Intent intent) + { + mIntent = intent; + } + + public void run (){ + try{ + //if this is a start on boot launch turn tor on + if (mIntent != null){ + String action = mIntent.getAction(); + + if (action!=null){ + if(action.equals(Intent.ACTION_BOOT_COMPLETED)||action.equals(CMD_START)){ + setTorProfile(STATUS_ON); + }else if (action.equals(CMD_STOP)){ + setTorProfile(STATUS_OFF); + }else if (action.equals(CMD_INIT)){ + initialize(); + sendCallbackStatus(mCurrentStatus); + }else if (action.equals(CMD_NEWNYM)){ + newIdentity(); + }else if (action.equals(CMD_FLUSH)){ + flushTransparentProxyRules(); + }else if (action.equals(CMD_UPDATE)){ + processSettings(); + }else if (action.equals(CMD_VPN)){ + startVpnService(); + } + } + }else{ + Log.d(TAG, "Got null onStartCommand() intent"); + } + + }catch (Exception e){ + Log.e(TAG,"error onBind",e); + } + } + } + @Override - public void onTaskRemoved(Intent rootIntent) { - Log.d(TAG,"task removed"); - - Intent intent = new Intent( this, DummyActivity.class ); - intent.addFlags( Intent.FLAG_ACTIVITY_NEW_TASK ); - startActivity( intent ); - } + public void onTaskRemoved(Intent rootIntent){ + Log.d(TAG,"task removed"); + Intent intent = new Intent( this, DummyActivity.class ); + intent.addFlags( Intent.FLAG_ACTIVITY_NEW_TASK ); + startActivity( intent ); + }
@Override - public boolean stopService(Intent name) { - - logNotice("TorService is being stopped: " + name); - - return super.stopService(name); - - } + public boolean stopService(Intent name) { + logNotice("TorService is being stopped: " + name); + return super.stopService(name); + }
- @Override + @Override public void onDestroy () { - String msg = ("TorService is being DESTROYED... shutting down!"); - - Log.d(TAG, msg); - sendCallbackLogMessage(msg); - - unregisterReceiver(mNetworkStateReceiver); - + String msg = ("TorService is being DESTROYED... shutting down!"); + Log.d(TAG, msg); + sendCallbackLogMessage(msg); + unregisterReceiver(mNetworkStateReceiver); clearNotifications (); - - super.onDestroy(); - + super.onDestroy(); }
private void stopTor () diff --cc src/org/torproject/android/ui/ChooseLocaleWizardActivity.java index 1858f66,0000000..6fdd503 mode 100644,000000..100644 --- a/src/org/torproject/android/ui/ChooseLocaleWizardActivity.java +++ b/src/org/torproject/android/ui/ChooseLocaleWizardActivity.java @@@ -1,136 -1,0 +1,136 @@@ +package org.torproject.android.ui; + +import java.util.Locale; + - import org.torproject.android.R; ++import org.sandroproxy.ony.R; +import org.torproject.android.TorConstants; +import org.torproject.android.service.TorServiceUtils; + +import android.app.Activity; +import android.content.Intent; +import android.content.SharedPreferences; +import android.content.SharedPreferences.Editor; +import android.content.res.Configuration; +import android.os.Bundle; +import android.util.Log; +import android.view.KeyEvent; +import android.view.View; +import android.widget.AdapterView; +import android.widget.AdapterView.OnItemClickListener; +import android.widget.ArrayAdapter; +import android.widget.Button; +import android.widget.ListView; +import android.widget.Toast; + +public class ChooseLocaleWizardActivity extends Activity implements TorConstants { + - private int flag = 0; - private ListView listLocales; - - protected void onCreate(Bundle savedInstanceState) - { ++ private int flag = 0; ++ private ListView listLocales; ++ ++ protected void onCreate(Bundle savedInstanceState) ++ { + super.onCreate(savedInstanceState); + - } - - @Override - protected void onStart() { - - super.onStart(); - setContentView(R.layout.layout_wizard_locale); - - - listLocales = (ListView)findViewById(R.id.wizard_locale_list); - Button next = ((Button)findViewById(R.id.btnWizard2)); - // next.setEnabled(false); - - String[] strLangs = getResources().getStringArray(R.array.languages); - strLangs[0] = Locale.getDefault().getDisplayName(); - ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, android.R.id.text1, strLangs); ++ } ++ ++ @Override ++ protected void onStart() { ++ ++ super.onStart(); ++ setContentView(R.layout.layout_wizard_locale); ++ ++ ++ listLocales = (ListView)findViewById(R.id.wizard_locale_list); ++ Button next = ((Button)findViewById(R.id.btnWizard2)); ++ // next.setEnabled(false); ++ ++ String[] strLangs = getResources().getStringArray(R.array.languages); ++ strLangs[0] = Locale.getDefault().getDisplayName(); ++ ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, android.R.id.text1, strLangs); + listLocales.setAdapter(adapter); - - listLocales.setSelection(0); - - - listLocales.setOnItemClickListener(new OnItemClickListener() { - ++ ++ listLocales.setSelection(0); ++ ++ ++ listLocales.setOnItemClickListener(new OnItemClickListener() { ++ + - @Override - public void onItemClick(AdapterView<?> arg0, View arg1, - int arg2, long arg3) { - - setLocalePref(arg2); - finish(); - startActivity(new Intent(ChooseLocaleWizardActivity.this, LotsaText.class)); - - } - }); - - next.setOnClickListener(new View.OnClickListener() { - - public void onClick(View v) { - setLocalePref(0); - finish(); - startActivity(new Intent(ChooseLocaleWizardActivity.this, LotsaText.class)); ++ @Override ++ public void onItemClick(AdapterView<?> arg0, View arg1, ++ int arg2, long arg3) { ++ ++ setLocalePref(arg2); ++ finish(); ++ startActivity(new Intent(ChooseLocaleWizardActivity.this, LotsaText.class)); ++ ++ } ++ }); ++ ++ next.setOnClickListener(new View.OnClickListener() { ++ ++ public void onClick(View v) { ++ setLocalePref(0); ++ finish(); ++ startActivity(new Intent(ChooseLocaleWizardActivity.this, LotsaText.class)); + - } - }); - ++ } ++ }); ++ + - - } - - private void setLocalePref(int selId) - { ++ ++ } ++ ++ private void setLocalePref(int selId) ++ { + - SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext()); ++ SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext()); + + Configuration config = getResources().getConfiguration(); + + String[] localeVals = getResources().getStringArray(R.array.languages_values); + + String lang = localeVals[selId]; + - Editor pEdit = prefs.edit(); - pEdit.putString(PREF_DEFAULT_LOCALE, lang); - pEdit.commit(); - Locale locale = null; - ++ Editor pEdit = prefs.edit(); ++ pEdit.putString(PREF_DEFAULT_LOCALE, lang); ++ pEdit.commit(); ++ Locale locale = null; ++ + if (lang.equals("xx")) + { - locale = Locale.getDefault(); ++ locale = Locale.getDefault(); + + } + else - locale = new Locale(lang); ++ locale = new Locale(lang); + + Locale.setDefault(locale); + config.locale = locale; + getResources().updateConfiguration(config, getResources().getDisplayMetrics()); + + + - - } ++ ++ } + - @Override - protected void onRestoreInstanceState(Bundle savedInstanceState) { - super.onRestoreInstanceState(savedInstanceState); - } ++ @Override ++ protected void onRestoreInstanceState(Bundle savedInstanceState) { ++ super.onRestoreInstanceState(savedInstanceState); ++ } + - @Override - protected void onSaveInstanceState(Bundle outState) { - super.onSaveInstanceState(outState); - - } - - //Code to override the back button! - @Override - public boolean onKeyDown(int keyCode, KeyEvent event) { - if(keyCode == KeyEvent.KEYCODE_BACK){ - Toast.makeText(getApplicationContext(), R.string.wizard_exit_at_first_screen_toast, Toast.LENGTH_SHORT).show(); - return true; - } - return false; - } ++ @Override ++ protected void onSaveInstanceState(Bundle outState) { ++ super.onSaveInstanceState(outState); ++ ++ } ++ ++ //Code to override the back button! ++ @Override ++ public boolean onKeyDown(int keyCode, KeyEvent event) { ++ if(keyCode == KeyEvent.KEYCODE_BACK){ ++ Toast.makeText(getApplicationContext(), R.string.wizard_exit_at_first_screen_toast, Toast.LENGTH_SHORT).show(); ++ return true; ++ } ++ return false; ++ } +} diff --cc src/org/torproject/android/ui/LotsaText.java index 5fdaa57,0000000..1601fe6 mode 100644,000000..100644 --- a/src/org/torproject/android/ui/LotsaText.java +++ b/src/org/torproject/android/ui/LotsaText.java @@@ -1,137 -1,0 +1,137 @@@ +package org.torproject.android.ui; + - import org.torproject.android.R; ++import org.sandroproxy.ony.R; +import org.torproject.android.TorConstants; +import org.torproject.android.service.TorServiceUtils; + +import android.app.Activity; +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.content.SharedPreferences.Editor; +import android.os.Bundle; +import android.view.KeyEvent; +import android.view.View; +import android.widget.Button; +import android.widget.TextView; + +public class LotsaText extends Activity implements TorConstants{ + + private Context context; + + protected void onCreate(Bundle savedInstanceState) + { + + + super.onCreate(savedInstanceState); + context = this; + + + } + + @Override + protected void onStart() { + + super.onStart(); + setContentView(R.layout.scrollingtext_buttons_view); + + SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext()); + + boolean wizardScreen1 = prefs.getBoolean("wizardscreen1",true); + if(wizardScreen1) + stepOne(); + else + stepTwo(); + + } + + @Override + protected void onResume() { + super.onResume(); + + + } + + private void stepOne() { + + SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext()); + + Editor pEdit = prefs.edit(); + pEdit.putBoolean("wizardscreen1",true); + pEdit.commit(); + + String title = context.getString(R.string.wizard_title); + String msg = context.getString(R.string.wizard_title_msg); + + setTitle(title); + + TextView txtBody = ((TextView)findViewById(R.id.WizardTextBody)); + txtBody.setText(msg); + + Button btn1 = ((Button)findViewById(R.id.btnWizard1)); + Button btn2 = ((Button)findViewById(R.id.btnWizard2)); + + btn1.setVisibility(Button.INVISIBLE); + + btn2.setOnClickListener(new View.OnClickListener() { + + public void onClick(View v) { + stepTwo(); + } + }); + + } + + private void stepTwo() { + + SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext()); + + Editor pEdit = prefs.edit(); + pEdit.putBoolean("wizardscreen1",false); + pEdit.commit(); + + setContentView(R.layout.scrollingtext_buttons_view); + String title = context.getString(R.string.wizard_warning_title); + String msg = context.getString(R.string.wizard_warning_msg); + + setTitle(title); + + TextView txtBody = ((TextView)findViewById(R.id.WizardTextBody)); + txtBody.setText(msg); + + Button btn1 = ((Button)findViewById(R.id.btnWizard1)); + Button btn2 = ((Button)findViewById(R.id.btnWizard2)); + + btn1.setVisibility(Button.VISIBLE); + + + btn1.setOnClickListener(new View.OnClickListener() { + + public void onClick(View v) { + + stepOne(); + } + }); + + btn2.setOnClickListener(new View.OnClickListener() { + + public void onClick(View v) { + finish(); + startActivity(new Intent(LotsaText.this, TipsAndTricks.class)); + } + }); + + } + + //Code to override the back button! + @Override + public boolean onKeyDown(int keyCode, KeyEvent event) { + if(keyCode == KeyEvent.KEYCODE_BACK){ + finish(); + startActivity(new Intent(getBaseContext(), ChooseLocaleWizardActivity.class)); + return true; + } + return true; + } + +} diff --cc src/org/torproject/android/ui/OrbotDiagnosticsActivity.java index 3f72d16,0000000..685093a mode 100644,000000..100644 --- a/src/org/torproject/android/ui/OrbotDiagnosticsActivity.java +++ b/src/org/torproject/android/ui/OrbotDiagnosticsActivity.java @@@ -1,337 -1,0 +1,338 @@@ +package org.torproject.android.ui; + +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.ArrayList; + ++import org.sandroproxy.ony.R; +import org.sufficientlysecure.rootcommands.Shell; +import org.sufficientlysecure.rootcommands.command.SimpleCommand; +import org.torproject.android.R; +import org.torproject.android.R.id; +import org.torproject.android.R.layout; +import org.torproject.android.R.menu; +import org.torproject.android.R.raw; +import org.torproject.android.service.TorResourceInstaller; +import org.torproject.android.service.TorServiceConstants; + +import android.app.Activity; +import android.content.Context; +import android.content.Intent; +import android.os.Bundle; +import android.os.Environment; +import android.os.Handler; +import android.os.Message; +import android.os.StatFs; +import android.text.format.Formatter; +import android.util.Log; +import android.view.Menu; +import android.view.MenuItem; +import android.widget.TextView; + + +public class OrbotDiagnosticsActivity extends Activity { + + private TextView mTextView = null; + private final static String TAG = "OrbotDiag"; + private StringBuffer log = new StringBuffer(); + Process mProcess; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + setContentView(R.layout.layout_diag); + + mTextView = (TextView)findViewById(R.id.diaglog); + + } + + private String getFreeStorage () + { + File path = Environment.getDataDirectory(); + StatFs stat = new StatFs(path.getPath()); + long blockSize = stat.getBlockSize(); + long availableBlocks = stat.getAvailableBlocks(); + return Formatter.formatFileSize(this, availableBlocks * blockSize); + } + + @Override + protected void onPause() { + super.onPause(); + + stopTor(); + } + + @Override + protected void onDestroy() { + + super.onDestroy(); + + } + + private void stopTor () + { + File appBinHome = this.getDir("bin", Context.MODE_PRIVATE); + + File fileTor= new File(appBinHome, TorServiceConstants.TOR_ASSET_KEY); + + if (mProcess != null) + mProcess.destroy(); + + + } + + + + @Override + protected void onResume() { + super.onResume(); + + + log("Hello, Orbot!"); + + try + { + log(android.os.Build.DEVICE); + log(android.os.Build.HARDWARE); + log(android.os.Build.MANUFACTURER); + log(android.os.Build.MODEL); + log(android.os.Build.VERSION.CODENAME); + log(android.os.Build.VERSION.RELEASE); + } + catch (Exception e) + { + log("error getting device info"); + } + + showFileTree (); + + runTorTest(); + } + + private void runTorTest () + { + try + { + File appBinHome = this.getDir("bin", Context.MODE_PRIVATE); + File appDataHome = this.getDir("data", Context.MODE_PRIVATE); + + File fileTor= new File(appBinHome, TorServiceConstants.TOR_ASSET_KEY); + enableBinExec (fileTor, appBinHome); + + InputStream is = getResources().openRawResource(R.raw.torrc); + File fileTorrc = new File(appBinHome, TorServiceConstants.TORRC_ASSET_KEY + "diag"); + TorResourceInstaller.streamToFile(is,fileTorrc, false, false); + + /** + ArrayList<String> alEnv = new ArrayList<String>(); + alEnv.add("HOME=" + appBinHome.getAbsolutePath()); + Shell shell = Shell.startShell(alEnv,appBinHome.getAbsolutePath()); + SimpleCommand cmdTor = new SimpleCommand(fileTor.getAbsolutePath() + " DataDirectory " + appDataHome.getAbsolutePath() + " -f " + fileTorrc.getAbsolutePath()); + shell.add(cmdTor); + **/ + + String cmd = fileTor.getAbsolutePath() + " DataDirectory " + appDataHome.getAbsolutePath() + " -f " + fileTorrc.getAbsolutePath(); + + log ("Executing command> " + cmd); + + mProcess = Runtime.getRuntime().exec(cmd); + + BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(mProcess.getInputStream())); + StreamGobbler sg = new StreamGobbler(); + sg.reader = bufferedReader; + sg.process = mProcess; + new Thread(sg).start(); + + if (mProcess.getErrorStream() != null) + { + bufferedReader = new BufferedReader(new InputStreamReader(mProcess.getErrorStream())); + sg = new StreamGobbler(); + sg.reader = bufferedReader; + sg.process = mProcess; + new Thread(sg).start(); + } + + + } + catch (Exception e) + { + Log.d(TAG,"runTorTest exception",e); + } + + } + + class StreamGobbler implements Runnable + { + BufferedReader reader; + Process process; + + public void run () + { + String line = null; + try { + while ( (line = reader.readLine()) != null) + { + Message msg = mHandler.obtainMessage(0); + msg.getData().putString("log", line); + mHandler.sendMessage(msg); + } + + } catch (IOException e) { + Log.d(TAG, "error reading line",e); + } + + //log("Tor exit code=" + process.exitValue() + ";"); + + } + } + + private boolean enableBinExec (File fileBin, File appBinHome) throws Exception + { + + log(fileBin.getName() + ": PRE: Is binary exec? " + fileBin.canExecute()); + + if (!fileBin.canExecute()) + { + log("(re)Setting permission on binary: " + fileBin.getAbsolutePath()); + Shell shell = Shell.startShell(new ArrayList<String>(), appBinHome.getAbsolutePath()); + + shell.add(new SimpleCommand("chmod " + TorServiceConstants.CHMOD_EXE_VALUE + ' ' + fileBin.getAbsolutePath())).waitForFinish(); + + File fileTest = new File(fileBin.getAbsolutePath()); + log(fileTest.getName() + ": POST: Is binary exec? " + fileTest.canExecute()); + + shell.close(); + } + + return fileBin.canExecute(); + } + + private void showFileTree () + { + + File fileDir = this.getDir("bin", Context.MODE_PRIVATE); + + if (fileDir.exists()) + { + log("checking file tree: " + fileDir.getAbsolutePath()); + printDir (fileDir.getName(), fileDir); + } + else + { + log("app_bin does not exist"); + } + + fileDir = this.getDir("data", Context.MODE_PRIVATE); + if (fileDir.exists()) + { + log("checking file tree: " + fileDir.getAbsolutePath()); + printDir (fileDir.getName(), fileDir); + } + else + { + log ("app_data does not exist"); + } + + + } + + private void printDir (String path, File fileDir) + { + File[] files = fileDir.listFiles(); + + if (files != null && files.length > 0) + { + for (File file : files) + { + + try + { + if (file.isDirectory()) + { + printDir(path + '/' + file.getName(), file); + } + else + { + log(path + '/' + file.getName() + " len:" + file.length() + " exec:" + file.canExecute()); + + } + } + catch (Exception e) + { + log("problem printing out file information"); + } + + } + } + } + + Handler mHandler = new Handler () + { + + @Override + public void handleMessage(Message msg) { + + super.handleMessage(msg); + + String logMsg = msg.getData().getString("log"); + log(logMsg); + } + + }; + + private void log (String msg) + { + Log.d(TAG, msg); + mTextView.append(msg + '\n'); + log.append(msg + '\n'); + } + + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate menu resource file. + getMenuInflater().inflate(R.menu.share_menu, menu); + + // Locate MenuItem with ShareActionProvider + MenuItem item = menu.findItem(R.id.menu_item_share); + + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + + case R.id.menu_item_share: + sendLog(); + return true; + + default: + return super.onOptionsItemSelected(item); + } + } + + private void sendLog () + { + int maxLength = 5000; + + String logShare = null; + + if (log.length() > maxLength) + logShare = log.substring(0, maxLength); + else + logShare = log.toString(); + + Intent sendIntent = new Intent(); + sendIntent.setAction(Intent.ACTION_SEND); + sendIntent.putExtra(Intent.EXTRA_TEXT, logShare); + sendIntent.setType("text/plain"); + startActivity(sendIntent); + } + + +} diff --cc src/org/torproject/android/ui/TipsAndTricks.java index 33548f4,0000000..5bf3cd6 mode 100644,000000..100644 --- a/src/org/torproject/android/ui/TipsAndTricks.java +++ b/src/org/torproject/android/ui/TipsAndTricks.java @@@ -1,248 -1,0 +1,244 @@@ +package org.torproject.android.ui; + +import org.torproject.android.OrbotMainActivity; +import org.torproject.android.R; +import org.torproject.android.TorConstants; + +import android.app.Activity; +import android.content.Intent; +import android.net.Uri; +import android.os.Bundle; +import android.util.Log; +import android.view.KeyEvent; +import android.view.View; +import android.view.View.OnClickListener; +import android.widget.Button; +import android.widget.TextView; + +public class TipsAndTricks extends Activity implements TorConstants { + - protected void onCreate(Bundle savedInstanceState) - { ++ protected void onCreate(Bundle savedInstanceState) ++ { + super.onCreate(savedInstanceState); + - } - - @Override - protected void onStart() { - - super.onStart(); - setContentView(R.layout.layout_wizard_tips); - - stepFive(); ++ } ++ ++ @Override ++ protected void onStart() { + - } - - @Override - protected void onResume() { - super.onResume(); - - - } ++ super.onStart(); ++ setContentView(R.layout.layout_wizard_tips); ++ ++ stepFive(); ++ ++ } ++ ++ @Override ++ protected void onResume() { ++ super.onResume(); ++ ++ ++ } + - void stepFive(){ - - - String title = getString(R.string.wizard_tips_title); - - setTitle(title); - ++ void stepFive(){ ++ ++ ++ String title = getString(R.string.wizard_tips_title); ++ ++ setTitle(title); ++ + Button btnLink = (Button)findViewById(R.id.WizardRootButtonInstallGibberbot); + + btnLink.setOnClickListener(new OnClickListener() { - - public void onClick(View view) { ++ ++ public void onClick(View view) { + - String url = getString(R.string.gibberbot_apk_url); - finish(); - startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); ++ String url = getString(R.string.gibberbot_apk_url); ++ finish(); ++ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); + - } - }); ++ } ++ }); + + btnLink = (Button)findViewById(R.id.WizardRootButtonInstallOrweb); + + btnLink.setOnClickListener(new OnClickListener() { - - public void onClick(View view) { - - String url = getString(R.string.orweb_apk_url); - finish(); - startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); ++ ++ public void onClick(View view) { ++ ++ String url = getString(R.string.orweb_apk_url); ++ finish(); ++ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); + - } - }); ++ } ++ }); + + btnLink = (Button)findViewById(R.id.WizardRootButtonInstallDuckgo); + + btnLink.setOnClickListener(new OnClickListener() { - - public void onClick(View view) { - - String url = getString(R.string.duckgo_apk_url); - finish(); - startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); ++ ++ public void onClick(View view) { ++ ++ String url = getString(R.string.duckgo_apk_url); ++ finish(); ++ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); + - } - }); ++ } ++ }); + + btnLink = (Button)findViewById(R.id.WizardRootButtonInstallFirefox); + + btnLink.setOnClickListener(new OnClickListener() { - - public void onClick(View view) { - - String url = getString(R.string.proxymob_setup_url); - finish(); - startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); ++ ++ public void onClick(View view) { ++ ++ String url = getString(R.string.proxymob_setup_url); ++ finish(); ++ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); + - } - }); ++ } ++ }); + + btnLink = (Button)findViewById(R.id.WizardRootButtonInstallTwitter); + + btnLink.setOnClickListener(new OnClickListener() { - - public void onClick(View view) { - - String url = getString(R.string.twitter_setup_url); - finish(); - startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); ++ ++ public void onClick(View view) { ++ ++ String url = getString(R.string.twitter_setup_url); ++ finish(); ++ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); + - } - }); ++ } ++ }); + + btnLink = (Button)findViewById(R.id.WizardRootButtonInstallStoryMaker); + + btnLink.setOnClickListener(new OnClickListener() { - - public void onClick(View view) { - - String url = getString(R.string.story_maker_url); - startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); ++ ++ public void onClick(View view) { ++ ++ String url = getString(R.string.story_maker_url); ++ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); + - } - }); ++ } ++ }); + + btnLink = (Button)findViewById(R.id.WizardRootButtonInstallMartus); + + btnLink.setOnClickListener(new OnClickListener() { - - public void onClick(View view) { - - String url = getString(R.string.martus_url); - startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); ++ ++ public void onClick(View view) { ++ ++ String url = getString(R.string.martus_url); ++ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); + - } - }); ++ } ++ }); + + + btnLink = (Button)findViewById(R.id.WizardRootButtonGooglePlay); + + btnLink.setOnClickListener(new OnClickListener() { - - public void onClick(View view) { - - String url = getString(R.string.wizard_tips_play_url); - startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); ++ ++ public void onClick(View view) { ++ ++ String url = getString(R.string.wizard_tips_play_url); ++ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); + - } - }); ++ } ++ }); + + + Button back = ((Button)findViewById(R.id.btnWizard1)); + Button next = ((Button)findViewById(R.id.btnWizard2)); + + back.setOnClickListener(new View.OnClickListener() { + + public void onClick(View v) { + finish(); + startActivityForResult(new Intent(TipsAndTricks.this, LotsaText.class), 1); + } + }); + + next.setOnClickListener(new View.OnClickListener() { + + public void onClick(View v) { + showWizardFinal(); + } + }); + + } + + private void showWizardFinal () + { + setContentView(R.layout.scrollingtext_buttons_view); + String title = getString(R.string.wizard_final); + String msg = getString(R.string.wizard_final_msg); + + setTitle(title); + + TextView txtBody = ((TextView)findViewById(R.id.WizardTextBody)); - txtBody.setText(msg); - ++ txtBody.setText(msg); ++ + Button btn1 = ((Button)findViewById(R.id.btnWizard1)); + Button btn2 = ((Button)findViewById(R.id.btnWizard2)); + + btn2.setText(getString(R.string.btn_finish)); + btn1.setVisibility(Button.VISIBLE); + + btn1.setOnClickListener(new View.OnClickListener() { + + public void onClick(View v) { + finish(); + startActivity(new Intent(TipsAndTricks.this, LotsaText.class)); + } + }); + + btn2.setOnClickListener(new View.OnClickListener() { + + public void onClick(View v) { + finish(); + } + }); + } + + //Code to override the back button! + @Override + public boolean onKeyDown(int keyCode, KeyEvent event) { + if(keyCode == KeyEvent.KEYCODE_BACK){ + finish(); + startActivity(new Intent(getBaseContext(), LotsaText.class)); + return true; + } + return false; + } + + /* + private void showWizardFinal () + { + String title = null; + String msg = null; + + + title = context.getString(R.string.wizard_final); + msg = context.getString(R.string.wizard_final_msg); + + DialogInterface.OnClickListener ocListener = new DialogInterface.OnClickListener() { + + @Override + public void onClick(DialogInterface dialog, int which) { + context.startActivity(new Intent(context, Orbot.class)); + + } + }; + + + new AlertDialog.Builder(context) + .setIcon(R.drawable.icon) + .setTitle(title) + .setPositiveButton(R.string.button_close, ocListener) + .setMessage(msg) + .show(); - - - - - }*/ - } ++ }*/ ++} diff --cc src/org/torproject/android/vpn/OrbotVpnService.java index e5b9668,66d22b8..483529a --- a/src/org/torproject/android/vpn/OrbotVpnService.java +++ b/src/org/torproject/android/vpn/OrbotVpnService.java @@@ -63,41 -90,46 +89,61 @@@ public class OrbotVpnService extends Vp // Stop the previous session by interrupting the thread. if (mThreadVPN == null || (!mThreadVPN.isAlive())) { - enableAppRouting (); - startSocksBypass (); - setupTun2Socks(); ++ enableAppRouting (); + setupTun2Socks(); }
return START_STICKY; }
+ private void enableAppRouting () + { + + boolean isLollipop = false; + + if (isLollipop) + { + //allow for specific apps to be sent through VPN based on list selection + } + else + { + //do socks bypass trick + } + } + + private void startSocksBypass(){ + mThreadProxy = new Thread () + { + public void run () + { + + try { + mProxyServer = new ProxyServer(new ServerAuthenticatorNone(null, null)); + ProxyServer.setVpnService(OrbotVpnService.this); + mProxyServer.start(mSocksProxyPort, 5, InetAddress.getLocalHost()); + } catch (Exception e) { + Log.d(TAG,"proxy server error: " + e.getLocalizedMessage(),e); + } + } + }; + + mThreadProxy.start(); + } + @Override public void onDestroy() { - - - - if (mInterface != null) - try { - mInterface.close(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } + if (mProxyServer != null){ + mProxyServer.stop(); + } + if (mInterface != null){ + try { + mInterface.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } }
@Override @@@ -111,161 -143,158 +157,81 @@@
private void setupTun2Socks() {
- mThreadVPN = new Thread () - { - - public void run () - { - if (mInterface == null) - { - // Set the locale to English (or probably any other language that^M - // uses Hindu-Arabic (aka Latin) numerals).^M - // We have found that VpnService.Builder does something locale-dependent^M - // internally that causes errors when the locale uses its own numerals^M - // (i.e., Farsi and Arabic).^M - Locale.setDefault(new Locale("en")); - - Builder builder = new Builder(); - - builder.setMtu(VPN_MTU); - builder.addAddress("10.0.0.1",28); - builder.setSession("DrobotVPN"); - builder.addRoute("0.0.0.0",0); - //builder.addRoute("192.0.0.0",8); - //builder.addRoute("192.168.43.0",8); - - // Create a new interface using the builder and save the parameters. - mInterface = builder.setSession(mSessionName) - .setConfigureIntent(mConfigureIntent) - .establish(); - - try - { - Tun2Socks.Start(mInterface, - VPN_MTU, - "10.0.0.2", - "255.255.255.0", - "127.0.0.1:" + TorServiceConstants.PORT_SOCKS_DEFAULT, - "10.0.0.1:" + String.valueOf(TorServiceConstants.TOR_DNS_PORT_DEFAULT), - true); - - } - catch (Exception e) - { - Log.d(TAG,"tun2Socks has stopped",e); - } - } - } - }; - mThreadVPN.start(); - showToolbarNotification(getString(R.string.status_activated), NOTIFY_ID, R.drawable.ic_stat_tor); + mThreadVPN = new Thread () + { + + public void run () + { + if (mInterface == null) + { + // Set the locale to English (or probably any other language that^M + // uses Hindu-Arabic (aka Latin) numerals).^M + // We have found that VpnService.Builder does something locale-dependent^M + // internally that causes errors when the locale uses its own numerals^M + // (i.e., Farsi and Arabic).^M + Locale.setDefault(new Locale("en")); + + String vpnName = "OrbotVPN"; + String virtualGateway = "10.0.0.1"; + String virtualRoute = "10.0.0.0"; + String virtualIP = "10.0.0.2"; + String virtualNetMask = "255.255.2555.0"; + String localSocks = "localhost:" + TorServiceConstants.PORT_SOCKS_DEFAULT; + String localDNS = "localhost:" + TorServiceConstants.TOR_DNS_PORT_DEFAULT; + + + Builder builder = new Builder(); + + builder.setMtu(VPN_MTU); + builder.addAddress(virtualGateway,8); + builder.setSession(vpnName); + + builder.addRoute("0.0.0.0",0); + builder.addRoute(virtualRoute,8); + + //builder.addDnsServer("8.8.8.8"); + + // Create a new interface using the builder and save the parameters. + mInterface = builder.setSession(mSessionName) + .setConfigureIntent(mConfigureIntent) + .establish(); + + try + { + Tun2Socks.Start(mInterface, VPN_MTU, virtualIP, virtualNetMask, localSocks , localDNS , true); + } + catch (Exception e) + { + Log.d(TAG,"tun2Socks has stopped",e); + } + } + } + }; + + mThreadVPN.start(); }
- @Override - public void onRevoke() { - - new Thread () - { - public void run() - { - try - { - mInterface.close(); - Tun2Socks.Stop(); - } - catch (Exception e) - { - Log.d(TAG,"error stopping tun2socks",e); - } - } - }.start(); - - super.onRevoke(); - - } + @Override + public void onRevoke() { + + new Thread () + { + public void run() + { + try + { + mInterface.close(); + Tun2Socks.Stop(); + } + catch (Exception e) + { + Log.d(TAG,"error stopping tun2socks",e); + } + } + }.start(); + clearNotifications(); + super.onRevoke(); + } + - private void clearNotifications() - { - if (mNotificationManager != null) - mNotificationManager.cancelAll(); - mNotificationShowing = false; - - } -
- /* - private void debugPacket(ByteBuffer packet) - {b - - int buffer = packet.get(); - int version; - int headerlength; - version = buffer >> 4; - headerlength = buffer & 0x0F; - headerlength *= 4; - Log.d(TAG, "IP Version:"+version); - Log.d(TAG, "Header Length:"+headerlength); - - String status = ""; - status += "Header Length:"+headerlength; - - buffer = packet.get(); //DSCP + EN - buffer = packet.getChar(); //Total Length - - Log.d(TAG, "Total Length:"+buffer); - - buffer = packet.getChar(); //Identification - Log.d(TAG, "Identification:"+buffer); - - buffer = packet.getChar(); //Flags + Fragment Offset - buffer = packet.get(); //Time to Live - buffer = packet.get(); //Protocol - - Log.d(TAG, "Protocol:"+buffer); - - status += " Protocol:"+buffer; - - buffer = packet.getChar(); //Header checksum - - String sourceIP = ""; - buffer = packet.get(); //Source IP 1st Octet - sourceIP += buffer; - sourceIP += "."; - - buffer = packet.get(); //Source IP 2nd Octet - sourceIP += buffer; - sourceIP += "."; - - buffer = packet.get(); //Source IP 3rd Octet - sourceIP += buffer; - sourceIP += "."; - - buffer = packet.get(); //Source IP 4th Octet - sourceIP += buffer; - - Log.d(TAG, "Source IP:"+sourceIP); - - status += " Source IP:"+sourceIP; - - String destIP = ""; - buffer = packet.get(); //Destination IP 1st Octet - destIP += buffer; - destIP += "."; - - buffer = packet.get(); //Destination IP 2nd Octet - destIP += buffer; - destIP += "."; - - buffer = packet.get(); //Destination IP 3rd Octet - destIP += buffer; - destIP += "."; - - buffer = packet.get(); //Destination IP 4th Octet - destIP += buffer; - - Log.d(TAG, "Destination IP:"+destIP); - - status += " Destination IP:"+destIP; - - //Log.d(TAG, "version:"+packet.getInt()); - //Log.d(TAG, "version:"+packet.getInt()); - //Log.d(TAG, "version:"+packet.getInt()); - - }*/ - - @SuppressLint("NewApi") - private void showToolbarNotification (String notifyMsg, int notifyType, int icon) - { - - //Reusable code. - Intent intent = new Intent(OrbotVpnService.this, Orbot.class); - PendingIntent pendIntent = PendingIntent.getActivity(OrbotVpnService.this, 0, intent, 0); - - if (mNotifyBuilder == null) - { - - mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); - - if (mNotifyBuilder == null) - { - mNotifyBuilder = new NotificationCompat.Builder(this) - .setContentTitle(getString(R.string.app_name)) - .setSmallIcon(R.drawable.ic_stat_tor); - mNotifyBuilder.setContentIntent(pendIntent); - } - } - - mNotifyBuilder.setContentText(notifyMsg); - mNotifyBuilder.setSmallIcon(icon); - - if (notifyType != NOTIFY_ID) - { - mNotifyBuilder.setTicker(notifyMsg); - // mNotifyBuilder.setLights(Color.GREEN, 1000, 1000); - } - else - { - mNotifyBuilder.setTicker(null); - } - - mNotifyBuilder.setOngoing(prefPersistNotifications); - - mNotification = mNotifyBuilder.build(); - - if (Build.VERSION.SDK_INT >= 16 && mShowExpandedNotifications) { - - - // Create remote view that needs to be set as bigContentView for the notification. - RemoteViews expandedView = new RemoteViews(this.getPackageName(), - R.layout.layout_notification_expanded); - - StringBuffer sbInfo = new StringBuffer(); - - - if (notifyType == NOTIFY_ID) - expandedView.setTextViewText(R.id.text, notifyMsg); - else - { - expandedView.setTextViewText(R.id.info, notifyMsg); - - } - expandedView.setTextViewText(R.id.title, getString(R.string.app_name)); - - expandedView.setImageViewResource(R.id.icon, icon); - mNotification.bigContentView = expandedView; - } - - if (prefPersistNotifications && (!mNotificationShowing)) - { - startForeground(NOTIFY_ID, mNotification); - } - else - { - mNotificationManager.notify(NOTIFY_ID, mNotification); - } - - mNotificationShowing = true; - } }