[tor-commits] [translation/tails-misc] Update translations for tails-misc

2014-04-01 Thread translation
commit 804c3a0ba79e61e772c1a81b9359ea16f8402200
Author: Translation commit bot translat...@torproject.org
Date:   Tue Apr 1 07:15:35 2014 +

Update translations for tails-misc
---
 zh_CN.po |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/zh_CN.po b/zh_CN.po
index db61b78..6f37b33 100644
--- a/zh_CN.po
+++ b/zh_CN.po
@@ -12,7 +12,7 @@ msgstr 
 Project-Id-Version: The Tor Project\n
 Report-Msgid-Bugs-To: \n
 POT-Creation-Date: 2014-03-23 08:55+0100\n
-PO-Revision-Date: 2014-04-01 04:41+\n
+PO-Revision-Date: 2014-04-01 07:05+\n
 Last-Translator: Jiong Meng\n
 Language-Team: Chinese (China) 
(http://www.transifex.com/projects/p/torproject/language/zh_CN/)\n
 MIME-Version: 1.0\n

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


[tor-commits] [translation/tails-misc_completed] Update translations for tails-misc_completed

2014-04-01 Thread translation
commit 62cb56324f754fe7d407bee1733fdc2de5e39201
Author: Translation commit bot translat...@torproject.org
Date:   Tue Apr 1 07:15:38 2014 +

Update translations for tails-misc_completed
---
 zh_CN.po |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/zh_CN.po b/zh_CN.po
index db61b78..6f37b33 100644
--- a/zh_CN.po
+++ b/zh_CN.po
@@ -12,7 +12,7 @@ msgstr 
 Project-Id-Version: The Tor Project\n
 Report-Msgid-Bugs-To: \n
 POT-Creation-Date: 2014-03-23 08:55+0100\n
-PO-Revision-Date: 2014-04-01 04:41+\n
+PO-Revision-Date: 2014-04-01 07:05+\n
 Last-Translator: Jiong Meng\n
 Language-Team: Chinese (China) 
(http://www.transifex.com/projects/p/torproject/language/zh_CN/)\n
 MIME-Version: 1.0\n

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


[tor-commits] [support-tools/master] Add queue graphs data for March 2014

2014-04-01 Thread lunar
commit 3eb13fac22732eaa67e34186200575debb95fe5a
Author: Lunar lu...@torproject.org
Date:   Tue Apr 1 11:11:57 2014 +0200

Add queue graphs data for March 2014
---
 queue-graphs/data/2014Q1.csv |6 ++
 1 file changed, 6 insertions(+)

diff --git a/queue-graphs/data/2014Q1.csv b/queue-graphs/data/2014Q1.csv
index 3e945b4..8be8a5a 100644
--- a/queue-graphs/data/2014Q1.csv
+++ b/queue-graphs/data/2014Q1.csv
@@ -11,3 +11,9 @@ month,queue,newtickets
 2014-02,fa,57
 2014-02,fr,39
 2014-02,zh,76
+2014-03,ar,14
+2014-03,en,1387
+2014-03,es,65
+2014-03,fa,54
+2014-03,fr,37
+2014-03,zh,80



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


[tor-commits] [support-tools/master] Add response time graphs data for 2014Q1

2014-04-01 Thread lunar
commit 780139a57259fb0dbad798dda66530d41de9d9e6
Author: Lunar lu...@torproject.org
Date:   Tue Apr 1 11:28:06 2014 +0200

Add response time graphs data for 2014Q1
---
 response-time/data/2014Q1.csv |  688 +
 1 file changed, 688 insertions(+)

diff --git a/response-time/data/2014Q1.csv b/response-time/data/2014Q1.csv
new file mode 100644
index 000..acb7d2a
--- /dev/null
+++ b/response-time/data/2014Q1.csv
@@ -0,0 +1,688 @@
+month,fromhours,tohours,requests
+2014-01,0,1,634
+2014-01,1,2,247
+2014-01,2,3,170
+2014-01,3,4,134
+2014-01,4,5,131
+2014-01,5,6,62
+2014-01,6,7,85
+2014-01,7,8,81
+2014-01,8,9,68
+2014-01,9,10,60
+2014-01,10,11,72
+2014-01,11,12,64
+2014-01,12,13,55
+2014-01,13,14,45
+2014-01,14,15,34
+2014-01,15,16,36
+2014-01,16,17,32
+2014-01,17,18,34
+2014-01,18,19,33
+2014-01,19,20,48
+2014-01,20,21,36
+2014-01,21,22,31
+2014-01,22,23,23
+2014-01,23,24,29
+2014-01,24,25,13
+2014-01,25,26,23
+2014-01,26,27,18
+2014-01,27,28,15
+2014-01,28,29,22
+2014-01,29,30,17
+2014-01,30,31,17
+2014-01,31,32,10
+2014-01,32,33,8
+2014-01,33,34,14
+2014-01,34,35,11
+2014-01,35,36,4
+2014-01,36,37,10
+2014-01,37,38,10
+2014-01,38,39,11
+2014-01,39,40,4
+2014-01,40,41,9
+2014-01,41,42,8
+2014-01,42,43,11
+2014-01,43,44,9
+2014-01,44,45,12
+2014-01,45,46,8
+2014-01,46,47,15
+2014-01,47,48,17
+2014-01,48,49,5
+2014-01,49,50,9
+2014-01,50,51,7
+2014-01,51,52,10
+2014-01,52,53,5
+2014-01,53,54,1
+2014-01,54,55,6
+2014-01,55,56,9
+2014-01,56,57,8
+2014-01,57,58,1
+2014-01,58,59,4
+2014-01,59,60,7
+2014-01,60,61,3
+2014-01,61,62,3
+2014-01,62,63,5
+2014-01,63,64,2
+2014-01,64,65,5
+2014-01,65,66,3
+2014-01,66,67,4
+2014-01,67,68,6
+2014-01,68,69,10
+2014-01,69,70,7
+2014-01,70,71,6
+2014-01,71,72,4
+2014-01,72,73,5
+2014-01,73,74,5
+2014-01,74,75,4
+2014-01,75,76,5
+2014-01,76,77,4
+2014-01,78,79,2
+2014-01,79,80,7
+2014-01,80,81,2
+2014-01,81,82,2
+2014-01,82,83,4
+2014-01,83,84,1
+2014-01,84,85,3
+2014-01,85,86,8
+2014-01,86,87,4
+2014-01,87,88,1
+2014-01,89,90,3
+2014-01,90,91,4
+2014-01,91,92,2
+2014-01,92,93,2
+2014-01,93,94,3
+2014-01,94,95,2
+2014-01,95,96,3
+2014-01,97,98,1
+2014-01,98,99,2
+2014-01,99,100,2
+2014-01,100,101,2
+2014-01,103,104,1
+2014-01,104,105,1
+2014-01,105,106,3
+2014-01,107,108,1
+2014-01,108,109,1
+2014-01,111,112,2
+2014-01,112,113,1
+2014-01,115,116,1
+2014-01,116,117,2
+2014-01,117,118,3
+2014-01,118,119,2
+2014-01,119,120,1
+2014-01,120,121,3
+2014-01,121,122,2
+2014-01,124,125,1
+2014-01,125,126,1
+2014-01,126,127,1
+2014-01,127,128,1
+2014-01,128,129,3
+2014-01,129,130,1
+2014-01,132,133,1
+2014-01,133,134,1
+2014-01,134,135,1
+2014-01,135,136,1
+2014-01,138,139,1
+2014-01,142,143,1
+2014-01,146,147,4
+2014-01,147,148,1
+2014-01,149,150,1
+2014-01,150,151,1
+2014-01,152,153,1
+2014-01,153,154,2
+2014-01,154,155,1
+2014-01,155,156,1
+2014-01,160,161,3
+2014-01,162,163,1
+2014-01,165,166,3
+2014-01,167,168,1
+2014-01,168,169,1
+2014-01,170,171,1
+2014-01,171,172,1
+2014-01,172,173,2
+2014-01,173,174,2
+2014-01,175,176,1
+2014-01,176,177,1
+2014-01,177,178,2
+2014-01,182,183,3
+2014-01,183,184,3
+2014-01,190,191,1
+2014-01,193,194,1
+2014-01,196,197,2
+2014-01,198,199,2
+2014-01,200,201,1
+2014-01,209,210,1
+2014-01,212,213,1
+2014-01,213,214,1
+2014-01,214,215,1
+2014-01,215,216,2
+2014-01,223,224,1
+2014-01,229,230,1
+2014-01,230,231,2
+2014-01,231,232,2
+2014-01,232,233,1
+2014-01,234,235,2
+2014-01,239,240,1
+2014-01,243,244,1
+2014-01,246,247,1
+2014-01,247,248,1
+2014-01,248,249,1
+2014-01,252,253,1
+2014-01,253,254,1
+2014-01,254,255,1
+2014-01,260,261,1
+2014-01,270,271,1
+2014-01,272,273,1
+2014-01,275,276,1
+2014-01,283,284,1
+2014-01,286,287,1
+2014-01,289,290,1
+2014-01,290,291,2
+2014-01,298,299,2
+2014-01,311,312,1
+2014-01,314,315,1
+2014-01,319,320,1
+2014-01,335,336,2
+2014-01,336,337,1
+2014-01,337,338,1
+2014-01,341,342,1
+2014-01,345,346,1
+2014-01,349,350,1
+2014-01,358,359,2
+2014-01,359,360,2
+2014-01,381,382,1
+2014-01,388,389,1
+2014-01,405,406,1
+2014-01,422,423,1
+2014-01,428,429,1
+2014-01,430,431,2
+2014-01,437,438,3
+2014-01,444,445,1
+2014-01,462,463,1
+2014-01,486,487,1
+2014-01,505,506,1
+2014-01,506,507,1
+2014-01,529,530,1
+2014-01,533,534,1
+2014-01,543,544,1
+2014-01,544,545,1
+2014-01,562,563,1
+2014-01,566,567,1
+2014-01,567,568,1
+2014-01,593,594,1
+2014-01,606,607,1
+2014-01,639,640,1
+2014-01,650,651,1
+2014-01,656,657,1
+2014-01,674,675,1
+2014-01,689,690,1
+2014-01,690,691,1
+2014-01,758,759,1
+2014-01,760,761,2
+2014-01,767,768,1
+2014-01,771,772,1
+2014-01,782,783,1
+2014-01,786,787,1
+2014-01,794,795,1
+2014-01,803,804,1
+2014-01,805,806,1
+2014-01,810,811,1
+2014-01,816,817,1
+2014-01,820,821,1
+2014-01,828,829,1
+2014-01,830,831,1
+2014-01,835,836,2
+2014-01,836,837,1
+2014-01,837,838,1
+2014-01,838,839,1
+2014-01,841,842,1
+2014-01,844,845,1
+2014-01,847,848,1
+2014-01,851,852,2
+2014-01,852,853,1
+2014-01,853,854,1
+2014-01,855,856,1
+2014-01,856,857,1
+2014-01,857,858,1
+2014-01,858,859,2

[tor-commits] [metrics-web/master] Fix NAs in top-10 countries by censorship events.

2014-04-01 Thread karsten
commit 1d492563cfd1f9f1b0d3e62a4ac6c47c011f3e38
Author: Karsten Loesing karsten.loes...@gmx.net
Date:   Tue Apr 1 11:44:22 2014 +0200

Fix NAs in top-10 countries by censorship events.

Spotted by sysrqb.
---
 website/rserve/tables.R |6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/website/rserve/tables.R b/website/rserve/tables.R
index 3e5fcb4..e8c02cc 100644
--- a/website/rserve/tables.R
+++ b/website/rserve/tables.R
@@ -39,8 +39,10 @@ write_userstats_censorship_events - function(start, end, 
path) {
   c - c[c$date = start  c$date = end  c$country != '' 
  c$transport == ''  c$version == ''  c$node == 'relay', ]
   r - data.frame(date = c$date, country = c$country,
-  upturn = ifelse(c$clients  c$upper, 1, 0),
-  downturn = ifelse(c$clients = c$lower, 1, 0))
+  upturn = ifelse(!is.na(c$upper) 
+  c$clients  c$upper, 1, 0),
+  downturn = ifelse(!is.na(c$lower) 
+c$clients = c$lower, 1, 0))
   r - aggregate(r[, c(upturn, downturn)],
 by = list(country = r$country), sum)
   r - r[!(r$country %in% c(zy, ??, a1, a2, o1, ap, eu)), ]

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


[tor-commits] [translation/tor-launcher-properties] Update translations for tor-launcher-properties

2014-04-01 Thread translation
commit 2aeb33983fc170e60240d3651c8ef6d2ed38dfe2
Author: Translation commit bot translat...@torproject.org
Date:   Tue Apr 1 15:15:31 2014 +

Update translations for tor-launcher-properties
---
 eu/torlauncher.properties |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/eu/torlauncher.properties b/eu/torlauncher.properties
index 838288a..2d57a88 100644
--- a/eu/torlauncher.properties
+++ b/eu/torlauncher.properties
@@ -7,7 +7,7 @@ torlauncher.tor_exited=Tor ustekabean irten da.
 torlauncher.please_restart_app=Mesedez aplikazio hau berrabiarazi ezazu.
 torlauncher.tor_controlconn_failed=Tor kontrol atakara ezin konektatu.
 torlauncher.tor_failed_to_start=Torek huts egin du abiarazterakoan.
-torlauncher.tor_control_failed=Failed to take control of Tor.
+torlauncher.tor_control_failed=Huts Toren kontrola hartzerakoan.
 torlauncher.tor_bootstrap_failed=Torek huts egin du Tor sare konexio bat 
ezartzerakoan.
 torlauncher.tor_bootstrap_failed_details=%1$S huts egin du (%2$S).
 
@@ -24,10 +24,10 @@ torlauncher.ensure_tor_is_running=Mesedez egiaztatu Tor 
exekutatzen ari dela.
 torlauncher.error_proxy_addr_missing=Torek proxy bat erabiliz Interneten 
sartzeko konfiguratu nahi baduzu edo IP helbidea edo ostalari-izena edo portu 
zenbakia zehaztu behar duzu.
 torlauncher.error_proxy_type_missing=Proxy mota hautatu behar duzu.
 torlauncher.error_bridges_missing=Zubi bat edo gehiago zehaztu behar duzu.
-torlauncher.error_default_bridges_type_missing=You must select a transport 
type for the provided bridges.
-torlauncher.error_bridge_bad_default_type=No provided bridges that have the 
transport type %S are available. Please adjust your settings.
+torlauncher.error_default_bridges_type_missing=Emandako zubietarako garraio 
mota bat hautatu behar duzu.
+torlauncher.error_bridge_bad_default_type=Ez daude eskuragarri %S garraio mota 
duten emandako zubirik. Mesedez doitu zure ezarpenak.
 
-torlauncher.recommended_bridge=(recommended)
+torlauncher.recommended_bridge=(gomendatuta)
 
 torlauncher.connect=Konektatu
 torlauncher.quit=Irten

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


[tor-commits] [translation/tails-iuk] Update translations for tails-iuk

2014-04-01 Thread translation
commit 87903b817741e79aedb73485d0f427468d3344d6
Author: Translation commit bot translat...@torproject.org
Date:   Tue Apr 1 15:15:55 2014 +

Update translations for tails-iuk
---
 ar.po |   11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/ar.po b/ar.po
index 6ab8991..4427f79 100644
--- a/ar.po
+++ b/ar.po
@@ -7,13 +7,14 @@
 # Mohammed ALDOUB voul...@gmail.com, 2014
 # ramli_omar ramli_o...@hotmail.com, 2014
 # Sherief Alaa sheriefala...@gmail.com, 2013-2014
+# uzumaki tx9...@hotmail.com, 2014
 msgid 
 msgstr 
 Project-Id-Version: The Tor Project\n
 Report-Msgid-Bugs-To: Tails developers ta...@boum.org\n
 POT-Creation-Date: 2014-03-05 15:11+0100\n
-PO-Revision-Date: 2014-03-06 08:17+\n
-Last-Translator: runasand runa.sand...@gmail.com\n
+PO-Revision-Date: 2014-04-01 15:02+\n
+Last-Translator: uzumaki tx9...@hotmail.com\n
 Language-Team: Arabic 
(http://www.transifex.com/projects/p/torproject/language/ar/)\n
 MIME-Version: 1.0\n
 Content-Type: text/plain; charset=UTF-8\n
@@ -49,11 +50,11 @@ msgstr 
 
 #: ../lib/Tails/IUK/Frontend.pm:245
 msgid Tails was started from a DVD or a read-only device
-msgstr 
+msgstr تم تشغيل Tails انطلاقا من قرص DVD أو من 
جهاز قابل للقراءة فقط
 
 #: ../lib/Tails/IUK/Frontend.pm:250
 msgid there is not enough free space on the Tails system partition
-msgstr 
+msgstr لا يوجد مكان فارغ كافٍ في تقسيم نظام 
Tails
 
 #: ../lib/Tails/IUK/Frontend.pm:255
 msgid not enough memory is available on this system
@@ -62,7 +63,7 @@ msgstr ذاكرة غير كافية في هذا النظام
 #: ../lib/Tails/IUK/Frontend.pm:261
 #, perl-brace-format
 msgid No explanation available for reason '%{reason}s'.
-msgstr 
+msgstr لا يوجد تفسير لهذا الأمر '%{reason}s'.
 
 #: ../lib/Tails/IUK/Frontend.pm:281
 msgid The system is up-to-date

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


[tor-commits] [tor/master] Fix a ubsan warning in addr_mask_get_bits

2014-04-01 Thread nickm
commit dfdeb6418d3d99e6e9099a3ad8ca83c206b52bdc
Author: Nick Mathewson ni...@torproject.org
Date:   Tue Mar 18 10:49:39 2014 -0400

Fix a ubsan warning in addr_mask_get_bits

ubsan doesn't like us to do (1u32) when 32 is wider than
unsigned.  Fortunately, we already special-case
addr_mask_get_bits(0), so we can just change the loop bounds.
---
 src/common/address.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/common/address.c b/src/common/address.c
index 69049fa..bb1a244 100644
--- a/src/common/address.c
+++ b/src/common/address.c
@@ -1585,7 +1585,7 @@ addr_mask_get_bits(uint32_t mask)
 return 0;
   if (mask == 0xu)
 return 32;
-  for (i=0; i=32; ++i) {
+  for (i=1; i=32; ++i) {
 if (mask == (uint32_t) ~((1u(32-i))-1)) {
   return i;
 }



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


[tor-commits] [tor/master] Fix a ubsan warning in our ctypes replacements

2014-04-01 Thread nickm
commit 2aea6ca3260cee82a60168c047f4d0cc71f7c652
Author: Nick Mathewson ni...@torproject.org
Date:   Tue Mar 18 10:47:26 2014 -0400

Fix a ubsan warning in our ctypes replacements

ubsan doesn't like 131, since that's an undefined integer
overflow.  Instead, we should do 1u31.
---
 src/common/compat.h |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/common/compat.h b/src/common/compat.h
index 32effa5..30a3303 100644
--- a/src/common/compat.h
+++ b/src/common/compat.h
@@ -321,7 +321,7 @@ tor_memstr(const void *haystack, size_t hlen, const char 
*needle)
   extern const uint32_t TOR_##name##_TABLE[];   \
   static INLINE int TOR_##name(char c) {\
 uint8_t u = c;  \
-return !!(TOR_##name##_TABLE[(u  5)  7]  (1  (u  31)));  \
+return !!(TOR_##name##_TABLE[(u  5)  7]  (1u  (u  31))); \
   }
 DECLARE_CTYPE_FN(ISALPHA)
 DECLARE_CTYPE_FN(ISALNUM)



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


[tor-commits] [tor/master] memarea.c: use flexible array member for mem

2014-04-01 Thread nickm
commit 204f7255f4c06fe12d99e785b91ea2fb18047018
Author: Nick Mathewson ni...@torproject.org
Date:   Tue Mar 18 10:02:27 2014 -0400

memarea.c: use flexible array member for mem

This make clang's memory sanitizer happier that we aren't reading
off the end of a char[1].  We hadn't replaced the char[1] with a
char[FLEXIBLE_ARRAY_MEMBER] before because we were doing a union
trick to force alignment.  Now we use __attribute__(aligned) where
available, and we do the union trick elsewhere.

Most of this patch is just replacing accesses to (x)-u.mem with
(x)-U_MEM, where U_MEM is defined as u.mem or mem depending on
our implementation.
---
 src/common/memarea.c |   43 +++
 1 file changed, 27 insertions(+), 16 deletions(-)

diff --git a/src/common/memarea.c b/src/common/memarea.c
index 0ae0ccc..e2d07fc 100644
--- a/src/common/memarea.c
+++ b/src/common/memarea.c
@@ -29,6 +29,13 @@
 #error void* is neither 4 nor 8 bytes long. I don't know how to align stuff.
 #endif
 
+#if defined(__GNUC__)  defined(FLEXIBLE_ARRAY_MEMBER)
+#define USE_ALIGNED_ATTRIBUTE
+#define U_MEM mem
+#else
+#define U_MEM u.mem
+#endif
+
 #ifdef USE_SENTINELS
 /** Magic value that we stick at the end of a memarea so we can make sure
  * there are no run-off-the-end bugs. */
@@ -39,12 +46,12 @@
  * end, set those bytes. */
 #define SET_SENTINEL(chunk) \
   STMT_BEGIN\
-  set_uint32( (chunk)-u.mem[chunk-mem_size], SENTINEL_VAL ); \
+  set_uint32( (chunk)-U_MEM[chunk-mem_size], SENTINEL_VAL ); \
   STMT_END
 /** Assert that the sentinel on a memarea is set correctly. */
 #define CHECK_SENTINEL(chunk)   \
   STMT_BEGIN\
-  uint32_t sent_val = get_uint32((chunk)-u.mem[chunk-mem_size]); \
+  uint32_t sent_val = get_uint32((chunk)-U_MEM[chunk-mem_size]); \
   tor_assert(sent_val == SENTINEL_VAL); \
   STMT_END
 #else
@@ -71,19 +78,23 @@ realign_pointer(void *ptr)
 typedef struct memarea_chunk_t {
   /** Next chunk in this area. Only kept around so we can free it. */
   struct memarea_chunk_t *next_chunk;
-  size_t mem_size; /** How much RAM is available in u.mem, total? */
-  char *next_mem; /** Next position in u.mem to allocate data at.  If it's
+  size_t mem_size; /** How much RAM is available in mem, total? */
+  char *next_mem; /** Next position in mem to allocate data at.  If it's
* greater than or equal to mem+mem_size, this chunk is
* full. */
+#ifdef USE_ALIGNED_ATTRIBUTE
+  char mem[FLEXIBLE_ARRAY_MEMBER] __attribute__((aligned(MEMAREA_ALIGN)));
+#else
   union {
 char mem[1]; /** Memory space in this chunk.  */
 void *void_for_alignment_; /** Dummy; used to make sure mem is aligned. */
   } u;
+#endif
 } memarea_chunk_t;
 
 /** How many bytes are needed for overhead before we get to the memory part
  * of a chunk? */
-#define CHUNK_HEADER_SIZE STRUCT_OFFSET(memarea_chunk_t, u)
+#define CHUNK_HEADER_SIZE STRUCT_OFFSET(memarea_chunk_t, U_MEM)
 
 /** What's the smallest that we'll allocate a chunk? */
 #define CHUNK_SIZE 4096
@@ -121,7 +132,7 @@ alloc_chunk(size_t sz, int freelist_ok)
 res = tor_malloc(chunk_size);
 res-next_chunk = NULL;
 res-mem_size = chunk_size - CHUNK_HEADER_SIZE - SENTINEL_LEN;
-res-next_mem = res-u.mem;
+res-next_mem = res-U_MEM;
 tor_assert(res-next_mem+res-mem_size+SENTINEL_LEN ==
((char*)res)+chunk_size);
 tor_assert(realign_pointer(res-next_mem) == res-next_mem);
@@ -140,7 +151,7 @@ chunk_free_unchecked(memarea_chunk_t *chunk)
 ++freelist_len;
 chunk-next_chunk = freelist;
 freelist = chunk;
-chunk-next_mem = chunk-u.mem;
+chunk-next_mem = chunk-U_MEM;
   } else {
 tor_free(chunk);
   }
@@ -183,7 +194,7 @@ memarea_clear(memarea_t *area)
 }
 area-first-next_chunk = NULL;
   }
-  area-first-next_mem = area-first-u.mem;
+  area-first-next_mem = area-first-U_MEM;
 }
 
 /** Remove all unused memarea chunks from the internal freelist. */
@@ -207,7 +218,7 @@ memarea_owns_ptr(const memarea_t *area, const void *p)
   memarea_chunk_t *chunk;
   const char *ptr = p;
   for (chunk = area-first; chunk; chunk = chunk-next_chunk) {
-if (ptr = chunk-u.mem  ptr  chunk-next_mem)
+if (ptr = chunk-U_MEM  ptr  chunk-next_mem)
   return 1;
   }
   return 0;
@@ -226,7 +237,7 @@ memarea_alloc(memarea_t *area, size_t sz)
   tor_assert(sz  SIZE_T_CEILING);
   if (sz == 0)
 sz = 1;
-  if (chunk-next_mem+sz  chunk-u.mem+chunk-mem_size) {
+  if (chunk-next_mem+sz  chunk-U_MEM+chunk-mem_size) {
 if (sz+CHUNK_HEADER_SIZE = CHUNK_SIZE) {
   /* This allocation is too big.  Stick it in a special chunk, and put
* that chunk second in the list. */
@@ -244,8 +255,8 @@ memarea_alloc(memarea_t 

[tor-commits] [tor/master] Merge remote-tracking branch 'public/bug11232'

2014-04-01 Thread nickm
commit 6bef082d0a6047fd3625f548d60ad257aaed2fab
Merge: c0441cc 61090bb
Author: Nick Mathewson ni...@torproject.org
Date:   Tue Apr 1 09:39:48 2014 -0400

Merge remote-tracking branch 'public/bug11232'

 changes/bug11232|4 
 src/common/address.c|2 +-
 src/common/compat.h |2 +-
 src/common/memarea.c|   43 +++
 src/ext/csiphash.c  |5 +
 src/test/test_circuitlist.c |6 +++---
 6 files changed, 41 insertions(+), 21 deletions(-)

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


[tor-commits] [tor/master] Fix a use-after-free in test_circuitlist.c

2014-04-01 Thread nickm
commit 98b1aad2018b572e19d2404ea7369afa2d0c4b05
Author: Nick Mathewson ni...@torproject.org
Date:   Tue Mar 18 09:46:39 2014 -0400

Fix a use-after-free in test_circuitlist.c

Found by clang-3.4 analyzers.
---
 src/test/test_circuitlist.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/test/test_circuitlist.c b/src/test/test_circuitlist.c
index 720b407..54aa51d 100644
--- a/src/test/test_circuitlist.c
+++ b/src/test/test_circuitlist.c
@@ -150,13 +150,13 @@ test_clist_maps(void *arg)
   tt_assert(! circuit_id_in_use_on_channel(100, ch1));
 
  done:
-  tor_free(ch1);
-  tor_free(ch2);
-  tor_free(ch3);
   if (or_c1)
 circuit_free(TO_CIRCUIT(or_c1));
   if (or_c2)
 circuit_free(TO_CIRCUIT(or_c2));
+  tor_free(ch1);
+  tor_free(ch2);
+  tor_free(ch3);
   UNMOCK(circuitmux_attach_circuit);
   UNMOCK(circuitmux_detach_circuit);
 }



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


[tor-commits] [tor/master] changes file for bug11232

2014-04-01 Thread nickm
commit 61090bb64f03d5fd944535311191486d22b3134d
Author: Nick Mathewson ni...@torproject.org
Date:   Tue Mar 18 10:59:51 2014 -0400

changes file for bug11232
---
 changes/bug11232 |4 
 1 file changed, 4 insertions(+)

diff --git a/changes/bug11232 b/changes/bug11232
new file mode 100644
index 000..c1a8780
--- /dev/null
+++ b/changes/bug11232
@@ -0,0 +1,4 @@
+  o Minor bugfixes:
+- Use AddressSanitizer and Ubsan sanitizers (in clang-3.4) to fix some
+  miscellaneous errors in our tests and codebase. Fix for bug 11232.
+  Bugfixes on versions back as far as 0.2.1.11-alpha.



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


[tor-commits] [tor/master] csiphash: don't attempt unaligned access

2014-04-01 Thread nickm
commit aaa33f144c4ad0db0c067df2f6703790be400acb
Author: Nick Mathewson ni...@torproject.org
Date:   Tue Mar 18 10:43:46 2014 -0400

csiphash: don't attempt unaligned access

In digestmap_set/get benchmarks, doing unaligned access on x86
doesn't save more than a percent or so in the fast case.  In the
slow case (where we cross a cache line), it could be pretty
expensive.  It also makes ubsan unhappy.
---
 src/ext/csiphash.c |5 +
 1 file changed, 5 insertions(+)

diff --git a/src/ext/csiphash.c b/src/ext/csiphash.c
index 4f58c4a..2a96f28 100644
--- a/src/ext/csiphash.c
+++ b/src/ext/csiphash.c
@@ -81,11 +81,16 @@
HALF_ROUND(v0,v1,v2,v3,13,16);  \
HALF_ROUND(v2,v1,v0,v3,17,21);
 
+#if 0
+/* This does not seem to save very much runtime in the fast case, and it's
+ * potentially a big loss in the slow case where we're misaligned and we cross
+ * a cache line. */
 #if (defined(__i386) || defined(__i386__) || defined(_M_IX86) ||   \
  defined(__x86_64) || defined(__x86_64__) ||   \
  defined(_M_AMD64) || defined(_M_X64) || defined(__INTEL__))
 #   define UNALIGNED_OK 1
 #endif
+#endif
 
 uint64_t siphash24(const void *src, unsigned long src_sz, const struct sipkey 
*key) {
uint64_t k0 = key-k0;



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


[tor-commits] [bridgedb/develop] Return a database handle via generator

2014-04-01 Thread isis
commit 2a99f95e6bd7357c6adbd2e5f4f09b24d169f770
Author: Matthew Finkel matthew.fin...@gmail.com
Date:   Fri Mar 21 02:48:46 2014 +

Return a database handle via generator

Define a new idiom for retrieving an instance of
bridgedb.Storage.Database

Use:
with bridgedb.Storage.getDB() as db:
db.do stuff with the database
---
 lib/bridgedb/Storage.py |  156 ---
 1 file changed, 149 insertions(+), 7 deletions(-)

diff --git a/lib/bridgedb/Storage.py b/lib/bridgedb/Storage.py
index fdeea23..d9d8b29 100644
--- a/lib/bridgedb/Storage.py
+++ b/lib/bridgedb/Storage.py
@@ -9,10 +9,15 @@ import binascii
 import sqlite3
 import time
 import hashlib
+from contextlib import contextmanager
+from contextlib import GeneratorContextManager
+from functools import wraps
 from ipaddr import IPAddress, IPv6Address, IPv4Address
+import sys
 
 import bridgedb.Stability as Stability
 from bridgedb.Stability import BridgeHistory
+import threading
 
 toHex = binascii.b2a_hex
 fromHex = binascii.a2b_hex
@@ -201,13 +206,14 @@ class BridgeData:
 self.first_seen = first_seen
 self.last_seen = last_seen
 
-class Database:
+class Database(object):
 def __init__(self, sqlite_fname, db_fname=None):
 if db_fname is None:
 self._conn = openDatabase(sqlite_fname)
 else:
 self._conn = openOrConvertDatabase(sqlite_fname, db_fname)
 self._cur = self._conn.cursor()
+self.sqlite_fname = sqlite_fname
 
 def commit(self):
 self._conn.commit()
@@ -216,6 +222,7 @@ class Database:
 self._conn.rollback()
 
 def close(self):
+#print Closing DB
 self._cur.close()
 self._conn.close()
 
@@ -498,12 +505,147 @@ def openOrConvertDatabase(sqlite_file, db_file):
 conn.commit()
 return conn
 
-_THE_DB = None
+class DBGeneratorContextManager(GeneratorContextManager):
+Overload __exit__() so we can call the generator many times
+def __exit__(self, type, value, traceback):
+Significantly based on contextlib.py
+if type is None:
+try:
+self.gen.next()
+except StopIteration:
+return
+return
+else:
+if value is None:
+# Need to force instantiation so we can reliably
+# tell if we get the same exception back
+value = type()
+try:
+self.gen.throw(type, value, traceback)
+raise RuntimeError(generator didn't stop after throw())
+except StopIteration, exc:
+# Suppress the exception *unless* it's the same exception that
+# was passed to throw().  This prevents a StopIteration
+# raised inside the with statement from being suppressed
+return exc is not value
+except:
+# only re-raise if it's *not* the exception that was
+# passed to throw(), because __exit__() must not raise
+# an exception unless __exit__() itself failed.  But throw()
+# has to raise the exception to signal propagation, so this
+# fixes the impedance mismatch between the throw() protocol
+# and the __exit__() protocol.
+#
+if sys.exc_info()[1] is not value:
+raise
+def contextmanager(func):
+@wraps(func)
+def helper(*args, **kwds):
+return DBGeneratorContextManager(func(*args, **kwds))
+return helper
+
+_DB_FNAME = None
+_LOCK = None
+_LOCKED = False
+_OPENED_DB = None
+_TOC = None
+
+def clearGlobalDB():
+Start from scratch
+global _DB_FNAME
+global _LOCK
+global _LOCKED
+global _OPENED_DB
+global _TOC
+
+_DB_FNAME = None
+_LOCK = None
+_LOCKED = False
+_OPENED_DB = None
+_TOC = None
+
+def checkAndConvertDB(sqlite_file, db_file):
+openOrConvertDatabase(sqlite_file, db_file).close()
+
+def setDBFilename(sqlite_fname):
+global _DB_FNAME
+_DB_FNAME = sqlite_fname
+
+@contextmanager
+def getDB(block=True):
+Generator: Return a usable database handler
+
+Always return a :class:`bridgedb.Storage.Database` that is
+usable within the current thread. If a connection already exists
+and it was created by the current thread, then return the
+associated :class:`bridgedb.Storage.Database` instance. Otherwise,
+create a new instance, blocking until the existing connection
+is closed, if applicable.
+
+Note: This is a blocking call, be careful about deadlocks!
+
+:rtype: :class:`bridgedb.Storage.Database`
+:returns: An instance of :class:`bridgedb.Storage.Database` used to
+query the database
+
+global _DB_FNAME
+global _LOCK
+global _LOCKED
+global _OPENED_DB
+global _TOC
+
+refcount = 0
+
+if not _LOCK:
+

[tor-commits] [bridgedb/develop] Add unit tests for bridgedb.Storage

2014-04-01 Thread isis
commit 766cc675c52488e658a0884f0e0b5c8b044731b2
Author: Matthew Finkel matthew.fin...@gmail.com
Date:   Fri Mar 21 02:48:00 2014 +

Add unit tests for bridgedb.Storage
---
 lib/bridgedb/test/test_Storage.py |   56 +
 1 file changed, 56 insertions(+)

diff --git a/lib/bridgedb/test/test_Storage.py 
b/lib/bridgedb/test/test_Storage.py
new file mode 100644
index 000..8b0affd
--- /dev/null
+++ b/lib/bridgedb/test/test_Storage.py
@@ -0,0 +1,56 @@
+#!/usr/bin/env python
+Unittests for the :mod:`bridgedb.Storage` module.
+
+from twisted.python import log
+from twisted.trial import unittest
+import bridgedb.Storage as Storage
+from twisted.internet import reactor
+from twisted.internet.threads import deferToThread
+import os
+import threading
+from time import sleep
+
+class DatabaseTest(unittest.TestCase):
+def setUp(self):
+self.dbfname = 'test-bridgedb.sqlite'
+Storage.setDBFilename(self.dbfname)
+
+def tearDown(self):
+if os.path.isfile(self.dbfname):
+os.unlink(self.dbfname)
+Storage.clearGlobalDB()
+
+def _runAndDie(self, timeout, func):
+with func():
+sleep(timeout)
+
+def _cb_assertTrue(self, result):
+self.assertTrue(result)
+
+def _cb_assertFalse(self, result):
+self.assertFalse(result)
+
+def _eb_Failure(self, failure):
+self.fail(failure)
+
+def test_getDB_FalseWhenLocked(self):
+Storage._LOCK = threading.Lock()
+Storage._LOCK.acquire()
+self.assertFalse(Storage._LOCK.acquire(False))
+
+def test_getDB_AcquireLock(self):
+Storage.initializeDBLock()
+with Storage.getDB() as db:
+self.assertIsInstance(db, Storage.Database)
+self.assertTrue(Storage.dbIsLocked())
+self.assertEqual(db, Storage._OPENED_DB)
+
+def test_getDB_ConcurrencyLock(self):
+timeout = 1
+d1 = deferToThread(self._runAndDie, timeout, Storage.getDB)
+d1.addCallback(self._cb_assertFalse)
+d1.addErrback(self._eb_Failure)
+d2 = deferToThread(Storage.getDB, False)
+d2.addCallback(self._cb_assertFalse)
+d2.addErrback(self._eb_Failure)
+d2.addCallback(self._cb_assertTrue, Storage.getDB(False))



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


[tor-commits] [bridgedb/develop] Add tests for SIGHUP and SIGUSR1 signals

2014-04-01 Thread isis
commit 9c4baf91858e51dc0dabb8475c4582260201ad72
Author: Matthew Finkel matthew.fin...@gmail.com
Date:   Fri Feb 7 03:15:03 2014 +

Add tests for SIGHUP and SIGUSR1 signals
---
 lib/bridgedb/test/test_bridgedb.py |   32 +++-
 1 file changed, 31 insertions(+), 1 deletion(-)

diff --git a/lib/bridgedb/test/test_bridgedb.py 
b/lib/bridgedb/test/test_bridgedb.py
index 5dc890d..1f4470b 100644
--- a/lib/bridgedb/test/test_bridgedb.py
+++ b/lib/bridgedb/test/test_bridgedb.py
@@ -89,8 +89,38 @@ class BridgeDBCliTest(unittest.TestCase):
 self.doCopyFile(eindesc, eidesc, 'duplicated cached-extrainfo(.new)')
 
 print(Running `bridgedb' to test server startups...)
-bridgedbProc = Popen([bridgedbScript, '-r', runDir])
+# Sorry Windows users
+devnull = open('/dev/null', 'w')
+bridgedbProc = Popen([bridgedbScript, '-r', runDir], stdout=devnull)
 time.sleep(30)
+assignments = pjoin(runDir, 'assignments.log')
+self.assertTrue(os.path.isfile(assignments))
+os.unlink(assignments)
+bridgedbProc.send_signal(signal.SIGHUP)
+time.sleep(5)
+try:
+self.assertTrue(os.path.isfile(assignments))
+except self.failureException as e:
+bridgedbProc.send_signal(signal.SIGKILL)
+bridgedbProcCode = bridgedbProc.wait()
+print(`bridgedb' exited with status code %d % 
int(bridgedbProcCode))
+raise e
+bridgedbProc.send_signal(signal.SIGUSR1)
+time.sleep(5)
+buckets = [['email', False], ['https', False], ['unallocated', False]]
+for rundirfile in os.listdir(runDir):
+for bucket in buckets:
+if rundirfile.startswith(bucket[0]):
+bucket[1] = True
+break
+for bucket in buckets:
+try:
+self.assertTrue(bucket[1], %s bucket was not dumped! % 
bucket[0])
+except self.failureException as e:
+bridgedbProc.send_signal(signal.SIGKILL)
+bridgedbProcCode = bridgedbProc.wait()
+print(`bridgedb' exited with status code %d % 
int(bridgedbProcCode))
+raise e
 bridgedbProc.send_signal(signal.SIGINT)
 bridgedbProcCode = bridgedbProc.wait()
 print(`bridgedb' exited with status code %d % int(bridgedbProcCode))



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


[tor-commits] [bridgedb/develop] Reparse descriptors in background thread on signal

2014-04-01 Thread isis
commit bd652aa560cfaf15b9b37979aba73e9f8f548b4e
Author: Matthew Finkel matthew.fin...@gmail.com
Date:   Fri Feb 7 01:16:34 2014 +

Reparse descriptors in background thread on signal

Create temporary distributors and fill them with bridges then
overwrite the old distributors' rings with the rings from the
temporary distributors. Factor out distributor creation code.

Bug fix 5232
---
 CHANGELOG|7 ++
 lib/bridgedb/Main.py |  203 +++---
 2 files changed, 134 insertions(+), 76 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 092ce8c..0498e4f 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,10 @@
+Changes in version 0.1.7 -
+* FIXES #5232 Perform long running and blocking transactions
+in background threads. Primarily this moves bridge
+descriptor reparsing into another thread and
+significantly increased the availability of bridgedb,
+as a result.
+
 Changes in version 0.1.6 - 2014-03-26
 BridgeDB 0.1.6 includes fixes for the following bugs:
* FIXES #11196 BridgeDB should use leekspin
diff --git a/lib/bridgedb/Main.py b/lib/bridgedb/Main.py
index 7fc4c6c..6c099b8 100644
--- a/lib/bridgedb/Main.py
+++ b/lib/bridgedb/Main.py
@@ -92,6 +92,7 @@ def load(state, splitter, clear=False):
 
 logging.info(Loading bridges...)
 
+bridges = {}
 status = {}
 addresses = {}
 timestamps = {}
@@ -118,8 +119,6 @@ def load(state, splitter, clear=False):
 logging.debug(Closing network status file)
 f.close()
 
-db = bridgedb.Storage.getDB()
-
 for fname in state.BRIDGE_FILES:
 logging.info(Opening bridge-server-descriptor file: '%s' % fname)
 f = open(fname, 'r')
@@ -191,6 +190,27 @@ def load(state, splitter, clear=False):
 logging.debug(Closing blocking-countries document)
 f.close()
 
+def updateBridgeHistory(bridges, timestamps):
+if not hasattr(state, 'config'):
+logging.info(updateBridgeHistory(): Config file not set \
+in State file.)
+return
+if state.COLLECT_TIMESTAMPS:
+logging.debug(Beginning bridge stability calculations)
+for bridge in bridges.values():
+if bridge.getID() in timestamps.keys():
+ts = timestamps[bridge.getID()][:]
+ts.sort()
+for timestamp in ts:
+logging.debug(
+Updating BridgeHistory timestamps for %s: %s
+% (bridge.fingerprint, timestamp))
+bridgedb.Stability.addOrUpdateBridgeHistory(
+bridge, timestamp)
+logging.debug(Stability calculations complete)
+
+reactor.callInThread(updateBridgeHistory, bridges, timestamps)
+
 bridges = None
 state.save()
 return
@@ -327,7 +347,7 @@ def _reloadFn(*args):
 
 def _handleSIGHUP(*args):
 Called when we receive a SIGHUP; invokes _reloadFn.
-reactor.callLater(0, _reloadFn, *args)
+reactor.callInThread(_reloadFn)
 
 def _handleSIGUSR1(*args):
 Handler for SIGUSR1. Calls :func:`~bridgedb.runner.doDumpBridges`.
@@ -340,7 +360,7 @@ def _handleSIGUSR1(*args):
 cfg = loadConfig(state.CONFIG_FILE, state.config)
 
 logging.info(Dumping bridge assignments to files...)
-reactor.callLater(0, runner.doDumpBridges, cfg)
+reactor.callInThread(runner.doDumpBridges, cfg)
 
 
 class ProxyCategory:
@@ -351,6 +371,75 @@ class ProxyCategory:
 def replaceProxyList(self, ipset):
 self.ipset = ipset
 
+def replaceBridgeRings(current, replacement):
+Replace the current thing with the new one
+current.splitter = replacement.splitter
+
+def createBridgeRings(cfg, proxyList, key):
+Create the bridge distributors defined by the config file
+
+:type cfg:  :class:`Conf`
+:param cfg: The current configuration, including any in-memory
+settings (i.e. settings whose values were not obtained from the
+config file, but were set via a function somewhere)
+:type proxyList: :class:`ProxyCategory`
+:param proxyList: The container for the IP addresses of any currently
+  known open proxies.
+:param bytes key: Splitter master key
+:rtype: tuple
+:returns: A BridgeSplitter splitter, an IPBasedDistributor or None,
+  and an EmailBasedDistributor or None.
+
+
+# Create a BridgeSplitter to assign the bridges to the different
+# distributors.
+splitter = Bridges.BridgeSplitter(crypto.getHMAC(key, Splitter-Key))
+logging.debug(Created splitter: %r % splitter)
+
+# Create ring parameters.
+ringParams = Bridges.BridgeRingParameters(needPorts=cfg.FORCE_PORTS,
+  needFlags=cfg.FORCE_FLAGS)
+
+emailDistributor = ipDistributor = None
+

[tor-commits] [bridgedb/develop] Handle previously unhandled exception when replying to mail

2014-04-01 Thread isis
commit b6d3091e6a3e76e919f96aa246c99b78617e931d
Author: Matthew Finkel matthew.fin...@gmail.com
Date:   Wed Mar 26 22:37:12 2014 +

Handle previously unhandled exception when replying to mail
---
 lib/bridgedb/EmailServer.py |   17 -
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/lib/bridgedb/EmailServer.py b/lib/bridgedb/EmailServer.py
index 79239c7..8b7783f 100644
--- a/lib/bridgedb/EmailServer.py
+++ b/lib/bridgedb/EmailServer.py
@@ -21,6 +21,7 @@ from twisted.internet import reactor
 from twisted.internet.defer import Deferred
 from twisted.internet.task import LoopingCall
 import twisted.mail.smtp
+from twisted.internet.error import ConnectionRefusedError
 
 from zope.interface import implements
 
@@ -235,6 +236,17 @@ def buildSpamWarningTemplate(t):
 + t.gettext(I18n.BRIDGEDB_TEXT[12]) + \n\n
 return msg_template 
 
+def _ebReplyToMailFailure(fail):
+Errback for a :api:`twisted.mail.smtp.SMTPSenderFactory`.
+
+:param fail: A :api:`twisted.python.failure.Failure` which occurred during
+the transaction.
+
+logging.debug(EmailServer._ebReplyToMailFailure() called with %r % fail)
+error = fail.getErrorMessage() or unknown failure.
+logging.exception(replyToMail Failure: %s % error)
+return None
+
 def replyToMail(lines, ctx):
 Reply to an incoming email. Maybe.
 
@@ -262,7 +274,10 @@ def replyToMail(lines, ctx):
 
 d = Deferred()
 factory = twisted.mail.smtp.SMTPSenderFactory(ctx.smtpFromAddr, sendToUser,
-  response, d)
+  response, d, retries=0,
+  timeout=30)
+d.addErrback(_ebReplyToMailFailure)
+logging.info(Sending reply to %r, Util.logSafely(sendToUser))
 reactor.connectTCP(ctx.smtpServer, ctx.smtpPort, factory)
 
 return d



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


[tor-commits] [bridgedb/develop] More unit tests for Email Server

2014-04-01 Thread isis
commit 0556e7daa8504756b34384a0f9b5dfa753556c09
Author: Matthew Finkel matthew.fin...@gmail.com
Date:   Fri Mar 21 03:19:23 2014 +

More unit tests for Email Server
---
 lib/bridgedb/test/test_EmailServer.py |  160 +
 1 file changed, 160 insertions(+)

diff --git a/lib/bridgedb/test/test_EmailServer.py 
b/lib/bridgedb/test/test_EmailServer.py
index 4c6bcd7..e8b9360 100644
--- a/lib/bridgedb/test/test_EmailServer.py
+++ b/lib/bridgedb/test/test_EmailServer.py
@@ -17,8 +17,13 @@ import os
 import shutil
 
 from io import StringIO
+import copy
 
 from bridgedb import EmailServer
+from bridgedb.Dist import BadEmail
+from bridgedb.Dist import EmailBasedDistributor
+from bridgedb.EmailServer import MailContext
+from bridgedb.Time import NoSchedule
 from bridgedb.persistent import Conf
 from bridgedb.test.util import fileCheckDecorator
 from twisted.python import log
@@ -29,8 +34,36 @@ TEST_CONFIG_FILE = StringIO(unicode(\
 EMAIL_DIST = True
 EMAIL_GPG_SIGNING_ENABLED = True
 EMAIL_GPG_SIGNING_KEY = 'TESTING.subkeys.sec'
+EMAIL_DOMAIN_MAP = {}
+EMAIL_DOMAIN_RULES = {
+   'gmail.com': [ignore_dots, dkim],
+   'example.com': [],
+}
+EMAIL_DOMAINS = [gmail.com, example.com]
+EMAIL_USERNAME = bridges
+EMAIL_SMTP_HOST = 127.0.0.1
+EMAIL_SMTP_PORT = 25
+EMAIL_SMTP_FROM_ADDR = bridges@localhost
+EMAIL_N_BRIDGES_PER_ANSWER = 3
+EMAIL_FROM_ADDR = bridges@localhost
+EMAIL_BIND_IP = 127.0.0.1
+EMAIL_PORT = 5225
 ))
 
+class FakeDistributor(EmailBasedDistributor):
+def __init__(self, key, domainmap, domainrules, answerParameters=None,
+ bridges=None):
+super(FakeDistributor, self).__init__(key, domainmap, domainrules,
+answerParameters)
+if bridges:
+self.bridges = bridges
+else:
+self.bridges = []
+
+def getBridgesForEmail(self, emailaddr, epoch, N=1,
+ parameters=None, countryCode=None, bridgeFilterRules=None):
+return self.bridges[:N]
+
 
 class EmailGnuPGTest(unittest.TestCase):
 Tests for :func:`bridgedb.EmailServer.getGPGContext`.
@@ -96,3 +129,130 @@ class EmailGnuPGTest(unittest.TestCase):
 self.makeBadKey()
 ctx = EmailServer.getGPGContext(self.config)
 self.assertTrue(ctx is None)
+
+class EmailCompositionTests(unittest.TestCase):
+Tests for :func:`bridgedb.EmailServer.getMailResponse`.
+
+def setUp(self):
+Create fake email and associated data
+configuration = {}
+TEST_CONFIG_FILE.seek(0)
+compiled = compile(TEST_CONFIG_FILE.read(), 'string', 'exec')
+exec compiled in configuration
+self.config = Conf(**configuration)
+
+# TODO: Add headers if we start validating them
+self.lines = [From: %s@%s.com, To: %s...@example.net,
+  Subject: testing, \n, get bridges]
+self.distributor = FakeDistributor('key', {}, {}, [])
+self.ctx = MailContext(self.config, self.distributor, NoSchedule())
+
+def test_getMailResponseNoFrom(self):
+lines = self.lines
+lines[0] = 
+lines[1] = self.lines[1] % bridges
+ret = EmailServer.getMailResponse(lines, self.ctx)
+self.assertIsInstance(ret, tuple)
+self.assertEqual(len(ret), 2)
+self.assertEqual(ret[0], None)
+self.assertEqual(ret[1], None)
+
+def test_getMailResponseBadAddress(self):
+lines = copy.copy(self.lines)
+lines[0] = self.lines[0] % (testing?, example)
+lines[1] = self.lines[1] % bridges
+lines[2] = 
+ret = EmailServer.getMailResponse(lines, self.ctx)
+self.assertIsInstance(ret, tuple)
+self.assertEqual(len(ret), 2)
+self.assertEqual(ret[0], None)
+self.assertEqual(ret[1], None)
+#lines[0] = self.lines[0] % (, example)
+lines[0] = From: %s@%s.com % (, example)
+ret = EmailServer.getMailResponse(lines, self.ctx)
+self.assertIsInstance(ret, tuple)
+self.assertEqual(len(ret), 2)
+self.assertEqual(ret[0], None)
+self.assertEqual(ret[1], None)
+
+def test_getMailResponseInvalidDomain(self):
+lines = copy.copy(self.lines)
+lines[0] = self.lines[0] % (testing, exa#mple)
+ret = EmailServer.getMailResponse(lines, self.ctx)
+self.assertIsInstance(ret, tuple)
+self.assertEqual(len(ret), 2)
+self.assertEqual(ret[0], None)
+self.assertEqual(ret[1], None)
+lines[0] = self.lines[0] % (testing, exam+ple)
+ret = EmailServer.getMailResponse(lines, self.ctx)
+self.assertIsInstance(ret, tuple)
+self.assertEqual(len(ret), 2)
+self.assertEqual(ret[0], None)
+self.assertEqual(ret[1], None)
+
+def test_getMailResponseDKIM(self):
+lines = copy.copy(self.lines)
+lines[0] = self.lines[0] % (testing, gmail)
+lines.append(X-DKIM-Authentication-Result: )
+ret = EmailServer.getMailResponse(lines, 

[tor-commits] [bridgedb/develop] Add TODO mentioning that we should be able to disable distributors

2014-04-01 Thread isis
commit 8dfcd5d7f77950828d3c95f93417baf7ea70c6b7
Author: Matthew Finkel matthew.fin...@gmail.com
Date:   Sun Mar 30 13:36:49 2014 +

Add TODO mentioning that we should be able to disable distributors

If we reparse our config and it tells us that a distributor, which
is currently running, should be disabled then we should be able to
shut it down.

Also wrap long lines.
---
 lib/bridgedb/Main.py |8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lib/bridgedb/Main.py b/lib/bridgedb/Main.py
index 1f7e52d..8a1b650 100644
--- a/lib/bridgedb/Main.py
+++ b/lib/bridgedb/Main.py
@@ -609,10 +609,14 @@ def startup(options):
 state.save()
 
 if inThread:
+# XXX shutdown the distributors if they were previously running
+# and should now be disabled
 if ipDistributorTmp:
-reactor.callFromThread(replaceBridgeRings, ipDistributor, 
ipDistributorTmp)
+reactor.callFromThread(replaceBridgeRings,
+   ipDistributor, ipDistributorTmp)
 if emailDistributorTmp:
-reactor.callFromThread(replaceBridgeRings, emailDistributor, 
emailDistributorTmp)
+reactor.callFromThread(replaceBridgeRings,
+   emailDistributor, emailDistributorTmp)
 else:
 # We're still starting up. Return these distributors so
 # they are configured in the outer-namespace



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


[tor-commits] [bridgedb/develop] Use the new idiom throughout code

2014-04-01 Thread isis
commit 63f046df60767bae1a2ec31e67346c4ebb6769f8
Author: Matthew Finkel matthew.fin...@gmail.com
Date:   Fri Mar 21 03:10:43 2014 +

Use the new idiom throughout code
---
 lib/bridgedb/Bridges.py   |   66 +++
 lib/bridgedb/Bucket.py|  104 +++
 lib/bridgedb/Dist.py  |  115 -
 lib/bridgedb/Stability.py |  204 ++---
 lib/bridgedb/Tests.py |4 +-
 5 files changed, 247 insertions(+), 246 deletions(-)

diff --git a/lib/bridgedb/Bridges.py b/lib/bridgedb/Bridges.py
index 2fb784a..bfe1316 100644
--- a/lib/bridgedb/Bridges.py
+++ b/lib/bridgedb/Bridges.py
@@ -308,38 +308,38 @@ class Bridge(object):
 A bridge is 'familiar' if 1/8 of all active bridges have appeared
 more recently than it, or if it has been around for a Weighted Time of 
8 days.
 
-db = bridgedb.Storage.getDB()
-return db.getBridgeHistory(self.fingerprint).familiar
+with bridgedb.Storage.getDB() as db:
+return db.getBridgeHistory(self.fingerprint).familiar
 
 @property
 def wfu(self):
 Weighted Fractional Uptime
-db = bridgedb.Storage.getDB()
-return db.getBridgeHistory(self.fingerprint).weightedFractionalUptime
+with bridgedb.Storage.getDB() as db:
+return 
db.getBridgeHistory(self.fingerprint).weightedFractionalUptime
 
 @property
 def weightedTime(self):
 Weighted Time
-db = bridgedb.Storage.getDB()
-return db.getBridgeHistory(self.fingerprint).weightedTime
+with bridgedb.Storage.getDB() as db:
+return db.getBridgeHistory(self.fingerprint).weightedTime
 
 @property
 def wmtbac(self):
 Weighted Mean Time Between Address Change
-db = bridgedb.Storage.getDB()
-return db.getBridgeHistory(self.fingerprint).wmtbac
+with bridgedb.Storage.getDB() as db:
+return db.getBridgeHistory(self.fingerprint).wmtbac
 
 @property
 def tosa(self):
 the Time On Same Address (TOSA)
-db = bridgedb.Storage.getDB()
-return db.getBridgeHistory(self.fingerprint).tosa
+with bridgedb.Storage.getDB() as db:
+return db.getBridgeHistory(self.fingerprint).tosa
 
 @property
 def weightedUptime(self):
 Weighted Uptime
-db = bridgedb.Storage.getDB()
-return db.getBridgeHistory(self.fingerprint).weightedUptime
+with bridgedb.Storage.getDB() as db:
+return db.getBridgeHistory(self.fingerprint).weightedUptime
 
 def getDescriptorDigests(desc):
 Return the SHA-1 hash hexdigests of all descriptor descs
@@ -1122,19 +1122,19 @@ class UnallocatedHolder(BridgeHolder):
 self.fingerprints = []
 
 def dumpAssignments(self, f, description=):
-db = bridgedb.Storage.getDB()
-allBridges = db.getAllBridges()
-for bridge in allBridges:
-if bridge.hex_key not in self.fingerprints:
-continue
-dist = bridge.distributor
-desc = [ description ]
-if dist.startswith(bridgedb.Bucket.PSEUDO_DISTRI_PREFIX):
-dist = dist.replace(bridgedb.Bucket.PSEUDO_DISTRI_PREFIX, )
-desc.append(bucket=%s % dist)
-elif dist != unallocated:
-continue
-f.write(%s %s\n % (bridge.hex_key,  .join(desc).strip()))
+with bridgedb.Storage.getDB() as db:
+allBridges = db.getAllBridges()
+for bridge in allBridges:
+if bridge.hex_key not in self.fingerprints:
+continue
+dist = bridge.distributor
+desc = [ description ]
+if dist.startswith(bridgedb.Bucket.PSEUDO_DISTRI_PREFIX):
+dist = dist.replace(bridgedb.Bucket.PSEUDO_DISTRI_PREFIX, 
)
+desc.append(bucket=%s % dist)
+elif dist != unallocated:
+continue
+f.write(%s %s\n % (bridge.hex_key,  .join(desc).strip()))
 
 class BridgeSplitter(BridgeHolder):
 A BridgeHolder that splits incoming bridges up based on an hmac,
@@ -1186,7 +1186,6 @@ class BridgeSplitter(BridgeHolder):
 
 def insert(self, bridge):
 assert self.rings
-db = bridgedb.Storage.getDB()
 
 for s in self.statsHolders:
 s.insert(bridge)
@@ -1205,16 +1204,17 @@ class BridgeSplitter(BridgeHolder):
 
 validRings = self.rings + self.pseudoRings
 
-ringname = db.insertBridgeAndGetRing(bridge, ringname, time.time(), 
+with bridgedb.Storage.getDB() as db:
+ringname = db.insertBridgeAndGetRing(bridge, ringname, 
time.time(), 
  validRings)
-db.commit()
+db.commit()
 
-# Pseudo distributors are always held in the unallocated ring
-if ringname in self.pseudoRings:
- 

[tor-commits] [bridgedb/develop] Open and convert the db, if necessary. Store DB filename for all.

2014-04-01 Thread isis
commit 1bd2c69fcbb8bf1b59b16e3f6d22066b53ff428c
Author: Matthew Finkel matthew.fin...@gmail.com
Date:   Wed Mar 26 05:21:00 2014 +

Open and convert the db, if necessary. Store DB filename for all.
---
 lib/bridgedb/Main.py |7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/lib/bridgedb/Main.py b/lib/bridgedb/Main.py
index 6c099b8..a28b75f 100644
--- a/lib/bridgedb/Main.py
+++ b/lib/bridgedb/Main.py
@@ -553,9 +553,10 @@ def startup(options):
  emailDistributorTmp,
  ipDistributorTmp) = createBridgeRings(cfg, proxyList, key)
 
-# Initialize our DB file.
-db = bridgedb.Storage.Database(cfg.DB_FILE + .sqlite, cfg.DB_FILE)
-bridgedb.Storage.setGlobalDB(db)
+# Initialize our DB.
+bridgedb.Storage.initializeDBLock()
+db = bridgedb.Storage.openOrConvertDatabase(cfg.DB_FILE + .sqlite, 
cfg.DB_FILE)
+bridgedb.Storage.setDBFilename(cfg.DB_FILE + .sqlite)
 load(state, splitter, clear=False)
 
 state = persistent.load()



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


[tor-commits] [bridgedb/develop] Bump leekspin to v0.1.3

2014-04-01 Thread isis
commit 6ce6bcc99988253516968797d31f3be2c0d7
Author: Matthew Finkel matthew.fin...@gmail.com
Date:   Thu Mar 27 03:10:05 2014 +

Bump leekspin to v0.1.3
---
 .travis.yml |2 +-
 CHANGELOG   |3 +++
 setup.py|2 +-
 3 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 5553a81..7aef0ca 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -28,7 +28,7 @@ python:
 
 install:
   - pip install -r requirements.txt
-  - pip install --no-use-wheel leekspin==0.1.1 coverage==3.7 coveralls==0.3 
sure==1.2.2
+  - pip install --no-use-wheel leekspin==0.1.3 coverage==3.7 coveralls==0.3 
sure==1.2.2
   - make install
 
 script:
diff --git a/CHANGELOG b/CHANGELOG
index 0498e4f..4f36267 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -5,6 +5,9 @@ Changes in version 0.1.7 -
 significantly increased the availability of bridgedb,
 as a result.
 
+And includes the following general changes:
+* BUMPS leekspin version to 0.1.3
+
 Changes in version 0.1.6 - 2014-03-26
 BridgeDB 0.1.6 includes fixes for the following bugs:
* FIXES #11196 BridgeDB should use leekspin
diff --git a/setup.py b/setup.py
index d859f87..d77bc1d 100644
--- a/setup.py
+++ b/setup.py
@@ -277,7 +277,7 @@ setuptools.setup(
 scripts=['scripts/bridgedb'],
 extras_require={'test': [sure==1.2.2,
  coverage==3.7,
- leekspin==0.1.1]},
+ leekspin==0.1.3]},
 zip_safe=False,
 cmdclass=get_cmdclass(),
 include_package_data=True,



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


[tor-commits] [bridgedb/develop] Add useful output during startup integration test

2014-04-01 Thread isis
commit a3d59f0b2b9870ee8ee184bfb6617844891f8b57
Author: Matthew Finkel matthew.fin...@gmail.com
Date:   Wed Mar 26 05:26:07 2014 +

Add useful output during startup integration test
---
 lib/bridgedb/test/test_bridgedb.py |4 
 1 file changed, 4 insertions(+)

diff --git a/lib/bridgedb/test/test_bridgedb.py 
b/lib/bridgedb/test/test_bridgedb.py
index 1f4470b..e73e2bc 100644
--- a/lib/bridgedb/test/test_bridgedb.py
+++ b/lib/bridgedb/test/test_bridgedb.py
@@ -92,10 +92,12 @@ class BridgeDBCliTest(unittest.TestCase):
 # Sorry Windows users
 devnull = open('/dev/null', 'w')
 bridgedbProc = Popen([bridgedbScript, '-r', runDir], stdout=devnull)
+print(Waiting 30 seconds while bridgedb loads...)
 time.sleep(30)
 assignments = pjoin(runDir, 'assignments.log')
 self.assertTrue(os.path.isfile(assignments))
 os.unlink(assignments)
+print(Sending SIGHUP, checking for assignments.log ...)
 bridgedbProc.send_signal(signal.SIGHUP)
 time.sleep(5)
 try:
@@ -105,6 +107,7 @@ class BridgeDBCliTest(unittest.TestCase):
 bridgedbProcCode = bridgedbProc.wait()
 print(`bridgedb' exited with status code %d % 
int(bridgedbProcCode))
 raise e
+print(Sending SIGUSR1, checking for bucket files...)
 bridgedbProc.send_signal(signal.SIGUSR1)
 time.sleep(5)
 buckets = [['email', False], ['https', False], ['unallocated', False]]
@@ -121,6 +124,7 @@ class BridgeDBCliTest(unittest.TestCase):
 bridgedbProcCode = bridgedbProc.wait()
 print(`bridgedb' exited with status code %d % 
int(bridgedbProcCode))
 raise e
+print(Done. Killing processes.)
 bridgedbProc.send_signal(signal.SIGINT)
 bridgedbProcCode = bridgedbProc.wait()
 print(`bridgedb' exited with status code %d % int(bridgedbProcCode))



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


[tor-commits] [bridgedb/develop] Use `email.message.Message` instead of `MimeWriter.MimeWriter`

2014-04-01 Thread isis
commit 5092364f7e3ce42b61b0336a95519639d0e59308
Author: Matthew Finkel matthew.fin...@gmail.com
Date:   Sun Mar 30 12:42:06 2014 +

Use `email.message.Message` instead of `MimeWriter.MimeWriter`

`MimeWriter.MimeWriter` was deprecated in Python 2.3, now is a great
time for us to switch to the replacement.

Fixes #11370
---
 CHANGELOG   |4 
 lib/bridgedb/EmailServer.py |   39 ++-
 2 files changed, 26 insertions(+), 17 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 4f36267..7f160df 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -4,6 +4,10 @@ Changes in version 0.1.7 -
 descriptor reparsing into another thread and
 significantly increased the availability of bridgedb,
 as a result.
+* FIXES #11370 We were using an old (and deprecated) module when
+we created our email responses. Now we use the newer
+version. This should only affect internal functionality
+and should not result in any noticable user-visible changes.
 
 And includes the following general changes:
 * BUMPS leekspin version to 0.1.3
diff --git a/lib/bridgedb/EmailServer.py b/lib/bridgedb/EmailServer.py
index 8b7783f..90b22af 100644
--- a/lib/bridgedb/EmailServer.py
+++ b/lib/bridgedb/EmailServer.py
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 ; test-case-name: bridgedb.test.test_EmailServer -*-
 # BridgeDB by Nick Mathewson.
 # Copyright (c) 2007-2013, The Tor Project, Inc.
 # See LICENSE for licensing information
@@ -6,8 +7,10 @@
 This module implements the email interface to the bridge database.
 
 
-from StringIO import StringIO
-import MimeWriter
+from __future__ import unicode_literals
+
+from email import message
+from io import StringIO
 import gettext
 import gpgme
 import logging
@@ -430,17 +433,19 @@ def addSMTPServer(cfg, dist, sched):
 def composeEmail(fromAddr, clientAddr, subject, body, msgID=False,
 gpgContext=None):
 
-f = StringIO()
-w = MimeWriter.MimeWriter(f)
-w.addheader(From, fromAddr)
-w.addheader(To, clientAddr)
-w.addheader(Message-ID, twisted.mail.smtp.messageid())
+msg = message.Message()
+msg.add_header(From, fromAddr)
+msg.add_header(To, clientAddr)
+msg.add_header(Message-ID, twisted.mail.smtp.messageid())
 if not subject.startswith(Re:): subject = Re: %s%subject
-w.addheader(Subject, subject)
+msg.add_header(Subject, subject)
 if msgID:
-w.addheader(In-Reply-To, msgID)
-w.addheader(Date, twisted.mail.smtp.rfc822date())
-mailbody = w.startbody(text/plain)
+msg.add_header(In-Reply-To, msgID)
+msg.add_header(Date, twisted.mail.smtp.rfc822date())
+msg.set_default_type(text/plain)
+headers = [': '.join(m) for m in msg.items()]
+mail = StringIO(\r\n.join(headers))
+mail.writelines(unicode(msg.as_string()))
 
 # gpg-clearsign messages
 if gpgContext:
@@ -450,20 +455,20 @@ def composeEmail(fromAddr, clientAddr, subject, body, 
msgID=False,
 if (len(sigs) != 1):
 logging.warn('Failed to sign message!')
 signature.seek(0)
-[mailbody.write(l) for l in signature]
+[mail.write(l) for l in signature]
 else:
-mailbody.write(body)
+mail.write(body)
 
 # Only log the email text (including all headers) if SAFE_LOGGING is
 # disabled:
 if not Util.safe_logging:
-f.seek(0)
-logging.debug(Email contents:\n%s % f.read())
+mail.seek(0)
+logging.debug(Email contents:\n%s % mail.read())
 else:
 logging.debug(Email text for %r created. % 
Util.logSafely(clientAddr))
-f.seek(0)
+mail.seek(0)
 
-return clientAddr, f
+return clientAddr, mail
 
 def getGPGContext(cfg):
 Import a key from a file and initialise a context for GnuPG operations.



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


[tor-commits] [bridgedb/develop] Only update distributor's hashring if it's still active

2014-04-01 Thread isis
commit a79d154de5db6293321f6c68835e8f4ff25032d8
Author: Matthew Finkel matthew.fin...@gmail.com
Date:   Fri Mar 28 00:15:16 2014 +

Only update distributor's hashring if it's still active

TODO: shutdown the distributor in this situation
---
 lib/bridgedb/Main.py |6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/bridgedb/Main.py b/lib/bridgedb/Main.py
index a28b75f..1f7e52d 100644
--- a/lib/bridgedb/Main.py
+++ b/lib/bridgedb/Main.py
@@ -609,8 +609,10 @@ def startup(options):
 state.save()
 
 if inThread:
-reactor.callFromThread(replaceBridgeRings, ipDistributor, 
ipDistributorTmp)
-reactor.callFromThread(replaceBridgeRings, emailDistributor, 
emailDistributorTmp)
+if ipDistributorTmp:
+reactor.callFromThread(replaceBridgeRings, ipDistributor, 
ipDistributorTmp)
+if emailDistributorTmp:
+reactor.callFromThread(replaceBridgeRings, emailDistributor, 
emailDistributorTmp)
 else:
 # We're still starting up. Return these distributors so
 # they are configured in the outer-namespace



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


[tor-commits] [bridgedb/develop] Make sure leekspin created our descriptors

2014-04-01 Thread isis
commit 286a33737d44b530feec987c09bbf65b421913cd
Author: Matthew Finkel matthew.fin...@gmail.com
Date:   Thu Mar 27 00:36:46 2014 +

Make sure leekspin created our descriptors
---
 lib/bridgedb/test/test_bridgedb.py |3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/bridgedb/test/test_bridgedb.py 
b/lib/bridgedb/test/test_bridgedb.py
index e73e2bc..3015094 100644
--- a/lib/bridgedb/test/test_bridgedb.py
+++ b/lib/bridgedb/test/test_bridgedb.py
@@ -87,6 +87,9 @@ class BridgeDBCliTest(unittest.TestCase):
 eidesc  = pjoin(runDir, 'cached-extrainfo')
 eindesc = pjoin(runDir, 'cached-extrainfo.new')
 self.doCopyFile(eindesc, eidesc, 'duplicated cached-extrainfo(.new)')
+self.assertTrue(os.path.isfile(eidesc))
+self.assertTrue(os.path.isfile(eindesc))
+
 
 print(Running `bridgedb' to test server startups...)
 # Sorry Windows users



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


[tor-commits] [bridgedb/develop] Merge remote-tracking branch 'tpo-sysrqb/bug5232_adding_concurrent_processing_squashed_r1' into develop

2014-04-01 Thread isis
commit 13231f18ff2dc8a80d6d5561833b503f690f3872
Merge: 8745167 8dfcd5d
Author: Isis Lovecruft i...@torproject.org
Date:   Tue Apr 1 21:54:44 2014 +

Merge remote-tracking branch 
'tpo-sysrqb/bug5232_adding_concurrent_processing_squashed_r1' into develop

 .travis.yml   |2 +-
 CHANGELOG |   14 +++
 lib/bridgedb/Bridges.py   |   66 +--
 lib/bridgedb/Bucket.py|  104 
 lib/bridgedb/Dist.py  |  115 +-
 lib/bridgedb/EmailServer.py   |   56 ++---
 lib/bridgedb/Main.py  |  210 +
 lib/bridgedb/Stability.py |  204 
 lib/bridgedb/Storage.py   |  158 +++--
 lib/bridgedb/Tests.py |4 +-
 lib/bridgedb/test/test_EmailServer.py |  160 +
 lib/bridgedb/test/test_Storage.py |   56 +
 lib/bridgedb/test/test_bridgedb.py|   39 +-
 setup.py  |2 +-
 14 files changed, 840 insertions(+), 350 deletions(-)

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


[tor-commits] [tor/master] Merge remote-tracking branch 'public/bug9870'

2014-04-01 Thread nickm
commit b4b91864bb3879587edc7e8c430337f24835b28c
Merge: 6bef082 c4bb3c8
Author: Nick Mathewson ni...@torproject.org
Date:   Tue Apr 1 20:48:15 2014 -0400

Merge remote-tracking branch 'public/bug9870'

Conflicts:
src/or/config.c

 changes/bug9870 |5 +
 src/or/config.c |   38 +-
 2 files changed, 30 insertions(+), 13 deletions(-)

diff --cc src/or/config.c
index 909ac14,dcbe88d..c42ceb3
--- a/src/or/config.c
+++ b/src/or/config.c
@@@ -1342,26 -1360,6 +1361,19 @@@ options_act(const or_options_t *old_opt
}
  #endif
  
 +  /* If we are a bridge with a pluggable transport proxy but no
 + Extended ORPort, inform the user that she is missing out. */
 +  if (server_mode(options)  options-ServerTransportPlugin 
 +  !options-ExtORPort_lines) {
 +log_notice(LD_CONFIG, We use pluggable transports but the Extended 
 +   ORPort is disabled. Tor and your pluggable transports proxy 
 +   communicate with each other via the Extended ORPort so it 
 +   is suggested you enable it: it will also allow your Bridge 
 +   to collect statistics about its clients that use pluggable 
 +   transports. Please enable it using the ExtORPort torrc option 

 +   (e.g. set 'ExtORPort auto').);
 +  }
 +
-   if (options-SafeLogging_ != SAFELOG_SCRUB_ALL 
-   (!old_options || old_options-SafeLogging_ != options-SafeLogging_)) {
- log_warn(LD_GENERAL, Your log may contain sensitive information - you 
-  disabled SafeLogging. Please log safely. Don't log unless it 
-  serves an important reason. Overwrite the log afterwards.);
-   }
- 
if (options-Bridges) {
  mark_bridge_list();
  for (cl = options-Bridges; cl; cl = cl-next) {

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


[tor-commits] [tor/master] Log only one message for dangerous log settings.

2014-04-01 Thread nickm
commit c4bb3c8d447400573eb45f3e2076e6b80187f1b9
Author: Nick Mathewson ni...@torproject.org
Date:   Wed Feb 12 15:32:50 2014 -0500

Log only one message for dangerous log settings.

We log only one message, containing a complete list of what's
wrong.  We log the complete list whenever any of the possible things
that could have gotten wrong gets worse.

Fix for #9870. Bugfix on 10480dff01bece13fab, which we merged in
0.2.5.1-alpha.
---
 changes/bug9870 |5 +
 src/or/config.c |   38 +-
 2 files changed, 30 insertions(+), 13 deletions(-)

diff --git a/changes/bug9870 b/changes/bug9870
new file mode 100644
index 000..b4b2c2d
--- /dev/null
+++ b/changes/bug9870
@@ -0,0 +1,5 @@
+  o Minor bugfixes:
+
+- Log only one message when we start logging in an unsafe
+  way. Previously, we would log as many messages as we had
+  problems. Fix for #9870; bugfix on 0.2.5.1-alpha.
diff --git a/src/or/config.c b/src/or/config.c
index d298177..dcbe88d 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -1148,12 +1148,31 @@ options_act_reversible(const or_options_t *old_options, 
char **msg)
 tor_free(severity);
 tor_log_update_sigsafe_err_fds();
   }
-  if (get_min_log_level() = LOG_INFO 
-  get_min_log_level() != old_min_log_level) {
-log_warn(LD_GENERAL, Your log may contain sensitive information: you're 
- logging more than \notice\. Please log safely. Don't log 
- unless it serves an important reason, and overwrite the log 
- afterwards.);
+
+  {
+const char *badness = NULL;
+int bad_safelog = 0, bad_severity = 0, new_badness = 0;
+if (options-SafeLogging_ != SAFELOG_SCRUB_ALL) {
+  bad_safelog = 1;
+  if (!old_options || old_options-SafeLogging_ != options-SafeLogging_)
+new_badness = 1;
+}
+if (get_min_log_level() = LOG_INFO) {
+  bad_severity = 1;
+  if (get_min_log_level() != old_min_log_level)
+new_badness = 1;
+}
+if (bad_safelog  bad_severity)
+  badness = you disabled SafeLogging, and 
+you're logging more than \notice\;
+else if (bad_safelog)
+  badness = you disabled SafeLogging;
+else
+  badness = you're logging more than \notice\;
+if (new_badness)
+  log_warn(LD_GENERAL, Your log may contain sensitive information - %s. 
+   Don't log unless it serves an important reason. 
+   Overwrite the log afterwards., badness);
   }
 
   SMARTLIST_FOREACH(replaced_listeners, connection_t *, conn,
@@ -1341,13 +1360,6 @@ options_act(const or_options_t *old_options)
   }
 #endif
 
-  if (options-SafeLogging_ != SAFELOG_SCRUB_ALL 
-  (!old_options || old_options-SafeLogging_ != options-SafeLogging_)) {
-log_warn(LD_GENERAL, Your log may contain sensitive information - you 
- disabled SafeLogging. Please log safely. Don't log unless it 
- serves an important reason. Overwrite the log afterwards.);
-  }
-
   if (options-Bridges) {
 mark_bridge_list();
 for (cl = options-Bridges; cl; cl = cl-next) {



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


[tor-commits] [tor/maint-0.2.4] Merge branch 'bug9213_doc_024' into maint-0.2.4

2014-04-01 Thread nickm
commit 48578e1512f2d5fa95e4fdde0564d2db8ee7f995
Merge: 24e0b10 a68e6ea
Author: Nick Mathewson ni...@torproject.org
Date:   Tue Apr 1 20:59:13 2014 -0400

Merge branch 'bug9213_doc_024' into maint-0.2.4

 changes/bug9213_doc |5 +
 doc/tor.1.txt   |5 -
 2 files changed, 9 insertions(+), 1 deletion(-)

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


[tor-commits] [tor/master] Merge remote-tracking branch 'origin/maint-0.2.4'

2014-04-01 Thread nickm
commit dfc32177d9ec3b8a639d6831ca4bc92c4f273dcb
Merge: b4b9186 48578e1
Author: Nick Mathewson ni...@torproject.org
Date:   Tue Apr 1 21:00:30 2014 -0400

Merge remote-tracking branch 'origin/maint-0.2.4'

 changes/bug9213_doc |5 +
 doc/tor.1.txt   |5 -
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --cc doc/tor.1.txt
index a42d550,eb9ad67..1cc8f84
--- a/doc/tor.1.txt
+++ b/doc/tor.1.txt
@@@ -42,13 -37,9 +42,13 @@@ COMMAND-LINE OPTION
  
  [[opt-f]] **-f** __FILE__::
  Specify a new configuration file to contain further Tor configuration
- options. (Default: $HOME/.torrc, or @CONFDIR@/torrc if that file is not
+ options. (Default: @CONFDIR@/torrc, or $HOME/.torrc if that file is not
  found)
  
 +[[opt-allow-missing-torrc]] **--allow-missing-torrc**::
 +Do not require that configuration file specified by **-f** exist if
 +default torrc can be accessed.
 +
  [[opt-defaults-torrc]] **--defaults-torrc** __FILE__::
  Specify a file in which to find default values for Tor options.  The
  contents of this file are overridden by those in the regular

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


[tor-commits] [tor/master] Removing is_internal_IP() function. Resolves ticket 4645.

2014-04-01 Thread nickm
commit 3a4b24c3aba56475822ad94d268b48fd58b74645
Author: rl1987 rl1...@sdf.lonestar.org
Date:   Sat Nov 16 18:29:54 2013 +0200

Removing is_internal_IP() function. Resolves ticket 4645.
---
 changes/ticket4645   |3 +++
 src/common/address.c |   13 -
 src/common/address.h |1 -
 src/or/config.c  |   15 +++
 src/or/directory.c   |   15 +--
 src/or/dirserv.c |7 ++-
 src/test/test_addr.c |1 -
 7 files changed, 33 insertions(+), 22 deletions(-)

diff --git a/changes/ticket4645 b/changes/ticket4645
new file mode 100644
index 000..cc665ba
--- /dev/null
+++ b/changes/ticket4645
@@ -0,0 +1,3 @@
+  o Code simplifications and refactoring:
+- Removing is_internal_IP() function. Resolves ticket 4645.
+
diff --git a/src/common/address.c b/src/common/address.c
index b9f2d93..0b5bb22 100644
--- a/src/common/address.c
+++ b/src/common/address.c
@@ -1421,19 +1421,6 @@ get_interface_address6(int severity, sa_family_t family, 
tor_addr_t *addr)
  * 024 IPv6 deprecate some of these.
  */
 
-/** Return true iff bip/b (in host order) is an IP reserved to localhost,
- * or reserved for local networks by RFC 1918.
- */
-int
-is_internal_IP(uint32_t ip, int for_listening)
-{
-  tor_addr_t myaddr;
-  myaddr.family = AF_INET;
-  myaddr.addr.in_addr.s_addr = htonl(ip);
-
-  return tor_addr_is_internal(myaddr, for_listening);
-}
-
 /** Given an address of the form ip:port, try to divide it into its
  * ip and port portions, setting *baddress_out/b to a newly
  * allocated string holding the address portion and *bport_out/b
diff --git a/src/common/address.h b/src/common/address.h
index 77e5855..bdca1f2 100644
--- a/src/common/address.h
+++ b/src/common/address.h
@@ -214,7 +214,6 @@ int tor_addr_port_parse(int severity, const char *addrport,
 int tor_addr_hostname_is_local(const char *name);
 
 /* IPv4 helpers */
-int is_internal_IP(uint32_t ip, int for_listening);
 int addr_port_lookup(int severity, const char *addrport, char **address,
 uint32_t *addr, uint16_t *port_out);
 int parse_port_range(const char *port, uint16_t *port_min_out,
diff --git a/src/or/config.c b/src/or/config.c
index e7847d5..f840b5e 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -2053,6 +2053,7 @@ resolve_my_address(int warn_severity, const or_options_t 
*options,
   int notice_severity = warn_severity = LOG_NOTICE ?
   LOG_NOTICE : warn_severity;
 
+  tor_addr_t myaddr;
   tor_assert(addr_out);
 
   /*
@@ -2103,8 +2104,11 @@ resolve_my_address(int warn_severity, const or_options_t 
*options,
  local interface. Using that., fmt_addr32(addr));
   strlcpy(hostname, guessed from interfaces, sizeof(hostname));
 } else { /* resolved hostname into addr */
+  myaddr.family = AF_INET;
+  myaddr.addr.in_addr.s_addr = htonl(addr);
+
   if (!explicit_hostname 
-  is_internal_IP(addr, 0)) {
+  tor_addr_is_internal(myaddr, 0)) {
 uint32_t interface_ip;
 
 log_fn(notice_severity, LD_CONFIG, Guessed local hostname '%s' 
@@ -2114,7 +2118,7 @@ resolve_my_address(int warn_severity, const or_options_t 
*options,
 if (get_interface_address(warn_severity, interface_ip)) {
   log_fn(warn_severity, LD_CONFIG,
  Could not get local interface IP address. Too bad.);
-} else if (is_internal_IP(interface_ip, 0)) {
+} else if (tor_addr_is_internal(myaddr, 0)) {
   log_fn(notice_severity, LD_CONFIG,
  Interface IP address '%s' is a private address too. 
  Ignoring., fmt_addr32(interface_ip));
@@ -2138,8 +2142,11 @@ resolve_my_address(int warn_severity, const or_options_t 
*options,
* out if it is and we don't want that.
*/
 
+  myaddr.family = AF_INET;
+  myaddr.addr.in_addr.s_addr = htonl(addr);
+
   addr_string = tor_dup_ip(addr);
-  if (is_internal_IP(addr, 0)) {
+  if (tor_addr_is_internal(myaddr, 0)) {
 /* make sure we're ok with publishing an internal IP */
 if (!options-DirAuthorities  !options-AlternateDirAuthority) {
   /* if they are using the default authorities, disallow internal IPs
@@ -2245,7 +2252,7 @@ is_local_addr(const tor_addr_t *addr)
  * resolve_my_address will never be called at all).  In those cases,
  * last_resolved_addr will be 0, and so checking to see whether ip is on
  * the same /24 as last_resolved_addr will be the same as checking whether
- * it was on net 0, which is already done by is_internal_IP.
+ * it was on net 0, which is already done by tor_addr_is_internal.
  */
 if ((last_resolved_addr  (uint32_t)0xff00ul)
 == (ip  (uint32_t)0xff00ul))
diff --git a/src/or/directory.c b/src/or/directory.c
index 0cacf06..7f26aff 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -1415,12 +1415,23 @@ http_set_address_origin(const char *headers, 
connection_t *conn)
 fwd = http_get_header(headers, X-Forwarded-For: );
   

[tor-commits] [tor/master] Fixes for bug4645 fix.

2014-04-01 Thread nickm
commit dafed84dabbb3afbada5e55ac1d030412418fae5
Author: Nick Mathewson ni...@torproject.org
Date:   Mon Feb 3 14:31:31 2014 -0500

Fixes for bug4645 fix.
---
 src/or/config.c  |   10 +-
 src/or/dirserv.c |   11 ---
 2 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/src/or/config.c b/src/or/config.c
index a90468d..517ca70 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -2108,22 +2108,22 @@ resolve_my_address(int warn_severity, const 
or_options_t *options,
 
   if (!explicit_hostname 
   tor_addr_is_internal(myaddr, 0)) {
-uint32_t interface_ip;
+tor_addr_t interface_ip;
 
 log_fn(notice_severity, LD_CONFIG, Guessed local hostname '%s' 
resolves to a private IP address (%s). Trying something 
else., hostname, fmt_addr32(addr));
 
-if (get_interface_address(warn_severity, interface_ip)) {
+if (get_interface_address6(warn_severity, AF_INET, interface_ip)0) {
   log_fn(warn_severity, LD_CONFIG,
  Could not get local interface IP address. Too bad.);
-} else if (tor_addr_is_internal(myaddr, 0)) {
+} else if (tor_addr_is_internal(interface_ip, 0)) {
   log_fn(notice_severity, LD_CONFIG,
  Interface IP address '%s' is a private address too. 
- Ignoring., fmt_addr32(interface_ip));
+ Ignoring., fmt_addr(interface_ip));
 } else {
   from_interface = 1;
-  addr = interface_ip;
+  addr = tor_addr_to_ipv4h(interface_ip);
   log_fn(notice_severity, LD_CONFIG,
  Learned IP address '%s' for local interface.
   Using that., fmt_addr32(addr));
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index b6bb607..e3e6519 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -524,20 +524,17 @@ dirserv_free_fingerprint_list(void)
 static int
 dirserv_router_has_valid_address(routerinfo_t *ri)
 {
-  struct in_addr iaddr;
+  tor_addr_t addr;
   if (get_options()-DirAllowPrivateAddresses)
 return 0; /* whatever it is, we're fine with it */
-  if (!tor_inet_aton(ri-address, iaddr)) {
-log_info(LD_DIRSERV,Router %s published non-IP address '%s'. Refusing.,
+  if (tor_addr_parse(addr, ri-address) != AF_INET) {
+log_info(LD_DIRSERV,Router %s published non-IPv4 address '%s'. Refusing.,
  router_describe(ri),
  ri-address);
 return -1;
   }
 
-  tor_addr_t toraddr;
-  tor_addr_from_in(toraddr,iaddr);
-
-  if (tor_addr_is_internal(toraddr, 0)) {
+  if (tor_addr_is_internal(addr, 0)) {
 log_info(LD_DIRSERV,
  Router %s published internal IP address '%s'. Refusing.,
  router_describe(ri), ri-address);



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


[tor-commits] [tor/master] Add one more missing heck on bug4645 fixes

2014-04-01 Thread nickm
commit 408bd98e79196933e447cbc68c73ecffebaf5a19
Author: Nick Mathewson ni...@torproject.org
Date:   Tue Apr 1 21:10:14 2014 -0400

Add one more missing heck on bug4645 fixes
---
 src/or/directory.c |5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/or/directory.c b/src/or/directory.c
index 6effe45..d6d2339 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -1415,9 +1415,8 @@ http_set_address_origin(const char *headers, connection_t 
*conn)
 fwd = http_get_header(headers, X-Forwarded-For: );
   if (fwd) {
 tor_addr_t toraddr;
-tor_addr_parse(toraddr,fwd);
-
-if (tor_addr_is_internal(toraddr,0)) {
+if (tor_addr_parse(toraddr,fwd) == -1 ||
+tor_addr_is_internal(toraddr,0)) {
   log_debug(LD_DIR, Ignoring local/internal IP %s, escaped(fwd));
   tor_free(fwd);
   return;



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


[tor-commits] [tor/master] Merge remote-tracking branch 'public/bug4645'

2014-04-01 Thread nickm
commit fc9e84062b73535b63bb3cf555604b1acbcc4c61
Merge: dfc3217 408bd98
Author: Nick Mathewson ni...@torproject.org
Date:   Tue Apr 1 21:49:01 2014 -0400

Merge remote-tracking branch 'public/bug4645'

Conflicts:
src/or/dirserv.c

 changes/ticket4645   |3 +++
 src/common/address.c |   13 -
 src/common/address.h |1 -
 src/or/config.c  |   21 +
 src/or/directory.c   |9 +
 src/or/dirserv.c |5 -
 src/test/test_addr.c |1 -
 7 files changed, 25 insertions(+), 28 deletions(-)

diff --cc src/or/dirserv.c
index 19ed12d,e3e6519..b6c5dd4
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@@ -504,12 -524,20 +504,15 @@@ dirserv_free_fingerprint_list(void
  static int
  dirserv_router_has_valid_address(routerinfo_t *ri)
  {
+   tor_addr_t addr;
if (get_options()-DirAllowPrivateAddresses)
  return 0; /* whatever it is, we're fine with it */
-   if (is_internal_IP(ri-addr, 0)) {
 -  if (tor_addr_parse(addr, ri-address) != AF_INET) {
 -log_info(LD_DIRSERV,Router %s published non-IPv4 address '%s'. 
Refusing.,
 - router_describe(ri),
 - ri-address);
 -return -1;
 -  }
++  tor_addr_from_ipv4h(addr, ri-addr);
+ 
+   if (tor_addr_is_internal(addr, 0)) {
  log_info(LD_DIRSERV,
 - Router %s published internal IP address '%s'. Refusing.,
 - router_describe(ri), ri-address);
 + Router %s published internal IP address. Refusing.,
 + router_describe(ri));
  return -1; /* it's a private IP, we should reject it */
}
return 0;

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


[tor-commits] [tor/master] Using proper functions to create tor_addr_t.

2014-04-01 Thread nickm
commit e82e772f2b1a2b2235d3b3bcde85666e09a182b5
Author: rl1987 rl1...@sdf.lonestar.org
Date:   Wed Nov 20 21:49:17 2013 +0200

Using proper functions to create tor_addr_t.
---
 src/or/config.c|6 ++
 src/or/directory.c |   13 ++---
 src/or/dirserv.c   |3 +--
 3 files changed, 5 insertions(+), 17 deletions(-)

diff --git a/src/or/config.c b/src/or/config.c
index f840b5e..a90468d 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -2104,8 +2104,7 @@ resolve_my_address(int warn_severity, const or_options_t 
*options,
  local interface. Using that., fmt_addr32(addr));
   strlcpy(hostname, guessed from interfaces, sizeof(hostname));
 } else { /* resolved hostname into addr */
-  myaddr.family = AF_INET;
-  myaddr.addr.in_addr.s_addr = htonl(addr);
+  tor_addr_from_ipv4h(myaddr, addr);
 
   if (!explicit_hostname 
   tor_addr_is_internal(myaddr, 0)) {
@@ -2142,8 +2141,7 @@ resolve_my_address(int warn_severity, const or_options_t 
*options,
* out if it is and we don't want that.
*/
 
-  myaddr.family = AF_INET;
-  myaddr.addr.in_addr.s_addr = htonl(addr);
+  tor_addr_from_ipv4h(myaddr,addr);
 
   addr_string = tor_dup_ip(addr);
   if (tor_addr_is_internal(myaddr, 0)) {
diff --git a/src/or/directory.c b/src/or/directory.c
index 7f26aff..6effe45 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -1414,20 +1414,11 @@ http_set_address_origin(const char *headers, 
connection_t *conn)
   if (!fwd)
 fwd = http_get_header(headers, X-Forwarded-For: );
   if (fwd) {
-struct in_addr in;
-if (!tor_inet_aton(fwd, in)) {
-  log_debug(LD_DIR, Ignoring unrecognized IP %s,
-escaped(fwd));
-  tor_free(fwd);
-  return;
-}
-
 tor_addr_t toraddr;
-toraddr.family = AF_INET;
-toraddr.addr.in_addr = in;
+tor_addr_parse(toraddr,fwd);
 
 if (tor_addr_is_internal(toraddr,0)) {
-  log_debug(LD_DIR, Ignoring local IP %s, escaped(fwd));
+  log_debug(LD_DIR, Ignoring local/internal IP %s, escaped(fwd));
   tor_free(fwd);
   return;
 }
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index 4a25f99..b6bb607 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -535,8 +535,7 @@ dirserv_router_has_valid_address(routerinfo_t *ri)
   }
 
   tor_addr_t toraddr;
-  toraddr.family = AF_INET;
-  toraddr.addr.in_addr = iaddr;
+  tor_addr_from_in(toraddr,iaddr);
 
   if (tor_addr_is_internal(toraddr, 0)) {
 log_info(LD_DIRSERV,



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


[tor-commits] [tor/master] Respond to AAAA requests on DNSPort with AAAA automaps

2014-04-01 Thread nickm
commit 46a3914079d6aa91ef456b4bb82d9f842feb0976
Author: Nick Mathewson ni...@torproject.org
Date:   Thu Mar 27 17:41:43 2014 -0400

Respond to  requests on DNSPort with  automaps

Other DNS+IPv6 problems remain, but at least this fixes the
automapping.

Fixes bug 10468; bugfix on 0.2.4.7-alpha.
---
 changes/bug10468 |4 
 src/or/dnsserv.c |   10 ++
 2 files changed, 14 insertions(+)

diff --git a/changes/bug10468 b/changes/bug10468
new file mode 100644
index 000..128eb3a
--- /dev/null
+++ b/changes/bug10468
@@ -0,0 +1,4 @@
+  o Minor bugfixes:
+- When using DNSPort and AutomapHostsOnResolve, respond to 
+  requests with  automapped answers. Fixes bug 10468; bugfix
+  on 0.2.4.7-alpha.
diff --git a/src/or/dnsserv.c b/src/or/dnsserv.c
index ebff7b5..4190e9c 100644
--- a/src/or/dnsserv.c
+++ b/src/or/dnsserv.c
@@ -131,6 +131,16 @@ evdns_server_callback(struct evdns_server_request *req, 
void *data_)
   else
 entry_conn-socks_request-command = SOCKS_COMMAND_RESOLVE_PTR;
 
+  if (q-type == EVDNS_TYPE_A) {
+entry_conn-ipv4_traffic_ok = 1;
+entry_conn-ipv6_traffic_ok = 0;
+entry_conn-prefer_ipv6_traffic = 0;
+  } else if (q-type == EVDNS_TYPE_) {
+entry_conn-ipv4_traffic_ok = 0;
+entry_conn-ipv6_traffic_ok = 1;
+entry_conn-prefer_ipv6_traffic = 1;
+  }
+
   strlcpy(entry_conn-socks_request-address, q-name,
   sizeof(entry_conn-socks_request-address));
 



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


[tor-commits] [tor/master] Merge remote-tracking branch 'public/bug10468_024'

2014-04-01 Thread nickm
commit 86f619d0d34657e96d8ae3e83a197382bf6ba344
Merge: fc9e840 46a3914
Author: Nick Mathewson ni...@torproject.org
Date:   Tue Apr 1 21:50:55 2014 -0400

Merge remote-tracking branch 'public/bug10468_024'

 changes/bug10468 |4 
 src/or/dnsserv.c |   10 ++
 2 files changed, 14 insertions(+)

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


[tor-commits] [tor/master] Free placeholder circid/chan-circuit map entries on exit

2014-04-01 Thread nickm
commit 852fd1819e911dfafef624640d9b54157073c326
Author: Nick Mathewson ni...@torproject.org
Date:   Tue Mar 25 10:14:26 2014 -0400

Free placeholder circid/chan-circuit map entries on exit

In circuitlist_free_all, we free all the circuits, removing them from
the map as we go, but we weren't actually freeing the placeholder
entries that we use to indicate pending DESTROY cells.

Fix for bug 11278; bugfix on the 7912 code that was merged in
0.2.5.1-alpha
---
 changes/bug11278 |3 +++
 src/or/circuitlist.c |   12 
 2 files changed, 15 insertions(+)

diff --git a/changes/bug11278 b/changes/bug11278
new file mode 100644
index 000..4fa59fc
--- /dev/null
+++ b/changes/bug11278
@@ -0,0 +1,3 @@
+  o Minor bugfixes:
+- Free placeholder entries in our circuit table at exit; fixes
+  a harmless memory leak. Fixes bug 11278; bugfix on 0.2.5.1-alpha.
diff --git a/src/or/circuitlist.c b/src/or/circuitlist.c
index b1efde5..5b8225a 100644
--- a/src/or/circuitlist.c
+++ b/src/or/circuitlist.c
@@ -833,6 +833,18 @@ circuit_free_all(void)
   smartlist_free(circuits_pending_chans);
   circuits_pending_chans = NULL;
 
+  {
+chan_circid_circuit_map_t **elt, **next, *c;
+for (elt = HT_START(chan_circid_map, chan_circid_map);
+ elt;
+ elt = next) {
+  c = *elt;
+  next = HT_NEXT_RMV(chan_circid_map, chan_circid_map, elt);
+
+  tor_assert(c-circuit == NULL);
+  tor_free(c);
+}
+  }
   HT_CLEAR(chan_circid_map, chan_circid_map);
 }
 



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


[tor-commits] [tor/master] Merge remote-tracking branch 'public/bug11278'

2014-04-01 Thread nickm
commit 17d5734df47bc4b9bd40f878e492eb676ca47ae8
Merge: 86f619d 852fd18
Author: Nick Mathewson ni...@torproject.org
Date:   Tue Apr 1 21:56:49 2014 -0400

Merge remote-tracking branch 'public/bug11278'

 changes/bug11278 |3 +++
 src/or/circuitlist.c |   12 
 2 files changed, 15 insertions(+)

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