[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[stem/master] Moving "Determine The Exit You’re Using" to the example scripts



commit 3299a5ad68c85d6f33f20b7cbeb68ee175877d16
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Wed Mar 26 09:01:04 2014 -0700

    Moving "Determine The Exit Youâ??re Using" to the example scripts
    
    Moving this example from our client usage tutorials to the example scripts.
    This is a good standalone example, and unrelated to the other tasks in the
    tutorial.
---
 docs/contents.rst                                 |    1 +
 docs/tutorials/double_double_toil_and_trouble.rst |    9 ++-
 docs/tutorials/examples/compare_flags.rst         |   20 +++---
 docs/tutorials/examples/exit_used.rst             |   73 +++++++++++++++++++++
 docs/tutorials/to_russia_with_love.rst            |   72 --------------------
 5 files changed, 92 insertions(+), 83 deletions(-)

diff --git a/docs/contents.rst b/docs/contents.rst
index d9b6159..70eda0f 100644
--- a/docs/contents.rst
+++ b/docs/contents.rst
@@ -13,6 +13,7 @@ Contents
    tutorials/double_double_toil_and_trouble
 
    tutorials/examples/compare_flags
+   tutorials/examples/exit_used
 
    change_log
    download
diff --git a/docs/tutorials/double_double_toil_and_trouble.rst b/docs/tutorials/double_double_toil_and_trouble.rst
index 3dabc1a..093592e 100644
--- a/docs/tutorials/double_double_toil_and_trouble.rst
+++ b/docs/tutorials/double_double_toil_and_trouble.rst
@@ -53,11 +53,18 @@ Applications
 Scripts
 =======
 
+Client Usage
+------------
+
+* `Determine The Exit You're Using <examples/exit_used.html>`_
+
+  Tells you the exit used for each Tor connection.
+
 Descriptors
 -----------
 
 * `Comparing Directory Authority Flags <examples/compare_flags.html>`_
 
   Compares the votes of two directory authorities, in this case moria1 and
-  maatuska, with a special interest in the 'Running' flag.
+  maatuska with a special interest in the 'Running' flag.
 
diff --git a/docs/tutorials/examples/compare_flags.rst b/docs/tutorials/examples/compare_flags.rst
index b0f7fc6..8aceefc 100644
--- a/docs/tutorials/examples/compare_flags.rst
+++ b/docs/tutorials/examples/compare_flags.rst
@@ -6,16 +6,6 @@ maatuska, with a special interest in the 'Running' flag.
 
 ::
 
-  % python compare_flags.py 
-  maatuska has the Running flag but moria1 doesn't: 92FCB6748A40E6088E22FBAB943AB2DD743EA818
-  maatuska has the Running flag but moria1 doesn't: 6871F682350BA931838C0EC1E4A23044DAE06A73
-  maatuska has the Running flag but moria1 doesn't: E2BB13AA2F6960CD93ABE5257A825687F3973C62
-  moria1 has the Running flag but maatuska doesn't: 546C54E2A89D88E0794D04AECBF1AC8AC9DA81DE
-  moria1 has the Running flag but maatuska doesn't: DCAEC3D069DC39AAE43D13C8AF31B5645E05ED61
-  ...
-
-::
-
   from stem.descriptor import DocumentHandler, remote
 
   # Query all authority votes asynchronously.
@@ -58,3 +48,13 @@ maatuska, with a special interest in the 'Running' flag.
     elif 'Running' in maatuska_vote.flags and 'Running' not in moria1_vote.flags:
       print "maatuska has the Running flag but moria1 doesn't: %s" % fingerprint
 
+::
+
+  % python compare_flags.py 
+  maatuska has the Running flag but moria1 doesn't: 92FCB6748A40E6088E22FBAB943AB2DD743EA818
+  maatuska has the Running flag but moria1 doesn't: 6871F682350BA931838C0EC1E4A23044DAE06A73
+  maatuska has the Running flag but moria1 doesn't: E2BB13AA2F6960CD93ABE5257A825687F3973C62
+  moria1 has the Running flag but maatuska doesn't: 546C54E2A89D88E0794D04AECBF1AC8AC9DA81DE
+  moria1 has the Running flag but maatuska doesn't: DCAEC3D069DC39AAE43D13C8AF31B5645E05ED61
+  ...
+
diff --git a/docs/tutorials/examples/exit_used.rst b/docs/tutorials/examples/exit_used.rst
new file mode 100644
index 0000000..2c27f98
--- /dev/null
+++ b/docs/tutorials/examples/exit_used.rst
@@ -0,0 +1,73 @@
+Determine The Exit You're Using
+===============================
+
+Lets say you're using Tor and one day you run into something odd. Maybe a
+misconfigured relay, or maybe one that's being malicious. How can you figure
+out what exit you're using?
+
+Here's a simple script that prints information about the exits used to service
+the requests going through Tor...
+
+::
+
+  import functools
+
+  from stem import StreamStatus
+  from stem.control import EventType, Controller
+
+  def main():
+    print "Tracking requests for tor exits. Press 'enter' to end."
+    print
+
+    with Controller.from_port() as controller:
+      controller.authenticate()
+
+      stream_listener = functools.partial(stream_event, controller)
+      controller.add_event_listener(stream_listener, EventType.STREAM)
+
+      raw_input()  # wait for user to press enter
+
+
+  def stream_event(controller, event):
+    if event.status == StreamStatus.SUCCEEDED:
+      circ = controller.get_circuit(event.circ_id)
+
+      exit_fingerprint = circ.path[-1][0]
+      exit_relay = controller.get_network_status(exit_fingerprint)
+
+      print "Exit relay for our connection to %s" % (event.target)
+      print "  address: %s:%i" % (exit_relay.address, exit_relay.or_port)
+      print "  fingerprint: %s" % exit_relay.fingerprint
+      print "  nickname: %s" % exit_relay.nickname
+      print "  locale: %s" % controller.get_info("ip-to-country/%s" % exit_relay.address, 'unknown')
+      print
+
+
+  if __name__ == '__main__':
+    main()
+
+Now if you make a request over Tor...
+
+::
+
+  % curl --socks4a 127.0.0.1:9050 google.com
+  <HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
+  <TITLE>301 Moved</TITLE></HEAD><BODY>
+  <H1>301 Moved</H1>
+  The document has moved
+  <A HREF="http://www.google.com/";>here</A>.
+  </BODY></HTML>
+
+... this script will tell you about the exit...
+
+::
+
+  % python exit_used.py
+  Tracking requests for tor exits. Press 'enter' to end.
+
+  Exit relay for our connection to 64.15.112.44:80
+    address: 31.172.30.2:443
+    fingerprint: A59E1E7C7EAEE083D756EE1FF6EC31CA3D8651D7
+    nickname: chaoscomputerclub19
+    locale: unknown
+
diff --git a/docs/tutorials/to_russia_with_love.rst b/docs/tutorials/to_russia_with_love.rst
index e69e828..33c04d3 100644
--- a/docs/tutorials/to_russia_with_love.rst
+++ b/docs/tutorials/to_russia_with_love.rst
@@ -4,7 +4,6 @@ To Russia With Love
 * :ref:`using-socksipy`
 * :ref:`using-pycurl`
 * :ref:`reading-twitter`
-* :ref:`determine-the-exit-you-re-using`
 
 .. _using-socksipy:
 
@@ -173,74 +172,3 @@ Now lets do somthing a little more interesting, and read a Twitter feed over Tor
 
 .. image:: /_static/twitter_output.png
 
-.. _determine-the-exit-you-re-using:
-
-Determine The Exit You're Using
----------------------------------
-
-Finally, lets say you're using Tor and one day you run into something odd. Maybe a misconfigured relay, or maybe one that's being malicious. How can you figure out what exit you're using?
-
-Here's a simple script that prints information about the exits used to service the requests going through Tor...
-
-::
-
-  import functools
-
-  from stem import StreamStatus
-  from stem.control import EventType, Controller
-
-  def main():
-    print "Tracking requests for tor exits. Press 'enter' to end."
-    print
-
-    with Controller.from_port() as controller:
-      controller.authenticate()
-
-      stream_listener = functools.partial(stream_event, controller)
-      controller.add_event_listener(stream_listener, EventType.STREAM)
-
-      raw_input()  # wait for user to press enter
-
-
-  def stream_event(controller, event):
-    if event.status == StreamStatus.SUCCEEDED:
-      circ = controller.get_circuit(event.circ_id)
-
-      exit_fingerprint = circ.path[-1][0]
-      exit_relay = controller.get_network_status(exit_fingerprint)
-
-      print "Exit relay for our connection to %s" % (event.target)
-      print "  address: %s:%i" % (exit_relay.address, exit_relay.or_port)
-      print "  fingerprint: %s" % exit_relay.fingerprint
-      print "  nickname: %s" % exit_relay.nickname
-      print "  locale: %s" % controller.get_info("ip-to-country/%s" % exit_relay.address, 'unknown')
-      print
-
-
-  if __name__ == '__main__':
-    main()
-
-Now if you make a request over Tor...
-
-::
-
-  % curl --socks4a 127.0.0.1:9050 google.com
-  <HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
-  <TITLE>301 Moved</TITLE></HEAD><BODY>
-  <H1>301 Moved</H1>
-  The document has moved
-  <A HREF="http://www.google.com/";>here</A>.
-  </BODY></HTML>
-
-... this script will tell you about the exit...
-
-::
-
-  % python example.py
-  Tracking requests for tor exits. Press 'enter' to end.
-
-  Exit relay for our connection to 64.15.112.44:80
-    address: 31.172.30.2:443
-    fingerprint: A59E1E7C7EAEE083D756EE1FF6EC31CA3D8651D7
-    nickname: chaoscomputerclub19
-    locale: unknown



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits