[tor-commits] [onionoo/master] Clarify protocol spec based on Norman's questions.

2012-08-04 Thread karsten
commit 0e0198f18af72b7b237661049b58e5f6dd1829d8
Author: Karsten Loesing karsten.loes...@gmx.net
Date:   Sat Aug 4 07:56:16 2012 +0200

Clarify protocol spec based on Norman's questions.
---
 web/index.html |   20 +---
 1 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/web/index.html b/web/index.html
index a74feac..384bfd4 100755
--- a/web/index.html
+++ b/web/index.html
@@ -782,7 +782,11 @@ running or that have been running in the past week.
 /tr
 /table
 pEach of the methods above can be parameterized to select only a subset
-of relay and/or bridge documents to be included in the response./p
+of relay and/or bridge documents to be included in the response.
+If multiple parameters are specified, they are combined using a logical
+AND operation, meaning that only the intersection of relays and bridges
+matching all parameters is returned.
+/p
 table border=0 cellpadding=4 cellspacing=0 summary=
 colgroup
 col width=150
@@ -797,9 +801,9 @@ of relay and/or bridge documents to be included in the 
response./p
 bfalse/b).
 /td/tr
 trtdbsearch/b/tdtdReturn only relays with the parameter value
-matching the beginning of a nickname, (possibly $-prefixed) fingerprint,
-or IP address, and bridges with the nickname or (possibly $-prefixed)
-hashed fingerprint.
+matching the beginning of a nickname, (possibly $-prefixed) beginning of a
+fingerprint, or beginning of an IP address, and bridges with the beginning
+of a nickname or (possibly $-prefixed) beginning of a hashed fingerprint.
 Searches are case-insensitive.
 If multiple search terms are given, separated by spaces, the intersection
 of all relays and bridges matching all search terms will be returned.
@@ -827,13 +831,15 @@ limited by providing further parameters./p
 /colgroup
 trtdborder/b/tdtdRe-order results by a comma-separated list
 of fields in ascending or descening order.
-Results are first ordered by the second list element, then by the second,
+Results are first ordered by the first list element, then by the second,
 and so on.
 Possible fields for ordering are: bconsensus_weight/b.
 Ascending order is the default; descending order is selected by prepending
 fields with a minus sign (b-/b).
-Relays which don't have any value for a field to be ordered by are always
-appended to the end, regardless or sorting order.
+Relays or bridges which don't have any value for a field to be ordered by
+are always appended to the end, regardless or sorting order.
+The ordering is defined independent of the requested document type and
+does not require the ordering field to be contained in the document.
 If no border/b parameter is given, ordering of results is
 undefined.
 /td/tr

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


[tor-commits] r25742: {website} minor touch-ups (website/trunk/about/en)

2012-08-04 Thread Roger Dingledine
Author: arma
Date: 2012-08-04 07:37:51 + (Sat, 04 Aug 2012)
New Revision: 25742

Modified:
   website/trunk/about/en/jobs-projectcoordinator.wml
Log:
minor touch-ups


Modified: website/trunk/about/en/jobs-projectcoordinator.wml
===
--- website/trunk/about/en/jobs-projectcoordinator.wml  2012-08-03 00:47:08 UTC 
(rev 25741)
+++ website/trunk/about/en/jobs-projectcoordinator.wml  2012-08-04 07:37:51 UTC 
(rev 25742)
@@ -2,7 +2,7 @@
 # Revision: $Revision: 25666 $
 # Translation-Priority: 3-low
 
-#include head.wmi TITLE=Tor Project: Jobs (browser hacker) CHARSET=UTF-8
+#include head.wmi TITLE=Tor Project: Jobs (project coordinator) 
CHARSET=UTF-8
 div id=content class=clearfix
div id=breadcrumbs
 a href=page indexHome raquo; /a
@@ -14,7 +14,7 @@
 
 p
 A project coordinator is the person who coordinates and helps track
-deliverables, progress, and provide metrics on past and current
+deliverables, progress, and metrics on past and current
 performance of projects.
 /p
 
@@ -24,7 +24,7 @@
 liDeriving deliverables, deadlines, and milestones for each active
 contract./li
 liDeveloping timelines and schedules for completion of milestones and
- deliverables for each active, and occassionally proposed, contract.li
+ deliverables for each active, and occassionally proposed, contract./li
 liCollecting ideas and potential deliverables for the future./li
 liRaising concerns, timeline slips, and probability of missed deadlines
 to management./li
@@ -42,7 +42,7 @@
 liHelping to write the monthly progress reports required for contracts./li
 /ul
 
-pIn general, you should be:/p
+pIn general, you should:/p
 ul
 liBe comfortable and experienced justifying and documenting technical
 decisions for a public, world-wide technical audience./li

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


[tor-commits] [translation/vidalia_help] Update translations for vidalia_help

2012-08-04 Thread translation
commit 07abdee43d3a469c3cd973369cd2a9625808dd1c
Author: Translation commit bot translat...@torproject.org
Date:   Sat Aug 4 18:15:16 2012 +

Update translations for vidalia_help
---
 ko/running.po |9 -
 1 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/ko/running.po b/ko/running.po
index 87e771a..4060607 100644
--- a/ko/running.po
+++ b/ko/running.po
@@ -1,12 +1,13 @@
 # 
 # Translators:
+#   siwooch...@me.com, 2012.
 msgid 
 msgstr 
 Project-Id-Version: The Tor Project\n
 Report-Msgid-Bugs-To: https://trac.torproject.org/projects/tor\n;
 POT-Creation-Date: 2010-06-26 17:00+0200\n
-PO-Revision-Date: 2010-11-30 05:03+\n
-Last-Translator: FULL NAME EMAIL@ADDRESS\n
+PO-Revision-Date: 2012-08-04 18:05+\n
+Last-Translator: chungsiwoo siwooch...@me.com\n
 Language-Team: LANGUAGE l...@li.org\n
 MIME-Version: 1.0\n
 Content-Type: text/plain; charset=UTF-8\n
@@ -17,7 +18,7 @@ msgstr 
 #. type: Content of: htmlbodyh1
 #: en/running.html:16
 msgid Running Tor
-msgstr 
+msgstr Tor 작동
 
 #. type: Content of: htmlbodyp
 #: en/running.html:20
@@ -147,5 +148,3 @@ msgid 
 You can also check the a href=\log.html\message log/a for details 
 about any problems Tor encountered before it exited.
 msgstr 
-
-

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


[tor-commits] [stem/master] First complete build of unit tests for torexport.

2012-08-04 Thread atagar
commit 9440f4ffa20aa7ba2a0e3297cbf5b245bf2c1c91
Author: Erik ei...@wesleyan.edu
Date:   Mon Jul 30 18:09:13 2012 -0400

First complete build of unit tests for torexport.

There is a bug in test_export_csv_file which will be fixed tomorrow
morning, otherwise all tests are functional and should be passing.
---
 stem/descriptor/export.py  |   53 ---
 test/mocking.py|   35 ++
 test/unit/descriptor/export.py |  147 ++--
 3 files changed, 176 insertions(+), 59 deletions(-)

diff --git a/stem/descriptor/export.py b/stem/descriptor/export.py
index dd7f324..af62be5 100644
--- a/stem/descriptor/export.py
+++ b/stem/descriptor/export.py
@@ -1,7 +1,7 @@
 import os, csv, sets, cStringIO
 
 
-def export_csv(descriptor, include_fields=[], exclude_fields=[]):
+def export_csv(descriptor, include_fields=(), exclude_fields=()):
   
   Takes a single descriptor object, puts it in a list, and passes it to
   descriptors_csv_exp to build a csv.
@@ -12,13 +12,15 @@ def export_csv(descriptor, include_fields=[], 
exclude_fields=[]):
   
   :returns: single csv line as a string with one descriptor attribute per cell.
   
-  descr = [descriptor]
+  
+  descr = (descriptor,)
   return export_csvs(descr, include_fields=include_fields, 
exclude_fields=exclude_fields)
 
 
 def export_csvs(descriptors, include_fields=[], exclude_fields=[], 
header=False):
   
-  Returns a string that is in csv format, ready to be placed in a .csv file.
+  Takes an iterable of descriptors, returns a string with one line per 
descriptor
+  where each line is a comma separated list of descriptor attributes.
   
   :param list descrs: List of descriptor objects whose attributes will be 
written.
   :param list include_fields: list of attribute fields to include in the csv 
string.
@@ -27,64 +29,67 @@ def export_csvs(descriptors, include_fields=[], 
exclude_fields=[], header=False)
 needed outside of csv_file_exp's call of this function.
   
   :returns: csv string with one descriptor per line and one attribute per cell.
+  :raises: ValueError if more than one descriptor type (e.g. server_descriptor,
+extrainfo_descriptor) is provided in the iterable.
   
   
-  _temp_file = cStringIO.StringIO()
+  # Need a file object to write to with DictWriter.
+  temp_file = cStringIO.StringIO()
   
   first = True
   
   for desc in descriptors:
+import sys
 attr = vars(desc)
 
 # Defining incl_fields and the dwriter object requires having access
 # to a descriptor object.
 if first:
   # All descriptor objects should be of the same type
-  # (i.e. server_descriptor.RelayDescriptor)
+  # (i.e. server_descriptor.RelayDesrciptor)
   desc_type = type(desc)
   
   # define incl_fields, 4 cases where final case is incl_fields already
   # defined and excl_fields left blank, so no action is necessary.
   if not include_fields and exclude_fields:
-_incl = sets.Set(attr.keys())
-include_fields = list(_incl.difference(exclude_fields))
+incl = set(attr.keys())
+include_fields = list(incl.difference(exclude_fields))
   
   elif not include_fields and not exclude_fields:
 include_fields = attr.keys()
   
   elif include_fields and exclude_fields:
-_incl = sets.Set(include_fields)
-include_fields = list(_incl.difference(exclude_fields))
+incl = set(include_fields)
+include_fields = list(incl.difference(exclude_fields))
   
-  dwriter = csv.DictWriter(_temp_file, include_fields, 
extrasaction='ignore')
-  first = False
+  dwriter = csv.DictWriter(temp_file, include_fields, 
extrasaction='ignore')
   
   if header:
 dwriter.writeheader()
+  first = False
 
 if desc_type == type(desc):
   dwriter.writerow(attr)
 else:
