├── README.md ├── onionviewer ├── models.py ├── onion-viewer.py ├── static │ ├── bootstrap │ │ ├── css │ │ │ ├── bootstrap-theme.css │ │ │ ├── bootstrap-theme.css.map │ │ │ ├── bootstrap-theme.min.css │ │ │ ├── bootstrap.css │ │ │ ├── bootstrap.css.map │ │ │ └── bootstrap.min.css │ │ ├── fonts │ │ │ ├── glyphicons-halflings-regular.eot │ │ │ ├── glyphicons-halflings-regular.svg │ │ │ ├── glyphicons-halflings-regular.ttf │ │ │ └── glyphicons-halflings-regular.woff │ │ └── js │ │ │ ├── bootstrap.js │ │ │ └── bootstrap.min.js │ └── js │ │ └── jquery.min.js └── templates │ ├── base.html │ ├── index.html │ ├── onion_address.html │ └── overview.html ├── patched tor └── tor-0.2.6.1-alpha │ ├── ChangeLog │ ├── Doxyfile.in │ ├── INSTALL │ ├── LICENSE │ ├── Makefile.am │ ├── Makefile.in │ ├── Makefile.nmake │ ├── README │ ├── ReleaseNotes │ ├── acinclude.m4 │ ├── aclocal.m4 │ ├── autogen.sh │ ├── autom4te.cache │ ├── output.0 │ ├── output.1 │ ├── requests │ ├── traces.0 │ └── traces.1 │ ├── changes │ ├── 12207 │ ├── bufferevent_compilation │ ├── bug10116 │ ├── bug1038-3 │ ├── bug11200-caching │ ├── bug11302 │ ├── bug11683 │ ├── bug11787 │ ├── bug11792 │ ├── bug12061 │ ├── bug12160 │ ├── bug12202 │ ├── bug12205 │ ├── bug12392 │ ├── bug12503 │ ├── bug12573 │ ├── bug12602 │ ├── bug12700 │ ├── bug12718 │ ├── bug12728 │ ├── bug12730-systemd-verify-config │ ├── bug12731-systemd-no-run-as-daemon │ ├── bug12751-systemd-filesystem-sandbox │ ├── bug12830 │ ├── bug12848 │ ├── bug12855 │ ├── bug12864 │ ├── bug12878 │ ├── bug12899 │ ├── bug12908 │ ├── bug12939-systemd-no-new-privileges │ ├── bug12948 │ ├── bug12996 │ ├── bug12997 │ ├── bug13000 │ ├── bug13060 │ ├── bug13064 │ ├── bug13071 │ ├── bug13081 │ ├── bug13085 │ ├── bug13102 │ ├── bug8387 │ ├── bug9801 │ ├── check_dup_args_gencert │ ├── coverage-html │ ├── crash_handler_in_tests │ ├── curve25519-donna32-bug │ ├── feature5583 │ ├── further-12184-diagnostic │ ├── geoip-august2014 │ ├── geoip-july2014 │ ├── geoip6-august2014 │ ├── geoip6-july2014 │ ├── no-wince │ ├── prop215 │ ├── test.h_msvc │ ├── threads-required │ ├── ticket12688 │ ├── ticket12690 │ └── ticket13036 │ ├── compile │ ├── config.guess │ ├── config.sub │ ├── configure │ ├── configure.ac │ ├── contrib │ ├── README │ ├── client-tools │ │ ├── tor-resolve.py │ │ └── torify │ ├── dirauth-tools │ │ ├── add-tor │ │ └── nagios-check-tor-authority-cert │ ├── dist │ │ ├── rc.subr │ │ ├── suse │ │ │ └── tor.sh.in │ │ ├── tor.service.in │ │ ├── tor.sh.in │ │ └── torctl.in │ ├── include.am │ ├── operator-tools │ │ ├── linux-tor-prio.sh │ │ ├── tor-exit-notice.html │ │ └── tor.logrotate.in │ ├── or-tools │ │ ├── check-tor │ │ ├── checksocks.pl │ │ └── exitlist │ └── win32build │ │ ├── package_nsis-mingw.sh │ │ ├── tor-mingw.nsi.in │ │ ├── tor.ico │ │ └── tor.nsi.in │ ├── depcomp │ ├── doc │ ├── HACKING │ ├── asciidoc-helper.sh │ ├── building-tor-msvc.txt │ ├── contrib │ │ └── tor-rpm-creation.txt │ ├── include.am │ ├── state-contents.txt │ ├── tor-fw-helper.1.txt │ ├── tor-gencert.1.txt │ ├── tor-resolve.1.txt │ ├── tor.1.txt │ └── torify.1.txt │ ├── install-sh │ ├── m4 │ ├── ax_check_sign.m4 │ └── pc_from_ucontext.m4 │ ├── missing │ ├── orconfig.h.in │ ├── scripts │ ├── README │ ├── coccinelle │ │ └── calloc.cocci │ ├── codegen │ │ ├── gen_linux_syscalls.pl │ │ ├── gen_server_ciphers.py │ │ └── get_mozilla_ciphers.py │ ├── maint │ │ ├── checkLogs.pl │ │ ├── checkOptionDocs.pl │ │ ├── checkSpace.pl │ │ ├── check_config_macros.pl │ │ ├── findMergedChanges.pl │ │ ├── format_changelog.py │ │ ├── redox.py │ │ ├── sortChanges.py │ │ └── updateVersions.pl │ └── test │ │ ├── cov-blame │ │ ├── cov-diff │ │ ├── coverage │ │ └── scan-build.sh │ └── src │ ├── common │ ├── Makefile.nmake │ ├── address.c │ ├── address.h │ ├── aes.c │ ├── aes.h │ ├── backtrace.c │ ├── backtrace.h │ ├── ciphers.inc │ ├── compat.c │ ├── compat.h │ ├── compat_libevent.c │ ├── compat_libevent.h │ ├── container.c │ ├── container.h │ ├── crypto.c │ ├── crypto.h │ ├── crypto_curve25519.c │ ├── crypto_curve25519.h │ ├── crypto_format.c │ ├── di_ops.c │ ├── di_ops.h │ ├── include.am │ ├── linux_syscalls.inc │ ├── log.c │ ├── memarea.c │ ├── memarea.h │ ├── mempool.c │ ├── mempool.h │ ├── procmon.c │ ├── procmon.h │ ├── sandbox.c │ ├── sandbox.h │ ├── testsupport.h │ ├── torgzip.c │ ├── torgzip.h │ ├── torint.h │ ├── torlog.h │ ├── tortls.c │ ├── tortls.h │ ├── util.c │ ├── util.h │ ├── util_codedigest.c │ ├── util_process.c │ └── util_process.h │ ├── config │ ├── geoip │ ├── geoip6 │ ├── include.am │ ├── mmdb-convert.py │ └── torrc.sample.in │ ├── ext │ ├── Makefile.nmake │ ├── OpenBSD_malloc_Linux.c │ ├── README │ ├── csiphash.c │ ├── curve25519_donna │ │ ├── README │ │ ├── curve25519-donna-c64.c │ │ └── curve25519-donna.c │ ├── eventdns.c │ ├── eventdns.h │ ├── ht.h │ ├── include.am │ ├── siphash.h │ ├── strlcat.c │ ├── strlcpy.c │ ├── tinytest.c │ ├── tinytest.h │ ├── tinytest_demo.c │ ├── tinytest_macros.h │ ├── tor_queue.h │ └── tor_queue.txt │ ├── include.am │ ├── or │ ├── Makefile.nmake │ ├── addressmap.c │ ├── addressmap.h │ ├── buffers.c │ ├── buffers.h │ ├── channel.c │ ├── channel.h │ ├── channeltls.c │ ├── channeltls.h │ ├── circpathbias.c │ ├── circpathbias.h │ ├── circuitbuild.c │ ├── circuitbuild.h │ ├── circuitlist.c │ ├── circuitlist.h │ ├── circuitmux.c │ ├── circuitmux.h │ ├── circuitmux_ewma.c │ ├── circuitmux_ewma.h │ ├── circuitstats.c │ ├── circuitstats.h │ ├── circuituse.c │ ├── circuituse.h │ ├── command.c │ ├── command.h │ ├── config.c │ ├── config.h │ ├── config_codedigest.c │ ├── confparse.c │ ├── confparse.h │ ├── connection.c │ ├── connection.h │ ├── connection_edge.c │ ├── connection_edge.h │ ├── connection_or.c │ ├── connection_or.h │ ├── control.c │ ├── control.h │ ├── cpuworker.c │ ├── cpuworker.h │ ├── directory.c │ ├── directory.h │ ├── dirserv.c │ ├── dirserv.h │ ├── dirvote.c │ ├── dirvote.h │ ├── dns.c │ ├── dns.h │ ├── dnsserv.c │ ├── dnsserv.h │ ├── entrynodes.c │ ├── entrynodes.h │ ├── eventdns_tor.h │ ├── ext_orport.c │ ├── ext_orport.h │ ├── fp_pair.c │ ├── fp_pair.h │ ├── geoip.c │ ├── geoip.h │ ├── hibernate.c │ ├── hibernate.h │ ├── include.am │ ├── main.c │ ├── main.h │ ├── microdesc.c │ ├── microdesc.h │ ├── networkstatus.c │ ├── networkstatus.h │ ├── nodelist.c │ ├── nodelist.h │ ├── ntmain.c │ ├── ntmain.h │ ├── onion.c │ ├── onion.h │ ├── onion_fast.c │ ├── onion_fast.h │ ├── onion_ntor.c │ ├── onion_ntor.h │ ├── onion_tap.c │ ├── onion_tap.h │ ├── or.h │ ├── policies.c │ ├── policies.h │ ├── reasons.c │ ├── reasons.h │ ├── relay.c │ ├── relay.h │ ├── rendclient.c │ ├── rendclient.h │ ├── rendcommon.c │ ├── rendcommon.h │ ├── rendmid.c │ ├── rendmid.h │ ├── rendservice.c │ ├── rendservice.h │ ├── rephist.c │ ├── rephist.h │ ├── replaycache.c │ ├── replaycache.h │ ├── router.c │ ├── router.h │ ├── routerlist.c │ ├── routerlist.h │ ├── routerparse.c │ ├── routerparse.h │ ├── routerset.c │ ├── routerset.h │ ├── statefile.c │ ├── statefile.h │ ├── status.c │ ├── status.h │ ├── tor_main.c │ ├── transports.c │ └── transports.h │ ├── test │ ├── Makefile.nmake │ ├── bench.c │ ├── bt_test.py │ ├── include.am │ ├── ntor_ref.py │ ├── slownacl_curve25519.py │ ├── test-child.c │ ├── test-network.sh │ ├── test.c │ ├── test.h │ ├── test_addr.c │ ├── test_bt_cl.c │ ├── test_buffers.c │ ├── test_cell_formats.c │ ├── test_cell_queue.c │ ├── test_circuitlist.c │ ├── test_circuitmux.c │ ├── test_cmdline_args.py │ ├── test_config.c │ ├── test_containers.c │ ├── test_controller_events.c │ ├── test_crypto.c │ ├── test_data.c │ ├── test_descriptors.inc │ ├── test_dir.c │ ├── test_entrynodes.c │ ├── test_extorport.c │ ├── test_hs.c │ ├── test_introduce.c │ ├── test_logging.c │ ├── test_microdesc.c │ ├── test_nodelist.c │ ├── test_ntor_cl.c │ ├── test_oom.c │ ├── test_options.c │ ├── test_policy.c │ ├── test_pt.c │ ├── test_relaycell.c │ ├── test_replay.c │ ├── test_routerkeys.c │ ├── test_routerset.c │ ├── test_socks.c │ ├── test_status.c │ └── test_util.c │ ├── tools │ ├── Makefile.nmake │ ├── include.am │ ├── tor-checkkey.c │ ├── tor-fw-helper │ │ ├── include.am │ │ ├── tor-fw-helper-natpmp.c │ │ ├── tor-fw-helper-natpmp.h │ │ ├── tor-fw-helper-upnp.c │ │ ├── tor-fw-helper-upnp.h │ │ ├── tor-fw-helper.c │ │ └── tor-fw-helper.h │ ├── tor-gencert.c │ └── tor-resolve.c │ └── win32 │ ├── include.am │ └── orconfig.h └── tools ├── models.py ├── noticelog-import.py ├── onion-publisher.py └── onion-receiver.py /README.md: -------------------------------------------------------------------------------- 1 | ## Tor & onionviewer ## 2 | ============= 3 | 4 | This repository contains a modified version of Tor which allows a node setup to be a hidden service directory to log all successfully resolved hidden services. 5 | Additionally this repository also contains tools to parse the Tor notice log for resolved hidden services. These tools will put the results in a SQLite database which can be viewed and researched with the provided *onionviewer* web application. 6 | 7 | Complete technical details can be found on the blog article this repository accompanies: [http://blog.0x3a.com/post/153468210759/monitoring-dns-inside-the-tor-network](http://blog.0x3a.com/post/153468210759/monitoring-dns-inside-the-tor-network) -------------------------------------------------------------------------------- /onionviewer/models.py: -------------------------------------------------------------------------------- 1 | from sqlalchemy.ext.declarative import declarative_base 2 | from sqlalchemy import Column, Integer, String, DateTime, Unicode 3 | 4 | Base = declarative_base() 5 | 6 | class OnionAddress(Base): 7 | __tablename__ = "onion_addresses" 8 | 9 | id = Column(Integer, primary_key=True) 10 | 11 | address = Column(String) 12 | first_seen = Column(DateTime) 13 | last_seen = Column(DateTime) 14 | count = Column(Integer) 15 | website_title = Column(Unicode) 16 | 17 | def __init__(self): 18 | self.count = 0 19 | 20 | def __repr__(self): 21 | return "" % (self.id, self.address, self.count) 22 | -------------------------------------------------------------------------------- /onionviewer/static/bootstrap/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0x3a/tor-dns/47914acb407570035a4f57611def7e03efa48b59/onionviewer/static/bootstrap/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /onionviewer/static/bootstrap/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0x3a/tor-dns/47914acb407570035a4f57611def7e03efa48b59/onionviewer/static/bootstrap/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /onionviewer/static/bootstrap/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0x3a/tor-dns/47914acb407570035a4f57611def7e03efa48b59/onionviewer/static/bootstrap/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /onionviewer/templates/base.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Onion Viewer 10 | 11 | 12 | 13 |
14 |
Onion Viewer
15 |
16 | {% block container %}{% endblock %} 17 | 18 | 19 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /onionviewer/templates/onion_address.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | 3 | {% block container %} 4 |
5 | 6 |
7 |
8 |

Onion address details

9 |
10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 |
Hidden service website title{% if onion_address.website_title %}{{ onion_address.website_title }}{% endif %}
Address{{ onion_address.address }}.onion
First seen{{ onion_address.first_seen }}
Last seen{{ onion_address.last_seen }}
Count{{ onion_address.count }}
36 |
37 |
38 | 39 | {% endblock %} 40 | -------------------------------------------------------------------------------- /onionviewer/templates/overview.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | 3 | {% block container %} 4 |
5 |
6 |
7 |

Onion addresses overview

