{"id":254266,"date":"2013-10-10T19:03:24","date_gmt":"2013-10-10T11:03:24","guid":{"rendered":"http:\/\/blog.zhenglei.net\/?p=254266"},"modified":"2013-10-25T17:14:03","modified_gmt":"2013-10-25T09:14:03","slug":"download-android-source-code-over-ssh","status":"publish","type":"post","link":"https:\/\/blog.zhenglei.net\/?p=254266","title":{"rendered":"Download android source code over SSH"},"content":{"rendered":"<p>1) Install http proxy with socks support<br \/>\n<strong>sudo apt-get install privoxy<\/strong><\/p>\n<p>2) Install DNS cache server<br \/>\n<strong>sudo apt-get install dnsmasq<\/strong><\/p>\n<p>3) Install DNS socks proxy<br \/>\n<strong>git clone https:\/\/github.com\/jtRIPper\/dns-tcp-socks-proxy.git<br \/>\ncd dns-tcp-socks-proxy<br \/>\nmake<\/strong><\/p>\n<p>4) Setup ssh connection to the external server, and listen on port 127.0.0.1:4567 (any one free)<\/p>\n<p><strong>ssh -p proto -D4567 user@ssh_server<\/strong><\/p>\n<p>5) Config privoxy listen on 127.0.0.1:8080,  and forward to ssh socks at 127.0.0.1:4567:<\/p>\n<p><strong>cat \/etc\/privoxy\/config <\/strong><br \/>\n<em> listen-address 127.0.0.1:8080<br \/>\nforward-socks5 \/ 127.0.0.1:4567  .<\/p>\n<p>forward 192.168.*.*\/  .<br \/>\nforward 10.*.*.*\/  .<br \/>\nforward 127.*.*.*\/  .<br \/>\n<\/em><\/p>\n<p>6) Config dnsmasq with upstream server point to dns-tcp-socks-proxy first<\/p>\n<p><strong>cat \/etc\/dnsmasq.conf<\/strong><\/p>\n<p><em>resolv-file=\/etc\/resolv-dnsmasq.conf<br \/>\nstrict-order<br \/>\nserver=\/221.24.172.in-addr.arpa\/internal_dns_ip<br \/>\nserver=\/61.24.172.in-addr.arpa\/internal_dns_ip<br \/>\nserver=\/62.24.172.in-addr.arpa\/internal_dns_ip<br \/>\nserver=\/63.24.172.in-addr.arpa\/internal_dns_ip<br \/>\ninterface=eth0<br \/>\nbind-interfaces<br \/>\nlog-queries<br \/>\nlog-dhcp<\/em><\/p>\n<p>With such configuration, dnsmasq will listen on eth0 interface and 127.0.0.1, and forward the query to the DNS resolver defined in \/etc\/resolv-dnsmasq.conf.<br \/>\nthe strict-order directory force dnsmasq to select the dns server according to the order of item defined in \/etc\/resolv-dnsmasq.conf<\/p>\n<p><strong>cat \/etc\/resolv-dnsmasq.conf <\/strong><br \/>\n<em>nameserver 127.0.0.2<br \/>\nnameserver 172.24.63.211<br \/>\nnameserver 172.24.63.212<\/em><\/p>\n<p>7) Config dns-tcp-socks-proxy listen to dnsmasq, and forward the query to the ssh socks, here 127.0.0.1:4567<\/p>\n<p><strong>cat dns_proxy.conf<\/strong><br \/>\n<em>socks_port = 4567<br \/>\nsocks_addr = 127.0.0.1<\/p>\n<p>listen_addr = 127.0.0.2<br \/>\nlisten_port = 53<\/p>\n<p>set_user = nobody<br \/>\nset_group = nobody<\/p>\n<p>resolv_conf = \/etc\/dns_proxy\/resolv.txt<br \/>\nlog_file = \/dev\/null<br \/>\n<\/em><\/p>\n<p>8) Config the local dns resolver to 127.0.0.1<br \/>\n<strong>cat \/etc\/resolv.conf<\/strong><br \/>\n<em>nameserver 127.0.0.1<\/em><\/p>\n<p>9) Sync android source code over SSH<br \/>\n<strong>repo sync<\/strong><\/p>\n<p>10) Note, with such configuration, we have:<br \/>\nhttp\/https local proxy at 127.0.0.1:8080,  forward to the external server via socks<br \/>\ndns local cache proxy at 127.0.0.1:53,   forward to the external server vis socks<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1) Install http proxy with socks support &hellip; <a href=\"https:\/\/blog.zhenglei.net\/?p=254266\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,2],"tags":[],"class_list":["post-254266","post","type-post","status-publish","format-standard","hentry","category-android","category-linux"],"_links":{"self":[{"href":"https:\/\/blog.zhenglei.net\/index.php?rest_route=\/wp\/v2\/posts\/254266","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.zhenglei.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.zhenglei.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.zhenglei.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.zhenglei.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=254266"}],"version-history":[{"count":11,"href":"https:\/\/blog.zhenglei.net\/index.php?rest_route=\/wp\/v2\/posts\/254266\/revisions"}],"predecessor-version":[{"id":254290,"href":"https:\/\/blog.zhenglei.net\/index.php?rest_route=\/wp\/v2\/posts\/254266\/revisions\/254290"}],"wp:attachment":[{"href":"https:\/\/blog.zhenglei.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=254266"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.zhenglei.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=254266"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.zhenglei.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=254266"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}