-  raise ValueError('More than one type of descriptor was provided.')
+  raise ValueError('More than one descriptor type provided. Started with a 
%s, and just got a %s' % (desc_type, type(desc)))
   
-  return _temp_file.getvalue()
+  return temp_file.getvalue()
   # cStringIO files are closed automatically when the current scope is exited.
 
-def export_csv_file(descriptors, document_location, header=True, 
include_fields=[], exclude_fields=[]):
+def export_csv_file(descriptors, document, include_fields=[], 
exclude_fields=[], header=True):
   
   Writes descriptor attributes to a csv file on disk.
   
   Calls get_csv_lines with the given argument, then writes the returned string
   to a file location specified by document_location.
   
-  :param list descrs: descriptor objects with attributes to export as csv file.
-  :param str doc_loc: location and file name for csv file to be written to.
-This overwrites existing files.
-  :param bool header: defaults to true, determines if doc will have a header 
row.
-  :param list incl_f: list of attribute fields to include in 

[tor-commits] [stem/master] First complete build of export.py tests.

2012-08-04 Thread atagar
commit aafb7b429e7220c938da7a591d17ca1b2463aa09
Author: Erik ei...@wesleyan.edu
Date:   Tue Jul 31 12:35:09 2012 -0400

First complete build of export.py tests.

Everything should pass, and testing export_csv_file() promted some changes,
which include the change from specifying a file for writing to providing
a document object.  This code is now ready for review.
---
 stem/descriptor/export.py  |9 +
 test/mocking.py|2 +-
 test/unit/descriptor/export.py |   14 +++---
 3 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/stem/descriptor/export.py b/stem/descriptor/export.py
index af62be5..1f94734 100644
--- a/stem/descriptor/export.py
+++ b/stem/descriptor/export.py
@@ -76,7 +76,7 @@ def export_csvs(descriptors, include_fields=[], 
exclude_fields=[], header=False)
   return temp_file.getvalue()
   # cStringIO files are closed automatically when the current scope is exited.
 
-def export_csv_file(descriptors, document, include_fields=[], 
exclude_fields=[], header=True):
+def export_csv_file(descriptors, document, include_fields=(), 
exclude_fields=(), header=True):
   
   Writes descriptor attributes to a csv file on disk.
   
@@ -89,7 +89,8 @@ def export_csv_file(descriptors, document, include_fields=[], 
exclude_fields=[],
   :param list include_fields: list of attribute fields to include in the csv 
line.
   :param list exclude_fields: list of attribute fields to exclude from csv 
line.
   
-  try:
+  if not hasattr(document, 'write'):
+raise AttributeError(Provided %r object does not have a write method. % 
document)
+  else:
 document.write(export_csvs(descriptors, include_fields=include_fields, 
exclude_fields=exclude_fields, header=header))
-  except AttributeError:
-print A valid document object was not provided; could not write
+  
diff --git a/test/mocking.py b/test/mocking.py
index b2d9737..071514d 100644
--- a/test/mocking.py
+++ b/test/mocking.py
@@ -69,7 +69,7 @@ def return_for_args(args_to_return_value, kwarg_type=None, 
default=None):
   :param object kwarg_type: type of kwarg mapping to be used in unwraping 
these arguments.
   :param functor default: returns the value of this function if the args don't 
match something that we have, we raise a ValueError by default
   
-
+  
   def _return_value(*args, **kwargs):
 # First handle the case in which we aren't expecting keyword args.
 if kwarg_type == None:
diff --git a/test/unit/descriptor/export.py b/test/unit/descriptor/export.py
index a785957..d006e85 100644
--- a/test/unit/descriptor/export.py
+++ b/test/unit/descriptor/export.py
@@ -136,20 +136,20 @@ class TestExport(unittest.TestCase):
 # Must use named tuples again for ret_vals dictionary.
 Fields = namedtuple('Fields', 'include_fields exclude_fields header')
 
-ret_vals = {(descriptor, sample_file):sample_csv_string,
-  (descriptor, sample_file, Fields(include_fields=('address', 
'onion_key'), exclude_fields=('address',), header=False)):sample_csv_string2}
+ret_vals = {((descriptor,), Fields(include_fields=(), exclude_fields=(), 
header=True)):sample_csv_string,
+  ((descriptor,), Fields(include_fields=('address', 'onion_key'), 
exclude_fields=('address',), header=False)):sample_csv_string2}
 # TODO Ask Danner: mock it once then do both tests (not including 
assertRaises), or do separate mockings.
 #the latter requires that we still include empty incl_fields and 
excl_fields parameters instead of
 #letting them default to [].  Same for header.
 mocking.mock(export.export_csvs, mocking.return_for_args(ret_vals, 
kwarg_type=Fields))
 
-export.export_csv_file(descriptor, sample_file)
+export.export_csv_file((descriptor,), sample_file)
 self.assertEqual(sample_csv_string, sample_file.getvalue())
 
-sample_file = cStringIO.StringIO
+sample_file = cStringIO.StringIO()
 
-export.export_csv_file(descriptor, sample_file, include_fields=('address', 
'onion_key'), exclude_fields=('address',), header=False)
+export.export_csv_file((descriptor,), sample_file, 
include_fields=('address', 'onion_key'), exclude_fields=('address',), 
header=False)
 self.assertEqual(sample_csv_string2, sample_file.getvalue())
-
+
 # Make sure error is Raised when necessary.
-self.assertRaises(export.export_csv_file, (descriptor, sample_csv_string))
+self.assertRaises(AttributeError, export.export_csv_file, (descriptor,), 
sample_csv_string)



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


[tor-commits] [stem/master] First draft of torexport, 3 functions defined to handle different use cases.

2012-08-04 Thread atagar
commit 508373f1a7824b1ff9b86a597a718918d4250e24
Author: Erik ei...@wesleyan.edu
Date:   Thu Jul 12 14:13:59 2012 -0400

First draft of torexport, 3 functions defined to handle different use cases.

First draft of torexport, 3 functions defined to handle different use cases.
csv_file_exp() takes a list of descriptors and exports their attributes as a
csv file. descriptors_csv_exp() takes a list of descriptors and returns a
generator.  Each iteration, this function returns a line of csv representing
the attributes of a single descriptor object.  descriptor_csv_exp() returns
a single line of csv based on the attributes of a sole descriptor object.
---
 stem/descriptor/export.py |   89 +
 1 files changed, 89 insertions(+), 0 deletions(-)

diff --git a/stem/descriptor/export.py b/stem/descriptor/export.py
new file mode 100644
index 000..2859fee
--- /dev/null
+++ b/stem/descriptor/export.py
@@ -0,0 +1,89 @@
+import os, csv, sets, cStringIO
+
+
+def descriptor_csv_exp(descr, incl_fields=[], excl_fields=[]):
+  
+  Takes a single descriptor object, puts it in a list, and passes it to
+  descriptors_csv_exp to build a csv.
+
+  :param object descr: single descriptor object to export as csv.
+  
+  descriptor = [descr]
+  for desc in descriptors_csv_exp(descriptor, incl_fields, excl_fields):
+return desc
+
+
+def descriptors_csv_exp(descrs, incl_fields=[], excl_fields=[], head=False):
+  
+  Builds a csv file based on attributes of descriptors.
+
+  :param list descrs: List of descriptor objects to export as a csv line.
+  :param list incl_fields: list of attribute fields to include in the csv line.
+  :param list excl_fields: list of attribute fields to exclude from csv line.
+  :param bool head: whether or not a header is requested; shouldn't be needed
+outside of csv_file_exp's call of this function.
+
+  :returns: generator for csv strings, one line per descr object.
+  
+  
+  _temp_file = cStringIO.StringIO()
+
+  first = True
+
+  for desc in descrs:
+attr = vars(desc)
+
+# Defining incl_fields and the dwriter object requires having access
+# to a descriptor object.
+if first:
+  # define incl_fields, 4 cases where final case is incl_fields already
+  # defined and excl_fields left blank, so no action is necessary.
+  if not incl_fields and excl_fields:
+_incl = sets.Set(attr.keys())
+incl_fields = list(_incl.difference(excl_fields))
+
+  elif not incl_fields and not excl_fields:
+incl_fields = attr.keys()
+
+  elif incl_fields and excl_fields:
+_incl = sets.Set(incl_fields)
+incl_fields = list(_incl.difference(excl_fields))
+
+  dwriter = csv.DictWriter(_temp_file, incl_fields)
+  first = False
+
+  if head:
+dwriter.writeheader()
+
+# Need to remove fields that aren't wanted for dwriter.
+final = {}
+for at in attr:
+  if at in incl_fields:
+final[at] = attr[at]
+
+dwriter.writerow(final)
+yield _temp_file.getvalue()
+
+# Clear cString wrapper for new descriptor.
+_temp_file.reset()
+_temp_file.truncate()
+
+  
+  _temp_file.close()
+
+def csv_file_exp(descrs, doc_loc, header=True, incl_f=[], excl_f=[]):
+  
+  Writes descriptor attributes to a csv file on disk.
+
+  :param list descrs: descriptor objects with attributes to export as csv file.
+  :param str doc_loc: location and file name for csv file to be written to.
+This overwrites existing files.
+  :param bool header: defaults to true, determines if doc will have a header 
row.
+  :param list incl_f: list of attribute fields to include in the csv line.
+  :param list excl_f: list of attribute fields to exclude from csv line.
+  
+  doc = open(doc_loc, 'w')
+
+  for line in descriptors_csv_exp(descrs, incl_fields=incl_f, 
excl_fields=excl_f, head=header):
+doc.write(line)
+



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


[tor-commits] [stem/master] minor documentation update

2012-08-04 Thread atagar
commit e94e00a61d262fd52706c0891276811ca0369e52
Author: Erik ei...@wesleyan.edu
Date:   Tue Jul 31 12:38:27 2012 -0400

minor documentation update
---
 stem/descriptor/export.py |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/stem/descriptor/export.py b/stem/descriptor/export.py
index 1f94734..11b4918 100644
--- a/stem/descriptor/export.py
+++ b/stem/descriptor/export.py
@@ -82,6 +82,7 @@ def export_csv_file(descriptors, document, include_fields=(), 
exclude_fields=(),
   
   Calls get_csv_lines with the given argument, then writes the returned string
   to a file location specified by document_location.
+  Precondition that param document has a 'write' attribute.
   
   :param list descriptors: descriptor objects with attributes to export as csv 
file.
   :param object document: File object to be written to.



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


[tor-commits] [stem/master] Moving descriptor contructor to mocking module

2012-08-04 Thread atagar
commit ff43d9e7ad306499dce6e20909d0ce2e842541b4
Author: Damian Johnson ata...@torproject.org
Date:   Sat Aug 4 10:48:06 2012 -0700

Moving descriptor contructor to mocking module

We'll need to construct server descriptors in both their unit tests and when
testing the exporter. The mocking module is both for function mocking and
creating mock objects so this is the perfect place for it. I might move the
extrainfo descriptor constructer here later if it seems useful.

Personally I'm finding the current exporter tests and mocking changes very
confusing so reverting the mocking changes and writing some simpler tests.
---
 test/mocking.py   |  104 +--
 test/unit/descriptor/server_descriptor.py |  129 -
 2 files changed, 110 insertions(+), 123 deletions(-)

diff --git a/test/mocking.py b/test/mocking.py
index 49b8c14..1deaf57 100644
--- a/test/mocking.py
+++ b/test/mocking.py
@@ -23,6 +23,7 @@ calling :func:`test.mocking.revert_mocking`.
   Instance Constructors
 get_message   - stem.socket.ControlMessage
 get_protocolinfo_response - stem.response.protocolinfo.ProtocolInfoResponse
+get_server_descriptor - text for a tor server descriptor
 
 
 import inspect
@@ -45,54 +46,63 @@ MOCK_STATE = {}
 
 BUILTIN_TYPE = type(open)
 
+CRYPTO_BLOB = 
+MIGJAoGBAJv5IIWQ+WDWYUdyA/0L8qbIkEVH/cwryZWoIaPAzINfrw1WfNZGtBmg
+skFtXhOHHqTRN4GPPrZsAIUOQGzQtGb66IQgT4tO/pj+P6QmSCCdTfhvGfgTCsC+
+WPi4Fl2qryzTb3QO5r5x7T8OsG2IBUET1bLQzmtbC560SYR49IvVAgMBAAE=
+
+
+RELAY_DESCRIPTOR_ATTR = (
+  (router, caerSidi 71.35.133.197 9001 0 0),
+  (published, 2012-03-01 17:15:27),
+  (bandwidth, 153600 256000 104590),
+  (reject, *:*),
+  (onion-key, \n-BEGIN RSA PUBLIC KEY-%s-END RSA PUBLIC 
KEY- % CRYPTO_BLOB),
+  (signing-key, \n-BEGIN RSA PUBLIC KEY-%s-END RSA PUBLIC 
KEY- % CRYPTO_BLOB),
+  (router-signature, \n-BEGIN SIGNATURE-%s-END SIGNATURE- 
% CRYPTO_BLOB),
+)
+
+BRIDGE_DESCRIPTOR_ATTR = (
+  (router, Unnamed 10.45.227.253 9001 0 0),
+  (router-digest, 006FD96BA35E7785A6A3B8B75FE2E2435A13BDB4),
+  (published, 2012-03-22 17:34:38),
+  (bandwidth, 409600 819200 5120),
+  (reject, *:*),
+)
+
 def no_op():
   def _no_op(*args): pass
   return _no_op
 
 def return_value(value):
-  def _return_value(*args, **kwargs):
-return value
+  def _return_value(*args): return value
   return _return_value
 
 def return_true(): return return_value(True)
 def return_false(): return return_value(False)
 def return_none(): return return_value(None)
 
-def return_for_args(args_to_return_value, kwarg_type=None, default=None):
+def return_for_args(args_to_return_value, default = None):
   
   Returns a value if the arguments to it match something in a given
-  'argument = return value' mapping. In the case of keyword arguments,
-  a type must be specified so _return_value can check these arguments as
-  well.  Otherwise, a default function is called with the arguments.
+  'argument = return value' mapping. Otherwise, a default function
+  is called with the arguments.
   
   :param dict args_to_return_value: mapping of arguments to the value we 
should provide
-  :param object kwarg_type: type of kwarg mapping to be used in unwraping 
these arguments.
-Though a dictionary would be the obvious choice, mapping expected keyword
-arguments and their values in the keys of args_to_return_value would result
-in unhashable types.  Instead, a named tuple may be used and kwarg_type
-provides the type of the named tuple so it may be parsed.
-See test/unit/descriptor/export.py for an example.
   :param functor default: returns the value of this function if the args don't 
match something that we have, we raise a ValueError by default
   
   
-  def _return_value(*args, **kwargs):
-# First handle the case in which we aren't expecting keyword args.
-if kwarg_type == None:
-  argument = args
+  def _return_value(*args):
+if args in args_to_return_value:
+  return args_to_return_value[args]
+elif default is None:
+  arg_label = , .join([str(v) for v in args])
+  raise ValueError(Unrecognized argument sent for return_for_args(): %s 
% arg_label)
 else:
-  argument = args + (kwarg_type(**kwargs),)
-
-try:
-  return args_to_return_value[argument]
-except KeyError:
-  if default is None:
-arg_label = , .join(map(str, argument))
-raise ValueError(Unrecognized argument sent for return_for_args(): 
%s % arg_label)
-  else:
-return default(args)
+  return default(args)
   
   return _return_value
-  
+
 def raise_exception(exception):
   def _raise(*args): raise exception
   return _raise
@@ -135,7 +145,7 @@ def mock(target, mock_call, target_module=None):
 target_function = target.__name__
 MOCK_STATE[mocking_id] = (target_module, target_function, target)
   
-  mock_wrapper = lambda 

[tor-commits] [stem/master] CSV export functionality for tor descriptors

2012-08-04 Thread atagar
commit f7157ae4f576acb1b90e458f479e2a820aefbe86
Merge: 051ed27 7022021
Author: Damian Johnson ata...@torproject.org
Date:   Sat Aug 4 12:18:56 2012 -0700

CSV export functionality for tor descriptors

 run_tests.py  |2 +
 stem/descriptor/__init__.py   |2 +-
 stem/descriptor/export.py |   89 
 test/mocking.py   |   63 ++
 test/unit/descriptor/__init__.py  |2 +-
 test/unit/descriptor/export.py|   93 +
 test/unit/descriptor/server_descriptor.py |  129 -
 7 files changed, 283 insertions(+), 97 deletions(-)

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


[tor-commits] [stem/master] Submitting for code review.

2012-08-04 Thread atagar
commit bb0dcfc7fdf9303251dbe7304005d349f9956fd6
Author: Erik ei...@wesleyan.edu
Date:   Wed Aug 1 16:40:56 2012 -0400

Submitting for code review.
---
 stem/descriptor/export.py  |   16 
 test/mocking.py|5 +
 test/unit/descriptor/export.py |9 -
 3 files changed, 13 insertions(+), 17 deletions(-)

diff --git a/stem/descriptor/export.py b/stem/descriptor/export.py
index 11b4918..89a5644 100644
--- a/stem/descriptor/export.py
+++ b/stem/descriptor/export.py
@@ -6,7 +6,7 @@ def export_csv(descriptor, include_fields=(), 
exclude_fields=()):
   Takes a single descriptor object, puts it in a list, and passes it to
   descriptors_csv_exp to build a csv.
   
-  :param object descriptor: single descriptor whose.
+  :param object descriptor: single descriptor whose attributes will be 
returned as a string.
   :param list include_fields: list of attribute fields to include in the csv 
string.
   :param list exclude_fields: list of attribute fields to exclude from csv 
string.
   
@@ -25,8 +25,7 @@ def export_csvs(descriptors, include_fields=[], 
exclude_fields=[], header=False)
   :param list descrs: List of descriptor objects whose attributes will be 
written.
   :param list include_fields: list of attribute fields to include in the csv 
string.
   :param list exclude_fields: list of attribute fields to exclude from csv 
string.
-  :param bool header: whether or not a header is requested; probably won't be
-needed outside of csv_file_exp's call of this function.
+  :param bool header: whether or not a header is requested.
   
   :returns: csv string with one descriptor per line and one attribute per cell.
   :raises: ValueError if more than one descriptor type (e.g. server_descriptor,
@@ -39,7 +38,7 @@ def export_csvs(descriptors, include_fields=[], 
exclude_fields=[], header=False)
   first = True
   
   for desc in descriptors:
-import sys
+#umport sys
 attr = vars(desc)
 
 # Defining incl_fields and the dwriter object requires having access
@@ -90,8 +89,9 @@ def export_csv_file(descriptors, document, include_fields=(), 
exclude_fields=(),
   :param list include_fields: list of attribute fields to include in the csv 
line.
   :param list exclude_fields: list of attribute fields to exclude from csv 
line.
   
-  if not hasattr(document, 'write'):
-raise AttributeError(Provided %r object does not have a write method. % 
document)
-  else:
-document.write(export_csvs(descriptors, include_fields=include_fields, 
exclude_fields=exclude_fields, header=header))
   
+  try:
+document.write(export_csvs(descriptors, include_fields=include_fields, 
exclude_fields=exclude_fields, header=header))
+  except AttributeError:
+print Provided %r object does not have a write() method. % document
+raise
diff --git a/test/mocking.py b/test/mocking.py
index 071514d..49b8c14 100644
--- a/test/mocking.py
+++ b/test/mocking.py
@@ -67,6 +67,11 @@ def return_for_args(args_to_return_value, kwarg_type=None, 
default=None):
   
   :param dict args_to_return_value: mapping of arguments to the value we 
should provide
   :param object kwarg_type: type of kwarg mapping to be used in unwraping 
these arguments.
+Though a dictionary would be the obvious choice, mapping expected keyword
+arguments and their values in the keys of args_to_return_value would result
+in unhashable types.  Instead, a named tuple may be used and kwarg_type
+provides the type of the named tuple so it may be parsed.
+See test/unit/descriptor/export.py for an example.
   :param functor default: returns the value of this function if the args don't 
match something that we have, we raise a ValueError by default
   
   
diff --git a/test/unit/descriptor/export.py b/test/unit/descriptor/export.py
index d006e85..12d5ed3 100644
--- a/test/unit/descriptor/export.py
+++ b/test/unit/descriptor/export.py
@@ -82,10 +82,6 @@ class TestExport(unittest.TestCase):
 
 
 # Single descriptor
-#print Type descriptor: %s % type(descriptor)
-#print Type SINGLE_ALL: %s % type(SINGLE_ALL)
-#print SINGLE_ALL
-#print Type fn Call: %s % type(export.export_csvs([descriptor]))
 self.assertEquals(SINGLE_ALL + \r\n, export.export_csvs([descriptor]))
 self.assertEqual(SINGLE_PART + \r\n, export.export_csvs([descriptor],
   include_fields=['address', 'exit_policy']))
@@ -95,14 +91,9 @@ class TestExport(unittest.TestCase):
   include_fields=['address', 'exit_policy', 'fingerprint'], 
exclude_fields=['fingerprint']))
 
 # Multiple descriptors
-#print Sample Call: \n %s \n\n %  export.export_csvs([descriptor, 
descriptor2], header=True)
-
 self.assertEqual(DOUBLE_ALL, export.export_csvs([descriptor, descriptor2]))
 self.assertEqual(DOUBLE_PART, export.export_csvs([descriptor, descriptor2],
   include_fields=['address', 'exit_policy']))