8 | 25 |
26 |
27 |
28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | {% for onion_address in overviewlist %} 40 | 41 | 42 | 43 | 44 | 45 | 47 | {% endfor %} 48 | 49 |
IDAddressFirst seenLast SeenCount
{{ onion_address.id }}{{ onion_address.address }}.onion{{ onion_address.first_seen|datetimeformat("Y-M-d HH:mm") }}{{ onion_address.last_seen|datetimeformat("Y-M-d HH:mm") }}{{ onion_address.count }} 46 |
50 |
51 |
52 |
53 | {% endblock %} 54 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/INSTALL: -------------------------------------------------------------------------------- 1 | 2 | Most users who realize that INSTALL files still exist should simply 3 | follow the directions at 4 | https://www.torproject.org/docs/tor-doc-unix 5 | 6 | If you got the source from git, run "./autogen.sh", which will 7 | run the various auto* programs. Then you can run ./configure, and 8 | refer to the above instructions. 9 | 10 | If it doesn't build for you: 11 | 12 | If you have problems finding libraries, try 13 | CPPFLAGS="-I/usr/local/include" LDFLAGS="-L/usr/local/lib" \ 14 | ./configure 15 | or 16 | ./configure --with-libevent-dir=/usr/local 17 | rather than simply ./configure. 18 | 19 | If you have mysterious autoconf failures while linking openssl, 20 | consider setting your LD_LIBRARY_PATH to the openssl lib directory. 21 | For example, "setenv LD_LIBRARY_PATH /usr/athena/lib". 22 | 23 | Lastly, check out 24 | https://www.torproject.org/docs/faq#DoesntWork 25 | 26 | How to do static builds of tor: 27 | 28 | Tor supports linking each of the libraries it needs statically. Use the 29 | --enable-static-X ./configure option in conjunction with the --with-X-dir 30 | option for libevent, zlib, and openssl. For this to work sanely, libevent 31 | should be built with --disable-shared --enable-static --with-pic, and 32 | OpenSSL should be built with no-shared no-dso. 33 | 34 | If you need to build tor so that system libraries are also statically linked, 35 | use the --enable-static-tor ./configure option. This won't work on OS X 36 | unless you build the required crt0.o yourself. It is also incompatible with 37 | the --enable-gcc-hardening option. 38 | 39 | An example of how to build a mostly static tor: 40 | ./configure --enable-static-libevent \ 41 | --enable-static-openssl \ 42 | --enable-static-zlib \ 43 | --with-libevent-dir=/tmp/static-tor/libevent-1.4.14b-stable \ 44 | --with-openssl-dir=/tmp/static-tor/openssl-0.9.8r/ \ 45 | --with-zlib-dir=/tmp/static-tor/zlib-1.2.5 46 | 47 | An example of how to build an entirely static tor: 48 | ./configure --enable-static-tor \ 49 | --with-libevent-dir=/tmp/static-tor/libevent-1.4.14b-stable \ 50 | --with-openssl-dir=/tmp/static-tor/openssl-0.9.8r/ \ 51 | --with-zlib-dir=/tmp/static-tor/zlib-1.2.5 52 | 53 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/Makefile.nmake: -------------------------------------------------------------------------------- 1 | all: 2 | cd src/common 3 | $(MAKE) /F Makefile.nmake 4 | cd ../../src/ext 5 | $(MAKE) /F Makefile.nmake 6 | cd ../../src/or 7 | $(MAKE) /F Makefile.nmake 8 | cd ../../src/test 9 | $(MAKE) /F Makefile.nmake 10 | 11 | clean: 12 | cd src/common 13 | $(MAKE) /F Makefile.nmake clean 14 | cd ../../src/ext 15 | $(MAKE) /F Makefile.nmake clean 16 | cd ../../src/or 17 | $(MAKE) /F Makefile.nmake clean 18 | cd ../../src/test 19 | $(MAKE) /F Makefile.nmake clean 20 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/README: -------------------------------------------------------------------------------- 1 | Tor protects your privacy on the internet by hiding the connection 2 | between your Internet address and the services you use. We believe Tor 3 | is reasonably secure, but please ensure you read the instructions and 4 | configure it properly. 5 | 6 | To build Tor from source: 7 | ./configure && make && make install 8 | 9 | Home page: 10 | https://www.torproject.org/ 11 | 12 | Download new versions: 13 | https://www.torproject.org/download/download.html 14 | 15 | Documentation, including links to installation and setup instructions: 16 | https://www.torproject.org/docs/documentation.html 17 | 18 | Making applications work with Tor: 19 | https://wiki.torproject.org/projects/tor/wiki/doc/TorifyHOWTO 20 | 21 | Frequently Asked Questions: 22 | https://www.torproject.org/docs/faq.html 23 | 24 | 25 | To get started working on Tor development: 26 | See the doc/HACKING file. 27 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ -x "`which autoreconf 2>/dev/null`" ] ; then 4 | opt="-if" 5 | 6 | for i in $@; do 7 | case "$i" in 8 | -v) 9 | opt=$opt"v" 10 | ;; 11 | esac 12 | done 13 | 14 | exec autoreconf $opt 15 | fi 16 | 17 | set -e 18 | 19 | # Run this to generate all the initial makefiles, etc. 20 | aclocal -I m4 && \ 21 | autoheader && \ 22 | autoconf && \ 23 | automake --add-missing --copy 24 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/12207: -------------------------------------------------------------------------------- 1 | - Testing: 2 | - Refactor the function that chooses guard nodes so that it can 3 | more easily be tested; write some tests for it. 4 | 5 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/bufferevent_compilation: -------------------------------------------------------------------------------- 1 | o Minor bugfixes: 2 | - Fix compilation when building with bufferevents enabled. (This 3 | configuration is still not expected to work, however.) 4 | Fixes bugs 12438, 12474, 11578; bugfixes on 0.2.5.1-alpha and 5 | 0.2.5.3-alpha. Patches from Anthony G. Basile and Sathyanarayanan 6 | Gunasekaran. 7 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/bug10116: -------------------------------------------------------------------------------- 1 | o Minor features: 2 | - When handling a low-memory situation, allocate less memory 3 | for teporary data structures. Fixes issue 10115. 4 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/bug1038-3: -------------------------------------------------------------------------------- 1 | o Minor bugfixes: 2 | - Warn and drop the circuit if we receive an inbound 'relay early' 3 | cell. Those used to be normal to receive on hidden service circuits 4 | due to bug 1038, but the buggy Tor versions are long gone from 5 | the network so we can afford to resume watching for them. Resolves 6 | the rest of bug 1038; bugfix on 0.2.1.19. 7 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/bug11200-caching: -------------------------------------------------------------------------------- 1 | o Major bugfixes: 2 | - When Tor starts with DisabledNetwork set, it would correctly 3 | conclude that it shouldn't try making circuits, but it would 4 | mistakenly cache this conclusion and continue believing it even 5 | when DisableNetwork is set to 0. Fixes the bug introduced by the 6 | fix for bug 11200; bugfix on 0.2.5.4-alpha. 7 | 8 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/bug11302: -------------------------------------------------------------------------------- 1 | o Bugfixes: 2 | - Check for orconns and use connection_or_close_for_error() rather than 3 | connection_mark_for_close() directly in the getsockopt() failure case 4 | of connection_handle_write_impl(). Fixes bug #11302. 5 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/bug11683: -------------------------------------------------------------------------------- 1 | o Minor bugfixes: 2 | - Always believe that v3 directory authorities serve extra-info 3 | documents, regardless of whether their server descriptor contains a 4 | "caches-extra-info" line or not. Fixes part of #11683. Bugfix on 5 | 0.2.0.1-alpha. 6 | - When running as a v3 directory authority, advertise that you serve 7 | extra-info documents so that clients who want them can find them from 8 | you too. Fixes part of bug #11683. Bugfix on 0.2.0.1-alpha. 9 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/bug11787: -------------------------------------------------------------------------------- 1 | o Minor bugfixes (directory bandwidth performance): 2 | - Don't flush the zlib buffer aggressively when compressing 3 | directory information for clients. This should save about 7% of 4 | the bandwidth currently used for compressed descriptors and 5 | microdescriptors. Fixes bug 11787; bugfix on 0.1.1.23. 6 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/bug11792: -------------------------------------------------------------------------------- 1 | o Minor features (security, OOM): 2 | - When closing an edge connection because we've run out of memory, 3 | also count the amount of memory that any tunnelled directory 4 | connection attached to that connection had consumed. Part of 5 | ticket 11792. 6 | 7 | - When considering whether we're running low on memory, consider 8 | memory that was allocated as part of zlib buffers as well. 9 | Count that memory as reclaimed by our OOM handler. Part of 10 | ticket 11792. 11 | 12 | - When handling out-of-memory conditions, also look at 13 | non-tunnneled directory connections, and kill the ones that have 14 | had data sitting on them for the longest. Part of ticket 11792. 15 | 16 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/bug12061: -------------------------------------------------------------------------------- 1 | o Minor features: 2 | - On unix, you can now use named pipes as the target of the Log 3 | option, and other options that try to append to files. Closes 4 | ticket 12061. Patch from "carlo von lynX". 5 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/bug12160: -------------------------------------------------------------------------------- 1 | o Bugfixes 2 | - Correctly update the local mark on the controlling channel when changing 3 | the address of an or_connection_t after the handshake. Fixes bug #12160; 4 | bugfix on 0.2.4.4-alpha. 5 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/bug12202: -------------------------------------------------------------------------------- 1 | o Code simplification and refactoring: 2 | - Change the entry_is_live() function to take named bitfield elements 3 | instead of an unnamed list of booleans. Closes ticket 12202. 4 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/bug12205: -------------------------------------------------------------------------------- 1 | o Minor refactoring: 2 | - Refactoring and unit-testing entry_is_time_to_retry() in 3 | entrynodes.c. Resolves ticket 12205. 4 | 5 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/bug12392: -------------------------------------------------------------------------------- 1 | o Minor bugfixes (testing, Windows): 2 | - Avoid passing an extra backslash when creating a temporary 3 | directory for running the unit tests on Windows. Fixes bug 12392; 4 | bugfix on 0.2.2.25-alpha. Patch from Gisle Vanem. 5 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/bug12503: -------------------------------------------------------------------------------- 1 | o Testing: 2 | - Fix and re-enable the fgets_eagain unit test. Fixes bug 12503; 3 | bugfix on 0.2.3.1-alpha. Patch from "cypherpunks." 4 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/bug12573: -------------------------------------------------------------------------------- 1 | o Major bugfixes: 2 | - Relays should not be assigned the HSDir flag if they are 3 | considered invalid. Also, do not assign the HSDir flag to relays 4 | that are currently hibernating. Fixes #12573. Bugfix on 5 | tor-0.2.0.10-alpha 6 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/bug12602: -------------------------------------------------------------------------------- 1 | o Minor bugfixes (portability): 2 | - Compile correctly with builds and forks of OpenSSL (such as 3 | LibreSSL) that disable compression. Fixes bug 12602; bugfix on 4 | 0.2.1.1-alpha. Patch from "dhill". 5 | 6 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/bug12700: -------------------------------------------------------------------------------- 1 | o Minor bugfixes: 2 | - When logging information about an EXTEND2 or EXTENDED2 cell, log 3 | their names correctly. Fixes part of bug 12700; bugfix on 4 | 0.2.4.8-alpha. 5 | 6 | o Minor bugfixes: 7 | - When logging information about a relay cell whose command we 8 | don't recognize, log its command as an integer. Fixes part of 9 | bug 12700; bugfix on 0.2.1.10-alpha. 10 | 11 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/bug12718: -------------------------------------------------------------------------------- 1 | o Minor bugfixes: 2 | - Correct a confusing error message when trying to extend a circuit 3 | via the control protocol but we don't know a descriptor or 4 | microdescriptor for one of the specified relays. Fixes bug 12718; 5 | bugfix on 0.2.3.1-alpha. 6 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/bug12728: -------------------------------------------------------------------------------- 1 | 2 | o Minor bugfixes: 3 | - When generating our family list, remove spaces from around the 4 | entries there. Fixes bug 12728; bugfix on 0.2.1.7-alpha. 5 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/bug12730-systemd-verify-config: -------------------------------------------------------------------------------- 1 | o Distribution: 2 | - Verify configuration file via ExecStartPre in the systemd unit file. 3 | Patch from intrigeri; resolves ticket 12730. 4 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/bug12731-systemd-no-run-as-daemon: -------------------------------------------------------------------------------- 1 | o Distribution: 2 | - Explicitly disable RunAsDaemon in the systemd unit file. 3 | Our current systemd unit uses "Type = simple", so systemd does 4 | not expect tor to fork. If the user has "RunAsDaemon 1" in their 5 | torrc, then things won't work as expected. This is e.g. the case 6 | on Debian (and derivatives), since there we pass 7 | "--defaults-torrc /usr/share/tor/tor-service-defaults-torrc" 8 | (that contains "RunAsDaemon 1") by default. 9 | Patch by intrigeri; resolves ticket 12731. 10 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/bug12751-systemd-filesystem-sandbox: -------------------------------------------------------------------------------- 1 | o Distribution: 2 | - systemd unit file: only allow tor to write to /var/lib/tor 3 | and /var/log/tor. The rest of the filesystem is accessible 4 | for reading only. 5 | Patch by intrigeri; resolves ticket 12751. 6 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/bug12830: -------------------------------------------------------------------------------- 1 | o Documentation: 2 | - Adjust the URLs in the README to refer to the new locations of 3 | several documents on the website. Patch from Matt Pagan. Fixes 4 | bug 12830. 5 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/bug12848: -------------------------------------------------------------------------------- 1 | o Major bugfixes (relay): 2 | - Avoid queuing or sending destroy cells for circuit ID zero when 3 | we fail to send a CREATE cell. Fixes bug 12848; bugfix on 4 | 0.0.8pre1. Found and fixed by "cypherpunks". 5 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/bug12855: -------------------------------------------------------------------------------- 1 | o Code simplification and refactoring 2 | - Use calloc and reallocarray functions in preference to 3 | multiply-then-malloc. This makes it less likely for us to fall 4 | victim to an integer overflow attack when allocating. Resolves 5 | ticket 12855. 6 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/bug12864: -------------------------------------------------------------------------------- 1 | o Minor bugfixes: 2 | - Restore the functionality of CookieAuthFileGroupReadable. Fixes bug 3 | 12864; bugfix on 0.2.5.1-alpha. 4 | 5 | o Minor features: 6 | - Add an ExtORPortCookieAuthFileGroupReadable option to make the 7 | cookie file for the ExtORPort g+r by default. 8 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/bug12878: -------------------------------------------------------------------------------- 1 | o Documentation: 2 | - Document 'reject6' and 'accept6' ExitPolicy entries. Resolves 3 | ticket 12878. 4 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/bug12899: -------------------------------------------------------------------------------- 1 | o Removed features: 2 | - The "AuthDirRejectUnlisted" option no longer has any effect, as 3 | the fingerprints file (approved-routers) has been deprecated. 4 | - Directory authorities do not support being Naming dirauths 5 | anymore. The "NamingAuthoritativeDir" config option has been 6 | obsoleted. 7 | 8 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/bug12908: -------------------------------------------------------------------------------- 1 | o Minor features: 2 | - Warn about attempts to run hidden services and relays in the 3 | same process: that's probably not a good idea. Closes ticket 4 | 12908. 5 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/bug12939-systemd-no-new-privileges: -------------------------------------------------------------------------------- 1 | o Distribution: 2 | - systemd unit file: ensures that the process and all its children 3 | can never gain new privileges. 4 | Patch by intrigeri; resolves ticket 12939. 5 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/bug12948: -------------------------------------------------------------------------------- 1 | o Major bugfixes: 2 | - Resume expanding abbreviations for command-line options. The fix 3 | for bug 4647 accidentally removed our hack from bug 586 that rewrote 4 | HashedControlPassword to __HashedControlSessionPassword when it 5 | appears on the commandline (which allowed the user to set her 6 | own HashedControlPassword in the torrc file while the controller 7 | generates a fresh session password for each run). Fixes bug 12948; 8 | bugfix on 0.2.5.1-alpha. 9 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/bug12996: -------------------------------------------------------------------------------- 1 | o Minor bugfixes: 2 | - Downgrade "Unexpected onionskin length after decryption" warning 3 | to a protocol-warn, since there's nothing relay operators can do 4 | about a client that sends them a malformed create cell. Resolves 5 | bug 12996; bugfix on 0.0.6rc1. 6 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/bug12997: -------------------------------------------------------------------------------- 1 | o Minor features: 2 | - Log more specific warnings when we get an ESTABLISH_RENDEZVOUS cell 3 | on a cannibalized or non-OR circuit. Resolves ticket 12997. 4 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/bug13000: -------------------------------------------------------------------------------- 1 | o Minor bugfixes: 2 | - If our previous bandwidth estimate was 0 bytes, allow publishing a 3 | new relay descriptor immediately. Fixes bug 13000; bugfix on 4 | 0.1.1.6-alpha. 5 | o Minor features: 6 | - Don't list relays with a bandwidth estimate of 0 in the consensus. 7 | Implements a feature proposed during discussion of bug 13000. 8 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/bug13060: -------------------------------------------------------------------------------- 1 | o Removed features: 2 | - Directory authorities do not support giving out the BadDirectory 3 | flag anymore. 4 | - Clients don't understand the BadDirectory flag in the consensus 5 | anymore, and ignore it. 6 | 7 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/bug13064: -------------------------------------------------------------------------------- 1 | o Minor bugfixes: 2 | - Fix TestingDirAuthVoteGuard to properly give out Guard flags in 3 | a testing network. Fixes bug 13064; bugfix on 0.2.5.2-alpha. 4 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/bug13071: -------------------------------------------------------------------------------- 1 | o Minor bugfixes (relay): 2 | - Escape all strings from the directory connection before logging them. 3 | Fixes bug 13071; bugfix on 0.1.1.15. Patch from "teor". 4 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/bug13081: -------------------------------------------------------------------------------- 1 | o Compilation fixes: 2 | - Make the nmake make files work again. Fixes bug 13081. Bugfix on 0.2.5.1-alpha. Patch 3 | from "NewEraCracker". 4 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/bug13085: -------------------------------------------------------------------------------- 1 | o Minor bugfixes (controller): 2 | - Actually send TRANSPORT_LAUNCHED and HS_DESC events to controllers. 3 | Fixes bug 13085; bugfix on 0.2.5.1-alpha. Patch by "teor". 4 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/bug13102: -------------------------------------------------------------------------------- 1 | o Code refactoring: 2 | - Use the standard macro name SIZE_MAX, instead of our own SIZE_T_MAX. 3 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/bug8387: -------------------------------------------------------------------------------- 1 | o Major bugfixes (client): 2 | 3 | - Perform circuit cleanup operations even when circuit 4 | construction operations are disabled (because the network is 5 | disabled, or because there isn't enough directory information). 6 | Previously, when we were not building predictive circuits, we 7 | were not closing expired circuits either. 8 | 9 | Fixes bug 8387; bugfix on 0.1.1.11-alpha. This bug became visible 10 | in 0.2.4.10-alpha when we became more strict about when we have 11 | "enough directory information to build circuits". 12 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/bug9801: -------------------------------------------------------------------------------- 1 | o Minor bugfixes: 2 | - When GeoIPExcludeUnkonwn is enabled, do not incorrectly decide 3 | that our options have changed every time we SIGHUP. Fixes bug 4 | 9801; bugfix on 0.2.4.10-alpha. Patch from "qwerty1". 5 | 6 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/check_dup_args_gencert: -------------------------------------------------------------------------------- 1 | o Minor features: 2 | - In tor-gencert, report an error if the user provides the same 3 | argument more than once. 4 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/coverage-html: -------------------------------------------------------------------------------- 1 | o Minor features (testing): 2 | 3 | - Add a "coverage-html" make target to generate HTML-visualized 4 | coverage results when building with --enable-coverage. (Requires lcov.) 5 | Patch from Kevin Murray. 6 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/crash_handler_in_tests: -------------------------------------------------------------------------------- 1 | o Minor features: 2 | - Enable the backtrace handler (where supported) when running the 3 | unit tests. 4 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/curve25519-donna32-bug: -------------------------------------------------------------------------------- 1 | o Major bugfixes: 2 | 3 | - Fix a bug in the bounds-checking in the 32-bit curve25519-donna 4 | implementation that caused incorrect results on 32-bit 5 | implementations when certain malformed inputs were used along with 6 | a small class of private ntor keys. This bug does not currently 7 | appear to allow an attacker to learn private keys or impersonate a 8 | Tor server, but it could provide a means to distinguish 32-bit Tor 9 | implementations from 64-bit Tor implementations. Fixes bug 12694; 10 | bugfix on 0.2.4.8-alpha. Bug found by Robert Ransom; fix from 11 | Adam Langley. 12 | 13 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/feature5583: -------------------------------------------------------------------------------- 1 | o Minor features: 2 | - Add an option to overwrite logs (TruncateLogFile). Closes ticket #5583. 3 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/further-12184-diagnostic: -------------------------------------------------------------------------------- 1 | o Minor features (diagnostic): 2 | - Slightly enhance the diagnostic message for bug 12184. 3 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/geoip-august2014: -------------------------------------------------------------------------------- 1 | o Minor features: 2 | - Update geoip to the August 7 2014 Maxmind GeoLite2 Country database. 3 | 4 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/geoip-july2014: -------------------------------------------------------------------------------- 1 | o Minor features: 2 | - Update geoip to the July 10 2014 Maxmind GeoLite2 Country database. 3 | 4 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/geoip6-august2014: -------------------------------------------------------------------------------- 1 | o Minor features: 2 | - Update geoip6 to the August 7 2014 Maxmind GeoLite2 Country database. 3 | 4 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/geoip6-july2014: -------------------------------------------------------------------------------- 1 | o Minor features: 2 | - Update geoip6 to the July 10 2014 Maxmind GeoLite2 Country database. 3 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/no-wince: -------------------------------------------------------------------------------- 1 | o Removed platform support: 2 | - We no longer include special code to build on Windows CE; as far 3 | as we know, nobody has used Tor on Windows CE in a very long 4 | time. Closes ticket 11446. 5 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/prop215: -------------------------------------------------------------------------------- 1 | o Removed features (directory authorities): 2 | 3 | - Directory authorities no longer advertise or support consensus 4 | methods 1 through 12 inclusive. These consensus methods were 5 | obsolete and/or insecure: maintaining the ability to support them 6 | served no good purpose. Implements part of proposal 215; 7 | closes ticket 10163. 8 | 9 | o Minor features (directory authorities) 10 | - If a directory authority can't find a best consensus method in the 11 | votes that it holds, it now falls back to its favorite consensus 12 | method. Previously, it fell back to method 1. Neither of these is 13 | likely to get enough signatures, but "fall back to favorite" 14 | doesn't require us to maintain support an obsolete consensus 15 | method. Implements another part of proposal 215. 16 | 17 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/test.h_msvc: -------------------------------------------------------------------------------- 1 | o Minor bugfixes (compilation): 2 | - Fix compilation of test.h with MSVC. Patch from Gisle Vanem; 3 | bugfix on 0.2.5.5-alpha. 4 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/threads-required: -------------------------------------------------------------------------------- 1 | o Removed features: 2 | - Tor no longer supports systems without threading support. 3 | When we began working on Tor, there were several systems that didn't 4 | have threads, or where the thread support wasn't able to run the 5 | threads of a single process on multiple CPUs. That no longer holds: 6 | every system where Tor needs to run well now has threading support. 7 | Resolves ticket 12439. 8 | 9 | o Minor features: 10 | - Threads are no longer disabled by default on Solaris; we believe that 11 | the versions of Solaris with broken threading support are all obsolete 12 | by now. Resolves ticket 9495. 13 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/ticket12688: -------------------------------------------------------------------------------- 1 | Major features: 2 | - Make the number of entry guards configurable via a new 3 | NumEntryGuards consensus parameter, and the number of directory 4 | guards configurable via a new NumDirectoryGuards consensus 5 | parameter. Implements ticket 12688. 6 | 7 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/ticket12690: -------------------------------------------------------------------------------- 1 | o Minor features: 2 | - Authorities now assign the Guard flag to the fastest 25% of the 3 | network (it used to be the fastest 50%). Also raise the consensus 4 | weight that guarantees the Guard flag from 250 to 2000. For the 5 | current network, this results in about 1100 guards, down from 2500. 6 | This step paves the way for moving the number of entry guards 7 | down to 1 (proposal 236) while still providing reasonable expected 8 | performance for most users. Implements ticket 12690. 9 | 10 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/changes/ticket13036: -------------------------------------------------------------------------------- 1 | o Minor bugfixes: 2 | - Fix a large number of false positive warnings from the clang 3 | analyzer static analysis tool. This should make real warnings 4 | easier for clang analyzer to find. Patch from "teor". Closes 5 | ticket 13036. 6 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/contrib/README: -------------------------------------------------------------------------------- 1 | The contrib/ directory contains small tools that might be useful for using 2 | with Tor. A few of them are included in the Tor source distribution; you can 3 | find the others in the main Tor repository. We don't guarantee that they're 4 | particularly useful. 5 | 6 | dirauth-tools/ -- Tools useful for directory authority administrators 7 | --------------------------------------------------------------------- 8 | 9 | add-tor is an old script to manipulate the approved-routers file. 10 | 11 | nagios-check-tor-authority-cert is a nagios script to check when Tor 12 | authority certificates are expired or nearly expired. 13 | 14 | client-tools/ -- Tools for use with Tor clients 15 | ----------------------------------------------- 16 | 17 | torify is a small wrapper script around torsocks. 18 | 19 | tor-resolve.py uses Tor's SOCKS port extensions to perform DNS lookups. You 20 | should probably use src/tools/tor-resolve instead. 21 | 22 | dist/ -- Scripts and files for use when packaging Tor 23 | ----------------------------------------------------- 24 | 25 | torctl, rc.subr, and tor.sh are init scripts for use with SysV-style init 26 | tools. Everybody likes to write init scripts differently, it seems. 27 | 28 | tor.service is a sample service file for use with systemd. 29 | 30 | The suse/ subdirectory contains files used by the suse distribution. 31 | 32 | operator-tools/ -- Tools for Tor relay operators 33 | ------------------------------------------------ 34 | 35 | tor-exit-notice.html is an HTML file for use with the DirPortFrontPage 36 | option. It tells visitors that your relay is a Tor exit node, and that they 37 | shouldn't assume you're the origin for the traffic that you're delivering. 38 | 39 | tor.logrotate is a configuration file for use with the logrotate tool. You 40 | may need to edit it to work for you. 41 | 42 | linux-tor-prio.sh uses Linux iptables tools to traffic-shape your Tor relay's 43 | traffic. If it breaks, you get to keep both pieces. 44 | 45 | or-tools/ -- Tools for interacting with relays 46 | ---------------------------------------------- 47 | 48 | checksocks.pl is a tool to scan relays to see if any of them have advertised 49 | public SOCKS ports, so we can tell them not to. 50 | 51 | check-tor is a quick shell script to try doing a TLS handshake with a router 52 | or to try fetching a directory from it. 53 | 54 | exitlist is a precursor of check.torproject.org: it parses a bunch of cached 55 | server descriptors to determine which can connect to a given address:port. 56 | 57 | win32build -- Old files for windows packaging 58 | --------------------------------------------- 59 | 60 | You shouldn't need these unless you're building some of the older Windows 61 | packages. 62 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/contrib/client-tools/torify: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | # This script used to call (the now deprecated) tsocks as a fallback in case 4 | # torsocks wasn't installed. 5 | # Now, it's just a backwards compatible shim around torsocks with reasonable 6 | # behavior if -v/--verbose or -h/--help arguments are passed. 7 | # 8 | # Copyright (c) 2004, 2006, 2009 Peter Palfrader 9 | # Modified by Jacob Appelbaum April 16th 2006 10 | # Stripped of all the tsocks cruft by ugh on February 22nd 2012 11 | # May be distributed under the same terms as Tor itself 12 | 13 | 14 | compat() { 15 | echo "torify is now just a wrapper around torsocks(1) for backwards compatibility." 16 | } 17 | 18 | usage() { 19 | compat 20 | echo "Usage: $0 [-hv] [...]" 21 | } 22 | 23 | case $# in 0) 24 | usage >&2 25 | exit 1 26 | esac 27 | 28 | case $# in 1) 29 | case $1 in -h|--help) 30 | usage 31 | exit 0 32 | esac 33 | esac 34 | 35 | case $1 in -v|--verbose) 36 | compat >&2 37 | shift 38 | esac 39 | 40 | # taken from Debian's Developer's Reference, 6.4 41 | pathfind() { 42 | OLDIFS="$IFS" 43 | IFS=: 44 | for p in $PATH; do 45 | if [ -x "$p/$*" ]; then 46 | IFS="$OLDIFS" 47 | return 0 48 | fi 49 | done 50 | IFS="$OLDIFS" 51 | return 1 52 | } 53 | 54 | if pathfind torsocks; then 55 | exec torsocks "$@" 56 | echo "$0: Failed to exec torsocks $@" >&2 57 | exit 1 58 | else 59 | echo "$0: torsocks not found in your PATH. Perhaps it isn't installed? (tsocks is no longer supported, for security reasons.)" >&2 60 | fi 61 | 62 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/contrib/dirauth-tools/nagios-check-tor-authority-cert: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # nagios-check-tor-authority-cert - check certificate expiry time 4 | 5 | # A nagios check for Tor v3 directory authorities: 6 | # - Checks the current certificate expiry time 7 | # 8 | # Usage: nagios-check-tor-authority-cert 9 | # e.g.: nagios-check-tor-authority-cert A9AC67E64B200BBF2FA26DF194AC0469E2A948C6 10 | 11 | # Copyright (c) 2008 Peter Palfrader 12 | # 13 | # Permission is hereby granted, free of charge, to any person obtaining 14 | # a copy of this software and associated documentation files (the 15 | # "Software"), to deal in the Software without restriction, including 16 | # without limitation the rights to use, copy, modify, merge, publish, 17 | # distribute, sublicense, and/or sell copies of the Software, and to 18 | # permit persons to whom the Software is furnished to do so, subject to 19 | # the following conditions: 20 | # 21 | # The above copyright notice and this permission notice shall be 22 | # included in all copies or substantial portions of the Software. 23 | # 24 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 25 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 26 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 27 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 28 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 29 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 30 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 31 | 32 | 33 | set -e 34 | set -u 35 | 36 | if [ -z "${1:-}" ]; then 37 | echo "Usage: $0 " 2>&1 38 | exit 3 39 | fi 40 | 41 | identity="$1" 42 | 43 | DIRSERVERS="" 44 | DIRSERVERS="$DIRSERVERS 86.59.21.38:80" # tor26 45 | DIRSERVERS="$DIRSERVERS 128.31.0.34:9031" # moria1 46 | DIRSERVERS="$DIRSERVERS 216.224.124.114:9030" # ides 47 | DIRSERVERS="$DIRSERVERS 80.190.246.100:80" # gabelmoo 48 | #DIRSERVERS="$DIRSERVERS 140.247.60.64:80" # lefkada 49 | DIRSERVERS="$DIRSERVERS 194.109.206.212:80" # dizum 50 | DIRSERVERS="$DIRSERVERS 213.73.91.31:80" # dannenberg 51 | 52 | TMPFILE="`tempfile`" 53 | trap 'rm -f "$TMPFILE"' 0 54 | 55 | for dirserver in $DIRSERVERS; do 56 | wget -q -O "$TMPFILE" "http://$dirserver/tor/keys/fp/$identity" 57 | if [ "$?" = 0 ]; then 58 | break 59 | else 60 | cat /dev/null > "$TMPFILE" 61 | continue 62 | fi 63 | done 64 | 65 | if ! [ -s "$TMPFILE" ] ; then 66 | echo "UNKNOWN: Downloading certificate for $identity failed." 67 | exit 3 68 | fi 69 | 70 | expirydate="$(awk '$1=="dir-key-expires" {printf "%s %s", $2, $3}' < "$TMPFILE")" 71 | expiryunix=$(TZ=UTC date -d "$expirydate" +%s) 72 | now=$(date +%s) 73 | 74 | if [ "$now" -ge "$expiryunix" ]; then 75 | echo "CRITICAL: Certificate expired $expirydate (authority $identity)." 76 | exit 2 77 | elif [ "$(( $now + 7*24*60*60 ))" -ge "$expiryunix" ]; then 78 | echo "CRITICAL: Certificate expires $expirydate (authority $identity)." 79 | exit 2 80 | elif [ "$(( $now + 30*24*60*60 ))" -ge "$expiryunix" ]; then 81 | echo "WARNING: Certificate expires $expirydate (authority $identity)." 82 | exit 1 83 | else 84 | echo "OK: Certificate expires $expirydate (authority $identity)." 85 | exit 0 86 | fi 87 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/contrib/dist/rc.subr: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # $FreeBSD: ports/security/tor-devel/files/tor.in,v 1.1 2006/02/17 22:21:25 mnag Exp $ 3 | # 4 | # (rc.subr written by Peter Thoenen for Net/FreeBSD) 5 | # 6 | # REQUIRE: NETWORKING SERVERS USR 7 | # BEFORE: LOGIN 8 | # 9 | # Add the following lines to /etc/rc.conf to enable tor 10 | # 11 | # tor_enable (bool): Set to "NO" by default 12 | # Set it to "YES" to enable tor 13 | # tor_conf (str): Points to your tor conf file 14 | # Default: /usr/local/etc/tor/torrc 15 | # tor_user (str): Tor Daemon user. Default _tor 16 | # 17 | 18 | . /etc/rc.subr 19 | 20 | name="tor" 21 | rcvar=${name}_enable 22 | 23 | load_rc_config ${name} 24 | 25 | : ${tor_enable="NO"} 26 | : ${tor_conf="/usr/local/etc/tor/torrc"} 27 | : ${tor_user="_tor"} 28 | : ${tor_pidfile="/var/run/tor/tor.pid"} 29 | : ${tor_logfile="/var/log/tor"} 30 | : ${tor_datadir="/var/run/tor"} 31 | 32 | required_files=${tor_conf} 33 | required_dirs=${tor_datadir} 34 | command="/usr/local/bin/${name}" 35 | command_args="-f ${tor_conf} --pidfile ${tor_pidfile} --runasdaemon 1 --datadirectory ${tor_datadir} --user ${tor_user}" 36 | extra_commands="log" 37 | log_cmd="${name}_log" 38 | 39 | tor_log() { 40 | cat ${tor_logfile} 41 | } 42 | 43 | run_rc_command "$1" 44 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/contrib/dist/suse/tor.sh.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Copyright (c) 2006-2007 Andrew Lewman 4 | # 5 | # tor The Onion Router 6 | # 7 | # Startup/shutdown script for tor. This is a wrapper around torctl; 8 | # torctl does the actual work in a relatively system-independent, or at least 9 | # distribution-independent, way, and this script deals with fitting the 10 | # whole thing into the conventions of the particular system at hand. 11 | # 12 | # These next couple of lines "declare" tor for the "chkconfig" program, 13 | # originally from SGI, used on Red Hat/Fedora and probably elsewhere. 14 | # 15 | # chkconfig: 2345 90 10 16 | # description: Onion Router - A low-latency anonymous proxy 17 | # 18 | 19 | ### BEGIN INIT INFO 20 | # Provides: tor 21 | # Required-Start: $remote_fs $network 22 | # Required-Stop: $remote_fs $network 23 | # Default-Start: 3 5 24 | # Default-Stop: 0 1 2 6 25 | # Short-Description: Start the tor daemon 26 | # Description: Start the tor daemon: the anon-proxy server 27 | ### END INIT INFO 28 | 29 | . /etc/rc.status 30 | 31 | # Shell functions sourced from /etc/rc.status: 32 | # rc_check check and set local and overall rc status 33 | # rc_status check and set local and overall rc status 34 | # rc_status -v ditto but be verbose in local rc status 35 | # rc_status -v -r ditto and clear the local rc status 36 | # rc_failed set local and overall rc status to failed 37 | # rc_reset clear local rc status (overall remains) 38 | # rc_exit exit appropriate to overall rc status 39 | 40 | # First reset status of this service 41 | rc_reset 42 | 43 | # Increase open file descriptors a reasonable amount 44 | ulimit -n 8192 45 | 46 | TORCTL=@BINDIR@/torctl 47 | 48 | # torctl will use these environment variables 49 | TORUSER=@TORUSER@ 50 | export TORUSER 51 | TORGROUP=@TORGROUP@ 52 | export TORGROUP 53 | 54 | TOR_DAEMON_PID_DIR="@LOCALSTATEDIR@/run/tor" 55 | 56 | if [ -x /bin/su ] ; then 57 | SUPROG=/bin/su 58 | elif [ -x /sbin/su ] ; then 59 | SUPROG=/sbin/su 60 | elif [ -x /usr/bin/su ] ; then 61 | SUPROG=/usr/bin/su 62 | elif [ -x /usr/sbin/su ] ; then 63 | SUPROG=/usr/sbin/su 64 | else 65 | SUPROG=/bin/su 66 | fi 67 | 68 | case "$1" in 69 | 70 | start) 71 | echo "Starting tor daemon" 72 | 73 | if [ ! -d $TOR_DAEMON_PID_DIR ] ; then 74 | mkdir -p $TOR_DAEMON_PID_DIR 75 | chown $TORUSER:$TORGROUP $TOR_DAEMON_PID_DIR 76 | fi 77 | 78 | ## Start daemon with startproc(8). If this fails 79 | ## the echo return value is set appropriate. 80 | 81 | startproc -f $TORCTL start 82 | # Remember status and be verbose 83 | rc_status -v 84 | ;; 85 | 86 | stop) 87 | echo "Stopping tor daemon" 88 | startproc -f $TORCTL stop 89 | # Remember status and be verbose 90 | rc_status -v 91 | ;; 92 | 93 | restart) 94 | echo "Restarting tor daemon" 95 | startproc -f $TORCTL restart 96 | # Remember status and be verbose 97 | rc_status -v 98 | ;; 99 | 100 | reload) 101 | echo "Reloading tor daemon" 102 | startproc -f $TORCTL reload 103 | # Remember status and be verbose 104 | rc_status -v 105 | ;; 106 | 107 | status) 108 | startproc -f $TORCTL status 109 | # Remember status and be verbose 110 | rc_status -v 111 | ;; 112 | 113 | *) 114 | echo "Usage: $0 (start|stop|restart|reload|status)" 115 | RETVAL=1 116 | esac 117 | 118 | rc_exit 119 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/contrib/dist/tor.service.in: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description = Anonymizing overlay network for TCP 3 | After = syslog.target network.target nss-lookup.target 4 | 5 | [Service] 6 | Type = simple 7 | ExecStartPre = @BINDIR@/tor -f @CONFDIR@/torrc --verify-config 8 | # A torrc that has "RunAsDaemon 1" won't work with the "simple" service type; 9 | # let's explicitly override it. 10 | ExecStart = @BINDIR@/tor -f @CONFDIR@/torrc --RunAsDaemon 0 11 | ExecReload = /bin/kill -HUP ${MAINPID} 12 | KillSignal = SIGINT 13 | TimeoutSec = 30 14 | Restart = on-failure 15 | LimitNOFILE = 32768 16 | 17 | # Hardening 18 | PrivateTmp = yes 19 | DeviceAllow = /dev/null rw 20 | DeviceAllow = /dev/urandom r 21 | InaccessibleDirectories = /home 22 | ReadOnlyDirectories = / 23 | ReadWriteDirectories = @LOCALSTATEDIR@/lib/tor 24 | ReadWriteDirectories = @LOCALSTATEDIR@/log/tor 25 | NoNewPrivileges = yes 26 | 27 | [Install] 28 | WantedBy = multi-user.target 29 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/contrib/dist/tor.sh.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # tor The Onion Router 4 | # 5 | # Startup/shutdown script for tor. This is a wrapper around torctl; 6 | # torctl does the actual work in a relatively system-independent, or at least 7 | # distribution-independent, way, and this script deals with fitting the 8 | # whole thing into the conventions of the particular system at hand. 9 | # This particular script is written for Red Hat/Fedora Linux, and may 10 | # also work on Mandrake, but not SuSE. 11 | # 12 | # These next couple of lines "declare" tor for the "chkconfig" program, 13 | # originally from SGI, used on Red Hat/Fedora and probably elsewhere. 14 | # 15 | # chkconfig: 2345 90 10 16 | # description: Onion Router - A low-latency anonymous proxy 17 | # 18 | 19 | PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin 20 | DAEMON=/usr/sbin/tor 21 | NAME=tor 22 | DESC="tor daemon" 23 | TORPIDDIR=/var/run/tor 24 | TORPID=$TORPIDDIR/tor.pid 25 | WAITFORDAEMON=60 26 | ARGS="" 27 | 28 | # Library functions 29 | if [ -f /etc/rc.d/init.d/functions ]; then 30 | . /etc/rc.d/init.d/functions 31 | elif [ -f /etc/init.d/functions ]; then 32 | . /etc/init.d/functions 33 | fi 34 | 35 | TORCTL=@BINDIR@/torctl 36 | 37 | # torctl will use these environment variables 38 | TORUSER=@TORUSER@ 39 | export TORUSER 40 | 41 | if [ -x /bin/su ] ; then 42 | SUPROG=/bin/su 43 | elif [ -x /sbin/su ] ; then 44 | SUPROG=/sbin/su 45 | elif [ -x /usr/bin/su ] ; then 46 | SUPROG=/usr/bin/su 47 | elif [ -x /usr/sbin/su ] ; then 48 | SUPROG=/usr/sbin/su 49 | else 50 | SUPROG=/bin/su 51 | fi 52 | 53 | # Raise ulimit based on number of file descriptors available (thanks, Debian) 54 | 55 | if [ -r /proc/sys/fs/file-max ]; then 56 | system_max=`cat /proc/sys/fs/file-max` 57 | if [ "$system_max" -gt "80000" ] ; then 58 | MAX_FILEDESCRIPTORS=32768 59 | elif [ "$system_max" -gt "40000" ] ; then 60 | MAX_FILEDESCRIPTORS=16384 61 | elif [ "$system_max" -gt "10000" ] ; then 62 | MAX_FILEDESCRIPTORS=8192 63 | else 64 | MAX_FILEDESCRIPTORS=1024 65 | cat << EOF 66 | 67 | Warning: Your system has very few filedescriptors available in total. 68 | 69 | Maybe you should try raising that by adding 'fs.file-max=100000' to your 70 | /etc/sysctl.conf file. Feel free to pick any number that you deem appropriate. 71 | Then run 'sysctl -p'. See /proc/sys/fs/file-max for the current value, and 72 | file-nr in the same directory for how many of those are used at the moment. 73 | 74 | EOF 75 | fi 76 | else 77 | MAX_FILEDESCRIPTORS=8192 78 | fi 79 | 80 | NICE="" 81 | 82 | case "$1" in 83 | 84 | start) 85 | if [ -n "$MAX_FILEDESCRIPTORS" ]; then 86 | echo -n "Raising maximum number of filedescriptors (ulimit -n) to $MAX_FILEDESCRIPTORS" 87 | if ulimit -n "$MAX_FILEDESCRIPTORS" ; then 88 | echo "." 89 | else 90 | echo ": FAILED." 91 | fi 92 | fi 93 | 94 | action $"Starting tor:" $TORCTL start 95 | RETVAL=$? 96 | ;; 97 | 98 | stop) 99 | action $"Stopping tor:" $TORCTL stop 100 | RETVAL=$? 101 | ;; 102 | 103 | restart) 104 | action $"Restarting tor:" $TORCTL restart 105 | RETVAL=$? 106 | ;; 107 | 108 | reload) 109 | action $"Reloading tor:" $TORCTL reload 110 | RETVAL=$? 111 | ;; 112 | 113 | status) 114 | $TORCTL status 115 | RETVAL=$? 116 | ;; 117 | 118 | *) 119 | echo "Usage: $0 (start|stop|restart|reload|status)" 120 | RETVAL=1 121 | esac 122 | 123 | exit $RETVAL 124 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/contrib/include.am: -------------------------------------------------------------------------------- 1 | 2 | EXTRA_DIST+= \ 3 | contrib/README \ 4 | contrib/client-tools/torify \ 5 | contrib/dist/rc.subr \ 6 | contrib/dist/suse/tor.sh.in \ 7 | contrib/dist/tor.sh \ 8 | contrib/dist/torctl \ 9 | contrib/dist/tor.service.in \ 10 | contrib/operator-tools/linux-tor-prio.sh \ 11 | contrib/operator-tools/tor-exit-notice.html \ 12 | contrib/or-tools/exitlist \ 13 | contrib/win32build/package_nsis-mingw.sh \ 14 | contrib/win32build/tor-mingw.nsi.in \ 15 | contrib/win32build/tor.ico \ 16 | contrib/win32build/tor.nsi.in 17 | 18 | bin_SCRIPTS+= contrib/client-tools/torify 19 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/contrib/operator-tools/tor.logrotate.in: -------------------------------------------------------------------------------- 1 | @LOCALSTATEDIR@/log/tor/*log { 2 | daily 3 | rotate 5 4 | compress 5 | delaycompress 6 | missingok 7 | notifempty 8 | # you may need to change the username/groupname below 9 | create 0640 _tor _tor 10 | sharedscripts 11 | postrotate 12 | /etc/init.d/tor reload > /dev/null 13 | endscript 14 | } 15 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/contrib/or-tools/check-tor: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ## Originally written by Peter Palfrader. 4 | 5 | ## This script lets you quickly check if a given router (by nickname) 6 | ## will let you do a TLS handshake, or will let you download a directory. 7 | 8 | ## Usage: check-tor nickname 9 | 10 | #set -x 11 | 12 | router="$1" 13 | dirserver="http://belegost.seul.org:80/tor/" 14 | 15 | lines=$( wget -q $dirserver --proxy=off -O - | grep -A5 '^router '"$router"' ' ) 16 | line=$( echo "$lines" | head -n1 ) 17 | 18 | if [ -z "$line" ]; then 19 | echo "Not found" >&2 20 | exit 1 21 | fi 22 | 23 | echo "$lines" 24 | echo 25 | 26 | ipor=$( echo "$line" | awk '{printf "%s:%s", $3, $4}' ) 27 | 28 | op=$( echo "$line" | awk '{printf $6}' ) 29 | ipop=$( echo "$line" | awk '{printf "%s:%s", $3, $6}' ) 30 | 31 | echo 32 | echo ">>" openssl s_client -connect "$ipor" 33 | timeout 5 openssl s_client -connect "$ipor" < /dev/null 34 | if [ "$op" != "0" ]; then 35 | echo 36 | echo ">>" wget --proxy=off -O - http://$ipop/tor/ 37 | timeout 5 wget --proxy=off -O - http://$ipop/tor/ | head -n3 38 | fi 39 | 40 | echo 41 | echo -n "$router "; echo "$lines" | grep 'fingerprint' | sed -e 's/^opt //' -e 's/^fingerprint //'; 42 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/contrib/or-tools/checksocks.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | 3 | require 5.005; 4 | use strict; 5 | use IO::Socket; 6 | use Getopt::Std; 7 | 8 | # Checks routers for open socks-ports and socks5 9 | # Successful connects go to STDOUT, failed ones to STDERR. 10 | # We only do one check per loop in -d mode, so it takes some time. 11 | 12 | # Contributed by Peter Kornherr , and 13 | # cleaned up by Peter Palfrader . 14 | 15 | our($opt_i,$opt_p,$opt_d,$opt_h,$opt_l); 16 | getopts('i:p:dhl:'); 17 | 18 | if ($opt_h || !($opt_d||$opt_i||$opt_l)) { 19 | print "Usage: $0 -d < file_with_routers_in_it\n"; 20 | print "or: $0 -i IP -p Port\n"; 21 | print "or: $0 -l IP:Port\n"; 22 | exit; 23 | } 24 | 25 | if ($opt_d) { 26 | open (IN,"<-") or die $!; 27 | while () { 28 | next unless /^router /; 29 | (my $routername,my $checkip,my $checkport) = (split(" "))[1,2,4]; 30 | &do_check($checkip,$checkport,$routername); 31 | } 32 | } elsif ($opt_i && $opt_p) { 33 | &do_check($opt_i,$opt_p); 34 | } elsif ($opt_l) { 35 | &do_check(split(":",$opt_l)); 36 | } 37 | 38 | sub do_check { 39 | (my $checkip, my $checkport,my $routername) = @_; 40 | # as socksports may not be published (therefore "0") here, 41 | # let's try 9050, the default port: 42 | if ($checkport == 0) { $checkport = 9050; } 43 | # print "Checking $checkip:$checkport\n"; 44 | my $s5socket = IO::Socket::INET->new(PeerAddr => $checkip, 45 | PeerPort => $checkport, Proto => "tcp", Type => SOCK_STREAM, 46 | Timeout => "20"); 47 | if ($s5socket) { 48 | my @got; 49 | print $s5socket pack("CCC",'5','1','0'); 50 | eval { 51 | local $SIG{ALRM} = sub { die "alarm\n" }; 52 | alarm 10; 53 | read ($s5socket,$got[0],1); 54 | read ($s5socket,$got[1],1); 55 | alarm 0; 56 | }; 57 | if ($@) { 58 | return; # die unless $@ eq "alarm\n"; 59 | } 60 | if ($got[0] eq pack('C','5')) { 61 | if(defined($routername)) { 62 | print "Found SOCKS5 at $routername ($checkip:$checkport)\n"; 63 | } else { 64 | print "Found SOCKS5 at $checkip:$checkport\n"; 65 | } 66 | } else { 67 | if(defined($routername)) { 68 | print "$routername ($checkip:$checkport) answers - " . 69 | "but not SOCKS5.\n"; 70 | } else { 71 | print "$checkip:$checkport answers - but not SOCKS5.\n"; 72 | } 73 | } 74 | } else { 75 | if(defined($routername)) { 76 | print STDERR "Can't connect to $routername " . 77 | "($checkip:$checkport) ($!)\n"; 78 | } else { 79 | print STDERR "Can't connect to $checkip:$checkport ($!)\n"; 80 | } 81 | } 82 | } 83 | 84 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/contrib/win32build/tor-mingw.nsi.in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0x3a/tor-dns/47914acb407570035a4f57611def7e03efa48b59/patched tor/tor-0.2.6.1-alpha/contrib/win32build/tor-mingw.nsi.in -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/contrib/win32build/tor.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0x3a/tor-dns/47914acb407570035a4f57611def7e03efa48b59/patched tor/tor-0.2.6.1-alpha/contrib/win32build/tor.ico -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/doc/asciidoc-helper.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Copyright (c) The Tor Project, Inc. 4 | # See LICENSE for licensing information 5 | # Run this to generate .html.in or .1.in files from asciidoc files. 6 | # Arguments: 7 | # html|man asciidocpath outputfile 8 | 9 | set -e 10 | 11 | if [ $# != 3 ]; then 12 | exit 1; 13 | fi 14 | 15 | output=$3 16 | 17 | if [ "$1" = "html" ]; then 18 | input=${output%%.html.in}.1.txt 19 | base=${output%%.html.in} 20 | 21 | if [ "$2" != none ]; then 22 | "$2" -d manpage -o $output $input; 23 | else 24 | echo "=================================="; 25 | echo; 26 | echo "You need asciidoc installed to be able to build the manpage."; 27 | echo "To build without manpages, use the --disable-asciidoc argument"; 28 | echo "when calling configure."; 29 | echo; 30 | echo "=================================="; 31 | exit 1; 32 | fi 33 | elif [ "$1" = "man" ]; then 34 | input=${output%%.1.in}.1.txt 35 | base=${output%%.1.in} 36 | 37 | if test "$2" = none; then 38 | echo "=================================="; 39 | echo; 40 | echo "You need asciidoc installed to be able to build the manpage."; 41 | echo "To build without manpages, use the --disable-asciidoc argument"; 42 | echo "when calling configure."; 43 | echo; 44 | echo "=================================="; 45 | exit 1; 46 | fi 47 | if "$2" -f manpage $input; then 48 | mv $base.1 $output; 49 | else 50 | cat<, Steven J. Murdoch 61 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/doc/tor-gencert.1.txt: -------------------------------------------------------------------------------- 1 | // Copyright (c) The Tor Project, Inc. 2 | // See LICENSE for licensing information 3 | // This is an asciidoc file used to generate the manpage/html reference. 4 | // Learn asciidoc on http://www.methods.co.nz/asciidoc/userguide.html 5 | :man source: Tor 6 | :man manual: Tor Manual 7 | tor-gencert(1) 8 | ============== 9 | Nick Mathewson 10 | 11 | NAME 12 | ---- 13 | tor-gencert - Generate certs and keys for Tor directory authorities 14 | 15 | SYNOPSIS 16 | -------- 17 | **tor-gencert** [-h|--help] [-v] [-r|--reuse] [--create-identity-key] [-i __id_file__] [-c 18 | __cert_file__] [-m __num__] [-a __address__:__port__] 19 | 20 | DESCRIPTION 21 | ----------- 22 | **tor-gencert** generates certificates and private keys for use by Tor 23 | directory authorities running the v3 Tor directory protocol, as used by 24 | Tor 0.2.0 and later. If you are not running a directory authority, you 25 | don't need to use tor-gencert. + 26 | 27 | Every directory authority has a long term authority __identity__ __key__ (which 28 | is distinct from the identity key it uses as a Tor server); this key 29 | should be kept offline in a secure location. It is used to certify 30 | shorter-lived __signing__ __keys__, which are kept online and used by the 31 | directory authority to sign votes and consensus documents. + 32 | 33 | After you use this program to generate a signing key and a certificate, 34 | copy those files to the keys subdirectory of your Tor process, and send 35 | Tor a SIGHUP signal. DO NOT COPY THE IDENTITY KEY. 36 | 37 | OPTIONS 38 | ------- 39 | **-v**:: 40 | Display verbose output. 41 | 42 | **-h** or **--help**:: 43 | Display help text and exit. 44 | 45 | **-r** or **--reuse**:: 46 | Generate a new certificate, but not a new signing key. This can be used to 47 | change the address or lifetime associated with a given key. 48 | 49 | **--create-identity-key**:: 50 | Generate a new identity key. You should only use this option the first time 51 | you run tor-gencert; in the future, you should use the identity key that's 52 | already there. 53 | 54 | **-i** __FILENAME__:: 55 | Read the identity key from the specified file. If the file is not present 56 | and --create-identity-key is provided, create the identity key in the 57 | specified file. Default: "./authority_identity_key" 58 | 59 | **-s** __FILENAME__:: 60 | Write the signing key to the specified file. Default: 61 | "./authority_signing_key" 62 | 63 | **-c** __FILENAME__:: 64 | Write the certificate to the specified file. Default: 65 | "./authority_certificate" 66 | 67 | **-m** __NUM__:: 68 | Number of months that the certificate should be valid. Default: 12. 69 | 70 | **--passphrase-fd** __FILEDES__:: 71 | Filedescriptor to read the file descriptor from. Ends at the first NUL or 72 | newline. Default: read from the terminal. 73 | 74 | **-a** __address__:__port__:: 75 | If provided, advertise the address:port combination as this authority's 76 | preferred directory port in its certificate. If the address is a hostname, 77 | the hostname is resolved to an IP before it's published. 78 | 79 | BUGS 80 | ---- 81 | This probably doesn't run on Windows. That's not a big issue, since we don't 82 | really want authorities to be running on Windows anyway. 83 | 84 | SEE ALSO 85 | -------- 86 | **tor**(1) + 87 | 88 | See also the "dir-spec.txt" file, distributed with Tor. 89 | 90 | AUTHORS 91 | ------- 92 | Roger Dingledine , Nick Mathewson . 93 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/doc/tor-resolve.1.txt: -------------------------------------------------------------------------------- 1 | // Copyright (c) The Tor Project, Inc. 2 | // See LICENSE for licensing information 3 | // This is an asciidoc file used to generate the manpage/html reference. 4 | // Learn asciidoc on http://www.methods.co.nz/asciidoc/userguide.html 5 | :man source: Tor 6 | :man manual: Tor Manual 7 | tor-resolve(1) 8 | ============== 9 | Peter Palfrader 10 | 11 | NAME 12 | ---- 13 | tor-resolve - resolve a hostname to an IP address via tor 14 | 15 | SYNOPSIS 16 | -------- 17 | **tor-resolve** [-4|-5] [-v] [-x] __hostname__ [__sockshost__[:__socksport__]] 18 | 19 | DESCRIPTION 20 | ----------- 21 | **tor-resolve** is a simple script to connect to a SOCKS proxy that knows about 22 | the SOCKS RESOLVE command, hand it a hostname, and return an IP address. 23 | 24 | By default, **tor-resolve** uses the Tor server running on 127.0.0.1 on SOCKS 25 | port 9050. If this isn't what you want, you should specify an explicit 26 | __sockshost__ and/or __socksport__ on the command line. 27 | 28 | OPTIONS 29 | ------- 30 | **-v**:: 31 | Display verbose output. 32 | 33 | **-x**:: 34 | Perform a reverse lookup: get the PTR record for an IPv4 address. 35 | 36 | **-5**:: 37 | Use the SOCKS5 protocol. (Default) 38 | 39 | **-4**:: 40 | Use the SOCKS4a protocol rather than the default SOCKS5 protocol. Doesn't 41 | support reverse DNS. 42 | 43 | SEE ALSO 44 | -------- 45 | **tor**(1), **torify**(1). + 46 | 47 | See doc/socks-extensions.txt in the Tor package for protocol details. 48 | 49 | AUTHORS 50 | ------- 51 | Roger Dingledine , Nick Mathewson . 52 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/doc/torify.1.txt: -------------------------------------------------------------------------------- 1 | // Copyright (c) The Tor Project, Inc. 2 | // See LICENSE for licensing information 3 | // This is an asciidoc file used to generate the manpage/html reference. 4 | // Learn asciidoc on http://www.methods.co.nz/asciidoc/userguide.html 5 | :man source: Tor 6 | :man manual: Tor Manual 7 | torify(1) 8 | ========= 9 | 10 | NAME 11 | ---- 12 | torify - wrapper for torsocks and tor 13 | 14 | SYNOPSIS 15 | -------- 16 | **torify** __application__ [__application's__ __arguments__] 17 | 18 | DESCRIPTION 19 | ----------- 20 | **torify** is a simple wrapper that attempts to find the best underlying Tor 21 | wrapper available on a system. It calls torsocks with a tor specific 22 | configuration file. + 23 | 24 | torsocks is an improved wrapper that explicitly rejects UDP, safely resolves DNS 25 | lookups and properly socksifies your TCP connections. + 26 | 27 | Please note that since both method use LD_PRELOAD, torify cannot be applied to 28 | suid binaries. 29 | 30 | WARNING 31 | ------- 32 | When used with torsocks, torify should not leak DNS requests or UDP data. + 33 | 34 | Both will leak ICMP data. 35 | 36 | SEE ALSO 37 | -------- 38 | **tor**(1), **tor-resolve**(1), **torsocks**(1) 39 | 40 | AUTHORS 41 | ------- 42 | Peter Palfrader and Jacob Appelbaum wrote this manual. 43 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/m4/ax_check_sign.m4: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # http://www.gnu.org/software/autoconf-archive/ax_check_sign.html 3 | # =========================================================================== 4 | # 5 | # SYNOPSIS 6 | # 7 | # AX_CHECK_SIGN (TYPE, [ACTION-IF-SIGNED], [ACTION-IF-UNSIGNED], [INCLUDES]) 8 | # 9 | # DESCRIPTION 10 | # 11 | # Checks whether TYPE is signed or not. If no INCLUDES are specified, the 12 | # default includes are used. If ACTION-IF-SIGNED is given, it is 13 | # additional shell code to execute when the type is signed. If 14 | # ACTION-IF-UNSIGNED is given, it is executed when the type is unsigned. 15 | # 16 | # This macro assumes that the type exists. Therefore the existence of the 17 | # type should be checked before calling this macro. For example: 18 | # 19 | # AC_CHECK_HEADERS([wchar.h]) 20 | # AC_CHECK_TYPE([wchar_t],,[ AC_MSG_ERROR([Type wchar_t not found.]) ]) 21 | # AX_CHECK_SIGN([wchar_t], 22 | # [ AC_DEFINE(WCHAR_T_SIGNED, 1, [Define if wchar_t is signed]) ], 23 | # [ AC_DEFINE(WCHAR_T_UNSIGNED, 1, [Define if wchar_t is unsigned]) ], [ 24 | # #ifdef HAVE_WCHAR_H 25 | # #include 26 | # #endif 27 | # ]) 28 | # 29 | # LICENSE 30 | # 31 | # Copyright (c) 2008 Ville Laurikari 32 | # 33 | # Copying and distribution of this file, with or without modification, are 34 | # permitted in any medium without royalty provided the copyright notice 35 | # and this notice are preserved. This file is offered as-is, without any 36 | # warranty. 37 | 38 | #serial 6 39 | 40 | AU_ALIAS([VL_CHECK_SIGN], [AX_CHECK_SIGN]) 41 | AC_DEFUN([AX_CHECK_SIGN], [ 42 | typename=`echo $1 | sed "s/@<:@^a-zA-Z0-9_@:>@/_/g"` 43 | AC_CACHE_CHECK([whether $1 is signed], ax_cv_decl_${typename}_signed, [ 44 | AC_TRY_COMPILE([$4], 45 | [ int foo @<:@ 1 - 2 * !((($1) -1) < 0) @:>@ ], 46 | [ eval "ax_cv_decl_${typename}_signed=\"yes\"" ], 47 | [ eval "ax_cv_decl_${typename}_signed=\"no\"" ])]) 48 | symbolname=`echo $1 | sed "s/@<:@^a-zA-Z0-9_@:>@/_/g" | tr "a-z" "A-Z"` 49 | if eval "test \"\${ax_cv_decl_${typename}_signed}\" = \"yes\""; then 50 | $2 51 | elif eval "test \"\${ax_cv_decl_${typename}_signed}\" = \"no\""; then 52 | $3 53 | fi 54 | ])dnl 55 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/scripts/README: -------------------------------------------------------------------------------- 1 | The scripts directory holds tools for use in building, generating, testing, 2 | and maintaining the Tor source code. It is mainly for use by developers. 3 | 4 | Code maintenance scripts 5 | ------------------------ 6 | 7 | maint/checkLogs.pl -- Verify that Tor log statements are unique. 8 | 9 | maint/check_config_macros.pl -- Look for autoconf tests whose results are 10 | never used. 11 | 12 | maint/checkOptionDocs.pl -- Make sure that Tor options are documented in the 13 | manpage, and that the manpage only documents real Tor options. 14 | 15 | maint/checkSpaces.pl -- Style checker for the Tor source code. Mainly checks 16 | whitespace. 17 | 18 | maint/findMergedChanges.pl -- Find a set of changes/* files that have been 19 | merged into an upstream version. 20 | 21 | maint/format_changelog.py -- Flow the changelog into the proper format. 22 | 23 | maint/redox.py -- Find places that should have DOCDOC comments to indicate a 24 | need for doxygen comments, and put those comments there. 25 | 26 | maint/updateVersions.pl -- Update the version number in the .nsi and windows 27 | orconfig.h files. 28 | 29 | 30 | Testing scripts 31 | --------------- 32 | 33 | test/cov-blame -- Mash up the results of gcov with git blame. Mainly useful 34 | to find out who has been writing untested code. 35 | 36 | test/cov-diff -- Compare two directories of gcov files to identify changed 37 | lines without coverage. 38 | 39 | test/coverage -- Generates a directory full of gcov files. You need to use 40 | this script instead of calling gcov directly because of our confusingly named 41 | object files. 42 | 43 | test/scan-build.sh -- Example script for invoking clang's scan-build 44 | static analysis tools. 45 | 46 | 47 | Code generation scripts 48 | ----------------------- 49 | 50 | codegen/gen_linux_syscalls.pl -- Generate a table mapping linux syscall 51 | numbers to their names. 52 | 53 | codegen/gen_server_ciphers.py -- Generate a sorted list of TLS ciphersuites 54 | for servers to choose from. 55 | 56 | codegen/get_mozilla_ciphers.py -- Generate a list of TLS ciphersuites for 57 | clients to use in order to look like Firefox. 58 | 59 | Code transformation scripts 60 | --------------------------- 61 | 62 | coccinelle/calloc.cocci -- Transform code to replace variants of 63 | malloc(a*b) with calloc(a,b) 64 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/scripts/coccinelle/calloc.cocci: -------------------------------------------------------------------------------- 1 | // Use calloc or realloc as appropriate instead of multiply-and-alloc 2 | 3 | @malloc_to_calloc@ 4 | expression a,b; 5 | @@ 6 | - tor_malloc(a * b) 7 | + tor_calloc(a, b) 8 | 9 | @malloc_zero_to_calloc@ 10 | expression a, b; 11 | @@ 12 | - tor_malloc_zero(a * b) 13 | + tor_calloc(a, b) 14 | 15 | @realloc_to_reallocarray@ 16 | expression a, b; 17 | expression p; 18 | @@ 19 | - tor_realloc(p, a * b) 20 | + tor_reallocarray(p, a, b) 21 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/scripts/codegen/gen_linux_syscalls.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | 3 | use strict; 4 | my %syscalls = (); 5 | 6 | while (<>) { 7 | if (/^#define (__NR_\w+) /) { 8 | $syscalls{$1} = 1; 9 | } 10 | } 11 | 12 | print <) { 10 | if ($more) { 11 | if (/LD_BUG/) { 12 | $more = 0; 13 | next; 14 | } 15 | if (/\"((?:[^\"\\]+|\\.*)+)\"(.*)/) { 16 | $last .= $1; 17 | if ($2 !~ /[,\)]/) { 18 | $more = 1; 19 | } else { 20 | $count{lc $last}++; 21 | $more = 0; 22 | } 23 | } elsif (/[,\)]/) { 24 | $count{lc $last}++; 25 | $more = 0; 26 | } elsif ($more == 2) { 27 | print "SKIPPED more\n"; 28 | } 29 | } elsif (/log_(?:warn|err|notice)\(\s*(LD_[A-Z_]*)\s*,\s*\"((?:[^\"\\]+|\\.)*)\"(.*)/) { 30 | next if ($1 eq 'LD_BUG'); 31 | my $s = $2; 32 | if ($3 =~ /[,\)]/ ) { 33 | $count{lc $s}++; 34 | } else { 35 | $more = 1; 36 | $last = $s; 37 | } 38 | } elsif (/log_(?:warn|err|notice)\(\s*((?:LD_[A-Z_]*)?)(.*)/) { 39 | next if ($1 eq 'LD_BUG'); 40 | my $extra = $2; 41 | chomp $extra; 42 | $last = ""; 43 | $more = 2 if ($extra eq ''); 44 | } 45 | } 46 | 47 | while ((my $phrase, my $count) = each %count) { 48 | if ($count > 1) { 49 | print "$count\t$phrase\n"; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/scripts/maint/checkOptionDocs.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | use strict; 3 | 4 | my %options = (); 5 | my %descOptions = (); 6 | my %torrcSampleOptions = (); 7 | my %manPageOptions = (); 8 | 9 | # Load the canonical list as actually accepted by Tor. 10 | open(F, "./src/or/tor --list-torrc-options |") or die; 11 | while () { 12 | next if m!\[notice\] Tor v0\.!; 13 | if (m!^([A-Za-z0-9_]+)!) { 14 | $options{$1} = 1; 15 | } else { 16 | print "Unrecognized output> "; 17 | print; 18 | } 19 | } 20 | close F; 21 | 22 | # Load the contents of torrc.sample 23 | sub loadTorrc { 24 | my ($fname, $options) = @_; 25 | local *F; 26 | open(F, "$fname") or die; 27 | while () { 28 | next if (m!##+!); 29 | if (m!#([A-Za-z0-9_]+)!) { 30 | $options->{$1} = 1; 31 | } 32 | } 33 | close F; 34 | 0; 35 | } 36 | 37 | loadTorrc("./src/config/torrc.sample.in", \%torrcSampleOptions); 38 | 39 | # Try to figure out what's in the man page. 40 | 41 | my $considerNextLine = 0; 42 | open(F, "./doc/tor.1.txt") or die; 43 | while () { 44 | if (m!^(?:\[\[([A-za-z0-9_]+)\]\] *)?\*\*([A-Za-z0-9_]+)\*\*!) { 45 | $manPageOptions{$2} = 1; 46 | print "Missing an anchor: $2\n" unless (defined $1 or $2 eq 'tor'); 47 | } 48 | } 49 | close F; 50 | 51 | # Now, display differences: 52 | 53 | sub subtractHashes { 54 | my ($s, $a, $b) = @_; 55 | my @lst = (); 56 | for my $k (keys %$a) { 57 | push @lst, $k unless (exists $b->{$k}); 58 | } 59 | print "$s: ", join(' ', sort @lst), "\n\n"; 60 | 0; 61 | } 62 | 63 | # subtractHashes("No online docs", \%options, \%descOptions); 64 | # subtractHashes("Orphaned online docs", \%descOptions, \%options); 65 | 66 | subtractHashes("Orphaned in torrc.sample.in", \%torrcSampleOptions, \%options); 67 | 68 | subtractHashes("Not in man page", \%options, \%manPageOptions); 69 | subtractHashes("Orphaned in man page", \%manPageOptions, \%options); 70 | 71 | 72 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/scripts/maint/check_config_macros.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | 3 | use strict; 4 | 5 | my @macros = (); 6 | 7 | open(F, 'orconfig.h.in'); 8 | while() { 9 | if (/^#undef +([A-Za-z0-9_]*)/) { 10 | push @macros, $1; 11 | } 12 | } 13 | close F; 14 | 15 | for my $m (@macros) { 16 | my $s = `git grep '$m' src`; 17 | if ($s eq '') { 18 | print "Unused: $m\n"; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/scripts/maint/findMergedChanges.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use warnings; 4 | use strict; 5 | 6 | sub nChanges { 7 | my ($branches, $fname) = @_; 8 | local *F; 9 | # requires perl 5.8. Avoids shell issues if we ever get a changes 10 | # file named by the parents of Little Johnny Tables. 11 | open F, "-|", "git", "log", "--no-merges", "--pretty=format:%H", $branches, "--", $fname 12 | or die "$!"; 13 | my @changes = ; 14 | return scalar @changes 15 | } 16 | 17 | my $look_for_type = "merged"; 18 | 19 | if (! @ARGV) { 20 | print <] changes/* 23 | 24 | A change is "merged" if it has ever been merged to release-0.2.4 and it has had 25 | no subsequent changes in master. 26 | 27 | A change is "unmerged" if it has never been merged to release-0.2.4 and it 28 | has had changes in master. 29 | 30 | A change is "weird" if it has been merged to release-0.2.4 and it *has* had 31 | subsequent changes in master. 32 | 33 | Suggested application: 34 | findMergedChanges.pl --merged changes/* | xargs -n 1 git rm 35 | 36 | EOF 37 | } 38 | 39 | my $target_branch = "origin/release-0.2.4"; 40 | my $head = "origin/master"; 41 | 42 | while (@ARGV and $ARGV[0] =~ /^--/) { 43 | my $flag = shift @ARGV; 44 | if ($flag =~ /^--(weird|merged|unmerged|list)/) { 45 | $look_for_type = $1; 46 | } elsif ($flag =~ /^--branch=(\S+)/) { 47 | $target_branch = $1; 48 | } elsif ($flag =~ /^--head=(\S+)/) { 49 | $head = $1; 50 | } else { 51 | die "Unrecognized flag $flag"; 52 | } 53 | } 54 | 55 | for my $changefile (@ARGV) { 56 | my $n_merged = nChanges($target_branch, $changefile); 57 | my $n_postmerged = nChanges("${target_branch}..${head}", $changefile); 58 | my $type; 59 | 60 | if ($n_merged != 0 and $n_postmerged == 0) { 61 | $type = "merged"; 62 | } elsif ($n_merged == 0 and $n_postmerged != 0) { 63 | $type = "unmerged"; 64 | } else { 65 | $type = "weird"; 66 | } 67 | 68 | if ($type eq $look_for_type) { 69 | print "$changefile\n"; 70 | } elsif ($look_for_type eq 'list') { 71 | printf "% 8s: %s\n", $type, $changefile; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/scripts/maint/sortChanges.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # Copyright (c) 2014, The Tor Project, Inc. 3 | # See LICENSE for licensing information 4 | 5 | """This script sorts a bunch of changes files listed on its command 6 | line into roughly the order in which they should appear in the 7 | changelog. 8 | 9 | TODO: collation support. 10 | """ 11 | 12 | import re 13 | import sys 14 | 15 | def fetch(fn): 16 | with open(fn) as f: 17 | s = f.read() 18 | s = "%s\n" % s.rstrip() 19 | return s 20 | 21 | def score(s): 22 | m = re.match(r'^ +o (.*)', s) 23 | if not m: 24 | print >>sys.stderr, "Can't score %r"%s 25 | lw = m.group(1).lower() 26 | if lw.startswith("major feature"): 27 | score = 0 28 | elif lw.startswith("major bug"): 29 | score = 1 30 | elif lw.startswith("major"): 31 | score = 2 32 | elif lw.startswith("minor feature"): 33 | score = 10 34 | elif lw.startswith("minor bug"): 35 | score = 11 36 | elif lw.startswith("minor"): 37 | score = 12 38 | else: 39 | score = 100 40 | 41 | return (score, lw, s) 42 | 43 | 44 | changes = [ score(fetch(fn)) for fn in sys.argv[1:] if not fn.endswith('~') ] 45 | 46 | changes.sort() 47 | 48 | for _, _, s in changes: 49 | print s 50 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/scripts/maint/updateVersions.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | 3 | $CONFIGURE_IN = './configure.ac'; 4 | $ORCONFIG_H = './src/win32/orconfig.h'; 5 | $TOR_NSI = './contrib/win32build/tor-mingw.nsi.in'; 6 | 7 | $quiet = 1; 8 | 9 | sub demand { 10 | my $fn = shift; 11 | die "Missing file $fn" unless (-f $fn); 12 | } 13 | 14 | demand($CONFIGURE_IN); 15 | demand($ORCONFIG_H); 16 | demand($TOR_NSI); 17 | 18 | # extract version from configure.ac 19 | 20 | open(F, $CONFIGURE_IN) or die "$!"; 21 | $version = undef; 22 | while () { 23 | if (/AC_INIT\(\[tor\],\s*\[([^\]]*)\]\)/) { 24 | $version = $1; 25 | last; 26 | } 27 | } 28 | die "No version found" unless $version; 29 | print "Tor version is $version\n" unless $quiet; 30 | close F; 31 | 32 | sub correctversion { 33 | my ($fn, $defchar) = @_; 34 | undef $/; 35 | open(F, $fn) or die "$!"; 36 | my $s = ; 37 | close F; 38 | if ($s =~ /^$defchar(?:)define\s+VERSION\s+\"([^\"]+)\"/m) { 39 | $oldver = $1; 40 | if ($oldver ne $version) { 41 | print "Version mismatch in $fn: It thinks that the version is $oldver. I think it's $version. Fixing.\n"; 42 | $line = $defchar . "define VERSION \"$version\""; 43 | open(F, ">$fn.bak"); 44 | print F $s; 45 | close F; 46 | $s =~ s/^$defchar(?:)define\s+VERSION.*?$/$line/m; 47 | open(F, ">$fn"); 48 | print F $s; 49 | close F; 50 | } else { 51 | print "$fn has the correct version. Good.\n" unless $quiet; 52 | } 53 | } else { 54 | print "Didn't find a version line in $fn -- uh oh.\n"; 55 | } 56 | } 57 | 58 | correctversion($TOR_NSI, "!"); 59 | correctversion($ORCONFIG_H, "#"); 60 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/scripts/test/cov-blame: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import os 4 | import re 5 | import subprocess 6 | import sys 7 | 8 | def handle_file(source_fname, cov_fname): 9 | 10 | lines_blm = subprocess.Popen(["git", "blame", source_fname], stdout=subprocess.PIPE).stdout.readlines() 11 | lines_cov = open(cov_fname).readlines() 12 | 13 | # XXXX expensive! 14 | while re.match(r'\s*-:\s*0:', lines_cov[0]): 15 | del lines_cov[0] 16 | 17 | if len(lines_blm) != len(lines_cov): 18 | print >>sys.stderr, "MISMATCH IN NUMBER OF LINES in",source_fname 19 | 20 | for b,c in zip(lines_blm, lines_cov): 21 | m = re.match(r'\s*([^\s:]+):', c) 22 | if not m: 23 | print >>sys.stderr, "CONFUSING LINE %r"% c 24 | cov = 'X' 25 | elif m.group(1) == '-': 26 | cov = '-' 27 | elif m.group(1)[0] == '#': 28 | cov = '#' 29 | elif m.group(1)[0].isdigit(): 30 | cov = '1' 31 | else: 32 | print >>sys.stderr, "CONFUSING LINE %r"% c 33 | cov = 'X' 34 | 35 | print cov, b, 36 | 37 | COV_DIR = sys.argv[1] 38 | SOURCES = sys.argv[2:] 39 | 40 | for fn in SOURCES: 41 | _, base = os.path.split(fn) 42 | cfn = os.path.join(COV_DIR, base) 43 | cfn += ".gcov" 44 | if os.path.exists(cfn): 45 | handle_file(fn, cfn) 46 | else: 47 | print >>sys.stderr, "NO FILE EXISTS CALLED ",cfn 48 | 49 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/scripts/test/cov-diff: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Copyright 2013 The Tor Project, Inc. 3 | # See LICENSE for licensing information. 4 | 5 | # cov-diff -- compare two directories full of gcov files. 6 | 7 | DIRA="$1" 8 | DIRB="$2" 9 | 10 | for A in $DIRA/*; do 11 | B=$DIRB/`basename $A` 12 | perl -pe 's/^\s*\d+:/ 1:/; s/^([^:]+:)[\d\s]+:/$1/;' "$A" > "$A.tmp" 13 | perl -pe 's/^\s*\d+:/ 1:/; s/^([^:]+:)[\d\s]+:/$1/;' "$B" > "$B.tmp" 14 | diff -u "$A.tmp" "$B.tmp" 15 | rm "$A.tmp" "$B.tmp" 16 | done 17 | 18 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/scripts/test/coverage: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Copyright 2013 The Tor Project, Inc. 3 | # See LICENSE for licensing information. 4 | 5 | # coverage -- run gcov on the appropriate set of object files to extract 6 | # coverage information. 7 | 8 | dst=$1 9 | 10 | for fn in src/or/*.c src/common/*.c; do 11 | BN=`basename $fn` 12 | DN=`dirname $fn` 13 | F=`echo $BN | sed -e 's/\.c$//;'` 14 | GC="${BN}.gcov" 15 | # Figure out the object file names 16 | ONS=`echo ${DN}/src_*-${F}.o` 17 | ONS_WILDCARD_LITERAL="${DN}/src_*-${F}.o" 18 | # If the wildcard didn't expand, no files 19 | if [ "$ONS" != "${ONS_WILDCARD_LITERAL}" ] 20 | then 21 | for on in $ONS; do 22 | # We should have a gcno file 23 | GCNO=`echo $on | sed -e 's/\.o$/\.gcno/;'` 24 | if [ -e $GCNO ] 25 | then 26 | # No need to test for gcda, since gcov assumes no execution 27 | # if it's absent 28 | rm -f $GC 29 | gcov -o $on $fn 30 | if [ -e $GC ] 31 | then 32 | if [ -n $dst ] 33 | then 34 | mv $GC $dst/$GC 35 | fi 36 | else 37 | echo "gcov -o $on $fn didn't make a .gcov file" 38 | fi 39 | else 40 | echo "Couldn't find gcno file for $on" 41 | fi 42 | done 43 | else 44 | echo "No object file found matching source file $fn" 45 | fi 46 | done 47 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/scripts/test/scan-build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Copyright 2014 The Tor Project, Inc 3 | # See LICENSE for licensing information 4 | # 5 | # This script is used for running a bunch of clang scan-build checkers 6 | # on Tor. 7 | # 8 | # It has hardwired paths for Nick's desktop at the moment. 9 | 10 | CHECKERS="\ 11 | --use-analyzer=/opt/clang-3.4/bin/clang \ 12 | -disable-checker deadcode.DeadStores \ 13 | -enable-checker alpha.core.CastSize \ 14 | -enable-checker alpha.core.CastToStruct \ 15 | -enable-checker alpha.core.IdenticalExpr \ 16 | -enable-checker alpha.core.SizeofPtr \ 17 | -enable-checker alpha.security.ArrayBoundV2 \ 18 | -enable-checker alpha.security.MallocOverflow \ 19 | -enable-checker alpha.security.ReturnPtrRange \ 20 | -enable-checker alpha.unix.SimpleStream 21 | -enable-checker alpha.unix.cstring.BufferOverlap \ 22 | -enable-checker alpha.unix.cstring.NotNullTerminated \ 23 | -enable-checker alpha.unix.cstring.OutOfBounds \ 24 | -enable-checker alpha.core.FixedAddr \ 25 | -enable-checker security.insecureAPI.strcpy 26 | " 27 | 28 | /opt/clang-3.4/bin/scan-build/scan-build \ 29 | $CHECKERS \ 30 | --use-analyzer=/opt/clang-3.4/bin/clang \ 31 | ./configure 32 | 33 | /opt/clang-3.4/bin/scan-build/scan-build \ 34 | $CHECKERS \ 35 | --use-analyzer=/opt/clang-3.4/bin/clang \ 36 | make -j2 37 | 38 | 39 | # Haven't tried this yet. 40 | # -enable-checker alpha.unix.PthreadLock 41 | 42 | # This one gives a false positive on every strcmp. 43 | # -enable-checker alpha.core.PointerSub 44 | 45 | # This one hates it when we stick a nonzero const in a pointer. 46 | # -enable-checker alpha.core.FixedAddr 47 | 48 | # This one crashes sometimes for me. 49 | # -enable-checker alpha.deadcode.IdempotentOperations 50 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/common/Makefile.nmake: -------------------------------------------------------------------------------- 1 | all: libor.lib libor-crypto.lib libor-event.lib 2 | 3 | CFLAGS = /O2 /MT /I ..\win32 /I ..\..\..\build-alpha\include /I ..\common \ 4 | /I ..\ext 5 | 6 | LIBOR_OBJECTS = address.obj backtrace.obj compat.obj container.obj di_ops.obj \ 7 | log.obj memarea.obj mempool.obj procmon.obj sandbox.obj util.obj \ 8 | util_codedigest.obj 9 | 10 | LIBOR_CRYPTO_OBJECTS = aes.obj crypto.obj crypto_format.obj torgzip.obj tortls.obj \ 11 | crypto_curve25519.obj curve25519-donna.obj 12 | 13 | LIBOR_EVENT_OBJECTS = compat_libevent.obj 14 | 15 | curve25519-donna.obj: ..\ext\curve25519_donna\curve25519-donna.c 16 | $(CC) $(CFLAGS) /D inline=_inline /c ..\ext\curve25519_donna\curve25519-donna.c 17 | 18 | libor.lib: $(LIBOR_OBJECTS) 19 | lib $(LIBOR_OBJECTS) /out:libor.lib 20 | 21 | libor-crypto.lib: $(LIBOR_CRYPTO_OBJECTS) 22 | lib $(LIBOR_CRYPTO_OBJECTS) /out:libor-crypto.lib 23 | 24 | libor-event.lib: $(LIBOR_EVENT_OBJECTS) 25 | lib $(LIBOR_EVENT_OBJECTS) /out:libor-event.lib 26 | 27 | clean: 28 | del *.obj *.lib libor*.lib 29 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/common/aes.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2003, Roger Dingledine 2 | * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson. 3 | * Copyright (c) 2007-2013, The Tor Project, Inc. */ 4 | /* See LICENSE for licensing information */ 5 | 6 | /* Implements a minimal interface to counter-mode AES. */ 7 | 8 | #ifndef TOR_AES_H 9 | #define TOR_AES_H 10 | 11 | /** 12 | * \file aes.h 13 | * \brief Headers for aes.c 14 | */ 15 | 16 | struct aes_cnt_cipher; 17 | typedef struct aes_cnt_cipher aes_cnt_cipher_t; 18 | 19 | aes_cnt_cipher_t* aes_new_cipher(const char *key, const char *iv); 20 | void aes_cipher_free(aes_cnt_cipher_t *cipher); 21 | void aes_crypt(aes_cnt_cipher_t *cipher, const char *input, size_t len, 22 | char *output); 23 | void aes_crypt_inplace(aes_cnt_cipher_t *cipher, char *data, size_t len); 24 | 25 | int evaluate_evp_for_aes(int force_value); 26 | int evaluate_ctr_for_aes(void); 27 | 28 | #endif 29 | 30 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/common/backtrace.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, The Tor Project, Inc. */ 2 | /* See LICENSE for licensing information */ 3 | 4 | #ifndef TOR_BACKTRACE_H 5 | #define TOR_BACKTRACE_H 6 | 7 | #include "orconfig.h" 8 | 9 | void log_backtrace(int severity, int domain, const char *msg); 10 | int configure_backtrace_handler(const char *tor_version); 11 | void clean_up_backtrace_handler(void); 12 | 13 | #ifdef EXPOSE_CLEAN_BACKTRACE 14 | #if defined(HAVE_EXECINFO_H) && defined(HAVE_BACKTRACE) && \ 15 | defined(HAVE_BACKTRACE_SYMBOLS_FD) && defined(HAVE_SIGACTION) 16 | void clean_backtrace(void **stack, int depth, const ucontext_t *ctx); 17 | #endif 18 | #endif 19 | 20 | #endif 21 | 22 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/common/crypto_curve25519.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2013, The Tor Project, Inc. */ 2 | /* See LICENSE for licensing information */ 3 | 4 | #ifndef TOR_CRYPTO_CURVE25519_H 5 | #define TOR_CRYPTO_CURVE25519_H 6 | 7 | #include "testsupport.h" 8 | #include "torint.h" 9 | 10 | /** Length of a curve25519 public key when encoded. */ 11 | #define CURVE25519_PUBKEY_LEN 32 12 | /** Length of a curve25519 secret key when encoded. */ 13 | #define CURVE25519_SECKEY_LEN 32 14 | /** Length of the result of a curve25519 handshake. */ 15 | #define CURVE25519_OUTPUT_LEN 32 16 | 17 | /** Wrapper type for a curve25519 public key */ 18 | typedef struct curve25519_public_key_t { 19 | uint8_t public_key[CURVE25519_PUBKEY_LEN]; 20 | } curve25519_public_key_t; 21 | 22 | /** Wrapper type for a curve25519 secret key */ 23 | typedef struct curve25519_secret_key_t { 24 | uint8_t secret_key[CURVE25519_SECKEY_LEN]; 25 | } curve25519_secret_key_t; 26 | 27 | /** A paired public and private key for curve25519. **/ 28 | typedef struct curve25519_keypair_t { 29 | curve25519_public_key_t pubkey; 30 | curve25519_secret_key_t seckey; 31 | } curve25519_keypair_t; 32 | 33 | #ifdef CURVE25519_ENABLED 34 | /* These functions require that we actually know how to use curve25519 keys. 35 | * The other data structures and functions in this header let us parse them, 36 | * store them, and move them around. 37 | */ 38 | 39 | int curve25519_public_key_is_ok(const curve25519_public_key_t *); 40 | 41 | int curve25519_secret_key_generate(curve25519_secret_key_t *key_out, 42 | int extra_strong); 43 | void curve25519_public_key_generate(curve25519_public_key_t *key_out, 44 | const curve25519_secret_key_t *seckey); 45 | int curve25519_keypair_generate(curve25519_keypair_t *keypair_out, 46 | int extra_strong); 47 | 48 | void curve25519_handshake(uint8_t *output, 49 | const curve25519_secret_key_t *, 50 | const curve25519_public_key_t *); 51 | 52 | int curve25519_keypair_write_to_file(const curve25519_keypair_t *keypair, 53 | const char *fname, 54 | const char *tag); 55 | 56 | int curve25519_keypair_read_from_file(curve25519_keypair_t *keypair_out, 57 | char **tag_out, 58 | const char *fname); 59 | 60 | #ifdef CRYPTO_CURVE25519_PRIVATE 61 | STATIC int curve25519_impl(uint8_t *output, const uint8_t *secret, 62 | const uint8_t *basepoint); 63 | #endif 64 | #endif 65 | 66 | #define CURVE25519_BASE64_PADDED_LEN 44 67 | 68 | int curve25519_public_from_base64(curve25519_public_key_t *pkey, 69 | const char *input); 70 | int curve25519_public_to_base64(char *output, 71 | const curve25519_public_key_t *pkey); 72 | 73 | #endif 74 | 75 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/common/crypto_format.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2013, The Tor Project, Inc. */ 2 | /* See LICENSE for licensing information */ 3 | 4 | /* Formatting and parsing code for crypto-related data structures. */ 5 | 6 | #include "orconfig.h" 7 | #ifdef HAVE_SYS_STAT_H 8 | #include 9 | #endif 10 | #include "crypto.h" 11 | #include "crypto_curve25519.h" 12 | #include "util.h" 13 | #include "torlog.h" 14 | 15 | int 16 | curve25519_public_to_base64(char *output, 17 | const curve25519_public_key_t *pkey) 18 | { 19 | char buf[128]; 20 | base64_encode(buf, sizeof(buf), 21 | (const char*)pkey->public_key, CURVE25519_PUBKEY_LEN); 22 | buf[CURVE25519_BASE64_PADDED_LEN] = '\0'; 23 | memcpy(output, buf, CURVE25519_BASE64_PADDED_LEN+1); 24 | return 0; 25 | } 26 | 27 | int 28 | curve25519_public_from_base64(curve25519_public_key_t *pkey, 29 | const char *input) 30 | { 31 | size_t len = strlen(input); 32 | if (len == CURVE25519_BASE64_PADDED_LEN - 1) { 33 | /* not padded */ 34 | return digest256_from_base64((char*)pkey->public_key, input); 35 | } else if (len == CURVE25519_BASE64_PADDED_LEN) { 36 | char buf[128]; 37 | if (base64_decode(buf, sizeof(buf), input, len) != CURVE25519_PUBKEY_LEN) 38 | return -1; 39 | memcpy(pkey->public_key, buf, CURVE25519_PUBKEY_LEN); 40 | return 0; 41 | } else { 42 | return -1; 43 | } 44 | } 45 | 46 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/common/di_ops.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2003-2004, Roger Dingledine 2 | * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson. 3 | * Copyright (c) 2007-2013, The Tor Project, Inc. */ 4 | /* See LICENSE for licensing information */ 5 | 6 | /** 7 | * \file di_ops.h 8 | * \brief Headers for di_ops.c 9 | **/ 10 | 11 | #ifndef TOR_DI_OPS_H 12 | #define TOR_DI_OPS_H 13 | 14 | #include "orconfig.h" 15 | #include "torint.h" 16 | 17 | int tor_memcmp(const void *a, const void *b, size_t sz); 18 | int tor_memeq(const void *a, const void *b, size_t sz); 19 | #define tor_memneq(a,b,sz) (!tor_memeq((a),(b),(sz))) 20 | 21 | /** Alias for the platform's memcmp() function. This function is 22 | * not data-independent: we define this alias so that we can 23 | * mark cases where we are deliberately using a data-dependent memcmp() 24 | * implementation. 25 | */ 26 | #define fast_memcmp(a,b,c) (memcmp((a),(b),(c))) 27 | #define fast_memeq(a,b,c) (0==memcmp((a),(b),(c))) 28 | #define fast_memneq(a,b,c) (0!=memcmp((a),(b),(c))) 29 | 30 | int safe_mem_is_zero(const void *mem, size_t sz); 31 | 32 | /** A type for a map from DIGEST256_LEN-byte blobs to void*, such that 33 | * data lookups take an amount of time proportional only to the size 34 | * of the map, and not to the position or presence of the item in the map. 35 | * 36 | * Not efficient for large maps! */ 37 | typedef struct di_digest256_map_t di_digest256_map_t; 38 | typedef void (*dimap_free_fn)(void *); 39 | 40 | void dimap_free(di_digest256_map_t *map, dimap_free_fn free_fn); 41 | void dimap_add_entry(di_digest256_map_t **map, 42 | const uint8_t *key, void *val); 43 | void *dimap_search(const di_digest256_map_t *map, const uint8_t *key, 44 | void *dflt_val); 45 | 46 | #endif 47 | 48 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/common/memarea.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2008-2013, The Tor Project, Inc. */ 2 | /* See LICENSE for licensing information */ 3 | /* Tor dependencies */ 4 | 5 | #ifndef TOR_MEMAREA_H 6 | #define TOR_MEMAREA_H 7 | 8 | typedef struct memarea_t memarea_t; 9 | 10 | memarea_t *memarea_new(void); 11 | void memarea_drop_all(memarea_t *area); 12 | void memarea_clear(memarea_t *area); 13 | int memarea_owns_ptr(const memarea_t *area, const void *ptr); 14 | void *memarea_alloc(memarea_t *area, size_t sz); 15 | void *memarea_alloc_zero(memarea_t *area, size_t sz); 16 | void *memarea_memdup(memarea_t *area, const void *s, size_t n); 17 | char *memarea_strdup(memarea_t *area, const char *s); 18 | char *memarea_strndup(memarea_t *area, const char *s, size_t n); 19 | void memarea_get_stats(memarea_t *area, 20 | size_t *allocated_out, size_t *used_out); 21 | void memarea_clear_freelist(void); 22 | void memarea_assert_ok(memarea_t *area); 23 | 24 | #endif 25 | 26 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/common/mempool.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2007-2013, The Tor Project, Inc. */ 2 | /* See LICENSE for licensing information */ 3 | 4 | /** 5 | * \file mempool.h 6 | * \brief Headers for mempool.c 7 | **/ 8 | 9 | #ifndef TOR_MEMPOOL_H 10 | #define TOR_MEMPOOL_H 11 | 12 | /** A memory pool is a context in which a large number of fixed-sized 13 | * objects can be allocated efficiently. See mempool.c for implementation 14 | * details. */ 15 | typedef struct mp_pool_t mp_pool_t; 16 | 17 | void *mp_pool_get(mp_pool_t *pool); 18 | void mp_pool_release(void *item); 19 | mp_pool_t *mp_pool_new(size_t item_size, size_t chunk_capacity); 20 | void mp_pool_clean(mp_pool_t *pool, int n_to_keep, int keep_recently_used); 21 | void mp_pool_destroy(mp_pool_t *pool); 22 | void mp_pool_assert_ok(mp_pool_t *pool); 23 | void mp_pool_log_status(mp_pool_t *pool, int severity); 24 | 25 | #define MP_POOL_ITEM_OVERHEAD (sizeof(void*)) 26 | 27 | #define MEMPOOL_STATS 28 | 29 | #ifdef MEMPOOL_PRIVATE 30 | /* These declarations are only used by mempool.c and test.c */ 31 | 32 | struct mp_pool_t { 33 | /** Doubly-linked list of chunks in which no items have been allocated. 34 | * The front of the list is the most recently emptied chunk. */ 35 | struct mp_chunk_t *empty_chunks; 36 | /** Doubly-linked list of chunks in which some items have been allocated, 37 | * but which are not yet full. The front of the list is the chunk that has 38 | * most recently been modified. */ 39 | struct mp_chunk_t *used_chunks; 40 | /** Doubly-linked list of chunks in which no more items can be allocated. 41 | * The front of the list is the chunk that has most recently become full. */ 42 | struct mp_chunk_t *full_chunks; 43 | /** Length of empty_chunks. */ 44 | int n_empty_chunks; 45 | /** Lowest value of empty_chunks since last call to 46 | * mp_pool_clean(-1). */ 47 | int min_empty_chunks; 48 | /** Size of each chunk (in items). */ 49 | int new_chunk_capacity; 50 | /** Size to allocate for each item, including overhead and alignment 51 | * padding. */ 52 | size_t item_alloc_size; 53 | #ifdef MEMPOOL_STATS 54 | /** Total number of items allocated ever. */ 55 | uint64_t total_items_allocated; 56 | /** Total number of chunks allocated ever. */ 57 | uint64_t total_chunks_allocated; 58 | /** Total number of chunks freed ever. */ 59 | uint64_t total_chunks_freed; 60 | #endif 61 | }; 62 | #endif 63 | 64 | #endif 65 | 66 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/common/procmon.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011-2013, The Tor Project, Inc. */ 2 | /* See LICENSE for licensing information */ 3 | 4 | /** 5 | * \file procmon.h 6 | * \brief Headers for procmon.c 7 | **/ 8 | 9 | #ifndef TOR_PROCMON_H 10 | #define TOR_PROCMON_H 11 | 12 | #include "compat.h" 13 | #include "compat_libevent.h" 14 | 15 | #include "torlog.h" 16 | 17 | typedef struct tor_process_monitor_t tor_process_monitor_t; 18 | 19 | /* DOCDOC tor_procmon_callback_t */ 20 | typedef void (*tor_procmon_callback_t)(void *); 21 | 22 | int tor_validate_process_specifier(const char *process_spec, 23 | const char **msg); 24 | tor_process_monitor_t *tor_process_monitor_new(struct event_base *base, 25 | const char *process_spec, 26 | log_domain_mask_t log_domain, 27 | tor_procmon_callback_t cb, 28 | void *cb_arg, 29 | const char **msg); 30 | void tor_process_monitor_free(tor_process_monitor_t *procmon); 31 | 32 | #endif 33 | 34 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/common/testsupport.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, The Tor Project, Inc. */ 2 | /* See LICENSE for licensing information */ 3 | 4 | #ifndef TOR_TESTSUPPORT_H 5 | #define TOR_TESTSUPPORT_H 6 | 7 | #ifdef TOR_UNIT_TESTS 8 | #define STATIC 9 | #else 10 | #define STATIC static 11 | #endif 12 | 13 | /** Quick and dirty macros to implement test mocking. 14 | * 15 | * To use them, suppose that you have a function you'd like to mock 16 | * with the signature "void writebuf(size_t n, char *buf)". You can then 17 | * declare the function as: 18 | * 19 | * MOCK_DECL(void, writebuf, (size_t n, char *buf)); 20 | * 21 | * and implement it as: 22 | * 23 | * MOCK_IMPL(void 24 | * writebuf,(size_t n, char *buf) 25 | * { 26 | * ... 27 | * } 28 | * 29 | * For the non-testing build, this will expand simply into: 30 | * 31 | * void writebuf(size_t n, char *buf); 32 | * void 33 | * writebuf(size_t n, char *buf) 34 | * { 35 | * ... 36 | * } 37 | * 38 | * But for the testing case, it will expand into: 39 | * 40 | * void writebuf__real(size_t n, char *buf); 41 | * extern void (*writebuf)(size_t n, char *buf); 42 | * 43 | * void (*writebuf)(size_t n, char *buf) = writebuf__real; 44 | * void 45 | * writebuf__real(size_t n, char *buf) 46 | * { 47 | * ... 48 | * } 49 | * 50 | * This is not a great mocking system! It is deliberately "the simplest 51 | * thing that could work", and pays for its simplicity in its lack of 52 | * features, and in its uglification of the Tor code. Replacing it with 53 | * something clever would be a fine thing. 54 | * 55 | * @{ */ 56 | #ifdef TOR_UNIT_TESTS 57 | #define MOCK_DECL(rv, funcname, arglist) \ 58 | rv funcname ##__real arglist; \ 59 | extern rv(*funcname) arglist 60 | #define MOCK_IMPL(rv, funcname, arglist) \ 61 | rv(*funcname) arglist = funcname ##__real; \ 62 | rv funcname ##__real arglist 63 | #define MOCK(func, replacement) \ 64 | do { \ 65 | (func) = (replacement); \ 66 | } while (0) 67 | #define UNMOCK(func) \ 68 | do { \ 69 | func = func ##__real; \ 70 | } while (0) 71 | #else 72 | #define MOCK_DECL(rv, funcname, arglist) \ 73 | rv funcname arglist 74 | #define MOCK_IMPL(rv, funcname, arglist) \ 75 | rv funcname arglist 76 | #endif 77 | /** @} */ 78 | 79 | #endif 80 | 81 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/common/torgzip.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2003, Roger Dingledine 2 | * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson. 3 | * Copyright (c) 2007-2013, The Tor Project, Inc. */ 4 | /* See LICENSE for licensing information */ 5 | 6 | /** 7 | * \file torgzip.h 8 | * \brief Headers for torgzip.h 9 | **/ 10 | 11 | #ifndef TOR_TORGZIP_H 12 | #define TOR_TORGZIP_H 13 | 14 | /** Enumeration of what kind of compression to use. Only ZLIB_METHOD is 15 | * guaranteed to be supported by the compress/uncompress functions here; 16 | * GZIP_METHOD may be supported if we built against zlib version 1.2 or later 17 | * and is_gzip_supported() returns true. */ 18 | typedef enum { 19 | NO_METHOD=0, GZIP_METHOD=1, ZLIB_METHOD=2, UNKNOWN_METHOD=3 20 | } compress_method_t; 21 | 22 | int 23 | tor_gzip_compress(char **out, size_t *out_len, 24 | const char *in, size_t in_len, 25 | compress_method_t method); 26 | int 27 | tor_gzip_uncompress(char **out, size_t *out_len, 28 | const char *in, size_t in_len, 29 | compress_method_t method, 30 | int complete_only, 31 | int protocol_warn_level); 32 | 33 | int is_gzip_supported(void); 34 | 35 | const char * 36 | tor_zlib_get_version_str(void); 37 | 38 | const char * 39 | tor_zlib_get_header_version_str(void); 40 | 41 | compress_method_t detect_compression_method(const char *in, size_t in_len); 42 | 43 | /** Return values from tor_zlib_process; see that function's documentation for 44 | * details. */ 45 | typedef enum { 46 | TOR_ZLIB_OK, TOR_ZLIB_DONE, TOR_ZLIB_BUF_FULL, TOR_ZLIB_ERR 47 | } tor_zlib_output_t; 48 | /** Internal state for an incremental zlib compression/decompression. */ 49 | typedef struct tor_zlib_state_t tor_zlib_state_t; 50 | tor_zlib_state_t *tor_zlib_new(int compress, compress_method_t method); 51 | 52 | tor_zlib_output_t tor_zlib_process(tor_zlib_state_t *state, 53 | char **out, size_t *out_len, 54 | const char **in, size_t *in_len, 55 | int finish); 56 | void tor_zlib_free(tor_zlib_state_t *state); 57 | 58 | size_t tor_zlib_state_size(const tor_zlib_state_t *state); 59 | size_t tor_zlib_get_total_allocation(void); 60 | 61 | #endif 62 | 63 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/common/util_codedigest.c: -------------------------------------------------------------------------------- 1 | 2 | #include "util.h" 3 | 4 | /** Return a string describing the digest of the source files in src/common/ 5 | */ 6 | const char * 7 | libor_get_digests(void) 8 | { 9 | return "" 10 | #include "common_sha1.i" 11 | ; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/common/util_process.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011-2013, The Tor Project, Inc. */ 2 | /* See LICENSE for licensing information */ 3 | 4 | /** 5 | * \file util_process.h 6 | * \brief Headers for util_process.c 7 | **/ 8 | 9 | #ifndef TOR_UTIL_PROCESS_H 10 | #define TOR_UTIL_PROCESS_H 11 | 12 | #ifndef _WIN32 13 | /** A callback structure waiting for us to get a SIGCHLD informing us that a 14 | * PID has been closed. Created by set_waitpid_callback. Cancelled or cleaned- 15 | * up from clear_waitpid_callback(). Do not access outside of the main thread; 16 | * do not access from inside a signal handler. */ 17 | typedef struct waitpid_callback_t waitpid_callback_t; 18 | 19 | waitpid_callback_t *set_waitpid_callback(pid_t pid, 20 | void (*fn)(int, void *), void *arg); 21 | void clear_waitpid_callback(waitpid_callback_t *ent); 22 | void notify_pending_waitpid_callbacks(void); 23 | #endif 24 | 25 | #endif 26 | 27 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/config/include.am: -------------------------------------------------------------------------------- 1 | confdir = $(sysconfdir)/tor 2 | 3 | tordatadir = $(datadir)/tor 4 | 5 | EXTRA_DIST+= src/config/geoip src/config/geoip6 6 | # fallback-consensus 7 | 8 | conf_DATA = src/config/torrc.sample 9 | 10 | tordata_DATA = src/config/geoip src/config/geoip6 11 | # fallback_consensus 12 | 13 | # If we don't have it, fake it. 14 | src_config_fallback-consensus: 15 | touch src/config/fallback-consensus 16 | 17 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/ext/Makefile.nmake: -------------------------------------------------------------------------------- 1 | all: csiphash.lib 2 | 3 | CFLAGS = /O2 /MT /I ..\win32 /I ..\..\..\build-alpha\include /I ..\common \ 4 | /I ..\ext 5 | 6 | CSIPHASH_OBJECTS = csiphash.obj 7 | 8 | csiphash.lib: $(CSIPHASH_OBJECTS) 9 | lib $(CSIPHASH_OBJECTS) $(CURVE25519_DONNA_OBJECTS) /out:csiphash.lib 10 | 11 | clean: 12 | del *.obj *.lib 13 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/ext/README: -------------------------------------------------------------------------------- 1 | 2 | OpenBSD_malloc_Linux.c: 3 | 4 | The OpenBSD malloc implementation, ported to Linux. Used only when 5 | --enable-openbsd-malloc is passed to the configure script. 6 | 7 | strlcat.c 8 | strlcpy.c 9 | 10 | Implementations of strlcat and strlcpy, the more sane replacements 11 | for strcat and strcpy. These are nonstandard, and some libc 12 | implementations refuse to add them for religious reasons. 13 | 14 | eventdns.[ch] 15 | 16 | A fork of Libevent's DNS implementation, used by Tor when Libevent 17 | 2.0 or later is not available. Once Libevent 2.0 is required, we 18 | should throw this away; it has diverged from evdns.[ch], and is 19 | no longer easily mergeable. 20 | 21 | ht.h 22 | 23 | An implementation of a hash table in the style of Niels Provos's 24 | tree.h. Shared with Libevent. 25 | 26 | tinytest.[ch] 27 | tinytest_demos.c 28 | tinytest_macros.h 29 | 30 | A unit testing framework. https://github.com/nmathewson/tinytest 31 | 32 | tor_queue.h 33 | 34 | A copy of sys/queue.h from OpenBSD. We keep our own copy rather 35 | than using sys/queue.h, since some platforms don't have a 36 | sys/queue.h, and the ones that do have diverged in incompatible 37 | ways. (CIRCLEQ or no CIRCLEQ? SIMPLQ or STAILQ?) We also rename 38 | the identifiers with a TOR_ prefix to avoid conflicts with 39 | the system headers. 40 | 41 | curve25519_donna/*.c 42 | 43 | A copy of Adam Langley's curve25519-donna mostly-portable 44 | implementations of curve25519. 45 | 46 | csiphash.c 47 | siphash.h 48 | 49 | Marek Majkowski's implementation of siphash 2-4, a secure keyed 50 | hash algorithm to avoid collision-based DoS attacks against hash 51 | tables. 52 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/ext/curve25519_donna/README: -------------------------------------------------------------------------------- 1 | See http://code.google.com/p/curve25519-donna/ for details. 2 | 3 | BUILDING: 4 | 5 | If you run `make`, two .a archives will be built, similar to djb's curve25519 6 | code. Alternatively, read on: 7 | 8 | The C implementation is contained within curve25519-donna.c. It has no external 9 | dependancies and is BSD licenced. You can copy/include/link it directly in with 10 | your program. Recommended C flags: -O2 11 | 12 | The x86-64 bit implementation is contained within curve25519-donna-x86-64.c and 13 | curve25519-donna-x86-64.s. Build like this: 14 | 15 | % cpp curve25519-donna-x86-64.s > curve25519-donna-x86-64.s.pp 16 | % as -o curve25519-donna-x86-64.s.o curve25519-donna-x86-64.s.pp 17 | % gcc -O2 -c curve25519-donna-x86-64.c 18 | 19 | Then the two .o files can be linked in 20 | 21 | USAGE: 22 | 23 | The usage is exactly the same as djb's code (as described at 24 | http://cr.yp.to/ecdh.html) expect that the function is called curve25519_donna. 25 | 26 | In short, 27 | 28 | To generate a private key, generate 32 random bytes and: 29 | 30 | mysecret[0] &= 248; 31 | mysecret[31] &= 127; 32 | mysecret[31] |= 64; 33 | 34 | To generate the public key, just do 35 | 36 | static const uint8_t basepoint[32] = {9}; 37 | curve25519_donna(mypublic, mysecret, basepoint); 38 | 39 | To generate an agreed key do: 40 | uint8_t shared_key[32]; 41 | curve25519_donna(shared_key, mysecret, theirpublic); 42 | 43 | And hash the shared_key with a cryptographic hash function before using. 44 | 45 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/ext/include.am: -------------------------------------------------------------------------------- 1 | 2 | AM_CPPFLAGS += -I$(srcdir)/src/ext -Isrc/ext 3 | 4 | EXTRA_DIST += src/ext/README 5 | 6 | EXTHEADERS = \ 7 | src/ext/ht.h \ 8 | src/ext/eventdns.h \ 9 | src/ext/tinytest.h \ 10 | src/ext/strlcat.c \ 11 | src/ext/strlcpy.c \ 12 | src/ext/tinytest_macros.h \ 13 | src/ext/tor_queue.h \ 14 | src/ext/siphash.h 15 | 16 | noinst_HEADERS+= $(EXTHEADERS) 17 | 18 | 19 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/ext/siphash.h: -------------------------------------------------------------------------------- 1 | #ifndef SIPHASH_H 2 | #define SIPHASH_H 3 | 4 | struct sipkey { 5 | uint64_t k0; 6 | uint64_t k1; 7 | }; 8 | uint64_t siphash24(const void *src, unsigned long src_sz, const struct sipkey *key); 9 | 10 | void siphash_set_global_key(const struct sipkey *key); 11 | uint64_t siphash24g(const void *src, unsigned long src_sz); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/ext/strlcat.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: strlcat.c,v 1.8 2001/05/13 15:40:15 deraadt Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 1998 Todd C. Miller 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. The name of the author may not be used to endorse or promote products 16 | * derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 19 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 20 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 21 | * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 22 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 23 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 24 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 25 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 26 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 27 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #if defined(LIBC_SCCS) && !defined(lint) 31 | static char *rcsid = "$OpenBSD: strlcat.c,v 1.8 2001/05/13 15:40:15 deraadt Exp $"; 32 | #endif /* LIBC_SCCS and not lint */ 33 | 34 | #include 35 | #include 36 | 37 | /* 38 | * Appends src to string dst of size siz (unlike strncat, siz is the 39 | * full size of dst, not space left). At most siz-1 characters 40 | * will be copied. Always NUL terminates (unless siz <= strlen(dst)). 41 | * Returns strlen(src) + MIN(siz, strlen(initial dst)). 42 | * If retval >= siz, truncation occurred. 43 | */ 44 | size_t 45 | strlcat(char *dst, const char *src, size_t siz) 46 | { 47 | register char *d = dst; 48 | register const char *s = src; 49 | register size_t n = siz; 50 | size_t dlen; 51 | 52 | /* Find the end of dst and adjust bytes left but don't go past end */ 53 | while (n-- != 0 && *d != '\0') 54 | d++; 55 | dlen = d - dst; 56 | n = siz - dlen; 57 | 58 | if (n == 0) 59 | return(dlen + strlen(s)); 60 | while (*s != '\0') { 61 | if (n != 1) { 62 | *d++ = *s; 63 | n--; 64 | } 65 | s++; 66 | } 67 | *d = '\0'; 68 | 69 | return(dlen + (s - src)); /* count does not include NUL */ 70 | } 71 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/ext/strlcpy.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: strlcpy.c,v 1.2 1998/11/06 04:33:16 wvdputte Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 1998 Todd C. Miller 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. The name of the author may not be used to endorse or promote products 16 | * derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 19 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 20 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 21 | * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 22 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 23 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 24 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 25 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 26 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 27 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #if defined(LIBC_SCCS) && !defined(lint) 31 | static char *rcsid = "$OpenBSD: strlcpy.c,v 1.2 1998/11/06 04:33:16 wvdputte Exp $"; 32 | #endif /* LIBC_SCCS and not lint */ 33 | 34 | #include 35 | #include 36 | 37 | /* 38 | * Copy src to string dst of size siz. At most siz-1 characters 39 | * will be copied. Always NUL terminates (unless siz == 0). 40 | * Returns strlen(src); if retval >= siz, truncation occurred. 41 | */ 42 | size_t strlcpy(char *dst, const char *src, size_t siz) 43 | { 44 | register char *d = dst; 45 | register const char *s = src; 46 | register size_t n = siz; 47 | 48 | if (n == 0) 49 | return(strlen(s)); 50 | while (*s != '\0') { 51 | if (n != 1) { 52 | *d++ = *s; 53 | n--; 54 | } 55 | s++; 56 | } 57 | *d = '\0'; 58 | 59 | return(s - src); /* count does not include NUL */ 60 | } 61 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/include.am: -------------------------------------------------------------------------------- 1 | include src/ext/include.am 2 | include src/common/include.am 3 | include src/or/include.am 4 | include src/test/include.am 5 | include src/tools/include.am 6 | include src/win32/include.am 7 | include src/config/include.am 8 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/or/Makefile.nmake: -------------------------------------------------------------------------------- 1 | all: tor.exe 2 | 3 | CFLAGS = /O2 /MT /I ..\win32 /I ..\..\..\build-alpha\include /I ..\common \ 4 | /I ..\ext 5 | 6 | LIBS = ..\..\..\build-alpha\lib\libevent.lib \ 7 | ..\..\..\build-alpha\lib\libcrypto.lib \ 8 | ..\..\..\build-alpha\lib\libssl.lib \ 9 | ..\..\..\build-alpha\lib\libz.lib \ 10 | ws2_32.lib advapi32.lib shell32.lib \ 11 | crypt32.lib gdi32.lib user32.lib 12 | 13 | LIBTOR_OBJECTS = \ 14 | addressmap.obj \ 15 | buffers.obj \ 16 | channel.obj \ 17 | channeltls.obj \ 18 | circpathbias.obj \ 19 | circuitbuild.obj \ 20 | circuitlist.obj \ 21 | circuitmux.obj \ 22 | circuitmux_ewma.obj \ 23 | circuitstats.obj \ 24 | circuituse.obj \ 25 | command.obj \ 26 | config.obj \ 27 | config_codedigest.obj \ 28 | confparse.obj \ 29 | connection.obj \ 30 | connection_edge.obj \ 31 | connection_or.obj \ 32 | control.obj \ 33 | cpuworker.obj \ 34 | directory.obj \ 35 | dirserv.obj \ 36 | dirvote.obj \ 37 | dns.obj \ 38 | dnsserv.obj \ 39 | ext_orport.obj \ 40 | fp_pair.obj \ 41 | entrynodes.obj \ 42 | geoip.obj \ 43 | hibernate.obj \ 44 | main.obj \ 45 | microdesc.obj \ 46 | networkstatus.obj \ 47 | nodelist.obj \ 48 | ntmain.obj \ 49 | onion.obj \ 50 | onion_fast.obj \ 51 | onion_ntor.obj \ 52 | onion_tap.obj \ 53 | policies.obj \ 54 | reasons.obj \ 55 | relay.obj \ 56 | rendclient.obj \ 57 | rendcommon.obj \ 58 | rendmid.obj \ 59 | rendservice.obj \ 60 | rephist.obj \ 61 | replaycache.obj \ 62 | router.obj \ 63 | routerlist.obj \ 64 | routerparse.obj \ 65 | routerset.obj \ 66 | statefile.obj \ 67 | status.obj \ 68 | transports.obj 69 | 70 | libtor.lib: $(LIBTOR_OBJECTS) 71 | lib $(LIBTOR_OBJECTS) /out:$@ 72 | 73 | tor.exe: libtor.lib tor_main.obj 74 | $(CC) $(CFLAGS) $(LIBS) libtor.lib ..\common\*.lib ..\ext\*.lib tor_main.obj /Fe$@ 75 | 76 | clean: 77 | del $(LIBTOR_OBJECTS) tor_main.obj *.lib tor.exe 78 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/or/addressmap.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2001 Matej Pfajfar. 2 | * Copyright (c) 2001-2004, Roger Dingledine. 3 | * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson. 4 | * Copyright (c) 2007-2013, The Tor Project, Inc. */ 5 | /* See LICENSE for licensing information */ 6 | 7 | #ifndef TOR_ADDRESSMAP_H 8 | #define TOR_ADDRESSMAP_H 9 | 10 | #include "testsupport.h" 11 | 12 | void addressmap_init(void); 13 | void addressmap_clear_excluded_trackexithosts(const or_options_t *options); 14 | void addressmap_clear_invalid_automaps(const or_options_t *options); 15 | void addressmap_clean(time_t now); 16 | void addressmap_clear_configured(void); 17 | void addressmap_clear_transient(void); 18 | void addressmap_free_all(void); 19 | #define AMR_FLAG_USE_IPV4_DNS (1u<<0) 20 | #define AMR_FLAG_USE_IPV6_DNS (1u<<1) 21 | int addressmap_rewrite(char *address, size_t maxlen, unsigned flags, 22 | time_t *expires_out, 23 | addressmap_entry_source_t *exit_source_out); 24 | int addressmap_rewrite_reverse(char *address, size_t maxlen, unsigned flags, 25 | time_t *expires_out); 26 | int addressmap_have_mapping(const char *address, int update_timeout); 27 | 28 | void addressmap_register(const char *address, char *new_address, 29 | time_t expires, addressmap_entry_source_t source, 30 | const int address_wildcard, 31 | const int new_address_wildcard); 32 | int parse_virtual_addr_network(const char *val, 33 | sa_family_t family, int validate_only, 34 | char **msg); 35 | int client_dns_incr_failures(const char *address); 36 | void client_dns_clear_failures(const char *address); 37 | void client_dns_set_addressmap(entry_connection_t *for_conn, 38 | const char *address, const tor_addr_t *val, 39 | const char *exitname, int ttl); 40 | const char *addressmap_register_virtual_address(int type, char *new_address); 41 | void addressmap_get_mappings(smartlist_t *sl, time_t min_expires, 42 | time_t max_expires, int want_expiry); 43 | int address_is_in_virtual_range(const char *addr); 44 | void clear_trackexithost_mappings(const char *exitname); 45 | void client_dns_set_reverse_addressmap(entry_connection_t *for_conn, 46 | const char *address, const char *v, 47 | const char *exitname, int ttl); 48 | int addressmap_address_should_automap(const char *address, 49 | const or_options_t *options); 50 | 51 | #ifdef ADDRESSMAP_PRIVATE 52 | typedef struct virtual_addr_conf_t { 53 | tor_addr_t addr; 54 | maskbits_t bits; 55 | } virtual_addr_conf_t; 56 | 57 | STATIC void get_random_virtual_addr(const virtual_addr_conf_t *conf, 58 | tor_addr_t *addr_out); 59 | #endif 60 | 61 | #endif 62 | 63 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/or/channeltls.h: -------------------------------------------------------------------------------- 1 | /* * Copyright (c) 2012-2013, The Tor Project, Inc. */ 2 | /* See LICENSE for licensing information */ 3 | 4 | /** 5 | * \file channeltls.h 6 | * \brief Header file for channeltls.c 7 | **/ 8 | 9 | #ifndef TOR_CHANNELTLS_H 10 | #define TOR_CHANNELTLS_H 11 | 12 | #include "or.h" 13 | #include "channel.h" 14 | 15 | #define BASE_CHAN_TO_TLS(c) (channel_tls_from_base((c))) 16 | #define TLS_CHAN_TO_BASE(c) (channel_tls_to_base((c))) 17 | 18 | #define TLS_CHAN_MAGIC 0x8a192427U 19 | 20 | #ifdef TOR_CHANNEL_INTERNAL_ 21 | 22 | struct channel_tls_s { 23 | /* Base channel_t struct */ 24 | channel_t base_; 25 | /* or_connection_t pointer */ 26 | or_connection_t *conn; 27 | }; 28 | 29 | #endif /* TOR_CHANNEL_INTERNAL_ */ 30 | 31 | channel_t * channel_tls_connect(const tor_addr_t *addr, uint16_t port, 32 | const char *id_digest); 33 | channel_listener_t * channel_tls_get_listener(void); 34 | channel_listener_t * channel_tls_start_listener(void); 35 | channel_t * channel_tls_handle_incoming(or_connection_t *orconn); 36 | 37 | /* Casts */ 38 | 39 | channel_t * channel_tls_to_base(channel_tls_t *tlschan); 40 | channel_tls_t * channel_tls_from_base(channel_t *chan); 41 | 42 | /* Things for connection_or.c to call back into */ 43 | ssize_t channel_tls_flush_some_cells(channel_tls_t *chan, ssize_t num_cells); 44 | int channel_tls_more_to_flush(channel_tls_t *chan); 45 | void channel_tls_handle_cell(cell_t *cell, or_connection_t *conn); 46 | void channel_tls_handle_state_change_on_orconn(channel_tls_t *chan, 47 | or_connection_t *conn, 48 | uint8_t old_state, 49 | uint8_t state); 50 | void channel_tls_handle_var_cell(var_cell_t *var_cell, 51 | or_connection_t *conn); 52 | void channel_tls_update_marks(or_connection_t *conn); 53 | 54 | /* Cleanup at shutdown */ 55 | void channel_tls_free_all(void); 56 | 57 | #endif 58 | 59 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/or/circpathbias.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2001 Matej Pfajfar. 2 | * Copyright (c) 2001-2004, Roger Dingledine. 3 | * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson. 4 | * Copyright (c) 2007-2013, The Tor Project, Inc. */ 5 | /* See LICENSE for licensing information */ 6 | 7 | /** 8 | * \file circuitbuild.h 9 | * \brief Header file for circuitbuild.c. 10 | **/ 11 | 12 | #ifndef TOR_CIRCPATHBIAS_H 13 | #define TOR_CIRCPATHBIAS_H 14 | 15 | double pathbias_get_extreme_rate(const or_options_t *options); 16 | double pathbias_get_extreme_use_rate(const or_options_t *options); 17 | int pathbias_get_dropguards(const or_options_t *options); 18 | void pathbias_count_timeout(origin_circuit_t *circ); 19 | void pathbias_count_build_success(origin_circuit_t *circ); 20 | int pathbias_count_build_attempt(origin_circuit_t *circ); 21 | int pathbias_check_close(origin_circuit_t *circ, int reason); 22 | int pathbias_check_probe_response(circuit_t *circ, const cell_t *cell); 23 | void pathbias_count_use_attempt(origin_circuit_t *circ); 24 | void pathbias_mark_use_success(origin_circuit_t *circ); 25 | void pathbias_mark_use_rollback(origin_circuit_t *circ); 26 | const char *pathbias_state_to_string(path_state_t state); 27 | 28 | #endif 29 | 30 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/or/circuitbuild.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2001 Matej Pfajfar. 2 | * Copyright (c) 2001-2004, Roger Dingledine. 3 | * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson. 4 | * Copyright (c) 2007-2013, The Tor Project, Inc. */ 5 | /* See LICENSE for licensing information */ 6 | 7 | /** 8 | * \file circuitbuild.h 9 | * \brief Header file for circuitbuild.c. 10 | **/ 11 | 12 | #ifndef TOR_CIRCUITBUILD_H 13 | #define TOR_CIRCUITBUILD_H 14 | 15 | char *circuit_list_path(origin_circuit_t *circ, int verbose); 16 | char *circuit_list_path_for_controller(origin_circuit_t *circ); 17 | void circuit_log_path(int severity, unsigned int domain, 18 | origin_circuit_t *circ); 19 | void circuit_rep_hist_note_result(origin_circuit_t *circ); 20 | origin_circuit_t *origin_circuit_init(uint8_t purpose, int flags); 21 | origin_circuit_t *circuit_establish_circuit(uint8_t purpose, 22 | extend_info_t *exit, 23 | int flags); 24 | int circuit_handle_first_hop(origin_circuit_t *circ); 25 | void circuit_n_chan_done(channel_t *chan, int status); 26 | int inform_testing_reachability(void); 27 | int circuit_timeout_want_to_count_circ(origin_circuit_t *circ); 28 | int circuit_send_next_onion_skin(origin_circuit_t *circ); 29 | void circuit_note_clock_jumped(int seconds_elapsed); 30 | int circuit_extend(cell_t *cell, circuit_t *circ); 31 | int circuit_init_cpath_crypto(crypt_path_t *cpath, const char *key_data, 32 | int reverse); 33 | struct created_cell_t; 34 | int circuit_finish_handshake(origin_circuit_t *circ, 35 | const struct created_cell_t *created_cell); 36 | int circuit_truncated(origin_circuit_t *circ, crypt_path_t *layer, 37 | int reason); 38 | int onionskin_answer(or_circuit_t *circ, 39 | const struct created_cell_t *created_cell, 40 | const char *keys, 41 | const uint8_t *rend_circ_nonce); 42 | int circuit_all_predicted_ports_handled(time_t now, int *need_uptime, 43 | int *need_capacity); 44 | 45 | int circuit_append_new_exit(origin_circuit_t *circ, extend_info_t *info); 46 | int circuit_extend_to_new_exit(origin_circuit_t *circ, extend_info_t *info); 47 | void onion_append_to_cpath(crypt_path_t **head_ptr, crypt_path_t *new_hop); 48 | extend_info_t *extend_info_new(const char *nickname, const char *digest, 49 | crypto_pk_t *onion_key, 50 | const curve25519_public_key_t *curve25519_key, 51 | const tor_addr_t *addr, uint16_t port); 52 | extend_info_t *extend_info_from_node(const node_t *r, int for_direct_connect); 53 | extend_info_t *extend_info_dup(extend_info_t *info); 54 | void extend_info_free(extend_info_t *info); 55 | const node_t *build_state_get_exit_node(cpath_build_state_t *state); 56 | const char *build_state_get_exit_nickname(cpath_build_state_t *state); 57 | 58 | const node_t *choose_good_entry_server(uint8_t purpose, 59 | cpath_build_state_t *state); 60 | 61 | #ifdef CIRCUITBUILD_PRIVATE 62 | STATIC circid_t get_unique_circ_id_by_chan(channel_t *chan); 63 | #endif 64 | 65 | #endif 66 | 67 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/or/circuitmux_ewma.h: -------------------------------------------------------------------------------- 1 | /* * Copyright (c) 2012-2013, The Tor Project, Inc. */ 2 | /* See LICENSE for licensing information */ 3 | 4 | /** 5 | * \file circuitmux_ewma.h 6 | * \brief Header file for circuitmux_ewma.c 7 | **/ 8 | 9 | #ifndef TOR_CIRCUITMUX_EWMA_H 10 | #define TOR_CIRCUITMUX_EWMA_H 11 | 12 | #include "or.h" 13 | #include "circuitmux.h" 14 | 15 | /* Everything but circuitmux_ewma.c should see this extern */ 16 | #ifndef TOR_CIRCUITMUX_EWMA_C_ 17 | 18 | extern circuitmux_policy_t ewma_policy; 19 | 20 | #endif /* !(TOR_CIRCUITMUX_EWMA_C_) */ 21 | 22 | /* Externally visible EWMA functions */ 23 | int cell_ewma_enabled(void); 24 | unsigned int cell_ewma_get_tick(void); 25 | void cell_ewma_set_scale_factor(const or_options_t *options, 26 | const networkstatus_t *consensus); 27 | 28 | #endif /* TOR_CIRCUITMUX_EWMA_H */ 29 | 30 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/or/circuituse.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2001 Matej Pfajfar. 2 | * Copyright (c) 2001-2004, Roger Dingledine. 3 | * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson. 4 | * Copyright (c) 2007-2013, The Tor Project, Inc. */ 5 | /* See LICENSE for licensing information */ 6 | 7 | /** 8 | * \file circuituse.h 9 | * \brief Header file for circuituse.c. 10 | **/ 11 | 12 | #ifndef TOR_CIRCUITUSE_H 13 | #define TOR_CIRCUITUSE_H 14 | 15 | void circuit_expire_building(void); 16 | void circuit_remove_handled_ports(smartlist_t *needed_ports); 17 | int circuit_stream_is_being_handled(entry_connection_t *conn, uint16_t port, 18 | int min); 19 | void circuit_log_ancient_one_hop_circuits(int age); 20 | #if 0 21 | int circuit_conforms_to_options(const origin_circuit_t *circ, 22 | const or_options_t *options); 23 | #endif 24 | void circuit_build_needed_circs(time_t now); 25 | void circuit_expire_old_circs_as_needed(time_t now); 26 | void circuit_detach_stream(circuit_t *circ, edge_connection_t *conn); 27 | 28 | void circuit_expire_old_circuits_serverside(time_t now); 29 | 30 | void reset_bandwidth_test(void); 31 | int circuit_enough_testing_circs(void); 32 | 33 | void circuit_has_opened(origin_circuit_t *circ); 34 | void circuit_try_attaching_streams(origin_circuit_t *circ); 35 | void circuit_build_failed(origin_circuit_t *circ); 36 | 37 | /** Flag to set when a circuit should have only a single hop. */ 38 | #define CIRCLAUNCH_ONEHOP_TUNNEL (1<<0) 39 | /** Flag to set when a circuit needs to be built of high-uptime nodes */ 40 | #define CIRCLAUNCH_NEED_UPTIME (1<<1) 41 | /** Flag to set when a circuit needs to be built of high-capacity nodes */ 42 | #define CIRCLAUNCH_NEED_CAPACITY (1<<2) 43 | /** Flag to set when the last hop of a circuit doesn't need to be an 44 | * exit node. */ 45 | #define CIRCLAUNCH_IS_INTERNAL (1<<3) 46 | origin_circuit_t *circuit_launch_by_extend_info(uint8_t purpose, 47 | extend_info_t *info, 48 | int flags); 49 | origin_circuit_t *circuit_launch(uint8_t purpose, int flags); 50 | void circuit_reset_failure_count(int timeout); 51 | int connection_ap_handshake_attach_chosen_circuit(entry_connection_t *conn, 52 | origin_circuit_t *circ, 53 | crypt_path_t *cpath); 54 | int connection_ap_handshake_attach_circuit(entry_connection_t *conn); 55 | 56 | void circuit_change_purpose(circuit_t *circ, uint8_t new_purpose); 57 | 58 | int hostname_in_track_host_exits(const or_options_t *options, 59 | const char *address); 60 | void mark_circuit_unusable_for_new_conns(origin_circuit_t *circ); 61 | 62 | #endif 63 | 64 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/or/command.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2001 Matej Pfajfar. 2 | * Copyright (c) 2001-2004, Roger Dingledine. 3 | * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson. 4 | * Copyright (c) 2007-2013, The Tor Project, Inc. */ 5 | /* See LICENSE for licensing information */ 6 | 7 | /** 8 | * \file command.h 9 | * \brief Header file for command.c. 10 | **/ 11 | 12 | #ifndef TOR_COMMAND_H 13 | #define TOR_COMMAND_H 14 | 15 | #include "channel.h" 16 | 17 | void command_process_cell(channel_t *chan, cell_t *cell); 18 | void command_process_var_cell(channel_t *chan, var_cell_t *cell); 19 | void command_setup_channel(channel_t *chan); 20 | void command_setup_listener(channel_listener_t *chan_l); 21 | 22 | const char *cell_command_to_string(uint8_t command); 23 | 24 | extern uint64_t stats_n_padding_cells_processed; 25 | extern uint64_t stats_n_create_cells_processed; 26 | extern uint64_t stats_n_created_cells_processed; 27 | extern uint64_t stats_n_relay_cells_processed; 28 | extern uint64_t stats_n_destroy_cells_processed; 29 | 30 | #endif 31 | 32 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/or/config_codedigest.c: -------------------------------------------------------------------------------- 1 | 2 | const char *tor_get_digests(void); 3 | 4 | /** Return a string describing the digest of the source files in src/or/ 5 | */ 6 | const char * 7 | tor_get_digests(void) 8 | { 9 | return "" 10 | #include "or_sha1.i" 11 | ; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/or/cpuworker.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2001 Matej Pfajfar. 2 | * Copyright (c) 2001-2004, Roger Dingledine. 3 | * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson. 4 | * Copyright (c) 2007-2013, The Tor Project, Inc. */ 5 | /* See LICENSE for licensing information */ 6 | 7 | /** 8 | * \file cpuworker.h 9 | * \brief Header file for cpuworker.c. 10 | **/ 11 | 12 | #ifndef TOR_CPUWORKER_H 13 | #define TOR_CPUWORKER_H 14 | 15 | void cpu_init(void); 16 | void cpuworkers_rotate(void); 17 | int connection_cpu_finished_flushing(connection_t *conn); 18 | int connection_cpu_reached_eof(connection_t *conn); 19 | int connection_cpu_process_inbuf(connection_t *conn); 20 | struct create_cell_t; 21 | int assign_onionskin_to_cpuworker(connection_t *cpuworker, 22 | or_circuit_t *circ, 23 | struct create_cell_t *onionskin); 24 | 25 | uint64_t estimated_usec_for_onionskins(uint32_t n_requests, 26 | uint16_t onionskin_type); 27 | void cpuworker_log_onionskin_overhead(int severity, int onionskin_type, 28 | const char *onionskin_type_name); 29 | 30 | #endif 31 | 32 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/or/dns.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2001 Matej Pfajfar. 2 | * Copyright (c) 2001-2004, Roger Dingledine. 3 | * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson. 4 | * Copyright (c) 2007-2013, The Tor Project, Inc. */ 5 | /* See LICENSE for licensing information */ 6 | 7 | /** 8 | * \file dns.h 9 | * \brief Header file for dns.c. 10 | **/ 11 | 12 | #ifndef TOR_DNS_H 13 | #define TOR_DNS_H 14 | 15 | int dns_init(void); 16 | int has_dns_init_failed(void); 17 | void dns_free_all(void); 18 | uint32_t dns_clip_ttl(uint32_t ttl); 19 | int dns_reset(void); 20 | void connection_dns_remove(edge_connection_t *conn); 21 | void assert_connection_edge_not_dns_pending(edge_connection_t *conn); 22 | void assert_all_pending_dns_resolves_ok(void); 23 | void dns_cancel_pending_resolve(const char *question); 24 | int dns_resolve(edge_connection_t *exitconn); 25 | void dns_launch_correctness_checks(void); 26 | int dns_seems_to_be_broken(void); 27 | int dns_seems_to_be_broken_for_ipv6(void); 28 | void dns_reset_correctness_checks(void); 29 | void dump_dns_mem_usage(int severity); 30 | 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/or/dnsserv.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2001 Matej Pfajfar. 2 | * Copyright (c) 2001-2004, Roger Dingledine. 3 | * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson. 4 | * Copyright (c) 2007-2013, The Tor Project, Inc. */ 5 | /* See LICENSE for licensing information */ 6 | 7 | /** 8 | * \file dnsserv.h 9 | * \brief Header file for dnsserv.c. 10 | **/ 11 | 12 | #ifndef TOR_DNSSERV_H 13 | #define TOR_DNSSERV_H 14 | 15 | void dnsserv_configure_listener(connection_t *conn); 16 | void dnsserv_close_listener(connection_t *conn); 17 | void dnsserv_resolved(entry_connection_t *conn, 18 | int answer_type, 19 | size_t answer_len, 20 | const char *answer, 21 | int ttl); 22 | void dnsserv_reject_request(entry_connection_t *conn); 23 | int dnsserv_launch_request(const char *name, int is_reverse, 24 | control_connection_t *control_conn); 25 | 26 | #endif 27 | 28 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/or/eventdns_tor.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2007-2013, The Tor Project, Inc. */ 2 | /* See LICENSE for licensing information */ 3 | 4 | #ifndef TOR_EVENTDNS_TOR_H 5 | #define TOR_EVENTDNS_TOR_H 6 | 7 | #include "orconfig.h" 8 | #define DNS_USE_OPENSSL_FOR_ID 9 | #ifndef HAVE_UINT 10 | typedef unsigned int uint; 11 | #endif 12 | #ifndef HAVE_U_CHAR 13 | typedef unsigned char u_char; 14 | #endif 15 | #ifdef _WIN32 16 | #define inline __inline 17 | #endif 18 | #include "torint.h" 19 | 20 | /* These are for debugging possible memory leaks. */ 21 | #include "util.h" 22 | #include "compat.h" 23 | 24 | #endif 25 | 26 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/or/ext_orport.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2001 Matej Pfajfar. 2 | * Copyright (c) 2001-2004, Roger Dingledine. 3 | * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson. 4 | * Copyright (c) 2007-2013, The Tor Project, Inc. */ 5 | /* See LICENSE for licensing information */ 6 | 7 | #ifndef EXT_ORPORT_H 8 | #define EXT_ORPORT_H 9 | 10 | int connection_ext_or_start_auth(or_connection_t *or_conn); 11 | 12 | ext_or_cmd_t *ext_or_cmd_new(uint16_t len); 13 | void ext_or_cmd_free(ext_or_cmd_t *cmd); 14 | void connection_or_set_ext_or_identifier(or_connection_t *conn); 15 | void connection_or_remove_from_ext_or_id_map(or_connection_t *conn); 16 | void connection_or_clear_ext_or_id_map(void); 17 | or_connection_t *connection_or_get_by_ext_or_id(const char *id); 18 | 19 | int connection_ext_or_finished_flushing(or_connection_t *conn); 20 | int connection_ext_or_process_inbuf(or_connection_t *or_conn); 21 | 22 | int init_ext_or_cookie_authentication(int is_enabled); 23 | char *get_ext_or_auth_cookie_file_name(void); 24 | void ext_orport_free_all(void); 25 | 26 | #ifdef EXT_ORPORT_PRIVATE 27 | STATIC int connection_write_ext_or_command(connection_t *conn, 28 | uint16_t command, 29 | const char *body, 30 | size_t bodylen); 31 | STATIC int handle_client_auth_nonce(const char *client_nonce, 32 | size_t client_nonce_len, 33 | char **client_hash_out, 34 | char **reply_out, size_t *reply_len_out); 35 | #ifdef TOR_UNIT_TESTS 36 | extern uint8_t *ext_or_auth_cookie; 37 | extern int ext_or_auth_cookie_is_set; 38 | #endif 39 | #endif 40 | 41 | #endif 42 | 43 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/or/fp_pair.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, The Tor Project, Inc. */ 2 | /* See LICENSE for licensing information */ 3 | 4 | /** 5 | * \file fp_pair.h 6 | * \brief Header file for fp_pair.c. 7 | **/ 8 | 9 | #ifndef _TOR_FP_PAIR_H 10 | #define _TOR_FP_PAIR_H 11 | 12 | /* 13 | * Declare fp_pair_map_t functions and structs 14 | */ 15 | 16 | typedef struct fp_pair_map_entry_s fp_pair_map_entry_t; 17 | typedef struct fp_pair_map_s fp_pair_map_t; 18 | typedef fp_pair_map_entry_t *fp_pair_map_iter_t; 19 | 20 | fp_pair_map_t * fp_pair_map_new(void); 21 | void * fp_pair_map_set(fp_pair_map_t *map, const fp_pair_t *key, void *val); 22 | void * fp_pair_map_set_by_digests(fp_pair_map_t *map, 23 | const char *first, const char *second, 24 | void *val); 25 | void * fp_pair_map_get(const fp_pair_map_t *map, const fp_pair_t *key); 26 | void * fp_pair_map_get_by_digests(const fp_pair_map_t *map, 27 | const char *first, const char *second); 28 | void * fp_pair_map_remove(fp_pair_map_t *map, const fp_pair_t *key); 29 | void fp_pair_map_free(fp_pair_map_t *map, void (*free_val)(void*)); 30 | int fp_pair_map_isempty(const fp_pair_map_t *map); 31 | int fp_pair_map_size(const fp_pair_map_t *map); 32 | fp_pair_map_iter_t * fp_pair_map_iter_init(fp_pair_map_t *map); 33 | fp_pair_map_iter_t * fp_pair_map_iter_next(fp_pair_map_t *map, 34 | fp_pair_map_iter_t *iter); 35 | fp_pair_map_iter_t * fp_pair_map_iter_next_rmv(fp_pair_map_t *map, 36 | fp_pair_map_iter_t *iter); 37 | void fp_pair_map_iter_get(fp_pair_map_iter_t *iter, 38 | fp_pair_t *key_out, void **val_out); 39 | int fp_pair_map_iter_done(fp_pair_map_iter_t *iter); 40 | void fp_pair_map_assert_ok(const fp_pair_map_t *map); 41 | 42 | #undef DECLARE_MAP_FNS 43 | 44 | #endif 45 | 46 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/or/geoip.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2001 Matej Pfajfar. 2 | * Copyright (c) 2001-2004, Roger Dingledine. 3 | * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson. 4 | * Copyright (c) 2007-2013, The Tor Project, Inc. */ 5 | /* See LICENSE for licensing information */ 6 | 7 | /** 8 | * \file geoip.h 9 | * \brief Header file for geoip.c. 10 | **/ 11 | 12 | #ifndef TOR_GEOIP_H 13 | #define TOR_GEOIP_H 14 | 15 | #include "testsupport.h" 16 | 17 | #ifdef GEOIP_PRIVATE 18 | STATIC int geoip_parse_entry(const char *line, sa_family_t family); 19 | STATIC int geoip_get_country_by_ipv4(uint32_t ipaddr); 20 | STATIC int geoip_get_country_by_ipv6(const struct in6_addr *addr); 21 | #endif 22 | int should_record_bridge_info(const or_options_t *options); 23 | int geoip_load_file(sa_family_t family, const char *filename); 24 | MOCK_DECL(int, geoip_get_country_by_addr, (const tor_addr_t *addr)); 25 | MOCK_DECL(int, geoip_get_n_countries, (void)); 26 | const char *geoip_get_country_name(country_t num); 27 | MOCK_DECL(int, geoip_is_loaded, (sa_family_t family)); 28 | const char *geoip_db_digest(sa_family_t family); 29 | MOCK_DECL(country_t, geoip_get_country, (const char *countrycode)); 30 | 31 | void geoip_note_client_seen(geoip_client_action_t action, 32 | const tor_addr_t *addr, const char *transport_name, 33 | time_t now); 34 | void geoip_remove_old_clients(time_t cutoff); 35 | 36 | void geoip_note_ns_response(geoip_ns_response_t response); 37 | char *geoip_get_transport_history(void); 38 | int geoip_get_client_history(geoip_client_action_t action, 39 | char **country_str, char **ipver_str); 40 | char *geoip_get_request_history(void); 41 | int getinfo_helper_geoip(control_connection_t *control_conn, 42 | const char *question, char **answer, 43 | const char **errmsg); 44 | void geoip_free_all(void); 45 | 46 | void geoip_start_dirreq(uint64_t dirreq_id, size_t response_size, 47 | dirreq_type_t type); 48 | void geoip_change_dirreq_state(uint64_t dirreq_id, dirreq_type_t type, 49 | dirreq_state_t new_state); 50 | 51 | void geoip_dirreq_stats_init(time_t now); 52 | void geoip_reset_dirreq_stats(time_t now); 53 | char *geoip_format_dirreq_stats(time_t now); 54 | time_t geoip_dirreq_stats_write(time_t now); 55 | void geoip_dirreq_stats_term(void); 56 | void geoip_entry_stats_init(time_t now); 57 | time_t geoip_entry_stats_write(time_t now); 58 | void geoip_entry_stats_term(void); 59 | void geoip_reset_entry_stats(time_t now); 60 | char *geoip_format_entry_stats(time_t now); 61 | void geoip_bridge_stats_init(time_t now); 62 | char *geoip_format_bridge_stats(time_t now); 63 | time_t geoip_bridge_stats_write(time_t now); 64 | void geoip_bridge_stats_term(void); 65 | const char *geoip_get_bridge_stats_extrainfo(time_t); 66 | char *geoip_get_bridge_stats_controller(time_t); 67 | 68 | #endif 69 | 70 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/or/hibernate.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2001 Matej Pfajfar. 2 | * Copyright (c) 2001-2004, Roger Dingledine. 3 | * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson. 4 | * Copyright (c) 2007-2013, The Tor Project, Inc. */ 5 | /* See LICENSE for licensing information */ 6 | 7 | /** 8 | * \file hibernate.h 9 | * \brief Header file for hibernate.c. 10 | **/ 11 | 12 | #ifndef TOR_HIBERNATE_H 13 | #define TOR_HIBERNATE_H 14 | 15 | #include "testsupport.h" 16 | 17 | int accounting_parse_options(const or_options_t *options, int validate_only); 18 | MOCK_DECL(int, accounting_is_enabled, (const or_options_t *options)); 19 | int accounting_get_interval_length(void); 20 | MOCK_DECL(time_t, accounting_get_end_time, (void)); 21 | void configure_accounting(time_t now); 22 | void accounting_run_housekeeping(time_t now); 23 | void accounting_add_bytes(size_t n_read, size_t n_written, int seconds); 24 | int accounting_record_bandwidth_usage(time_t now, or_state_t *state); 25 | void hibernate_begin_shutdown(void); 26 | MOCK_DECL(int, we_are_hibernating, (void)); 27 | void consider_hibernation(time_t now); 28 | int getinfo_helper_accounting(control_connection_t *conn, 29 | const char *question, char **answer, 30 | const char **errmsg); 31 | 32 | #ifdef HIBERNATE_PRIVATE 33 | /** Possible values of hibernate_state */ 34 | typedef enum { 35 | /** We are running normally. */ 36 | HIBERNATE_STATE_LIVE=1, 37 | /** We're trying to shut down cleanly, and we'll kill all active connections 38 | * at shutdown_time. */ 39 | HIBERNATE_STATE_EXITING=2, 40 | /** We're running low on allocated bandwidth for this period, so we won't 41 | * accept any new connections. */ 42 | HIBERNATE_STATE_LOWBANDWIDTH=3, 43 | /** We are hibernating, and we won't wake up till there's more bandwidth to 44 | * use. */ 45 | HIBERNATE_STATE_DORMANT=4, 46 | /** We start out in state default, which means we havent decided which state 47 | * we're in. */ 48 | HIBERNATE_STATE_INITIAL=5 49 | } hibernate_state_t; 50 | 51 | #ifdef TOR_UNIT_TESTS 52 | void hibernate_set_state_for_testing_(hibernate_state_t newstate); 53 | #endif 54 | #endif 55 | 56 | #endif 57 | 58 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/or/main.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2001 Matej Pfajfar. 2 | * Copyright (c) 2001-2004, Roger Dingledine. 3 | * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson. 4 | * Copyright (c) 2007-2013, The Tor Project, Inc. */ 5 | /* See LICENSE for licensing information */ 6 | 7 | /** 8 | * \file main.h 9 | * \brief Header file for main.c. 10 | **/ 11 | 12 | #ifndef TOR_MAIN_H 13 | #define TOR_MAIN_H 14 | 15 | extern int can_complete_circuit; 16 | 17 | int connection_add_impl(connection_t *conn, int is_connecting); 18 | #define connection_add(conn) connection_add_impl((conn), 0) 19 | #define connection_add_connecting(conn) connection_add_impl((conn), 1) 20 | int connection_remove(connection_t *conn); 21 | void connection_unregister_events(connection_t *conn); 22 | int connection_in_array(connection_t *conn); 23 | void add_connection_to_closeable_list(connection_t *conn); 24 | int connection_is_on_closeable_list(connection_t *conn); 25 | 26 | smartlist_t *get_connection_array(void); 27 | MOCK_DECL(uint64_t,get_bytes_read,(void)); 28 | MOCK_DECL(uint64_t,get_bytes_written,(void)); 29 | 30 | /** Bitmask for events that we can turn on and off with 31 | * connection_watch_events. */ 32 | typedef enum watchable_events { 33 | /* Yes, it is intentional that these match Libevent's EV_READ and EV_WRITE */ 34 | READ_EVENT=0x02, /**< We want to know when a connection is readable */ 35 | WRITE_EVENT=0x04 /**< We want to know when a connection is writable */ 36 | } watchable_events_t; 37 | void connection_watch_events(connection_t *conn, watchable_events_t events); 38 | int connection_is_reading(connection_t *conn); 39 | MOCK_DECL(void,connection_stop_reading,(connection_t *conn)); 40 | MOCK_DECL(void,connection_start_reading,(connection_t *conn)); 41 | 42 | int connection_is_writing(connection_t *conn); 43 | MOCK_DECL(void,connection_stop_writing,(connection_t *conn)); 44 | MOCK_DECL(void,connection_start_writing,(connection_t *conn)); 45 | 46 | void connection_stop_reading_from_linked_conn(connection_t *conn); 47 | 48 | void directory_all_unreachable(time_t now); 49 | void directory_info_has_arrived(time_t now, int from_cache); 50 | 51 | void ip_address_changed(int at_interface); 52 | void dns_servers_relaunch_checks(void); 53 | void reschedule_descriptor_update_check(void); 54 | 55 | MOCK_DECL(long,get_uptime,(void)); 56 | 57 | unsigned get_signewnym_epoch(void); 58 | 59 | void handle_signals(int is_parent); 60 | void process_signal(uintptr_t sig); 61 | 62 | int try_locking(const or_options_t *options, int err_if_locked); 63 | int have_lockfile(void); 64 | void release_lockfile(void); 65 | 66 | void tor_cleanup(void); 67 | void tor_free_all(int postfork); 68 | 69 | int tor_main(int argc, char *argv[]); 70 | 71 | int do_main_loop(void); 72 | int tor_init(int argc, char **argv); 73 | 74 | #ifdef MAIN_PRIVATE 75 | STATIC void init_connection_lists(void); 76 | STATIC void close_closeable_connections(void); 77 | #endif 78 | 79 | #endif 80 | 81 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/or/microdesc.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2001 Matej Pfajfar. 2 | * Copyright (c) 2001-2004, Roger Dingledine. 3 | * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson. 4 | * Copyright (c) 2007-2013, The Tor Project, Inc. */ 5 | /* See LICENSE for licensing information */ 6 | 7 | /** 8 | * \file microdesc.h 9 | * \brief Header file for microdesc.c. 10 | **/ 11 | 12 | #ifndef TOR_MICRODESC_H 13 | #define TOR_MICRODESC_H 14 | 15 | microdesc_cache_t *get_microdesc_cache(void); 16 | 17 | void microdesc_check_counts(void); 18 | 19 | smartlist_t *microdescs_add_to_cache(microdesc_cache_t *cache, 20 | const char *s, const char *eos, saved_location_t where, 21 | int no_save, time_t listed_at, 22 | smartlist_t *requested_digests256); 23 | smartlist_t *microdescs_add_list_to_cache(microdesc_cache_t *cache, 24 | smartlist_t *descriptors, saved_location_t where, 25 | int no_save); 26 | 27 | void microdesc_cache_clean(microdesc_cache_t *cache, time_t cutoff, int force); 28 | int microdesc_cache_rebuild(microdesc_cache_t *cache, int force); 29 | int microdesc_cache_reload(microdesc_cache_t *cache); 30 | void microdesc_cache_clear(microdesc_cache_t *cache); 31 | 32 | microdesc_t *microdesc_cache_lookup_by_digest256(microdesc_cache_t *cache, 33 | const char *d); 34 | 35 | size_t microdesc_average_size(microdesc_cache_t *cache); 36 | 37 | smartlist_t *microdesc_list_missing_digest256(networkstatus_t *ns, 38 | microdesc_cache_t *cache, 39 | int downloadable_only, 40 | digestmap_t *skip); 41 | 42 | void microdesc_free_(microdesc_t *md, const char *fname, int line); 43 | #define microdesc_free(md) \ 44 | microdesc_free_((md), __FILE__, __LINE__) 45 | void microdesc_free_all(void); 46 | 47 | void update_microdesc_downloads(time_t now); 48 | void update_microdescs_from_networkstatus(time_t now); 49 | 50 | int usable_consensus_flavor(void); 51 | int we_fetch_microdescriptors(const or_options_t *options); 52 | int we_fetch_router_descriptors(const or_options_t *options); 53 | int we_use_microdescriptors_for_circuits(const or_options_t *options); 54 | 55 | #endif 56 | 57 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/or/ntmain.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2001 Matej Pfajfar. 2 | * Copyright (c) 2001-2004, Roger Dingledine. 3 | * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson. 4 | * Copyright (c) 2007-2013, The Tor Project, Inc. */ 5 | /* See LICENSE for licensing information */ 6 | 7 | /** 8 | * \file ntmain.h 9 | * \brief Header file for ntmain.c. 10 | **/ 11 | 12 | #ifndef TOR_NTMAIN_H 13 | #define TOR_NTMAIN_H 14 | 15 | #ifdef _WIN32 16 | #define NT_SERVICE 17 | #endif 18 | 19 | #ifdef NT_SERVICE 20 | int nt_service_parse_options(int argc, char **argv, int *should_exit); 21 | int nt_service_is_stopping(void); 22 | void nt_service_set_state(DWORD state); 23 | #else 24 | #define nt_service_is_stopping() 0 25 | #endif 26 | 27 | #endif 28 | 29 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/or/onion_fast.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2001 Matej Pfajfar. 2 | * Copyright (c) 2001-2004, Roger Dingledine. 3 | * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson. 4 | * Copyright (c) 2007-2013, The Tor Project, Inc. */ 5 | /* See LICENSE for licensing information */ 6 | 7 | /** 8 | * \file onion_fast.h 9 | * \brief Header file for onion_fast.c. 10 | **/ 11 | 12 | #ifndef TOR_ONION_FAST_H 13 | #define TOR_ONION_FAST_H 14 | 15 | #define CREATE_FAST_LEN DIGEST_LEN 16 | #define CREATED_FAST_LEN (DIGEST_LEN*2) 17 | 18 | typedef struct fast_handshake_state_t { 19 | uint8_t state[DIGEST_LEN]; 20 | } fast_handshake_state_t; 21 | 22 | void fast_handshake_state_free(fast_handshake_state_t *victim); 23 | 24 | int fast_onionskin_create(fast_handshake_state_t **handshake_state_out, 25 | uint8_t *handshake_out); 26 | 27 | int fast_server_handshake(const uint8_t *message_in, 28 | uint8_t *handshake_reply_out, 29 | uint8_t *key_out, 30 | size_t key_out_len); 31 | 32 | int fast_client_handshake(const fast_handshake_state_t *handshake_state, 33 | const uint8_t *handshake_reply_out, 34 | uint8_t *key_out, 35 | size_t key_out_len); 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/or/onion_ntor.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2013, The Tor Project, Inc. */ 2 | /* See LICENSE for licensing information */ 3 | 4 | #ifndef TOR_ONION_NTOR_H 5 | #define TOR_ONION_NTOR_H 6 | 7 | #include "torint.h" 8 | #include "crypto_curve25519.h" 9 | #include "di_ops.h" 10 | 11 | /** State to be maintained by a client between sending an ntor onionskin 12 | * and receiving a reply. */ 13 | typedef struct ntor_handshake_state_t ntor_handshake_state_t; 14 | 15 | /** Length of an ntor onionskin, as sent from the client to server. */ 16 | #define NTOR_ONIONSKIN_LEN 84 17 | /** Length of an ntor reply, as sent from server to client. */ 18 | #define NTOR_REPLY_LEN 64 19 | 20 | #ifdef CURVE25519_ENABLED 21 | void ntor_handshake_state_free(ntor_handshake_state_t *state); 22 | 23 | int onion_skin_ntor_create(const uint8_t *router_id, 24 | const curve25519_public_key_t *router_key, 25 | ntor_handshake_state_t **handshake_state_out, 26 | uint8_t *onion_skin_out); 27 | 28 | int onion_skin_ntor_server_handshake(const uint8_t *onion_skin, 29 | const di_digest256_map_t *private_keys, 30 | const curve25519_keypair_t *junk_keypair, 31 | const uint8_t *my_node_id, 32 | uint8_t *handshake_reply_out, 33 | uint8_t *key_out, 34 | size_t key_out_len); 35 | 36 | int onion_skin_ntor_client_handshake( 37 | const ntor_handshake_state_t *handshake_state, 38 | const uint8_t *handshake_reply, 39 | uint8_t *key_out, 40 | size_t key_out_len); 41 | 42 | #ifdef ONION_NTOR_PRIVATE 43 | 44 | /** Storage held by a client while waiting for an ntor reply from a server. */ 45 | struct ntor_handshake_state_t { 46 | /** Identity digest of the router we're talking to. */ 47 | uint8_t router_id[DIGEST_LEN]; 48 | /** Onion key of the router we're talking to. */ 49 | curve25519_public_key_t pubkey_B; 50 | 51 | /** 52 | * Short-lived keypair for use with this handshake. 53 | * @{ */ 54 | curve25519_secret_key_t seckey_x; 55 | curve25519_public_key_t pubkey_X; 56 | /** @} */ 57 | }; 58 | #endif 59 | 60 | #endif 61 | 62 | #endif 63 | 64 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/or/onion_tap.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2001 Matej Pfajfar. 2 | * Copyright (c) 2001-2004, Roger Dingledine. 3 | * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson. 4 | * Copyright (c) 2007-2013, The Tor Project, Inc. */ 5 | /* See LICENSE for licensing information */ 6 | 7 | /** 8 | * \file onion_tap.h 9 | * \brief Header file for onion_tap.c. 10 | **/ 11 | 12 | #ifndef TOR_ONION_TAP_H 13 | #define TOR_ONION_TAP_H 14 | 15 | #define TAP_ONIONSKIN_CHALLENGE_LEN (PKCS1_OAEP_PADDING_OVERHEAD+\ 16 | CIPHER_KEY_LEN+\ 17 | DH_KEY_LEN) 18 | #define TAP_ONIONSKIN_REPLY_LEN (DH_KEY_LEN+DIGEST_LEN) 19 | 20 | int onion_skin_TAP_create(crypto_pk_t *router_key, 21 | crypto_dh_t **handshake_state_out, 22 | char *onion_skin_out); 23 | 24 | int onion_skin_TAP_server_handshake(const char *onion_skin, 25 | crypto_pk_t *private_key, 26 | crypto_pk_t *prev_private_key, 27 | char *handshake_reply_out, 28 | char *key_out, 29 | size_t key_out_len); 30 | 31 | int onion_skin_TAP_client_handshake(crypto_dh_t *handshake_state, 32 | const char *handshake_reply, 33 | char *key_out, 34 | size_t key_out_len); 35 | 36 | #endif 37 | 38 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/or/policies.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2001 Matej Pfajfar. 2 | * Copyright (c) 2001-2004, Roger Dingledine. 3 | * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson. 4 | * Copyright (c) 2007-2013, The Tor Project, Inc. */ 5 | /* See LICENSE for licensing information */ 6 | 7 | /** 8 | * \file policies.h 9 | * \brief Header file for policies.c. 10 | **/ 11 | 12 | #ifndef TOR_POLICIES_H 13 | #define TOR_POLICIES_H 14 | 15 | /* (length of 16 | * "accept6 [ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff]/128:65535-65535\n" 17 | * plus a terminating NUL, rounded up to a nice number.) 18 | */ 19 | #define POLICY_BUF_LEN 72 20 | 21 | int firewall_is_fascist_or(void); 22 | int fascist_firewall_allows_address_or(const tor_addr_t *addr, uint16_t port); 23 | int fascist_firewall_allows_or(const routerinfo_t *ri); 24 | int fascist_firewall_allows_node(const node_t *node); 25 | int fascist_firewall_allows_address_dir(const tor_addr_t *addr, uint16_t port); 26 | int dir_policy_permits_address(const tor_addr_t *addr); 27 | int socks_policy_permits_address(const tor_addr_t *addr); 28 | int authdir_policy_permits_address(uint32_t addr, uint16_t port); 29 | int authdir_policy_valid_address(uint32_t addr, uint16_t port); 30 | int authdir_policy_badexit_address(uint32_t addr, uint16_t port); 31 | 32 | int validate_addr_policies(const or_options_t *options, char **msg); 33 | void policy_expand_private(smartlist_t **policy); 34 | void policy_expand_unspec(smartlist_t **policy); 35 | int policies_parse_from_options(const or_options_t *options); 36 | 37 | addr_policy_t *addr_policy_get_canonical_entry(addr_policy_t *ent); 38 | int cmp_addr_policies(smartlist_t *a, smartlist_t *b); 39 | MOCK_DECL(addr_policy_result_t, compare_tor_addr_to_addr_policy, 40 | (const tor_addr_t *addr, uint16_t port, const smartlist_t *policy)); 41 | 42 | addr_policy_result_t compare_tor_addr_to_node_policy(const tor_addr_t *addr, 43 | uint16_t port, const node_t *node); 44 | 45 | int policies_parse_exit_policy(config_line_t *cfg, smartlist_t **dest, 46 | int ipv6exit, 47 | int rejectprivate, uint32_t local_address, 48 | int add_default_policy); 49 | void policies_exit_policy_append_reject_star(smartlist_t **dest); 50 | void addr_policy_append_reject_addr(smartlist_t **dest, 51 | const tor_addr_t *addr); 52 | void policies_set_node_exitpolicy_to_reject_all(node_t *exitrouter); 53 | int exit_policy_is_general_exit(smartlist_t *policy); 54 | int policy_is_reject_star(const smartlist_t *policy, sa_family_t family); 55 | int getinfo_helper_policies(control_connection_t *conn, 56 | const char *question, char **answer, 57 | const char **errmsg); 58 | int policy_write_item(char *buf, size_t buflen, addr_policy_t *item, 59 | int format_for_desc); 60 | 61 | void addr_policy_list_free(smartlist_t *p); 62 | void addr_policy_free(addr_policy_t *p); 63 | void policies_free_all(void); 64 | 65 | char *policy_summarize(smartlist_t *policy, sa_family_t family); 66 | 67 | short_policy_t *parse_short_policy(const char *summary); 68 | char *write_short_policy(const short_policy_t *policy); 69 | void short_policy_free(short_policy_t *policy); 70 | int short_policy_is_reject_star(const short_policy_t *policy); 71 | addr_policy_result_t compare_tor_addr_to_short_policy( 72 | const tor_addr_t *addr, uint16_t port, 73 | const short_policy_t *policy); 74 | 75 | #endif 76 | 77 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/or/reasons.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2001 Matej Pfajfar. 2 | * Copyright (c) 2001-2004, Roger Dingledine. 3 | * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson. 4 | * Copyright (c) 2007-2013, The Tor Project, Inc. */ 5 | /* See LICENSE for licensing information */ 6 | 7 | /** 8 | * \file reasons.h 9 | * \brief Header file for reasons.c. 10 | **/ 11 | 12 | #ifndef TOR_REASONS_H 13 | #define TOR_REASONS_H 14 | 15 | const char *stream_end_reason_to_control_string(int reason); 16 | const char *stream_end_reason_to_string(int reason); 17 | socks5_reply_status_t stream_end_reason_to_socks5_response(int reason); 18 | uint8_t errno_to_stream_end_reason(int e); 19 | 20 | const char *orconn_end_reason_to_control_string(int r); 21 | int tls_error_to_orconn_end_reason(int e); 22 | int errno_to_orconn_end_reason(int e); 23 | 24 | const char *circuit_end_reason_to_control_string(int reason); 25 | const char *socks4_response_code_to_string(uint8_t code); 26 | const char *socks5_response_code_to_string(uint8_t code); 27 | 28 | const char *bandwidth_weight_rule_to_string(enum bandwidth_weight_rule_t rule); 29 | 30 | #endif 31 | 32 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/or/rendclient.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2001 Matej Pfajfar. 2 | * Copyright (c) 2001-2004, Roger Dingledine. 3 | * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson. 4 | * Copyright (c) 2007-2013, The Tor Project, Inc. */ 5 | /* See LICENSE for licensing information */ 6 | 7 | /** 8 | * \file rendclient.h 9 | * \brief Header file for rendclient.c. 10 | **/ 11 | 12 | #ifndef TOR_RENDCLIENT_H 13 | #define TOR_RENDCLIENT_H 14 | 15 | void rend_client_purge_state(void); 16 | 17 | void rend_client_introcirc_has_opened(origin_circuit_t *circ); 18 | void rend_client_rendcirc_has_opened(origin_circuit_t *circ); 19 | int rend_client_introduction_acked(origin_circuit_t *circ, 20 | const uint8_t *request, 21 | size_t request_len); 22 | void rend_client_refetch_v2_renddesc(const rend_data_t *rend_query); 23 | void rend_client_cancel_descriptor_fetches(void); 24 | void rend_client_purge_last_hid_serv_requests(void); 25 | 26 | #define INTRO_POINT_FAILURE_GENERIC 0 27 | #define INTRO_POINT_FAILURE_TIMEOUT 1 28 | #define INTRO_POINT_FAILURE_UNREACHABLE 2 29 | 30 | int rend_client_report_intro_point_failure(extend_info_t *failed_intro, 31 | const rend_data_t *rend_query, 32 | unsigned int failure_type); 33 | 34 | int rend_client_rendezvous_acked(origin_circuit_t *circ, 35 | const uint8_t *request, 36 | size_t request_len); 37 | int rend_client_receive_rendezvous(origin_circuit_t *circ, 38 | const uint8_t *request, 39 | size_t request_len); 40 | void rend_client_desc_trynow(const char *query); 41 | 42 | void rend_client_note_connection_attempt_ended(const char *onion_address); 43 | 44 | extend_info_t *rend_client_get_random_intro(const rend_data_t *rend_query); 45 | int rend_client_any_intro_points_usable(const rend_cache_entry_t *entry); 46 | 47 | int rend_client_send_introduction(origin_circuit_t *introcirc, 48 | origin_circuit_t *rendcirc); 49 | int rend_parse_service_authorization(const or_options_t *options, 50 | int validate_only); 51 | rend_service_authorization_t *rend_client_lookup_service_authorization( 52 | const char *onion_address); 53 | void rend_service_authorization_free_all(void); 54 | rend_data_t *rend_data_dup(const rend_data_t *request); 55 | 56 | #endif 57 | 58 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/or/rendcommon.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2001 Matej Pfajfar. 2 | * Copyright (c) 2001-2004, Roger Dingledine. 3 | * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson. 4 | * Copyright (c) 2007-2013, The Tor Project, Inc. */ 5 | /* See LICENSE for licensing information */ 6 | 7 | /** 8 | * \file rendcommon.h 9 | * \brief Header file for rendcommon.c. 10 | **/ 11 | 12 | #ifndef TOR_RENDCOMMON_H 13 | #define TOR_RENDCOMMON_H 14 | 15 | /** Free all storage associated with data */ 16 | static INLINE void 17 | rend_data_free(rend_data_t *data) 18 | { 19 | tor_free(data); 20 | } 21 | 22 | int rend_cmp_service_ids(const char *one, const char *two); 23 | 24 | void rend_process_relay_cell(circuit_t *circ, const crypt_path_t *layer_hint, 25 | int command, size_t length, 26 | const uint8_t *payload); 27 | 28 | void rend_service_descriptor_free(rend_service_descriptor_t *desc); 29 | int rend_get_service_id(crypto_pk_t *pk, char *out); 30 | void rend_encoded_v2_service_descriptor_free( 31 | rend_encoded_v2_service_descriptor_t *desc); 32 | void rend_intro_point_free(rend_intro_point_t *intro); 33 | 34 | void rend_cache_init(void); 35 | void rend_cache_clean(time_t now); 36 | void rend_cache_clean_v2_descs_as_dir(time_t now); 37 | void rend_cache_purge(void); 38 | void rend_cache_free_all(void); 39 | int rend_valid_service_id(const char *query); 40 | int rend_desc_v2_parse_service_id(const char *desc, char *out); 41 | int rend_cache_lookup_entry(const char *query, int version, 42 | rend_cache_entry_t **entry_out); 43 | int rend_cache_lookup_v2_desc_as_dir(const char *query, const char **desc); 44 | /** Return value from rend_cache_store_v2_desc_as_{dir,client}. */ 45 | typedef enum { 46 | RCS_NOTDIR = -2, /**< We're not a directory */ 47 | RCS_BADDESC = -1, /**< This descriptor is no good. */ 48 | RCS_OKAY = 0 /**< All worked as expected */ 49 | } rend_cache_store_status_t; 50 | 51 | rend_cache_store_status_t rend_cache_store_v2_desc_as_dir(const char *desc); 52 | rend_cache_store_status_t rend_cache_store_v2_desc_as_client(const char *desc, 53 | const rend_data_t *rend_query); 54 | 55 | int rend_encode_v2_descriptors(smartlist_t *descs_out, 56 | rend_service_descriptor_t *desc, time_t now, 57 | uint8_t period, rend_auth_type_t auth_type, 58 | crypto_pk_t *client_key, 59 | smartlist_t *client_cookies); 60 | int rend_compute_v2_desc_id(char *desc_id_out, const char *service_id, 61 | const char *descriptor_cookie, 62 | time_t now, uint8_t replica); 63 | int rend_id_is_in_interval(const char *a, const char *b, const char *c); 64 | void rend_get_descriptor_id_bytes(char *descriptor_id_out, 65 | const char *service_id, 66 | const char *secret_id_part); 67 | 68 | #endif 69 | 70 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/or/rendmid.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2001 Matej Pfajfar. 2 | * Copyright (c) 2001-2004, Roger Dingledine. 3 | * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson. 4 | * Copyright (c) 2007-2013, The Tor Project, Inc. */ 5 | /* See LICENSE for licensing information */ 6 | 7 | /** 8 | * \file rendmid.h 9 | * \brief Header file for rendmid.c. 10 | **/ 11 | 12 | #ifndef TOR_RENDMID_H 13 | #define TOR_RENDMID_H 14 | 15 | int rend_mid_establish_intro(or_circuit_t *circ, const uint8_t *request, 16 | size_t request_len); 17 | int rend_mid_introduce(or_circuit_t *circ, const uint8_t *request, 18 | size_t request_len); 19 | int rend_mid_establish_rendezvous(or_circuit_t *circ, const uint8_t *request, 20 | size_t request_len); 21 | int rend_mid_rendezvous(or_circuit_t *circ, const uint8_t *request, 22 | size_t request_len); 23 | 24 | #endif 25 | 26 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/or/replaycache.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2013, The Tor Project, Inc. */ 2 | /* See LICENSE for licensing information */ 3 | 4 | /** 5 | * \file replaycache.h 6 | * \brief Header file for replaycache.c. 7 | **/ 8 | 9 | #ifndef TOR_REPLAYCACHE_H 10 | #define TOR_REPLAYCACHE_H 11 | 12 | typedef struct replaycache_s replaycache_t; 13 | 14 | #ifdef REPLAYCACHE_PRIVATE 15 | 16 | struct replaycache_s { 17 | /* Scrub interval */ 18 | time_t scrub_interval; 19 | /* Last scrubbed */ 20 | time_t scrubbed; 21 | /* 22 | * Horizon 23 | * (don't return true on digests in the cache but older than this) 24 | */ 25 | time_t horizon; 26 | /* 27 | * Digest map: keys are digests, values are times the digest was last seen 28 | */ 29 | digestmap_t *digests_seen; 30 | }; 31 | 32 | #endif /* REPLAYCACHE_PRIVATE */ 33 | 34 | /* replaycache_t free/new */ 35 | 36 | void replaycache_free(replaycache_t *r); 37 | replaycache_t * replaycache_new(time_t horizon, time_t interval); 38 | 39 | #ifdef REPLAYCACHE_PRIVATE 40 | 41 | /* 42 | * replaycache_t internal functions: 43 | * 44 | * These take the time to treat as the present as an argument for easy unit 45 | * testing. For everything else, use the wrappers below instead. 46 | */ 47 | 48 | STATIC int replaycache_add_and_test_internal( 49 | time_t present, replaycache_t *r, const void *data, size_t len, 50 | time_t *elapsed); 51 | STATIC void replaycache_scrub_if_needed_internal( 52 | time_t present, replaycache_t *r); 53 | 54 | #endif /* REPLAYCACHE_PRIVATE */ 55 | 56 | /* 57 | * replaycache_t methods 58 | */ 59 | 60 | int replaycache_add_and_test(replaycache_t *r, const void *data, size_t len); 61 | int replaycache_add_test_and_elapsed( 62 | replaycache_t *r, const void *data, size_t len, time_t *elapsed); 63 | void replaycache_scrub_if_needed(replaycache_t *r); 64 | 65 | #endif 66 | 67 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/or/statefile.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2001 Matej Pfajfar. 2 | * Copyright (c) 2001-2004, Roger Dingledine. 3 | * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson. 4 | * Copyright (c) 2007-2013, The Tor Project, Inc. */ 5 | /* See LICENSE for licensing information */ 6 | 7 | #ifndef TOR_STATEFILE_H 8 | #define TOR_STATEFILE_H 9 | 10 | MOCK_DECL(or_state_t *,get_or_state,(void)); 11 | int did_last_state_file_write_fail(void); 12 | int or_state_save(time_t now); 13 | 14 | void save_transport_to_state(const char *transport_name, 15 | const tor_addr_t *addr, uint16_t port); 16 | char *get_stored_bindaddr_for_server_transport(const char *transport); 17 | int or_state_load(void); 18 | int or_state_loaded(void); 19 | void or_state_free_all(void); 20 | 21 | #ifdef STATEFILE_PRIVATE 22 | STATIC config_line_t *get_transport_in_state_by_name(const char *transport); 23 | STATIC void or_state_free(or_state_t *state); 24 | STATIC or_state_t *or_state_new(void); 25 | #endif 26 | 27 | #endif 28 | 29 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/or/status.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2010-2013, The Tor Project, Inc. */ 2 | /* See LICENSE for licensing information */ 3 | 4 | #ifndef TOR_STATUS_H 5 | #define TOR_STATUS_H 6 | 7 | #include "testsupport.h" 8 | 9 | int log_heartbeat(time_t now); 10 | 11 | #ifdef STATUS_PRIVATE 12 | STATIC int count_circuits(void); 13 | STATIC char *secs_to_uptime(long secs); 14 | STATIC char *bytes_to_usage(uint64_t bytes); 15 | #endif 16 | 17 | #endif 18 | 19 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/or/tor_main.c: -------------------------------------------------------------------------------- 1 | /* Copyright 2001-2004 Roger Dingledine. 2 | * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson. 3 | * Copyright (c) 2007-2013, The Tor Project, Inc. */ 4 | /* See LICENSE for licensing information */ 5 | 6 | /** String describing which Tor Git repository version the source was 7 | * built from. This string is generated by a bit of shell kludging in 8 | * src/or/include.am, and is usually right. 9 | */ 10 | const char tor_git_revision[] = 11 | #ifndef _MSC_VER 12 | #include "micro-revision.i" 13 | #endif 14 | ""; 15 | 16 | /** 17 | * \file tor_main.c 18 | * \brief Stub module containing a main() function. Allows unit 19 | * test binary to link against main.c. 20 | **/ 21 | 22 | int tor_main(int argc, char *argv[]); 23 | 24 | /** We keep main() in a separate file so that our unit tests can use 25 | * functions from main.c) 26 | */ 27 | int 28 | main(int argc, char *argv[]) 29 | { 30 | return tor_main(argc, argv); 31 | } 32 | 33 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/test/Makefile.nmake: -------------------------------------------------------------------------------- 1 | all: test.exe test-child.exe bench.exe 2 | 3 | CFLAGS = /I ..\win32 /I ..\..\..\build-alpha\include /I ..\common /I ..\or \ 4 | /I ..\ext 5 | 6 | LIBS = ..\..\..\build-alpha\lib\libevent.lib \ 7 | ..\..\..\build-alpha\lib\libcrypto.lib \ 8 | ..\..\..\build-alpha\lib\libssl.lib \ 9 | ..\..\..\build-alpha\lib\libz.lib \ 10 | ..\or\libtor.lib \ 11 | ws2_32.lib advapi32.lib shell32.lib \ 12 | crypt32.lib gdi32.lib user32.lib 13 | 14 | TEST_OBJECTS = test.obj test_addr.obj test_containers.obj \ 15 | test_controller_events.ogj test_crypto.obj test_data.obj test_dir.obj \ 16 | test_microdesc.obj test_pt.obj test_util.obj test_config.obj \ 17 | test_cell_formats.obj test_replay.obj test_introduce.obj tinytest.obj \ 18 | test_hs.obj 19 | 20 | tinytest.obj: ..\ext\tinytest.c 21 | $(CC) $(CFLAGS) /D snprintf=_snprintf /c ..\ext\tinytest.c 22 | 23 | test.exe: $(TEST_OBJECTS) 24 | $(CC) $(CFLAGS) $(LIBS) ..\common\*.lib $(TEST_OBJECTS) /Fe$@ 25 | 26 | bench.exe: bench.obj 27 | $(CC) $(CFLAGS) bench.obj $(LIBS) ..\common\*.lib /Fe$@ 28 | 29 | test-child.exe: test-child.obj 30 | $(CC) $(CFLAGS) test-child.obj /Fe$@ 31 | 32 | clean: 33 | del *.obj *.lib test.exe bench.exe test-child.exe 34 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/test/bt_test.py: -------------------------------------------------------------------------------- 1 | # Copyright 2013, The Tor Project, Inc 2 | # See LICENSE for licensing information 3 | 4 | """ 5 | bt_test.py 6 | 7 | This file tests the output from test-bt-cl to make sure it's as expected. 8 | 9 | Example usage: 10 | 11 | $ ./src/test/test-bt-cl crash | ./src/test/bt_test.py 12 | OK 13 | $ ./src/test/test-bt-cl assert | ./src/test/bt_test.py 14 | OK 15 | 16 | """ 17 | 18 | import sys 19 | 20 | 21 | def matches(lines, funcs): 22 | if len(lines) < len(funcs): 23 | return False 24 | try: 25 | for l, f in zip(lines, funcs): 26 | l.index(f) 27 | except ValueError: 28 | return False 29 | else: 30 | return True 31 | 32 | FUNCNAMES = "crash oh_what a_tangled_web we_weave main".split() 33 | 34 | LINES = sys.stdin.readlines() 35 | 36 | for I in range(len(LINES)): 37 | if matches(LINES[I:], FUNCNAMES): 38 | print("OK") 39 | break 40 | else: 41 | print("BAD") 42 | 43 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/test/slownacl_curve25519.py: -------------------------------------------------------------------------------- 1 | # This is the curve25519 implementation from Matthew Dempsky's "Slownacl" 2 | # library. It is in the public domain. 3 | # 4 | # It isn't constant-time. Don't use it except for testing. 5 | # 6 | # Nick got the slownacl source from: 7 | # https://github.com/mdempsky/dnscurve/tree/master/slownacl 8 | 9 | __all__ = ['smult_curve25519_base', 'smult_curve25519'] 10 | 11 | import sys 12 | 13 | P = 2 ** 255 - 19 14 | A = 486662 15 | 16 | def expmod(b, e, m): 17 | if e == 0: return 1 18 | t = expmod(b, e // 2, m) ** 2 % m 19 | if e & 1: t = (t * b) % m 20 | return t 21 | 22 | def inv(x): 23 | return expmod(x, P - 2, P) 24 | 25 | # Addition and doubling formulas taken from Appendix D of "Curve25519: 26 | # new Diffie-Hellman speed records". 27 | 28 | def add(n,m,d): 29 | (xn,zn), (xm,zm), (xd,zd) = n, m, d 30 | x = 4 * (xm * xn - zm * zn) ** 2 * zd 31 | z = 4 * (xm * zn - zm * xn) ** 2 * xd 32 | return (x % P, z % P) 33 | 34 | def double(n): 35 | (xn,zn) = n 36 | x = (xn ** 2 - zn ** 2) ** 2 37 | z = 4 * xn * zn * (xn ** 2 + A * xn * zn + zn ** 2) 38 | return (x % P, z % P) 39 | 40 | def curve25519(n, base): 41 | one = (base,1) 42 | two = double(one) 43 | # f(m) evaluates to a tuple containing the mth multiple and the 44 | # (m+1)th multiple of base. 45 | def f(m): 46 | if m == 1: return (one, two) 47 | (pm, pm1) = f(m // 2) 48 | if (m & 1): 49 | return (add(pm, pm1, one), double(pm1)) 50 | return (double(pm), add(pm, pm1, one)) 51 | ((x,z), _) = f(n) 52 | return (x * inv(z)) % P 53 | 54 | if sys.version < '3': 55 | def b2i(c): 56 | return ord(c) 57 | def i2b(i): 58 | return chr(i) 59 | def ba2bs(ba): 60 | return "".join(ba) 61 | else: 62 | def b2i(c): 63 | return c 64 | def i2b(i): 65 | return i 66 | def ba2bs(ba): 67 | return bytes(ba) 68 | 69 | def unpack(s): 70 | if len(s) != 32: raise ValueError('Invalid Curve25519 argument') 71 | return sum(b2i(s[i]) << (8 * i) for i in range(32)) 72 | 73 | def pack(n): 74 | return ba2bs([i2b((n >> (8 * i)) & 255) for i in range(32)]) 75 | 76 | def clamp(n): 77 | n &= ~7 78 | n &= ~(128 << 8 * 31) 79 | n |= 64 << 8 * 31 80 | return n 81 | 82 | def smult_curve25519(n, p): 83 | n = clamp(unpack(n)) 84 | p = unpack(p) 85 | return pack(curve25519(n, p)) 86 | 87 | def smult_curve25519_base(n): 88 | n = clamp(unpack(n)) 89 | return pack(curve25519(n, 9)) 90 | 91 | 92 | # 93 | # This part I'm adding in for compatibility with the curve25519 python 94 | # module. -Nick 95 | # 96 | import os 97 | 98 | class Private: 99 | def __init__(self, secret=None, seed=None): 100 | self.private = pack(clamp(unpack(os.urandom(32)))) 101 | 102 | def get_public(self): 103 | return Public(smult_curve25519_base(self.private)) 104 | 105 | def get_shared_key(self, public, hashfn): 106 | return hashfn(smult_curve25519(self.private, public.public)) 107 | 108 | def serialize(self): 109 | return self.private 110 | 111 | class Public: 112 | def __init__(self, public): 113 | self.public = public 114 | 115 | def serialize(self): 116 | return self.public 117 | 118 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/test/test-child.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011-2013, The Tor Project, Inc. */ 2 | /* See LICENSE for licensing information */ 3 | 4 | #include 5 | #include "orconfig.h" 6 | #ifdef _WIN32 7 | #define WINDOWS_LEAN_AND_MEAN 8 | #include 9 | #else 10 | #include 11 | #endif 12 | #include 13 | 14 | #ifdef _WIN32 15 | #define SLEEP(sec) Sleep((sec)*1000) 16 | #else 17 | #define SLEEP(sec) sleep(sec) 18 | #endif 19 | 20 | /** Trivial test program which prints out its command line arguments so we can 21 | * check if tor_spawn_background() works */ 22 | int 23 | main(int argc, char **argv) 24 | { 25 | int i; 26 | int delay = 1; 27 | int fast = 0; 28 | 29 | if (argc > 1) { 30 | if (!strcmp(argv[1], "--hang")) { 31 | delay = 60; 32 | } else if (!strcmp(argv[1], "--fast")) { 33 | fast = 1; 34 | delay = 0; 35 | } 36 | } 37 | 38 | fprintf(stdout, "OUT\n"); 39 | fprintf(stderr, "ERR\n"); 40 | for (i = 1; i < argc; i++) 41 | fprintf(stdout, "%s\n", argv[i]); 42 | if (!fast) 43 | fprintf(stdout, "SLEEPING\n"); 44 | /* We need to flush stdout so that test_util_spawn_background_partial_read() 45 | succeed. Otherwise ReadFile() will get the entire output in one */ 46 | // XXX: Can we make stdio flush on newline? 47 | fflush(stdout); 48 | if (!fast) 49 | SLEEP(1); 50 | fprintf(stdout, "DONE\n"); 51 | fflush(stdout); 52 | if (fast) 53 | return 0; 54 | 55 | while (--delay) { 56 | SLEEP(1); 57 | } 58 | 59 | return 0; 60 | } 61 | 62 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/test/test-network.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | until [ -z $1 ] 4 | do 5 | case $1 in 6 | --chutney-path) 7 | export CHUTNEY_PATH="$2" 8 | shift 9 | ;; 10 | --tor-path) 11 | export TOR_DIR="$2" 12 | shift 13 | ;; 14 | --flavo?r|--network-flavo?r) 15 | export NETWORK_FLAVOUR="$2" 16 | shift 17 | ;; 18 | *) 19 | echo "Sorry, I don't know what to do with '$1'." 20 | exit 2 21 | ;; 22 | esac 23 | shift 24 | done 25 | 26 | TOR_DIR="${TOR_DIR:-$PWD}" 27 | NETWORK_FLAVOUR=${NETWORK_FLAVOUR:-basic} 28 | CHUTNEY_NETWORK=networks/$NETWORK_FLAVOUR 29 | myname=$(basename $0) 30 | 31 | [ -d "$CHUTNEY_PATH" ] && [ -x "$CHUTNEY_PATH/chutney" ] || { 32 | echo "$myname: missing 'chutney' in CHUTNEY_PATH ($CHUTNEY_PATH)" 33 | exit 1 34 | } 35 | cd "$CHUTNEY_PATH" 36 | # For picking up the right tor binaries. 37 | PATH="$TOR_DIR/src/or:$TOR_DIR/src/tools:$PATH" 38 | ./tools/bootstrap-network.sh $NETWORK_FLAVOUR || exit 2 39 | 40 | # Sleep some, waiting for the network to bootstrap. 41 | # TODO: Add chutney command 'bootstrap-status' and use that instead. 42 | BOOTSTRAP_TIME=18 43 | echo -n "$myname: sleeping for $BOOTSTRAP_TIME seconds" 44 | n=$BOOTSTRAP_TIME; while [ $n -gt 0 ]; do 45 | sleep 1; n=$(expr $n - 1); echo -n . 46 | done; echo "" 47 | ./chutney verify $CHUTNEY_NETWORK 48 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/test/test_bt_cl.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2013, The Tor Project, Inc. */ 2 | /* See LICENSE for licensing information */ 3 | 4 | #include "orconfig.h" 5 | #include 6 | #include 7 | 8 | #include "or.h" 9 | #include "util.h" 10 | #include "backtrace.h" 11 | #include "torlog.h" 12 | 13 | /* -1: no crash. 14 | * 0: crash with a segmentation fault. 15 | * 1x: crash with an assertion failure. */ 16 | static int crashtype = 0; 17 | 18 | #ifdef __GNUC__ 19 | #define NOINLINE __attribute__((noinline)) 20 | #define NORETURN __attribute__((noreturn)) 21 | #endif 22 | 23 | int crash(int x) NOINLINE; 24 | int oh_what(int x) NOINLINE; 25 | int a_tangled_web(int x) NOINLINE; 26 | int we_weave(int x) NOINLINE; 27 | static void abort_handler(int s) NORETURN; 28 | 29 | int 30 | crash(int x) 31 | { 32 | if (crashtype == 0) { 33 | #if defined(__clang_analyzer__) || defined(__COVERITY__) 34 | tor_assert(1 == 0); /* Avert your eyes, clangalyzer and coverity! You 35 | * don't need to see us dereference NULL. */ 36 | #else 37 | *(volatile int *)0 = 0; 38 | #endif 39 | } else if (crashtype == 1) { 40 | tor_assert(1 == 0); 41 | } else if (crashtype == -1) { 42 | ; 43 | } 44 | 45 | crashtype *= x; 46 | return crashtype; 47 | } 48 | 49 | int 50 | oh_what(int x) 51 | { 52 | /* We call crash() twice here, so that the compiler won't try to do a 53 | * tail-call optimization. Only the first call will actually happen, but 54 | * telling the compiler to maybe do the second call will prevent it from 55 | * replacing the first call with a jump. */ 56 | return crash(x) + crash(x*2); 57 | } 58 | 59 | int 60 | a_tangled_web(int x) 61 | { 62 | return oh_what(x) * 99 + oh_what(x); 63 | } 64 | 65 | int 66 | we_weave(int x) 67 | { 68 | return a_tangled_web(x) + a_tangled_web(x+1); 69 | } 70 | 71 | static void 72 | abort_handler(int s) 73 | { 74 | (void)s; 75 | exit(0); 76 | } 77 | 78 | int 79 | main(int argc, char **argv) 80 | { 81 | log_severity_list_t severity; 82 | 83 | if (argc < 2) { 84 | puts("I take an argument. It should be \"assert\" or \"crash\" or " 85 | "\"none\""); 86 | return 1; 87 | } 88 | if (!strcmp(argv[1], "assert")) { 89 | crashtype = 1; 90 | } else if (!strcmp(argv[1], "crash")) { 91 | crashtype = 0; 92 | } else if (!strcmp(argv[1], "none")) { 93 | crashtype = -1; 94 | } else { 95 | puts("Argument should be \"assert\" or \"crash\" or \"none\""); 96 | return 1; 97 | } 98 | 99 | init_logging(); 100 | set_log_severity_config(LOG_WARN, LOG_ERR, &severity); 101 | add_stream_log(&severity, "stdout", STDOUT_FILENO); 102 | tor_log_update_sigsafe_err_fds(); 103 | 104 | configure_backtrace_handler(NULL); 105 | 106 | signal(SIGABRT, abort_handler); 107 | 108 | printf("%d\n", we_weave(2)); 109 | 110 | clean_up_backtrace_handler(); 111 | 112 | return 0; 113 | } 114 | 115 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/test/test_circuitmux.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, The Tor Project, Inc. */ 2 | /* See LICENSE for licensing information */ 3 | 4 | #define TOR_CHANNEL_INTERNAL_ 5 | #define CIRCUITMUX_PRIVATE 6 | #define RELAY_PRIVATE 7 | #include "or.h" 8 | #include "channel.h" 9 | #include "circuitmux.h" 10 | #include "relay.h" 11 | #include "test.h" 12 | 13 | /* XXXX duplicated function from test_circuitlist.c */ 14 | static channel_t * 15 | new_fake_channel(void) 16 | { 17 | channel_t *chan = tor_malloc_zero(sizeof(channel_t)); 18 | channel_init(chan); 19 | return chan; 20 | } 21 | 22 | static int 23 | has_queued_writes(channel_t *c) 24 | { 25 | (void) c; 26 | return 1; 27 | } 28 | 29 | /** Test destroy cell queue with no interference from other queues. */ 30 | static void 31 | test_cmux_destroy_cell_queue(void *arg) 32 | { 33 | circuitmux_t *cmux = NULL; 34 | channel_t *ch = NULL; 35 | circuit_t *circ = NULL; 36 | cell_queue_t *cq = NULL; 37 | packed_cell_t *pc = NULL; 38 | 39 | #ifdef ENABLE_MEMPOOLS 40 | init_cell_pool(); 41 | #endif /* ENABLE_MEMPOOLS */ 42 | (void) arg; 43 | 44 | cmux = circuitmux_alloc(); 45 | tt_assert(cmux); 46 | ch = new_fake_channel(); 47 | ch->has_queued_writes = has_queued_writes; 48 | ch->wide_circ_ids = 1; 49 | 50 | circ = circuitmux_get_first_active_circuit(cmux, &cq); 51 | tt_assert(!circ); 52 | tt_assert(!cq); 53 | 54 | circuitmux_append_destroy_cell(ch, cmux, 100, 10); 55 | circuitmux_append_destroy_cell(ch, cmux, 190, 6); 56 | circuitmux_append_destroy_cell(ch, cmux, 30, 1); 57 | 58 | tt_int_op(circuitmux_num_cells(cmux), ==, 3); 59 | 60 | circ = circuitmux_get_first_active_circuit(cmux, &cq); 61 | tt_assert(!circ); 62 | tt_assert(cq); 63 | 64 | tt_int_op(cq->n, ==, 3); 65 | 66 | pc = cell_queue_pop(cq); 67 | tt_assert(pc); 68 | test_mem_op(pc->body, ==, "\x00\x00\x00\x64\x04\x0a\x00\x00\x00", 9); 69 | packed_cell_free(pc); 70 | pc = NULL; 71 | 72 | tt_int_op(circuitmux_num_cells(cmux), ==, 2); 73 | 74 | done: 75 | circuitmux_free(cmux); 76 | channel_free(ch); 77 | packed_cell_free(pc); 78 | 79 | #ifdef ENABLE_MEMPOOLS 80 | free_cell_pool(); 81 | #endif /* ENABLE_MEMPOOLS */ 82 | } 83 | 84 | struct testcase_t circuitmux_tests[] = { 85 | { "destroy_cell_queue", test_cmux_destroy_cell_queue, TT_FORK, NULL, NULL }, 86 | END_OF_TESTCASES 87 | }; 88 | 89 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/test/test_nodelist.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2007-2013, The Tor Project, Inc. */ 2 | /* See LICENSE for licensing information */ 3 | 4 | /** 5 | * \file test_nodelist.c 6 | * \brief Unit tests for nodelist related functions. 7 | **/ 8 | 9 | #include "or.h" 10 | #include "nodelist.h" 11 | #include "test.h" 12 | 13 | /** Tese the case when node_get_by_id() returns NULL, 14 | * node_get_verbose_nickname_by_id should return the base 16 encoding 15 | * of the id. 16 | */ 17 | static void 18 | test_nodelist_node_get_verbose_nickname_by_id_null_node(void *arg) 19 | { 20 | char vname[MAX_VERBOSE_NICKNAME_LEN+1]; 21 | const char ID[] = "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA" 22 | "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA"; 23 | (void) arg; 24 | 25 | /* make sure node_get_by_id returns NULL */ 26 | test_assert(!node_get_by_id(ID)); 27 | node_get_verbose_nickname_by_id(ID, vname); 28 | test_streq(vname, "$AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); 29 | done: 30 | return; 31 | } 32 | 33 | /** For routers without named flag, get_verbose_nickname should return 34 | * "Fingerprint~Nickname" 35 | */ 36 | static void 37 | test_nodelist_node_get_verbose_nickname_not_named(void *arg) 38 | { 39 | node_t mock_node; 40 | routerstatus_t mock_rs; 41 | 42 | char vname[MAX_VERBOSE_NICKNAME_LEN+1]; 43 | 44 | (void) arg; 45 | 46 | memset(&mock_node, 0, sizeof(node_t)); 47 | memset(&mock_rs, 0, sizeof(routerstatus_t)); 48 | 49 | /* verbose nickname should use ~ instead of = for unnamed routers */ 50 | strlcpy(mock_rs.nickname, "TestOR", sizeof(mock_rs.nickname)); 51 | mock_node.rs = &mock_rs; 52 | memcpy(mock_node.identity, 53 | "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA" 54 | "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA", 55 | DIGEST_LEN); 56 | node_get_verbose_nickname(&mock_node, vname); 57 | test_streq(vname, "$AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA~TestOR"); 58 | 59 | done: 60 | return; 61 | } 62 | 63 | #define NODE(name, flags) \ 64 | { #name, test_nodelist_##name, (flags), NULL, NULL } 65 | 66 | struct testcase_t nodelist_tests[] = { 67 | NODE(node_get_verbose_nickname_by_id_null_node, TT_FORK), 68 | NODE(node_get_verbose_nickname_not_named, TT_FORK), 69 | END_OF_TESTCASES 70 | }; 71 | 72 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/test/test_routerkeys.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2001-2004, Roger Dingledine. 2 | * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson. 3 | * Copyright (c) 2007-2013, The Tor Project, Inc. */ 4 | /* See LICENSE for licensing information */ 5 | 6 | #include "orconfig.h" 7 | #define ROUTER_PRIVATE 8 | #include "or.h" 9 | #include "config.h" 10 | #include "router.h" 11 | #include "util.h" 12 | #include "crypto.h" 13 | 14 | #include "test.h" 15 | 16 | static void 17 | test_routerkeys_write_fingerprint(void *arg) 18 | { 19 | crypto_pk_t *key = pk_generate(2); 20 | or_options_t *options = get_options_mutable(); 21 | const char *ddir = get_fname("write_fingerprint"); 22 | char *cp = NULL, *cp2 = NULL; 23 | char fp[FINGERPRINT_LEN+1]; 24 | 25 | (void)arg; 26 | 27 | tt_assert(key); 28 | 29 | options->ORPort_set = 1; /* So that we can get the server ID key */ 30 | tor_free(options->DataDirectory); 31 | options->DataDirectory = tor_strdup(ddir); 32 | options->Nickname = tor_strdup("haflinger"); 33 | set_server_identity_key(key); 34 | set_client_identity_key(crypto_pk_dup_key(key)); 35 | 36 | tt_int_op(0, ==, check_private_dir(ddir, CPD_CREATE, NULL)); 37 | tt_int_op(crypto_pk_cmp_keys(get_server_identity_key(),key),==,0); 38 | 39 | /* Write fingerprint file */ 40 | tt_int_op(0, ==, router_write_fingerprint(0)); 41 | cp = read_file_to_str(get_fname("write_fingerprint/fingerprint"), 42 | 0, NULL); 43 | crypto_pk_get_fingerprint(key, fp, 0); 44 | tor_asprintf(&cp2, "haflinger %s\n", fp); 45 | tt_str_op(cp, ==, cp2); 46 | tor_free(cp); 47 | tor_free(cp2); 48 | 49 | /* Write hashed-fingerprint file */ 50 | tt_int_op(0, ==, router_write_fingerprint(1)); 51 | cp = read_file_to_str(get_fname("write_fingerprint/hashed-fingerprint"), 52 | 0, NULL); 53 | crypto_pk_get_hashed_fingerprint(key, fp); 54 | tor_asprintf(&cp2, "haflinger %s\n", fp); 55 | tt_str_op(cp, ==, cp2); 56 | tor_free(cp); 57 | tor_free(cp2); 58 | 59 | /* Replace outdated file */ 60 | write_str_to_file(get_fname("write_fingerprint/hashed-fingerprint"), 61 | "junk goes here", 0); 62 | tt_int_op(0, ==, router_write_fingerprint(1)); 63 | cp = read_file_to_str(get_fname("write_fingerprint/hashed-fingerprint"), 64 | 0, NULL); 65 | crypto_pk_get_hashed_fingerprint(key, fp); 66 | tor_asprintf(&cp2, "haflinger %s\n", fp); 67 | tt_str_op(cp, ==, cp2); 68 | tor_free(cp); 69 | tor_free(cp2); 70 | 71 | done: 72 | crypto_pk_free(key); 73 | set_client_identity_key(NULL); 74 | tor_free(cp); 75 | tor_free(cp2); 76 | } 77 | 78 | #define TEST(name, flags) \ 79 | { #name , test_routerkeys_ ## name, (flags), NULL, NULL } 80 | 81 | struct testcase_t routerkeys_tests[] = { 82 | TEST(write_fingerprint, TT_FORK), 83 | END_OF_TESTCASES 84 | }; 85 | 86 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/tools/Makefile.nmake: -------------------------------------------------------------------------------- 1 | all: tor-resolve.exe tor-gencert.exe 2 | 3 | CFLAGS = /I ..\win32 /I ..\..\..\build-alpha\include /I ..\common /I ..\or 4 | 5 | LIBS = ..\..\..\build-alpha\lib\libevent.lib \ 6 | ..\..\..\build-alpha\lib\libcrypto.lib \ 7 | ..\..\..\build-alpha\lib\libssl.lib \ 8 | ..\..\..\build-alpha\lib\libz.lib \ 9 | ws2_32.lib advapi32.lib shell32.lib \ 10 | crypt32.lib gdi32.lib user32.lib 11 | 12 | tor-gencert.exe: tor-gencert.obj 13 | $(CC) $(CFLAGS) $(LIBS) ..\common\*.lib tor-gencert.obj 14 | 15 | tor-resolve.exe: tor-resolve.obj 16 | $(CC) $(CFLAGS) $(LIBS) ..\common\*.lib tor-resolve.obj 17 | 18 | clean: 19 | del *.obj *.lib *.exe 20 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/tools/include.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS+= src/tools/tor-resolve src/tools/tor-gencert 2 | noinst_PROGRAMS+= src/tools/tor-checkkey 3 | 4 | src_tools_tor_resolve_SOURCES = src/tools/tor-resolve.c 5 | src_tools_tor_resolve_LDFLAGS = 6 | src_tools_tor_resolve_LDADD = src/common/libor.a @TOR_LIB_MATH@ @TOR_LIB_WS32@ 7 | 8 | src_tools_tor_gencert_SOURCES = src/tools/tor-gencert.c 9 | src_tools_tor_gencert_LDFLAGS = @TOR_LDFLAGS_zlib@ @TOR_LDFLAGS_openssl@ 10 | src_tools_tor_gencert_LDADD = src/common/libor.a src/common/libor-crypto.a \ 11 | $(LIBDONNA) \ 12 | @TOR_LIB_MATH@ @TOR_ZLIB_LIBS@ @TOR_OPENSSL_LIBS@ \ 13 | @TOR_LIB_WS32@ @TOR_LIB_GDI@ @CURVE25519_LIBS@ 14 | 15 | src_tools_tor_checkkey_SOURCES = src/tools/tor-checkkey.c 16 | src_tools_tor_checkkey_LDFLAGS = @TOR_LDFLAGS_zlib@ @TOR_LDFLAGS_openssl@ 17 | src_tools_tor_checkkey_LDADD = src/common/libor.a src/common/libor-crypto.a \ 18 | $(LIBDONNA) \ 19 | @TOR_LIB_MATH@ @TOR_ZLIB_LIBS@ @TOR_OPENSSL_LIBS@ \ 20 | @TOR_LIB_WS32@ @TOR_LIB_GDI@ @CURVE25519_LIBS@ 21 | 22 | include src/tools/tor-fw-helper/include.am 23 | 24 | 25 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/tools/tor-checkkey.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2008-2013, The Tor Project, Inc. */ 2 | /* See LICENSE for licensing information */ 3 | 4 | #include "orconfig.h" 5 | 6 | #include 7 | #include 8 | #include "crypto.h" 9 | #include "torlog.h" 10 | #include "../common/util.h" 11 | #include "compat.h" 12 | #include 13 | #include 14 | 15 | int 16 | main(int c, char **v) 17 | { 18 | crypto_pk_t *env; 19 | char *str; 20 | RSA *rsa; 21 | int wantdigest=0; 22 | int fname_idx; 23 | char *fname=NULL; 24 | init_logging(); 25 | 26 | if (c < 2) { 27 | fprintf(stderr, "Hi. I'm tor-checkkey. Tell me a filename that " 28 | "has a PEM-encoded RSA public key (like in a cert) and I'll " 29 | "dump the modulus. Use the --digest option too and I'll " 30 | "dump the digest.\n"); 31 | return 1; 32 | } 33 | 34 | if (crypto_global_init(0, NULL, NULL)) { 35 | fprintf(stderr, "Couldn't initialize crypto library.\n"); 36 | return 1; 37 | } 38 | 39 | if (!strcmp(v[1], "--digest")) { 40 | wantdigest = 1; 41 | fname_idx = 2; 42 | if (c<3) { 43 | fprintf(stderr, "too few arguments"); 44 | return 1; 45 | } 46 | } else { 47 | wantdigest = 0; 48 | fname_idx = 1; 49 | } 50 | 51 | fname = expand_filename(v[fname_idx]); 52 | str = read_file_to_str(fname, 0, NULL); 53 | tor_free(fname); 54 | if (!str) { 55 | fprintf(stderr, "Couldn't read %s\n", v[fname_idx]); 56 | return 1; 57 | } 58 | 59 | env = crypto_pk_new(); 60 | if (crypto_pk_read_public_key_from_string(env, str, strlen(str))<0) { 61 | fprintf(stderr, "Couldn't parse key.\n"); 62 | return 1; 63 | } 64 | tor_free(str); 65 | 66 | if (wantdigest) { 67 | char digest[HEX_DIGEST_LEN+1]; 68 | if (crypto_pk_get_fingerprint(env, digest, 0)<0) 69 | return 1; 70 | printf("%s\n",digest); 71 | } else { 72 | rsa = crypto_pk_get_rsa_(env); 73 | str = BN_bn2hex(rsa->n); 74 | 75 | printf("%s\n", str); 76 | } 77 | 78 | return 0; 79 | } 80 | 81 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/tools/tor-fw-helper/include.am: -------------------------------------------------------------------------------- 1 | if USE_FW_HELPER 2 | bin_PROGRAMS+= src/tools/tor-fw-helper/tor-fw-helper 3 | endif 4 | 5 | src_tools_tor_fw_helper_tor_fw_helper_SOURCES = \ 6 | src/tools/tor-fw-helper/tor-fw-helper.c \ 7 | src/tools/tor-fw-helper/tor-fw-helper-natpmp.c \ 8 | src/tools/tor-fw-helper/tor-fw-helper-upnp.c 9 | noinst_HEADERS+= \ 10 | src/tools/tor-fw-helper/tor-fw-helper.h \ 11 | src/tools/tor-fw-helper/tor-fw-helper-natpmp.h \ 12 | src/tools/tor-fw-helper/tor-fw-helper-upnp.h 13 | 14 | if NAT_PMP 15 | nat_pmp_ldflags = @TOR_LDFLAGS_libnatpmp@ 16 | nat_pmp_ldadd = -lnatpmp @TOR_LIB_IPHLPAPI@ 17 | nat_pmp_cppflags = @TOR_CPPFLAGS_libnatpmp@ 18 | else 19 | nat_pmp_ldflags = 20 | nat_pmp_ldadd = 21 | nat_pmp_cppflags = 22 | endif 23 | 24 | if MINIUPNPC 25 | miniupnpc_ldflags = @TOR_LDFLAGS_libminiupnpc@ 26 | miniupnpc_ldadd = -lminiupnpc @TOR_LIB_IPHLPAPI@ 27 | miniupnpc_cppflags = @TOR_CPPFLAGS_libminiupnpc@ 28 | else 29 | miniupnpc_ldflags = 30 | miniupnpc_ldadd = 31 | miniupnpc_cppflags = 32 | endif 33 | 34 | src_tools_tor_fw_helper_tor_fw_helper_LDFLAGS = $(nat_pmp_ldflags) $(miniupnpc_ldflags) 35 | src_tools_tor_fw_helper_tor_fw_helper_LDADD = src/common/libor.a $(nat_pmp_ldadd) $(miniupnpc_ldadd) -lm @TOR_LIB_WS32@ 36 | src_tools_tor_fw_helper_tor_fw_helper_CPPFLAGS = $(nat_pmp_cppflags) $(miniupnpc_cppflags) -I"$(top_srcdir)/src/ext" 37 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/tools/tor-fw-helper/tor-fw-helper-natpmp.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2010, Jacob Appelbaum, Steven J. Murdoch. 2 | * Copyright (c) 2010-2013, The Tor Project, Inc. */ 3 | /* See LICENSE for licensing information */ 4 | 5 | /** 6 | * \file tor-fw-helper-natpmp.h 7 | **/ 8 | 9 | #ifdef NAT_PMP 10 | #ifndef TOR_TOR_FW_HELPER_NATPMP_H 11 | #define TOR_TOR_FW_HELPER_NATPMP_H 12 | 13 | #include 14 | 15 | /** This is the default NAT-PMP lease time in seconds. */ 16 | #define NATPMP_DEFAULT_LEASE 3600 17 | /** NAT-PMP has many codes for success; this is one of them. */ 18 | #define NATPMP_SUCCESS 0 19 | 20 | /** This is our NAT-PMP meta structure - it holds our request data, responses, 21 | * various NAT-PMP parameters, and of course the status of the motion in the 22 | * NAT-PMP ocean. */ 23 | typedef struct natpmp_state_t { 24 | natpmp_t natpmp; 25 | natpmpresp_t response; 26 | int fetch_public_ip; 27 | int status; 28 | int init; /**< Have we been initialized? */ 29 | int protocol; /**< This will only be TCP. */ 30 | int lease; 31 | } natpmp_state_t; 32 | 33 | const tor_fw_backend_t *tor_fw_get_natpmp_backend(void); 34 | 35 | int tor_natpmp_init(tor_fw_options_t *tor_fw_options, void *backend_state); 36 | 37 | int tor_natpmp_cleanup(tor_fw_options_t *tor_fw_options, void *backend_state); 38 | 39 | int tor_natpmp_add_tcp_mapping(uint16_t internal_port, uint16_t external_port, 40 | int is_verbose, void *backend_state); 41 | 42 | int tor_natpmp_fetch_public_ip(tor_fw_options_t *tor_fw_options, 43 | void *backend_state); 44 | 45 | #endif 46 | #endif 47 | 48 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/tools/tor-fw-helper/tor-fw-helper-upnp.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2010, Jacob Appelbaum, Steven J. Murdoch. 2 | * Copyright (c) 2010-2013, The Tor Project, Inc. */ 3 | /* See LICENSE for licensing information */ 4 | 5 | /** 6 | * \file tor-fw-helper-upnp.h 7 | * \brief The main header for our firewall helper. 8 | **/ 9 | 10 | #ifdef MINIUPNPC 11 | #ifndef TOR_TOR_FW_HELPER_UPNP_H 12 | #define TOR_TOR_FW_HELPER_UPNP_H 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | /** This is a magic number for miniupnpc lan address size. */ 20 | #define UPNP_LANADDR_SZ 64 21 | 22 | /** This is our miniupnpc meta structure - it holds our request data, 23 | * responses, and various miniupnpc parameters. */ 24 | typedef struct miniupnpc_state_t { 25 | struct UPNPUrls urls; 26 | struct IGDdatas data; 27 | char lanaddr[UPNP_LANADDR_SZ]; 28 | int init; 29 | } miniupnpc_state_t; 30 | 31 | const tor_fw_backend_t *tor_fw_get_miniupnp_backend(void); 32 | 33 | int tor_upnp_init(tor_fw_options_t *options, void *backend_state); 34 | 35 | int tor_upnp_cleanup(tor_fw_options_t *options, void *backend_state); 36 | 37 | int tor_upnp_fetch_public_ip(tor_fw_options_t *options, void *backend_state); 38 | 39 | int tor_upnp_add_tcp_mapping(uint16_t internal_port, uint16_t external_port, 40 | int is_verbose, void *backend_state); 41 | 42 | #endif 43 | #endif 44 | 45 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/tools/tor-fw-helper/tor-fw-helper.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2010, Jacob Appelbaum, Steven J. Murdoch. 2 | * Copyright (c) 2010-2013, The Tor Project, Inc. */ 3 | /* See LICENSE for licensing information */ 4 | 5 | /** 6 | * \file tor-fw-helper.h 7 | * \brief The main header for our firewall helper. 8 | **/ 9 | 10 | #ifndef TOR_TOR_FW_HELPER_H 11 | #define TOR_TOR_FW_HELPER_H 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | /** The current version of tor-fw-helper. */ 20 | #define tor_fw_version "0.2" 21 | 22 | /** This is an arbitrary hard limit - We currently have two (NAT-PMP and UPnP). 23 | We're likely going to add the Intel UPnP library but nothing else comes to 24 | mind at the moment. */ 25 | #define MAX_BACKENDS 23 26 | 27 | /** Forward traffic received in port external_port in the 28 | * external side of our NAT to internal_port in this host. */ 29 | typedef struct { 30 | uint16_t external_port; 31 | uint16_t internal_port; 32 | } port_to_forward_t; 33 | 34 | /** This is where we store parsed commandline options. */ 35 | typedef struct { 36 | int verbose; 37 | int help; 38 | int test_commandline; 39 | struct smartlist_t *ports_to_forward; 40 | int fetch_public_ip; 41 | int nat_pmp_status; 42 | int upnp_status; 43 | int public_ip_status; 44 | } tor_fw_options_t; 45 | 46 | /** This is our main structure that defines our backend helper API; each helper 47 | * must conform to these public methods if it expects to be handled in a 48 | * non-special way. */ 49 | typedef struct tor_fw_backend_t { 50 | const char *name; 51 | size_t state_len; 52 | int (*init)(tor_fw_options_t *options, void *backend_state); 53 | int (*cleanup)(tor_fw_options_t *options, void *backend_state); 54 | int (*fetch_public_ip)(tor_fw_options_t *options, void *backend_state); 55 | int (*add_tcp_mapping)(uint16_t internal_port, uint16_t external_port, 56 | int is_verbose, void *backend_state); 57 | } tor_fw_backend_t; 58 | #endif 59 | 60 | -------------------------------------------------------------------------------- /patched tor/tor-0.2.6.1-alpha/src/win32/include.am: -------------------------------------------------------------------------------- 1 | 2 | EXTRA_DIST+= src/win32/orconfig.h 3 | 4 | -------------------------------------------------------------------------------- /tools/models.py: -------------------------------------------------------------------------------- 1 | from sqlalchemy.ext.declarative import declarative_base 2 | from sqlalchemy import Column, Integer, String, DateTime, Unicode 3 | 4 | Base = declarative_base() 5 | 6 | class OnionAddress(Base): 7 | __tablename__ = "onion_addresses" 8 | 9 | id = Column(Integer, primary_key=True) 10 | 11 | address = Column(String) 12 | first_seen = Column(DateTime) 13 | last_seen = Column(DateTime) 14 | count = Column(Integer) 15 | website_title = Column(Unicode) 16 | 17 | def __init__(self): 18 | self.count = 0 19 | 20 | def __repr__(self): 21 | return "" % (self.id, self.address, self.count) 22 | -------------------------------------------------------------------------------- /tools/onion-publisher.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import zmq 4 | import random 5 | import sys 6 | import time 7 | import subprocess 8 | import datetime 9 | import argparse 10 | 11 | epoch = datetime.datetime.utcfromtimestamp(0) 12 | def unix_time_millis(dt): 13 | return (dt - epoch).total_seconds() * 1000.0 14 | 15 | def start_publisher(host, port, noticefile): 16 | context = zmq.Context() 17 | socket = context.socket(zmq.PUB) 18 | socket.bind("tcp://%s:%s" % (host, port)) 19 | 20 | print '[+] ---- onion.watch ZMQ publisher started on tcp://%s:%s ----' % (host, port) 21 | 22 | f = subprocess.Popen(['tail', '-F', noticefile], stdout=subprocess.PIPE,stderr=subprocess.PIPE) 23 | print '[+] Tailing notice log \'%s\'' % noticefile 24 | 25 | while True: 26 | line = f.stdout.readline() 27 | if 'HSDIR_REQUEST' not in line or '|None' in line: 28 | continue 29 | 30 | lsplit = line.split('|') 31 | if len(lsplit) != 3: 32 | continue 33 | 34 | parsed_date = datetime.datetime.strptime(line.split('[')[0] + str(datetime.datetime.now().year), "%b %d %H:%M:%S.%f %Y") 35 | address = lsplit[2].rstrip().lstrip() 36 | 37 | topic = 101010 38 | message = "%d %f|%s" % (topic, unix_time_millis(parsed_date), address) 39 | print '[+] Sending new request: ' + message 40 | socket.send(message) 41 | 42 | def main(): 43 | defaults = dict( 44 | listen = '127.0.0.1', 45 | port = 5556, 46 | noticelog = "notice.log" 47 | ) 48 | 49 | parser = argparse.ArgumentParser(description=__doc__, 50 | formatter_class=argparse.ArgumentDefaultsHelpFormatter 51 | ) 52 | parser.set_defaults(**defaults) 53 | 54 | parser.add_argument('-l', '--listen', help="address to listen on") 55 | parser.add_argument('-p', '--port', help="port to listen on") 56 | parser.add_argument('-n', '--noticelog', help="notice logfile from the Tor client to tail") 57 | args = parser.parse_args() 58 | 59 | start_publisher(port=args.port, host=args.listen, noticefile=args.noticelog) 60 | 61 | if __name__ == "__main__": 62 | sys.exit(main()) 63 | --------------------------------------------------------------------------------