-#print export.export_csvs([descriptor, descriptor2], 

[tor-commits] [stem/master] Revising descriptor exporter and associated tests

2012-08-04 Thread atagar
commit 7022021c4207a0066cb93261629f2ba020d307f6
Author: Damian Johnson ata...@torproject.org
Date:   Sat Aug 4 12:13:47 2012 -0700

Revising descriptor exporter and associated tests

Several changes for the prior csv export functionality, especially its 
tests.
Most notably this includes...

* rewrite of the tests to be simpler and break down by test cases
* newline breaks rather than windows style '\r\n'
* excluding private attributes (attributes that start with an underscore)
* writing directly to a file in export_csv_file() rather than buffering to 
a string first
* general refactoring to hopefully improve readability
---
 run_tests.py |6 +-
 stem/descriptor/__init__.py  |2 +-
 stem/descriptor/export.py|  148 ++
 test/unit/descriptor/__init__.py |2 +-
 test/unit/descriptor/export.py   |  189 ++
 5 files changed, 142 insertions(+), 205 deletions(-)

diff --git a/run_tests.py b/run_tests.py
index bed8e50..4ad551a 100755
--- a/run_tests.py
+++ b/run_tests.py
@@ -16,6 +16,7 @@ import test.output
 import test.runner
 import test.check_whitespace
 import test.unit.connection.authentication
+import test.unit.descriptor.export
 import test.unit.descriptor.reader
 import test.unit.descriptor.server_descriptor
 import test.unit.descriptor.extrainfo_descriptor
@@ -50,8 +51,6 @@ import test.integ.util.proc
 import test.integ.util.system
 import test.integ.process
 import test.integ.version
-#TODO move this by other descriptor tests
-import test.unit.descriptor.export
 
 import stem.prereq
 import stem.util.conf
@@ -109,6 +108,7 @@ UNIT_TESTS = (
   test.unit.util.proc.TestProc,
   test.unit.util.system.TestSystem,
   test.unit.util.tor_tools.TestTorTools,
+  test.unit.descriptor.export.TestExport,
   test.unit.descriptor.reader.TestDescriptorReader,
   test.unit.descriptor.server_descriptor.TestServerDescriptor,
   test.unit.descriptor.extrainfo_descriptor.TestExtraInfoDescriptor,
@@ -123,9 +123,7 @@ UNIT_TESTS = (
   test.unit.response.protocolinfo.TestProtocolInfoResponse,
   test.unit.response.authchallenge.TestAuthChallengeResponse,
   test.unit.connection.authentication.TestAuthenticate,
-  test.unit.descriptor.export.TestExport,
 )
-#  TODO move export test to proper location
 
 INTEG_TESTS = (
   test.integ.util.conf.TestConf,
diff --git a/stem/descriptor/__init__.py b/stem/descriptor/__init__.py
index bb6f874..45cd016 100644
--- a/stem/descriptor/__init__.py
+++ b/stem/descriptor/__init__.py
@@ -13,7 +13,7 @@ Package for parsing and processing descriptor data.
 
 
 __all__ = [
-  descriptor,
+  export,
   reader,
   extrainfo_descriptor,
   server_descriptor,
diff --git a/stem/descriptor/export.py b/stem/descriptor/export.py
index 89a5644..16a148d 100644
--- a/stem/descriptor/export.py
+++ b/stem/descriptor/export.py
@@ -1,97 +1,89 @@
-import os, csv, sets, cStringIO
+
+Utilities for exporting descriptors to other formats.
+
 
+import csv
+import cStringIO
 
-def export_csv(descriptor, include_fields=(), exclude_fields=()):
+import stem.descriptor
+
+class _ExportDialect(csv.excel):
+  lineterminator = '\n'
+
+def export_csv(descriptors, included_fields = (), excluded_fields = (), header 
= True):
   
-  Takes a single descriptor object, puts it in a list, and passes it to
-  descriptors_csv_exp to build a csv.
+  Provides a newline separated CSV for one or more descriptors. If simply
+  provided with descriptors then the CSV contains all of its attributes,
+  labelled with a header row. Either 'included_fields' or 'excluded_fields' can
+  be used for more granular control over its attributes and the order.
   
-  :param object descriptor: single descriptor whose attributes will be 
returned as a string.
-  :param list include_fields: list of attribute fields to include in the csv 
string.
-  :param list exclude_fields: list of attribute fields to exclude from csv 
string.
+  :param Descriptor,list descriptors: descriptor or list of descriptors to be 
exported
+  :param list included_fields: attributes to include in the csv
+  :param list excluded_fields: attributes to exclude from the csv
+  :param bool header: if True then the first line will be a comma separated 
list of the attribute names
   
-  :returns: single csv line as a string with one descriptor attribute per cell.
+  :returns: str of the CSV for the descriptors, one per line
+  :raises: ValueError if descriptors contain more than one descriptor type
   
   
-  descr = (descriptor,)
-  return export_csvs(descr, include_fields=include_fields, 
exclude_fields=exclude_fields)
+  output_buffer = cStringIO.StringIO()
+  export_csv_file(output_buffer, descriptors, included_fields, 
excluded_fields, header)
+  return output_buffer.getvalue()
 
-
-def export_csvs(descriptors, include_fields=[], exclude_fields=[], 
header=False):
+def export_csv_file(output_file, descriptors, included_fields = (), 

[tor-commits] [torbrowser/maint-2.3] Remove crashy cache isolation patch for now :/.

2012-08-04 Thread mikeperry
commit f2be42f3984acb20c58c05cf5534396fef635161
Author: Mike Perry mikeperry-...@fscked.org
Date:   Fri Aug 3 22:14:23 2012 -0700

Remove crashy cache isolation patch for now :/.

It asserts during debug builds, and also may have issues with XUL dialogs?
---
 ...solate-the-Image-Cache-per-url-bar-domain.patch |  910 
 1 files changed, 0 insertions(+), 910 deletions(-)

diff --git 
a/src/current-patches/firefox/alpha/0021-Isolate-the-Image-Cache-per-url-bar-domain.patch
 
b/src/current-patches/firefox/alpha/0021-Isolate-the-Image-Cache-per-url-bar-domain.patch
deleted file mode 100644
index b21536c..000
--- 
a/src/current-patches/firefox/alpha/0021-Isolate-the-Image-Cache-per-url-bar-domain.patch
+++ /dev/null
@@ -1,910 +0,0 @@
-From 1b18f231fce26c0b6d3c2bb2c6e30e30c8e05a1e Mon Sep 17 00:00:00 2001
-From: Mike Perry mikeperry-...@torproject.org
-Date: Mon, 30 Jul 2012 18:37:36 -0700
-Subject: [PATCH 21/21] Isolate the Image Cache per url bar domain.
-
-Also adds a new API to mozIThirdPartyUtil to allow you to get the url bar URI
-for a channel or nsIDocument.

- content/base/src/ThirdPartyUtil.cpp|   52 +
- content/base/src/ThirdPartyUtil.h  |2 +
- content/base/src/nsContentUtils.cpp|   13 +-
- embedding/browser/webBrowser/nsContextMenuInfo.cpp |   29 ++-
- extensions/cookie/nsCookiePermission.cpp   |3 +
- image/public/imgILoader.idl|4 +-
- image/src/imgLoader.cpp|  200 
- image/src/imgLoader.h  |   13 +-
- image/src/imgRequest.cpp   |9 +-
- image/src/imgRequest.h |3 +
- layout/generic/nsImageFrame.cpp|   11 +-
- netwerk/base/public/mozIThirdPartyUtil.idl |   21 ++
- netwerk/cookie/nsICookiePermission.idl |1 +
- toolkit/system/gnome/nsAlertsIconListener.cpp  |3 +-
- widget/cocoa/nsMenuItemIconX.mm|9 +-
- 15 files changed, 272 insertions(+), 101 deletions(-)
-
-diff --git a/content/base/src/ThirdPartyUtil.cpp 
b/content/base/src/ThirdPartyUtil.cpp
-index 6a415e9..62333f3 100644
 a/content/base/src/ThirdPartyUtil.cpp
-+++ b/content/base/src/ThirdPartyUtil.cpp
-@@ -40,6 +40,9 @@
- #include nsIServiceManager.h
- #include nsIHttpChannelInternal.h
- #include nsIDOMWindow.h
-+#include nsICookiePermission.h
-+#include nsIDOMDocument.h
-+#include nsIDocument.h
- #include nsILoadContext.h
- #include nsIPrincipal.h
- #include nsIScriptObjectPrincipal.h
-@@ -54,6 +57,7 @@ ThirdPartyUtil::Init()
- 
-   nsresult rv;
-   mTLDService = do_GetService(NS_EFFECTIVETLDSERVICE_CONTRACTID, rv);
-+  mCookiePermissions = do_GetService(NS_COOKIEPERMISSION_CONTRACTID);
-   return rv;
- }
- 
-@@ -315,3 +319,51 @@ ThirdPartyUtil::GetBaseDomain(nsIURI* aHostURI,
- 
-   return NS_OK;
- }
-+
-+NS_IMETHODIMP
-+ThirdPartyUtil::GetFirstPartyURI(nsIChannel *aChannel,
-+ nsIDocument *aDoc,
-+ nsIURI **aOutput)
-+{
-+  nsresult rv = NS_ERROR_NULL_POINTER;
-+
-+  if (!aChannel  aDoc) {
-+aChannel = aDoc-GetChannel();
-+  }
-+
-+  // If aChannel is specified or available, use the official route
-+  // for sure
-+  if (aChannel) {
-+rv = mCookiePermissions-GetOriginatingURI(aChannel, aOutput);
-+  }
-+
-+  // If the channel was missing, closed or broken, try the
-+  // window hierarchy directly. 
-+  //
-+  // This might fail to work for first-party loads themselves, but 
-+  // we don't need this codepath for that case.
-+  if (NS_FAILED(rv)  aDoc) {
-+nsCOMPtrnsIDOMWindow top;
-+nsCOMPtrnsIDOMDocument topDDoc;
-+
-+aDoc-GetWindow()-GetTop(getter_AddRefs(top));
-+top-GetDocument(getter_AddRefs(topDDoc));
-+
-+nsCOMPtrnsIDocument topDoc(do_QueryInterface(topDDoc));
-+*aOutput = topDoc-GetOriginalURI();
-+
-+if (*aOutput)
-+  rv = NS_OK;
-+  }
-+
-+  // TODO: We could provide a route through the loadgroup + notification
-+  // callbacks too, but either channel or document was always available
-+  // in the cases where this function was originally needed (the image cache).
-+  // The notification callbacks also appear to suffers from the same 
limitation
-+  // as the document path. See nsICookiePermissions.GetOriginatingURI() for
-+  // details.
-+
-+  return rv;
-+}
-+
-+
-diff --git a/content/base/src/ThirdPartyUtil.h 
b/content/base/src/ThirdPartyUtil.h
-index 58ddb15..ba70162 100644
 a/content/base/src/ThirdPartyUtil.h
-+++ b/content/base/src/ThirdPartyUtil.h
-@@ -46,6 +46,7 @@
- class nsIURI;
- class nsIChannel;
- class nsIDOMWindow;
-+class nsICookiePermission;
- 
- class ThirdPartyUtil : public mozIThirdPartyUtil
- {
-@@ -61,6 +62,7 @@ private:
-   static already_AddRefednsIURI GetURIFromWindow(nsIDOMWindow* aWin);
- 
-   nsCOMPtrnsIEffectiveTLDService mTLDService;
-+  

[tor-commits] [torbrowser/master] Merge branch 'maint-2.3'

2012-08-04 Thread mikeperry
commit 71dd3ae3159edb99ae3e50dac865389e558be2ff
Merge: fdae985 f2be42f
Author: Mike Perry mikeperry-...@fscked.org
Date:   Sat Aug 4 12:46:41 2012 -0700

Merge branch 'maint-2.3'

 ...solate-the-Image-Cache-per-url-bar-domain.patch |  910 
 1 files changed, 0 insertions(+), 910 deletions(-)

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


[tor-commits] [torbrowser/master] Remove crashy cache isolation patch for now :/.

2012-08-04 Thread mikeperry
commit f2be42f3984acb20c58c05cf5534396fef635161
Author: Mike Perry mikeperry-...@fscked.org
Date:   Fri Aug 3 22:14:23 2012 -0700

Remove crashy cache isolation patch for now :/.

It asserts during debug builds, and also may have issues with XUL dialogs?
---
 ...solate-the-Image-Cache-per-url-bar-domain.patch |  910 
 1 files changed, 0 insertions(+), 910 deletions(-)

diff --git 
a/src/current-patches/firefox/alpha/0021-Isolate-the-Image-Cache-per-url-bar-domain.patch
 
b/src/current-patches/firefox/alpha/0021-Isolate-the-Image-Cache-per-url-bar-domain.patch
deleted file mode 100644
index b21536c..000
--- 
a/src/current-patches/firefox/alpha/0021-Isolate-the-Image-Cache-per-url-bar-domain.patch
+++ /dev/null
@@ -1,910 +0,0 @@
-From 1b18f231fce26c0b6d3c2bb2c6e30e30c8e05a1e Mon Sep 17 00:00:00 2001
-From: Mike Perry mikeperry-...@torproject.org
-Date: Mon, 30 Jul 2012 18:37:36 -0700
-Subject: [PATCH 21/21] Isolate the Image Cache per url bar domain.
-
-Also adds a new API to mozIThirdPartyUtil to allow you to get the url bar URI
-for a channel or nsIDocument.

- content/base/src/ThirdPartyUtil.cpp|   52 +
- content/base/src/ThirdPartyUtil.h  |2 +
- content/base/src/nsContentUtils.cpp|   13 +-
- embedding/browser/webBrowser/nsContextMenuInfo.cpp |   29 ++-
- extensions/cookie/nsCookiePermission.cpp   |3 +
- image/public/imgILoader.idl|4 +-
- image/src/imgLoader.cpp|  200 
- image/src/imgLoader.h  |   13 +-
- image/src/imgRequest.cpp   |9 +-
- image/src/imgRequest.h |3 +
- layout/generic/nsImageFrame.cpp|   11 +-
- netwerk/base/public/mozIThirdPartyUtil.idl |   21 ++
- netwerk/cookie/nsICookiePermission.idl |1 +
- toolkit/system/gnome/nsAlertsIconListener.cpp  |3 +-
- widget/cocoa/nsMenuItemIconX.mm|9 +-
- 15 files changed, 272 insertions(+), 101 deletions(-)
-
-diff --git a/content/base/src/ThirdPartyUtil.cpp 
b/content/base/src/ThirdPartyUtil.cpp
-index 6a415e9..62333f3 100644
 a/content/base/src/ThirdPartyUtil.cpp
-+++ b/content/base/src/ThirdPartyUtil.cpp
-@@ -40,6 +40,9 @@
- #include nsIServiceManager.h
- #include nsIHttpChannelInternal.h
- #include nsIDOMWindow.h
-+#include nsICookiePermission.h
-+#include nsIDOMDocument.h
-+#include nsIDocument.h
- #include nsILoadContext.h
- #include nsIPrincipal.h
- #include nsIScriptObjectPrincipal.h
-@@ -54,6 +57,7 @@ ThirdPartyUtil::Init()
- 
-   nsresult rv;
-   mTLDService = do_GetService(NS_EFFECTIVETLDSERVICE_CONTRACTID, rv);
-+  mCookiePermissions = do_GetService(NS_COOKIEPERMISSION_CONTRACTID);
-   return rv;
- }
- 
-@@ -315,3 +319,51 @@ ThirdPartyUtil::GetBaseDomain(nsIURI* aHostURI,
- 
-   return NS_OK;
- }
-+
-+NS_IMETHODIMP
-+ThirdPartyUtil::GetFirstPartyURI(nsIChannel *aChannel,
-+ nsIDocument *aDoc,
-+ nsIURI **aOutput)
-+{
-+  nsresult rv = NS_ERROR_NULL_POINTER;
-+
-+  if (!aChannel  aDoc) {
-+aChannel = aDoc-GetChannel();
-+  }
-+
-+  // If aChannel is specified or available, use the official route
-+  // for sure
-+  if (aChannel) {
-+rv = mCookiePermissions-GetOriginatingURI(aChannel, aOutput);
-+  }
-+
-+  // If the channel was missing, closed or broken, try the
-+  // window hierarchy directly. 
-+  //
-+  // This might fail to work for first-party loads themselves, but 
-+  // we don't need this codepath for that case.
-+  if (NS_FAILED(rv)  aDoc) {
-+nsCOMPtrnsIDOMWindow top;
-+nsCOMPtrnsIDOMDocument topDDoc;
-+
-+aDoc-GetWindow()-GetTop(getter_AddRefs(top));
-+top-GetDocument(getter_AddRefs(topDDoc));
-+
-+nsCOMPtrnsIDocument topDoc(do_QueryInterface(topDDoc));
-+*aOutput = topDoc-GetOriginalURI();
-+
-+if (*aOutput)
-+  rv = NS_OK;
-+  }
-+
-+  // TODO: We could provide a route through the loadgroup + notification
-+  // callbacks too, but either channel or document was always available
-+  // in the cases where this function was originally needed (the image cache).
-+  // The notification callbacks also appear to suffers from the same 
limitation
-+  // as the document path. See nsICookiePermissions.GetOriginatingURI() for
-+  // details.
-+
-+  return rv;
-+}
-+
-+
-diff --git a/content/base/src/ThirdPartyUtil.h 
b/content/base/src/ThirdPartyUtil.h
-index 58ddb15..ba70162 100644
 a/content/base/src/ThirdPartyUtil.h
-+++ b/content/base/src/ThirdPartyUtil.h
-@@ -46,6 +46,7 @@
- class nsIURI;
- class nsIChannel;
- class nsIDOMWindow;
-+class nsICookiePermission;
- 
- class ThirdPartyUtil : public mozIThirdPartyUtil
- {
-@@ -61,6 +62,7 @@ private:
-   static already_AddRefednsIURI GetURIFromWindow(nsIDOMWindow* aWin);
- 
-   nsCOMPtrnsIEffectiveTLDService mTLDService;
-+  

[tor-commits] [torbrowser/maint-2.3] Build openssl as shared again.

2012-08-04 Thread erinn
commit ab9c09755df62d003980ee359e7a6355c9b2320d
Author: Shondoit Walker shond...@gmail.com
Date:   Tue Jul 31 13:07:09 2012 +0200

Build openssl as shared again.

 Commit 78c122cefc948c255a7e20218085af2e8d1bc1f9 changed it to no-shared
 for no apparent reason and it broke the build.
---
 build-scripts/windows-alpha.mk |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/build-scripts/windows-alpha.mk b/build-scripts/windows-alpha.mk
index 7bdb8cb..cb9e1ae 100644
--- a/build-scripts/windows-alpha.mk
+++ b/build-scripts/windows-alpha.mk
@@ -62,7 +62,7 @@ build-zlib: $(ZLIB_DIR)
cd $(ZLIB_DIR)  $(ZLIB_OPTS) make -f win32/Makefile.gcc install
touch $(STAMP_DIR)/build-zlib
 
-OPENSSL_OPTS=-no-idea -no-rc5 -no-md2 no-shared zlib --prefix=$(BUILT_DIR) 
--openssldir=$(BUILT_DIR) -L$(BUILT_DIR)/lib -Wl,--nxcompat -Wl,--dynamicbase 
-I$(BUILT_DIR)/include
+OPENSSL_OPTS=-no-idea -no-rc5 -no-md2 shared zlib --prefix=$(BUILT_DIR) 
--openssldir=$(BUILT_DIR) -L$(BUILT_DIR)/lib -Wl,--nxcompat -Wl,--dynamicbase 
-I$(BUILT_DIR)/include
 build-openssl: build-zlib $(OPENSSL_DIR)
cd $(OPENSSL_DIR)  ./config $(OPENSSL_OPTS)
cd $(OPENSSL_DIR)  make depend



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


[tor-commits] [torbrowser/maint-2.3] Update libpng to 1.5.12.

2012-08-04 Thread erinn
commit 089be37104b665d003ca85cae94526e22e52e5ea
Author: Shondoit Walker shond...@gmail.com
Date:   Tue Jul 31 13:04:13 2012 +0200

Update libpng to 1.5.12.
---
 build-scripts/versions-alpha.mk |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/build-scripts/versions-alpha.mk b/build-scripts/versions-alpha.mk
index c5c23d2..6226abe 100644
--- a/build-scripts/versions-alpha.mk
+++ b/build-scripts/versions-alpha.mk
@@ -4,7 +4,7 @@ RELEASE_VER=2.3.19-alpha
 
 ZLIB_VER=1.2.7
 OPENSSL_VER=1.0.1c
-LIBPNG_VER=1.5.11
+LIBPNG_VER=1.5.12
 QT_VER=4.8.1
 VIDALIA_VER=0.2.20
 LIBEVENT_VER=2.0.19-stable



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


[tor-commits] [torbrowser/master] Update libpng to 1.5.12.

2012-08-04 Thread erinn
commit 089be37104b665d003ca85cae94526e22e52e5ea
Author: Shondoit Walker shond...@gmail.com
Date:   Tue Jul 31 13:04:13 2012 +0200

Update libpng to 1.5.12.
---
 build-scripts/versions-alpha.mk |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/build-scripts/versions-alpha.mk b/build-scripts/versions-alpha.mk
index c5c23d2..6226abe 100644
--- a/build-scripts/versions-alpha.mk
+++ b/build-scripts/versions-alpha.mk
@@ -4,7 +4,7 @@ RELEASE_VER=2.3.19-alpha
 
 ZLIB_VER=1.2.7
 OPENSSL_VER=1.0.1c
-LIBPNG_VER=1.5.11
+LIBPNG_VER=1.5.12
 QT_VER=4.8.1
 VIDALIA_VER=0.2.20
 LIBEVENT_VER=2.0.19-stable



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


[tor-commits] [torbrowser/maint-2.3] Use the predefined COMPRESSED_NAME

2012-08-04 Thread erinn
commit ba5724c720ccbf06b5e3db19018dbc91ecb28e45
Author: Shondoit Walker shond...@gmail.com
Date:   Thu Aug 2 09:25:07 2012 +0200

Use the predefined COMPRESSED_NAME

COMPRESSED_NAME is already defined according to the USE_OBFSPROXY flag
as introduced in commit a08b546605d13d82e6f664bf8e2d8b3caf61327c.
---
 build-scripts/linux-alpha.mk   |5 +
 build-scripts/osx-alpha.mk |7 ++-
 build-scripts/windows-alpha.mk |3 ---
 3 files changed, 3 insertions(+), 12 deletions(-)

diff --git a/build-scripts/linux-alpha.mk b/build-scripts/linux-alpha.mk
index ceb2014..8427a10 100644
--- a/build-scripts/linux-alpha.mk
+++ b/build-scripts/linux-alpha.mk
@@ -377,10 +377,7 @@ bundle-localized: bundle-localized_$(LANGCODE).stamp
 compressed-bundle-localized: bundle-localized_$(LANGCODE).stamp
-rm -f $(DISTDIR)/$(COMPRESSED_NAME)_$(LANGCODE).tar.gz
-mkdir $(DISTDIR)
-ifeq ($(USE_OBFSPROXY),1)
-   tar -cvf - $(NAME)_$(LANGCODE) |tardy -unu 0 -una root -gnu 0 -gna 
wheel |gzip -c9 
$(DISTDIR)/$(DEFAULT_COMPRESSED_BASENAME)obfsproxy-$(LANGCODE).tar.gz
-endif
-   tar -cvf - $(NAME)_$(LANGCODE) |tardy -unu 0 -una root -gnu 0 -gna 
wheel |gzip -c9 $(DISTDIR)/$(DEFAULT_COMPRESSED_BASENAME)$(LANGCODE).tar.gz
+   tar -cvf - $(NAME)_$(LANGCODE) |tardy -unu 0 -una root -gnu 0 -gna 
wheel |gzip -c9 $(DISTDIR)/$(COMPRESSED_NAME)$(LANGCODE).tar.gz
rm *.zip *.xpi
 
 copy-files_%: generic-bundle.stamp
diff --git a/build-scripts/osx-alpha.mk b/build-scripts/osx-alpha.mk
index 377fba9..ad75326 100644
--- a/build-scripts/osx-alpha.mk
+++ b/build-scripts/osx-alpha.mk
@@ -374,13 +374,10 @@ bundle-localized_%.stamp:
 bundle-localized: bundle-localized_$(LANGCODE).stamp
 
 compressed-bundle-localized: bundle-localized_$(LANGCODE).stamp
-   -rm -f $(DISTDIR)/$(COMPRESSED_NAME)_$(LANGCODE).zip
+   -rm -f $(DISTDIR)/$(COMPRESSED_NAME)$(LANGCODE).zip
-mkdir $(DISTDIR)
#hdiutil create -volname Tor Browser Bundle for OS X -format UDBZ 
-imagekey zlib-level=9 -srcfolder $(DISTDIR)/tmp/ 
$(DISTDIR)/$(DEFAULT_COMPRESSED_BASENAME)$(LANGCODE).dmg
-   zip -r $(DISTDIR)/$(DEFAULT_COMPRESSED_BASENAME)$(LANGCODE).zip 
$(NAME)_$(LANGCODE).app
-ifeq ($(USE_OBFSPROXY),1)
-   zip -r 
$(DISTDIR)/$(DEFAULT_COMPRESSED_BASENAME)obfsproxy-$(LANGCODE).zip 
$(NAME)_$(LANGCODE).app
-endif
+   zip -r $(DISTDIR)/$(COMPRESSED_NAME)$(LANGCODE).zip 
$(NAME)_$(LANGCODE).app
-rm -f *.zip *.xpi
 
 copy-files_%: generic-bundle.stamp
diff --git a/build-scripts/windows-alpha.mk b/build-scripts/windows-alpha.mk
index cb9e1ae..5847a34 100644
--- a/build-scripts/windows-alpha.mk
+++ b/build-scripts/windows-alpha.mk
@@ -373,9 +373,6 @@ bundle-localized: bundle-localized_$(LANGCODE).stamp
 
 compressed-bundle-localized: $(SEVENZIP) bundle-localized_$(LANGCODE).stamp
rm -f $(COMPRESSED_NAME)_$(LANGCODE).exe
-ifeq ($(USE_OBFSPROXY),1)
-   cd $(NAME)_$(LANGCODE); $(SEVENZIP) a -mx9 -sfx7z.sfx 
../$(COMPRESSED_NAME)-obfsproxy_$(LANGCODE).exe $(NAME)
-endif
cd $(NAME)_$(LANGCODE); $(SEVENZIP) a -mx9 -sfx7z.sfx 
../$(COMPRESSED_NAME)_$(LANGCODE).exe $(NAME)
 
 copy-files_%: generic-bundle.stamp

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


[tor-commits] [torbrowser/master] Build openssl as shared again.

2012-08-04 Thread erinn
commit ab9c09755df62d003980ee359e7a6355c9b2320d
Author: Shondoit Walker shond...@gmail.com
Date:   Tue Jul 31 13:07:09 2012 +0200

Build openssl as shared again.

 Commit 78c122cefc948c255a7e20218085af2e8d1bc1f9 changed it to no-shared
 for no apparent reason and it broke the build.
---
 build-scripts/windows-alpha.mk |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/build-scripts/windows-alpha.mk b/build-scripts/windows-alpha.mk
index 7bdb8cb..cb9e1ae 100644
--- a/build-scripts/windows-alpha.mk
+++ b/build-scripts/windows-alpha.mk
@@ -62,7 +62,7 @@ build-zlib: $(ZLIB_DIR)
cd $(ZLIB_DIR)  $(ZLIB_OPTS) make -f win32/Makefile.gcc install
touch $(STAMP_DIR)/build-zlib
 
-OPENSSL_OPTS=-no-idea -no-rc5 -no-md2 no-shared zlib --prefix=$(BUILT_DIR) 
--openssldir=$(BUILT_DIR) -L$(BUILT_DIR)/lib -Wl,--nxcompat -Wl,--dynamicbase 
-I$(BUILT_DIR)/include
+OPENSSL_OPTS=-no-idea -no-rc5 -no-md2 shared zlib --prefix=$(BUILT_DIR) 
--openssldir=$(BUILT_DIR) -L$(BUILT_DIR)/lib -Wl,--nxcompat -Wl,--dynamicbase 
-I$(BUILT_DIR)/include
 build-openssl: build-zlib $(OPENSSL_DIR)
cd $(OPENSSL_DIR)  ./config $(OPENSSL_OPTS)
cd $(OPENSSL_DIR)  make depend



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


[tor-commits] [torbrowser/master] Use the predefined COMPRESSED_NAME

2012-08-04 Thread erinn
commit ba5724c720ccbf06b5e3db19018dbc91ecb28e45
Author: Shondoit Walker shond...@gmail.com
Date:   Thu Aug 2 09:25:07 2012 +0200

Use the predefined COMPRESSED_NAME

COMPRESSED_NAME is already defined according to the USE_OBFSPROXY flag
as introduced in commit a08b546605d13d82e6f664bf8e2d8b3caf61327c.
---
 build-scripts/linux-alpha.mk   |5 +
 build-scripts/osx-alpha.mk |7 ++-
 build-scripts/windows-alpha.mk |3 ---
 3 files changed, 3 insertions(+), 12 deletions(-)

diff --git a/build-scripts/linux-alpha.mk b/build-scripts/linux-alpha.mk
index ceb2014..8427a10 100644
--- a/build-scripts/linux-alpha.mk
+++ b/build-scripts/linux-alpha.mk
@@ -377,10 +377,7 @@ bundle-localized: bundle-localized_$(LANGCODE).stamp
 compressed-bundle-localized: bundle-localized_$(LANGCODE).stamp
-rm -f $(DISTDIR)/$(COMPRESSED_NAME)_$(LANGCODE).tar.gz
-mkdir $(DISTDIR)
-ifeq ($(USE_OBFSPROXY),1)
-   tar -cvf - $(NAME)_$(LANGCODE) |tardy -unu 0 -una root -gnu 0 -gna 
wheel |gzip -c9 
$(DISTDIR)/$(DEFAULT_COMPRESSED_BASENAME)obfsproxy-$(LANGCODE).tar.gz
-endif
-   tar -cvf - $(NAME)_$(LANGCODE) |tardy -unu 0 -una root -gnu 0 -gna 
wheel |gzip -c9 $(DISTDIR)/$(DEFAULT_COMPRESSED_BASENAME)$(LANGCODE).tar.gz
+   tar -cvf - $(NAME)_$(LANGCODE) |tardy -unu 0 -una root -gnu 0 -gna 
wheel |gzip -c9 $(DISTDIR)/$(COMPRESSED_NAME)$(LANGCODE).tar.gz
rm *.zip *.xpi
 
 copy-files_%: generic-bundle.stamp
diff --git a/build-scripts/osx-alpha.mk b/build-scripts/osx-alpha.mk
index 377fba9..ad75326 100644
--- a/build-scripts/osx-alpha.mk
+++ b/build-scripts/osx-alpha.mk
@@ -374,13 +374,10 @@ bundle-localized_%.stamp:
 bundle-localized: bundle-localized_$(LANGCODE).stamp
 
 compressed-bundle-localized: bundle-localized_$(LANGCODE).stamp
-   -rm -f $(DISTDIR)/$(COMPRESSED_NAME)_$(LANGCODE).zip
+   -rm -f $(DISTDIR)/$(COMPRESSED_NAME)$(LANGCODE).zip
-mkdir $(DISTDIR)
#hdiutil create -volname Tor Browser Bundle for OS X -format UDBZ 
-imagekey zlib-level=9 -srcfolder $(DISTDIR)/tmp/ 
$(DISTDIR)/$(DEFAULT_COMPRESSED_BASENAME)$(LANGCODE).dmg
-   zip -r $(DISTDIR)/$(DEFAULT_COMPRESSED_BASENAME)$(LANGCODE).zip 
$(NAME)_$(LANGCODE).app
-ifeq ($(USE_OBFSPROXY),1)
-   zip -r 
$(DISTDIR)/$(DEFAULT_COMPRESSED_BASENAME)obfsproxy-$(LANGCODE).zip 
$(NAME)_$(LANGCODE).app
-endif
+   zip -r $(DISTDIR)/$(COMPRESSED_NAME)$(LANGCODE).zip 
$(NAME)_$(LANGCODE).app
-rm -f *.zip *.xpi
 
 copy-files_%: generic-bundle.stamp
diff --git a/build-scripts/windows-alpha.mk b/build-scripts/windows-alpha.mk
index cb9e1ae..5847a34 100644
--- a/build-scripts/windows-alpha.mk
+++ b/build-scripts/windows-alpha.mk
@@ -373,9 +373,6 @@ bundle-localized: bundle-localized_$(LANGCODE).stamp
 
 compressed-bundle-localized: $(SEVENZIP) bundle-localized_$(LANGCODE).stamp
rm -f $(COMPRESSED_NAME)_$(LANGCODE).exe
-ifeq ($(USE_OBFSPROXY),1)
-   cd $(NAME)_$(LANGCODE); $(SEVENZIP) a -mx9 -sfx7z.sfx 
../$(COMPRESSED_NAME)-obfsproxy_$(LANGCODE).exe $(NAME)
-endif
cd $(NAME)_$(LANGCODE); $(SEVENZIP) a -mx9 -sfx7z.sfx 
../$(COMPRESSED_NAME)_$(LANGCODE).exe $(NAME)
 
 copy-files_%: generic-bundle.stamp



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


[tor-commits] [torbrowser/master] Merge branch 'maint-2.3'

2012-08-04 Thread erinn
commit a82e8fb15132a8e71b3f21a20b218f989e4e
Merge: 71dd3ae ba5724c
Author: Erinn Clark er...@torproject.org
Date:   Sat Aug 4 21:05:40 2012 +0100

Merge branch 'maint-2.3'

 build-scripts/linux-alpha.mk|5 +
 build-scripts/osx-alpha.mk  |7 ++-
 build-scripts/versions-alpha.mk |2 +-
 build-scripts/windows-alpha.mk  |5 +
 4 files changed, 5 insertions(+), 14 deletions(-)

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


[tor-commits] [stem/master] Parsing transport lines in non-bridge relays

2012-08-04 Thread atagar
commit 3f380f95876baffe48725828c23706dd9b46b760
Author: Damian Johnson ata...@torproject.org
Date:   Sat Aug 4 19:49:39 2012 -0700

Parsing transport lines in non-bridge relays

Spotted a relay in the wild with a transport line and asn thinks that, 
though
it's an oddity and doesn't make sense for non-bridges, this isn't a bug...
extra-info toorvoid 0B37323298FF98CD86ED404895BB27B7426E8AE1
published 2012-08-04 12:19:13
transport obfs2 83.212.96.201:33570

Expanding the parser to allow for it in any extrainfo descriptor.
---
 stem/descriptor/extrainfo_descriptor.py  |   29 ++---
 test/unit/descriptor/extrainfo_descriptor.py |8 +-
 2 files changed, 22 insertions(+), 15 deletions(-)

diff --git a/stem/descriptor/extrainfo_descriptor.py 
b/stem/descriptor/extrainfo_descriptor.py
index be2a6dc..8d66df6 100644
--- a/stem/descriptor/extrainfo_descriptor.py
+++ b/stem/descriptor/extrainfo_descriptor.py
@@ -179,6 +179,7 @@ class ExtraInfoDescriptor(stem.descriptor.Descriptor):
   :var str fingerprint: **\*** identity key fingerprint
   :var datetime published: **\*** time in GMT when this descriptor was made
   :var str geoip_db_digest: sha1 of geoIP database file
+  :var list transport: transport method recognized by the bridge (ex. obfs3)
   
   **Bi-directional connection usage:**
   
@@ -287,6 +288,7 @@ class ExtraInfoDescriptor(stem.descriptor.Descriptor):
 self.fingerprint = None
 self.published = None
 self.geoip_db_digest = None
+self.transport = None
 
 self.conn_bi_direct_end = None
 self.conn_bi_direct_interval = None
@@ -421,6 +423,19 @@ class ExtraInfoDescriptor(stem.descriptor.Descriptor):
   raise ValueError(Geoip digest line had an invalid sha1 digest: %s 
% line)
 
 self.geoip_db_digest = value
+  elif keyword == transport:
+# transport transportname address:port [arglist]
+# Everything after the transportname is scrubbed in published bridge
+# descriptors, so we'll never see it in practice.
+#
+# These entries really only make sense for bridges, but have been seen
+# on non-bridges in the wild when the relay operator configured it this
+# way.
+
+if self.transport is None:
+  self.transport = []
+
+self.transport.append(value)
   elif keyword == cell-circuits-per-decile:
 # cell-circuits-per-decile num
 
@@ -746,12 +761,10 @@ class BridgeExtraInfoDescriptor(ExtraInfoDescriptor):
   
   Bridge extra-info descriptor (`specification 
https://metrics.torproject.org/formats.html#bridgedesc`_)
   
-  :var list transport: transport method recognized by the bridge (ex. obfs3)
   
   
   def __init__(self, raw_contents, validate = True):
 self._digest = None
-self.transport = None
 
 super(BridgeExtraInfoDescriptor, self).__init__(raw_contents, validate)
   
@@ -766,17 +779,7 @@ class BridgeExtraInfoDescriptor(ExtraInfoDescriptor):
   value, _ = values[0]
   line = %s %s % (keyword, value) # original line
   
-  if keyword == transport:
-# transport transportname address:port [arglist]
-# Everything after the transportname is scrubbed in published bridge
-# descriptors, so we'll never see it in practice.
-
-if self.transport is None:
-  self.transport = []
-
-self.transport.append(value)
-del entries[transport]
-  elif keyword == router-digest:
+  if keyword == router-digest:
 if validate and not stem.util.tor_tools.is_hex_digits(value, 40):
   raise ValueError(Router digest line had an invalid sha1 digest: %s 
% line)
 
diff --git a/test/unit/descriptor/extrainfo_descriptor.py 
b/test/unit/descriptor/extrainfo_descriptor.py
index c40ac94..1008af7 100644
--- a/test/unit/descriptor/extrainfo_descriptor.py
+++ b/test/unit/descriptor/extrainfo_descriptor.py
@@ -522,14 +522,18 @@ class TestExtraInfoDescriptor(unittest.TestCase):
   
   def test_transport_line(self):
 
-Basic exercise of the bridge descriptor's transport entry.
-attributes.
+Basic exercise for both a bridge and relay's transport entry.
 
 
 desc_text = _make_descriptor({transport: obfs3}, is_bridge = True)
 desc = BridgeExtraInfoDescriptor(desc_text)
 self.assertEquals([obfs3], desc.transport)
 self.assertEquals([], desc.get_unrecognized_lines())
+
+desc_text = _make_descriptor({transport: obfs2 83.212.96.201:33570})
+desc = RelayExtraInfoDescriptor(desc_text)
+self.assertEquals([obfs2 83.212.96.201:33570], desc.transport)
+self.assertEquals([], desc.get_unrecognized_lines())
   
   def _expect_invalid_attr(self, desc_text, attr = None, expected_value = 
None):
 

___
tor-commits mailing list
tor-commits@lists.torproject.org

[tor-commits] [stem/master] GETINFO caching and logging

2012-08-04 Thread atagar
commit 73fcfaf8ccbc2c1cb714f35fcc8e2823daf39808
Author: Damian Johnson ata...@torproject.org
Date:   Sat Aug 4 18:52:33 2012 -0700

GETINFO caching and logging

Caching static GETINFO results, short circuiting geoip lookups when the 
geoip
db is unavailable, and logging the call runtimes.
---
 stem/control.py  |  139 +++---
 stem/response/getinfo.py |   18 ++
 2 files changed, 137 insertions(+), 20 deletions(-)

diff --git a/stem/control.py b/stem/control.py
index 16bcb10..673261c 100644
--- a/stem/control.py
+++ b/stem/control.py
@@ -9,10 +9,13 @@ interacting at a higher level.
 
 ::
 
-  from_port - Provides a Controller based on a port connection.
-  from_socket_file - Provides a Controller based on a socket file connection.
-  
   Controller - General controller class intended for direct use.
+| |- from_port - Provides a Controller based on a port connection.
+| +- from_socket_file - Provides a Controller based on a socket file 
connection.
+|
+|- is_caching_enabled - true if the controller has enabled caching
+|- is_geoip_unavailable - true if we've discovered our geoip db to be 
unavailable
+|- clear_cache - clears any cached results
 |- get_info - issues a GETINFO query for a parameter
 |- get_conf - gets the value of a configuration option
 |- get_conf_mapping - gets the values of multiple configuration options
@@ -72,6 +75,24 @@ MAPPED_CONFIG_KEYS = {
   hiddenserviceoptions: HiddenServiceOptions
 }
 
+# unchangeable GETINFO parameters
+CACHEABLE_GETINFO_PARAMS = (
+  'version',
+  'config-file',
+  'exit-policy/default',
+  'fingerprint',
+  'config/names',
+  'config/defaults',
+  'info/names',
+  'events/names',
+  'features/names',
+  'process/descriptor-limit',
+)
+
+# number of sequential attempts before we decide that the Tor geoip database
+# is unavailable
+GEOIP_FAILURE_THRESHOLD = 5
+
 # TODO: The Thread's isAlive() method and theading's currentThread() was
 # changed to the more conventional is_alive() and current_thread() in python
 # 2.6 and above. We should use that when dropping python 2.5 compatability.
@@ -454,6 +475,19 @@ class Controller(BaseController):
   from_port = staticmethod(from_port)
   from_socket_file = staticmethod(from_socket_file)
   
+  def __init__(self, control_socket, enable_caching = True):
+super(Controller, self).__init__(control_socket)
+
+self._is_caching_enabled = enable_caching
+self._request_cache = {}
+
+# number of sequental 'GETINFO ip-to-country/*' lookups that have failed
+self._geoip_failure_count = 0
+  
+  def connect(self):
+super(Controller, self).connect()
+self.clear_cache()
+  
   def close(self):
 # making a best-effort attempt to quit before detaching the socket
 if self.is_alive():
@@ -462,7 +496,38 @@ class Controller(BaseController):
 
 super(Controller, self).close()
   
-  def get_info(self, param, default = UNDEFINED):
+  def is_caching_enabled(self):
+
+True if caching has been enabled, False otherwise.
+
+:returns: bool to indicate if caching is enabled
+
+
+return self._is_caching_enabled
+  
+  def is_geoip_unavailable(self):
+
+Provides True if we've concluded hat our geoip database is unavailable,
+False otherwise. This is determined by having our 'GETINFO ip-to-country/*'
+lookups fail so this will default to False if we aren't making those
+queries.
+
+Geoip failures will be untracked if caching is disabled.
+
+:returns: bool to indicate if we've concluded our geoip database to be 
unavailable or not
+
+
+return self._geoip_failure_count = GEOIP_FAILURE_THRESHOLD
+  
+  def clear_cache(self):
+
+Drops any cached results.
+
+
+self._request_cache = {}
+self._geoip_failure_count = 0
+  
+  def get_info(self, params, default = UNDEFINED):
 
 Queries the control socket for the given GETINFO option. If provided a
 default then that's returned if the GETINFO option is undefined or the
@@ -484,35 +549,69 @@ class Controller(BaseController):
   :class:`stem.socket.InvalidArguments` if the 'param' requested was 
invalid
 
 
-# TODO: add caching?
-# TODO: special geoip handling?
-# TODO: add logging, including call runtime
+start_time = time.time()
+reply = {}
 
-if isinstance(param, str):
+if isinstance(params, str):
   is_multiple = False
-  param = [param]
+  params = set([params])
 else:
+  if not params: return {}
   is_multiple = True
+  params = set(params)
+
+# check for cached results
+for param in list(params):
+  cache_key = getinfo.%s % param.lower()
+  
+  if cache_key in self._request_cache:
+reply[param] = self._request_cache[cache_key]
+params.remove(param)
+  elif param.startswith('ip-to-country/') and self.is_geoip_unavailable():
+

[tor-commits] [tor/release-0.2.2] bump to 0.2.2.37-dev

2012-08-04 Thread arma
commit 421fe0c1c12f544fa9d02d2f10792c503db95f89
Author: Roger Dingledine a...@torproject.org
Date:   Sun Aug 5 01:24:00 2012 -0400

bump to 0.2.2.37-dev
---
 configure.in |2 +-
 contrib/tor-mingw.nsi.in |2 +-
 src/win32/orconfig.h |2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/configure.in b/configure.in
index 4cf21b3..1b6827b 100644
--- a/configure.in
+++ b/configure.in
@@ -4,7 +4,7 @@ dnl Copyright (c) 2007-2008, The Tor Project, Inc.
 dnl See LICENSE for licensing information
 
 AC_INIT
-AM_INIT_AUTOMAKE(tor, 0.2.2.37)
+AM_INIT_AUTOMAKE(tor, 0.2.2.37-dev)
 AM_CONFIG_HEADER(orconfig.h)
 
 AC_CANONICAL_HOST
diff --git a/contrib/tor-mingw.nsi.in b/contrib/tor-mingw.nsi.in
index 95cfab7..e859a38 100644
--- a/contrib/tor-mingw.nsi.in
+++ b/contrib/tor-mingw.nsi.in
@@ -8,7 +8,7 @@
 !include LogicLib.nsh
 !include FileFunc.nsh
 !insertmacro GetParameters
-!define VERSION 0.2.2.37
+!define VERSION 0.2.2.37-dev
 !define INSTALLER tor-${VERSION}-win32.exe
 !define WEBSITE https://www.torproject.org/;
 !define LICENSE LICENSE
diff --git a/src/win32/orconfig.h b/src/win32/orconfig.h
index d139eb9..7ed5171 100644
--- a/src/win32/orconfig.h
+++ b/src/win32/orconfig.h
@@ -233,5 +233,5 @@
 #define USING_TWOS_COMPLEMENT
 
 /* Version number of package */
-#define VERSION 0.2.2.37
+#define VERSION 0.2.2.37-dev
 

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


[tor-commits] [tor/release-0.2.3] fold in more changes files

2012-08-04 Thread arma
commit 8c7e8c702715fa7f92196075ec2178d5ec71d4a3
Author: Roger Dingledine a...@torproject.org
Date:   Sun Aug 5 01:25:59 2012 -0400

fold in more changes files
---
 ChangeLog |   44 
 1 files changed, 36 insertions(+), 8 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 7998df5..3e5465d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,22 +1,50 @@
-Changes in version 0.2.3.20-rc - 2012-08-??
-  o Major bugfixes:
-- When disabling guards for having too high a proportion of failed
-  circuits, make sure to look at each guard. Fixes bug 6397; bugfix
-  on 0.2.3.17-beta.
+Changes in version 0.2.3.20-rc - 2012-08-05
+  o Security fixes:
+- Avoid read-from-freed-memory and double-free bugs that could occur
+  when a DNS request fails while launching it. Fixes bug 6480;
+  bugfix on 0.2.0.1-alpha.
+- Avoid an uninitialized memory read when reading a vote or consensus
+  document that has an unrecognized flavor name. This read could
+  lead to a remote crash bug. Fixes bug 6530; bugfix on 0.2.2.6-alpha.
+- Try to leak less information about what relays a client is
+  choosing to a side-channel attacker. Previously, a Tor client would
+  stop iterating through the list of available relays as soon as it
+  had chosen one, thus finishing a little earlier when it picked
+  a router earlier in the list. If an attacker can recover this
+  timing information (nontrivial but not proven to be impossible),
+  they could learn some coarse-grained information about which relays
+  a client was picking (middle nodes in particular are likelier to
+  be affected than exits). The timing attack might be mitigated by
+  other factors (see bug 6537 for some discussion), but it's best
+  not to take chances. Fixes bug 6537; bugfix on 0.0.8rc1.
 
   o Minor features:
+- Try to make the warning when giving an obsolete SOCKSListenAddress
+  a little more useful.
 - Terminate active server managed proxies if Tor stops being a
   relay. Addresses parts of bug 6274; bugfix on 0.2.3.6-alpha.
 - Provide a better error message about possible OSX Asciidoc failure
-  reasons. Fix for bug 6436.
-- Try to make the warning when giving an obsolete SOCKSListenAddress
-  a little more useful.
+  reasons. Fixes bug 6436.
+- Warn when Tor is configured to use accounting in a way that can
+  link a hidden service to some other hidden service or public
+  address. Resolves ticket 6490.
 
   o Minor bugfixes:
 - Check return value of fputs() when writing authority certificate
   file. Fixes Coverity issue 709056; bugfix on 0.2.0.1-alpha.
 - Ignore ServerTransportPlugin lines when Tor is not configured as
   a relay. Fixes bug 6274; bugfix on 0.2.3.6-alpha.
+- When disabling guards for having too high a proportion of failed
+  circuits, make sure to look at each guard. Fixes bug 6397; bugfix
+  on 0.2.3.17-beta.
+- Fix some typos in the manpages. Patch from A. Costa. Fixes bug 6500.
+
+  o Packaging (RPM):
+- Update our default RPM spec files to work with mock and rpmbuild
+  on RHEL/Fedora. They have an updated set of dependencies and
+  conflicts, a fix for an ancient typo when creating the _tor
+  user, and better instructions. Thanks to Ondrej Mikle for the
+  patch series. Fixes bug 6043.
 
   o Testing:
 - Make it possible to set the TestingTorNetwork configuration

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