commit b1f16f73f7a07653a70fd897710b7b6f59be7d15 Author: Damian Johnson atagar@torproject.org Date: Sat May 28 11:19:38 2016 -0700
Parse IPv6 ORPort of fallback directories
Include the 'ipv6=' lines among information we parse. Useful in general, but doing this at the moment so we can check the IPv6 endpoints in DocTor...
https://trac.torproject.org/projects/tor/ticket/18177 --- cache_fallback_directories.py | 4 ++ stem/control.py | 4 +- stem/descriptor/fallback_directories.cfg | 56 +++++++++++++++++++++++- stem/descriptor/remote.py | 73 ++++++++++++++++++++++++++------ test/unit/descriptor/remote.py | 1 + 5 files changed, 121 insertions(+), 17 deletions(-)
diff --git a/cache_fallback_directories.py b/cache_fallback_directories.py index 21d9fcf..cd613e4 100755 --- a/cache_fallback_directories.py +++ b/cache_fallback_directories.py @@ -60,4 +60,8 @@ if __name__ == '__main__': conf.set('%s.or_port' % fingerprint, str(directory.or_port)) conf.set('%s.dir_port' % fingerprint, str(directory.dir_port))
+ if directory.orport_v6: + conf.set('%s.orport6_address' % fingerprint, str(directory.orport_v6[0])) + conf.set('%s.orport6_port' % fingerprint, str(directory.orport_v6[1])) + conf.save(stem.descriptor.remote.CACHE_PATH) diff --git a/stem/control.py b/stem/control.py index f1eb274..31e19d5 100644 --- a/stem/control.py +++ b/stem/control.py @@ -487,8 +487,8 @@ def event_description(event):
:param str event: the event for which a description is needed
- :returns: str The event description or **None** if this is an event name we - don't have a description for + :returns: **str** The event description or **None** if this is an event name + we don't have a description for """
global EVENT_DESCRIPTIONS diff --git a/stem/descriptor/fallback_directories.cfg b/stem/descriptor/fallback_directories.cfg index 50ad27b..c896c5b 100644 --- a/stem/descriptor/fallback_directories.cfg +++ b/stem/descriptor/fallback_directories.cfg @@ -1,14 +1,18 @@ tor_commit 1fd4340f827065485f8ce3fd03c5573f89880893 -stem_commit b5661f160a393984fd99b2cb67438ee4eb76e3a9 +stem_commit 7773234cbdd43e768babe6bb930303e4c13b74e3 9504CB22EEB25D344DE63CB7A6F2C46F895C3686.address 46.101.102.71 9504CB22EEB25D344DE63CB7A6F2C46F895C3686.or_port 443 9504CB22EEB25D344DE63CB7A6F2C46F895C3686.dir_port 80 +9504CB22EEB25D344DE63CB7A6F2C46F895C3686.orport6_address 2a03:b0c0:3:d0::2ed:7001 +9504CB22EEB25D344DE63CB7A6F2C46F895C3686.orport6_port 9050 823AA81E277F366505545522CEDC2F529CE4DC3F.address 192.160.102.164 823AA81E277F366505545522CEDC2F529CE4DC3F.or_port 9001 823AA81E277F366505545522CEDC2F529CE4DC3F.dir_port 80 AEA43CB1E47BE5F8051711B2BF01683DB1568E05.address 37.187.7.74 AEA43CB1E47BE5F8051711B2BF01683DB1568E05.or_port 443 AEA43CB1E47BE5F8051711B2BF01683DB1568E05.dir_port 80 +AEA43CB1E47BE5F8051711B2BF01683DB1568E05.orport6_address 2001:41d0:a:74a::1 +AEA43CB1E47BE5F8051711B2BF01683DB1568E05.orport6_port 443 86C281AD135058238D7A337D546C902BE8505DDE.address 185.96.88.29 86C281AD135058238D7A337D546C902BE8505DDE.or_port 443 86C281AD135058238D7A337D546C902BE8505DDE.dir_port 80 @@ -18,6 +22,8 @@ AEA43CB1E47BE5F8051711B2BF01683DB1568E05.dir_port 80 387B065A38E4DAA16D9D41C2964ECBC4B31D30FF.address 62.210.92.11 387B065A38E4DAA16D9D41C2964ECBC4B31D30FF.or_port 9101 387B065A38E4DAA16D9D41C2964ECBC4B31D30FF.dir_port 9130 +387B065A38E4DAA16D9D41C2964ECBC4B31D30FF.orport6_address 2001:bc8:338c::1 +387B065A38E4DAA16D9D41C2964ECBC4B31D30FF.orport6_port 9101 DE134FC8E5CC4EC8A5DE66934E70AC9D70267197.address 195.191.233.221 DE134FC8E5CC4EC8A5DE66934E70AC9D70267197.or_port 443 DE134FC8E5CC4EC8A5DE66934E70AC9D70267197.dir_port 80 @@ -27,24 +33,34 @@ DE134FC8E5CC4EC8A5DE66934E70AC9D70267197.dir_port 80 50586E25BE067FD1F739998550EDDCB1A14CA5B2.address 212.51.134.123 50586E25BE067FD1F739998550EDDCB1A14CA5B2.or_port 9001 50586E25BE067FD1F739998550EDDCB1A14CA5B2.dir_port 9030 +50586E25BE067FD1F739998550EDDCB1A14CA5B2.orport6_address 2a02:168:6e00:0:3a60:77ff:fe9c:8bd1 +50586E25BE067FD1F739998550EDDCB1A14CA5B2.orport6_port 9001 BCEDF6C193AA687AE471B8A22EBF6BC57C2D285E.address 198.96.155.3 BCEDF6C193AA687AE471B8A22EBF6BC57C2D285E.or_port 5001 BCEDF6C193AA687AE471B8A22EBF6BC57C2D285E.dir_port 8080 F65E0196C94DFFF48AFBF2F5F9E3E19AAE583FD0.address 94.242.246.23 F65E0196C94DFFF48AFBF2F5F9E3E19AAE583FD0.or_port 9001 F65E0196C94DFFF48AFBF2F5F9E3E19AAE583FD0.dir_port 443 +F65E0196C94DFFF48AFBF2F5F9E3E19AAE583FD0.orport6_address 2a01:608:ffff:ff07::1:23 +F65E0196C94DFFF48AFBF2F5F9E3E19AAE583FD0.orport6_port 9003 616081EC829593AF4232550DE6FFAA1D75B37A90.address 95.128.43.164 616081EC829593AF4232550DE6FFAA1D75B37A90.or_port 443 616081EC829593AF4232550DE6FFAA1D75B37A90.dir_port 80 +616081EC829593AF4232550DE6FFAA1D75B37A90.orport6_address 2a02:ec0:209:10::4 +616081EC829593AF4232550DE6FFAA1D75B37A90.orport6_port 443 58ED9C9C35E433EE58764D62892B4FFD518A3CD0.address 185.21.100.50 58ED9C9C35E433EE58764D62892B4FFD518A3CD0.or_port 9001 58ED9C9C35E433EE58764D62892B4FFD518A3CD0.dir_port 9030 +58ED9C9C35E433EE58764D62892B4FFD518A3CD0.orport6_address 2a00:1158:2:cd00:0:74:6f:72 +58ED9C9C35E433EE58764D62892B4FFD518A3CD0.orport6_port 443 35E8B344F661F4F2E68B17648F35798B44672D7E.address 146.0.32.144 35E8B344F661F4F2E68B17648F35798B44672D7E.or_port 9001 35E8B344F661F4F2E68B17648F35798B44672D7E.dir_port 9030 14419131033443AE6E21DA82B0D307F7CAE42BDB.address 144.76.14.145 14419131033443AE6E21DA82B0D307F7CAE42BDB.or_port 143 14419131033443AE6E21DA82B0D307F7CAE42BDB.dir_port 110 +14419131033443AE6E21DA82B0D307F7CAE42BDB.orport6_address 2a01:4f8:190:9490::dead +14419131033443AE6E21DA82B0D307F7CAE42BDB.orport6_port 443 79E169B25E4C7CE99584F6ED06F379478F23E2B8.address 62.210.129.246 79E169B25E4C7CE99584F6ED06F379478F23E2B8.or_port 443 79E169B25E4C7CE99584F6ED06F379478F23E2B8.dir_port 80 @@ -57,6 +73,8 @@ EBE718E1A49EE229071702964F8DB1F318075FF8.dir_port 443 489D94333DF66D57FFE34D9D59CC2D97E2CB0053.address 37.187.102.186 489D94333DF66D57FFE34D9D59CC2D97E2CB0053.or_port 9001 489D94333DF66D57FFE34D9D59CC2D97E2CB0053.dir_port 9030 +489D94333DF66D57FFE34D9D59CC2D97E2CB0053.orport6_address 2001:41d0:a:26ba::1 +489D94333DF66D57FFE34D9D59CC2D97E2CB0053.orport6_port 9001 99E246DB480B313A3012BC3363093CC26CD209C7.address 81.7.10.93 99E246DB480B313A3012BC3363093CC26CD209C7.or_port 31337 99E246DB480B313A3012BC3363093CC26CD209C7.dir_port 31336 @@ -78,12 +96,16 @@ AE6A8C18E7499B586CD36246AC4BCAFFBBF93AB2.dir_port 80 9007C1D8E4F03D506A4A011B907A9E8D04E3C605.address 151.80.42.103 9007C1D8E4F03D506A4A011B907A9E8D04E3C605.or_port 9001 9007C1D8E4F03D506A4A011B907A9E8D04E3C605.dir_port 9030 +9007C1D8E4F03D506A4A011B907A9E8D04E3C605.orport6_address 2001:41d0:e:f67::114 +9007C1D8E4F03D506A4A011B907A9E8D04E3C605.orport6_port 9001 B143D439B72D239A419F8DCE07B8A8EB1B486FA7.address 212.129.62.232 B143D439B72D239A419F8DCE07B8A8EB1B486FA7.or_port 443 B143D439B72D239A419F8DCE07B8A8EB1B486FA7.dir_port 80 32EE911D968BE3E016ECA572BB1ED0A9EE43FC2F.address 109.105.109.162 32EE911D968BE3E016ECA572BB1ED0A9EE43FC2F.or_port 60784 32EE911D968BE3E016ECA572BB1ED0A9EE43FC2F.dir_port 52860 +32EE911D968BE3E016ECA572BB1ED0A9EE43FC2F.orport6_address 2001:948:7:2::163 +32EE911D968BE3E016ECA572BB1ED0A9EE43FC2F.orport6_port 5001 39F096961ED2576975C866D450373A9913AFDC92.address 198.50.191.95 39F096961ED2576975C866D450373A9913AFDC92.or_port 443 39F096961ED2576975C866D450373A9913AFDC92.dir_port 80 @@ -99,15 +121,21 @@ BC630CBBB518BE7E9F4E09712AB0269E9DC7D626.dir_port 9030 AC66FFA4AB35A59EBBF5BF4C70008BF24D8A7A5C.address 195.154.164.243 AC66FFA4AB35A59EBBF5BF4C70008BF24D8A7A5C.or_port 443 AC66FFA4AB35A59EBBF5BF4C70008BF24D8A7A5C.dir_port 80 +AC66FFA4AB35A59EBBF5BF4C70008BF24D8A7A5C.orport6_address 2001:bc8:399f:f000::1 +AC66FFA4AB35A59EBBF5BF4C70008BF24D8A7A5C.orport6_port 993 A10C4F666D27364036B562823E5830BC448E046A.address 171.25.193.77 A10C4F666D27364036B562823E5830BC448E046A.or_port 443 A10C4F666D27364036B562823E5830BC448E046A.dir_port 80 +A10C4F666D27364036B562823E5830BC448E046A.orport6_address 2001:67c:289c:3::77 +A10C4F666D27364036B562823E5830BC448E046A.orport6_port 443 CBEE0F3303C8C50462A12107CA2AE061831931BC.address 91.121.54.8 CBEE0F3303C8C50462A12107CA2AE061831931BC.or_port 9001 CBEE0F3303C8C50462A12107CA2AE061831931BC.dir_port 9030 CBEFF7BA4A4062045133C053F2D70524D8BBE5BE.address 178.62.199.226 CBEFF7BA4A4062045133C053F2D70524D8BBE5BE.or_port 443 CBEFF7BA4A4062045133C053F2D70524D8BBE5BE.dir_port 80 +CBEFF7BA4A4062045133C053F2D70524D8BBE5BE.orport6_address 2a03:b0c0:2:d0::b7:5001 +CBEFF7BA4A4062045133C053F2D70524D8BBE5BE.orport6_port 443 B87C84E38DAECFFFFDE98E5AEE5786AFDC748F2C.address 178.62.36.64 B87C84E38DAECFFFFDE98E5AEE5786AFDC748F2C.or_port 9001 B87C84E38DAECFFFFDE98E5AEE5786AFDC748F2C.dir_port 9030 @@ -132,12 +160,16 @@ CBD0D1BD110EC52963082D839AC6A89D0AE243E7.dir_port 9030 DD85503F2D1F52EF9EAD621E942298F46CD2FC10.address 178.62.173.203 DD85503F2D1F52EF9EAD621E942298F46CD2FC10.or_port 9001 DD85503F2D1F52EF9EAD621E942298F46CD2FC10.dir_port 9030 +DD85503F2D1F52EF9EAD621E942298F46CD2FC10.orport6_address 2a03:b0c0:0:1010::a4:b001 +DD85503F2D1F52EF9EAD621E942298F46CD2FC10.orport6_port 9001 C414F28FD2BEC1553024299B31D4E726BEB8E788.address 188.138.112.60 C414F28FD2BEC1553024299B31D4E726BEB8E788.or_port 1521 C414F28FD2BEC1553024299B31D4E726BEB8E788.dir_port 1433 FFA72BD683BC2FCF988356E6BEC1E490F313FB07.address 193.11.164.243 FFA72BD683BC2FCF988356E6BEC1E490F313FB07.or_port 9001 FFA72BD683BC2FCF988356E6BEC1E490F313FB07.dir_port 9030 +FFA72BD683BC2FCF988356E6BEC1E490F313FB07.orport6_address 2001:6b0:7:125::243 +FFA72BD683BC2FCF988356E6BEC1E490F313FB07.orport6_port 9001 5665A3904C89E22E971305EE8C1997BCA4123C69.address 94.23.204.175 5665A3904C89E22E971305EE8C1997BCA4123C69.or_port 9001 5665A3904C89E22E971305EE8C1997BCA4123C69.dir_port 9030 @@ -147,6 +179,8 @@ FFA72BD683BC2FCF988356E6BEC1E490F313FB07.dir_port 9030 E781F4EC69671B3F1864AE2753E0890351506329.address 176.31.180.157 E781F4EC69671B3F1864AE2753E0890351506329.or_port 22 E781F4EC69671B3F1864AE2753E0890351506329.dir_port 143 +E781F4EC69671B3F1864AE2753E0890351506329.orport6_address 2001:41d0:8:eb9d::1 +E781F4EC69671B3F1864AE2753E0890351506329.orport6_port 22 D62FB817B0288085FAC38A6DC8B36DCD85B70260.address 185.14.185.240 D62FB817B0288085FAC38A6DC8B36DCD85B70260.or_port 443 D62FB817B0288085FAC38A6DC8B36DCD85B70260.dir_port 9030 @@ -159,6 +193,8 @@ D62FB817B0288085FAC38A6DC8B36DCD85B70260.dir_port 9030 CFECDDCA990E3EF7B7EC958B22441386B6B8D820.address 81.7.17.171 CFECDDCA990E3EF7B7EC958B22441386B6B8D820.or_port 443 CFECDDCA990E3EF7B7EC958B22441386B6B8D820.dir_port 80 +CFECDDCA990E3EF7B7EC958B22441386B6B8D820.orport6_address 2a02:180:1:1::517:11ab +CFECDDCA990E3EF7B7EC958B22441386B6B8D820.orport6_port 443 92ECC9E0E2AF81BB954719B189AC362E254AD4A5.address 91.219.237.244 92ECC9E0E2AF81BB954719B189AC362E254AD4A5.or_port 443 92ECC9E0E2AF81BB954719B189AC362E254AD4A5.dir_port 80 @@ -168,12 +204,16 @@ D2A1703758A0FBBA026988B92C2F88BAB59F9361.dir_port 9030 0756B7CD4DFC8182BE23143FAC0642F515182CEB.address 5.9.110.236 0756B7CD4DFC8182BE23143FAC0642F515182CEB.or_port 9001 0756B7CD4DFC8182BE23143FAC0642F515182CEB.dir_port 9030 +0756B7CD4DFC8182BE23143FAC0642F515182CEB.orport6_address 2a01:4f8:162:51e2::2 +0756B7CD4DFC8182BE23143FAC0642F515182CEB.orport6_port 9001 2541759BEC04D37811C2209A88E863320271EC9C.address 185.61.138.18 2541759BEC04D37811C2209A88E863320271EC9C.or_port 4443 2541759BEC04D37811C2209A88E863320271EC9C.dir_port 8080 9030DCF419F6E2FBF84F63CBACBA0097B06F557E.address 5.79.68.161 9030DCF419F6E2FBF84F63CBACBA0097B06F557E.or_port 443 9030DCF419F6E2FBF84F63CBACBA0097B06F557E.dir_port 81 +9030DCF419F6E2FBF84F63CBACBA0097B06F557E.orport6_address 2001:1af8:4700:a012:1::1 +9030DCF419F6E2FBF84F63CBACBA0097B06F557E.orport6_port 443 DAA39FC00B196B353C2A271459C305C429AF09E4.address 193.35.52.53 DAA39FC00B196B353C2A271459C305C429AF09E4.or_port 9001 DAA39FC00B196B353C2A271459C305C429AF09E4.dir_port 9030 @@ -204,6 +244,8 @@ A0F06C2FADF88D3A39AA3072B406F09D7095AC9E.dir_port 80 08DC0F3C6E3D9C527C1FC8745D35DD1B0DE1875D.address 37.187.1.149 08DC0F3C6E3D9C527C1FC8745D35DD1B0DE1875D.or_port 9001 08DC0F3C6E3D9C527C1FC8745D35DD1B0DE1875D.dir_port 9030 +08DC0F3C6E3D9C527C1FC8745D35DD1B0DE1875D.orport6_address 2001:41d0:a:195::1 +08DC0F3C6E3D9C527C1FC8745D35DD1B0DE1875D.orport6_port 9001 2BA2C8E96B2590E1072AECE2BDB5C48921BF8510.address 144.76.26.175 2BA2C8E96B2590E1072AECE2BDB5C48921BF8510.or_port 9011 2BA2C8E96B2590E1072AECE2BDB5C48921BF8510.dir_port 9012 @@ -222,12 +264,16 @@ A0F06C2FADF88D3A39AA3072B406F09D7095AC9E.dir_port 80 BF0FB582E37F738CD33C3651125F2772705BB8E8.address 148.251.190.229 BF0FB582E37F738CD33C3651125F2772705BB8E8.or_port 9010 BF0FB582E37F738CD33C3651125F2772705BB8E8.dir_port 9030 +BF0FB582E37F738CD33C3651125F2772705BB8E8.orport6_address 2a01:4f8:211:c68::2 +BF0FB582E37F738CD33C3651125F2772705BB8E8.orport6_port 9010 6FC6F08270D565BE89B7C819DD8E2D487397C073.address 94.126.23.174 6FC6F08270D565BE89B7C819DD8E2D487397C073.or_port 9001 6FC6F08270D565BE89B7C819DD8E2D487397C073.dir_port 9030 75F1992FD3F403E9C082A5815EB5D12934CDF46C.address 46.101.237.246 75F1992FD3F403E9C082A5815EB5D12934CDF46C.or_port 9001 75F1992FD3F403E9C082A5815EB5D12934CDF46C.dir_port 9030 +75F1992FD3F403E9C082A5815EB5D12934CDF46C.orport6_address 2a03:b0c0:3:d0::208:5001 +75F1992FD3F403E9C082A5815EB5D12934CDF46C.orport6_port 9050 855BC2DABE24C861CD887DB9B2E950424B49FC34.address 84.219.173.60 855BC2DABE24C861CD887DB9B2E950424B49FC34.or_port 443 855BC2DABE24C861CD887DB9B2E950424B49FC34.dir_port 9030 @@ -237,6 +283,8 @@ BF0FB582E37F738CD33C3651125F2772705BB8E8.dir_port 9030 7A32C9519D80CA458FC8B034A28F5F6815649A98.address 82.223.21.74 7A32C9519D80CA458FC8B034A28F5F6815649A98.or_port 9001 7A32C9519D80CA458FC8B034A28F5F6815649A98.dir_port 9030 +7A32C9519D80CA458FC8B034A28F5F6815649A98.orport6_address 2001:470:53e0::cafe +7A32C9519D80CA458FC8B034A28F5F6815649A98.orport6_port 9050 0C2C599AFCB26F5CFC2C7592435924C1D63D9484.address 5.196.88.122 0C2C599AFCB26F5CFC2C7592435924C1D63D9484.or_port 9001 0C2C599AFCB26F5CFC2C7592435924C1D63D9484.dir_port 9030 @@ -258,9 +306,13 @@ D1B8AAA98C65F3DF7D8BB3AF881CAEB84A33D8EE.dir_port 9030 2EBD117806EE43C3CC885A8F1E4DC60F207E7D3E.address 62.210.124.124 2EBD117806EE43C3CC885A8F1E4DC60F207E7D3E.or_port 9101 2EBD117806EE43C3CC885A8F1E4DC60F207E7D3E.dir_port 9130 +2EBD117806EE43C3CC885A8F1E4DC60F207E7D3E.orport6_address 2001:bc8:3f23:100::1 +2EBD117806EE43C3CC885A8F1E4DC60F207E7D3E.orport6_port 9101 AD253B49E303C6AB1E048B014392AC569E8A7DAE.address 163.172.131.88 AD253B49E303C6AB1E048B014392AC569E8A7DAE.or_port 443 AD253B49E303C6AB1E048B014392AC569E8A7DAE.dir_port 80 +AD253B49E303C6AB1E048B014392AC569E8A7DAE.orport6_address 2001:bc8:4400:2100::2:1009 +AD253B49E303C6AB1E048B014392AC569E8A7DAE.orport6_port 443 ACD889D86E02EDDAB1AFD81F598C0936238DC6D0.address 86.59.119.88 ACD889D86E02EDDAB1AFD81F598C0936238DC6D0.or_port 443 ACD889D86E02EDDAB1AFD81F598C0936238DC6D0.dir_port 80 @@ -294,6 +346,8 @@ ABCB4965F1FEE193602B50A365425105C889D3F8.dir_port 9030 5CF8AFA5E4B0BB88942A44A3F3AAE08C3BDFD60B.address 178.16.208.62 5CF8AFA5E4B0BB88942A44A3F3AAE08C3BDFD60B.or_port 443 5CF8AFA5E4B0BB88942A44A3F3AAE08C3BDFD60B.dir_port 80 +5CF8AFA5E4B0BB88942A44A3F3AAE08C3BDFD60B.orport6_address 2a00:1c20:4089:1234:a6a4:2926:d0af:dfee +5CF8AFA5E4B0BB88942A44A3F3AAE08C3BDFD60B.orport6_port 443 1ECD73B936CB6E6B3CD647CC204F108D9DF2C9F7.address 91.219.237.229 1ECD73B936CB6E6B3CD647CC204F108D9DF2C9F7.or_port 443 1ECD73B936CB6E6B3CD647CC204F108D9DF2C9F7.dir_port 80 diff --git a/stem/descriptor/remote.py b/stem/descriptor/remote.py index 2a40d2d..6d48e39 100644 --- a/stem/descriptor/remote.py +++ b/stem/descriptor/remote.py @@ -704,8 +704,7 @@ class Directory(object):
.. versionadded:: 1.5.0
- :var str address: IP address of the authority, currently they're all IPv4 but - this may not always be the case + :var str address: IPv4 address of the directory :var int or_port: port on which the relay services relay traffic :var int dir_port: port on which directory information is available :var str fingerprint: relay fingerprint @@ -919,10 +918,14 @@ class FallbackDirectory(Directory): ...
.. versionadded:: 1.5.0 + + :var str orport_v6: **(address, port)** tuple for the directory's IPv6 + ORPort, or **None** if it doesn't have one """
- def __init__(self, address = None, or_port = None, dir_port = None, fingerprint = None): + def __init__(self, address = None, or_port = None, dir_port = None, fingerprint = None, orport_v6 = None): super(FallbackDirectory, self).__init__(address, or_port, dir_port, fingerprint) + self.orport_v6 = orport_v6
@staticmethod def from_cache(): @@ -948,25 +951,35 @@ class FallbackDirectory(Directory):
attr = {}
- for attr_name in ('address', 'or_port', 'dir_port'): + for attr_name in ('address', 'or_port', 'dir_port', 'orport6_address', 'orport6_port'): key = '%s.%s' % (fingerprint, attr_name) attr[attr_name] = conf.get(key)
- if not attr[attr_name]: + if not attr[attr_name] and not attr_name.startswith('orport6_'): raise IOError("'%s' is missing from %s" % (key, CACHE_PATH))
if not connection.is_valid_ipv4_address(attr['address']): - raise IOError("'%s.address' was an invalid address (%s)" % (fingerprint, attr['address'])) + raise IOError("'%s.address' was an invalid IPv4 address (%s)" % (fingerprint, attr['address'])) elif not connection.is_valid_port(attr['or_port']): raise IOError("'%s.or_port' was an invalid port (%s)" % (fingerprint, attr['or_port'])) elif not connection.is_valid_port(attr['dir_port']): raise IOError("'%s.dir_port' was an invalid port (%s)" % (fingerprint, attr['dir_port'])) + elif attr['orport6_address'] and not connection.is_valid_ipv6_address(attr['orport6_address']): + raise IOError("'%s.orport6_address' was an invalid IPv6 address (%s)" % (fingerprint, attr['orport6_address'])) + elif attr['orport6_port'] and not connection.is_valid_port(attr['orport6_port']): + raise IOError("'%s.orport6_port' was an invalid port (%s)" % (fingerprint, attr['orport6_port'])) + + if attr['orport6_address'] and attr['orport6_port']: + orport_v6 = (attr['orport6_address'], int(attr['orport6_port'])) + else: + orport_v6 = None
results[fingerprint] = FallbackDirectory( address = attr['address'], or_port = int(attr['or_port']), dir_port = int(attr['dir_port']), fingerprint = fingerprint, + orport_v6 = orport_v6, )
return results @@ -1004,19 +1017,21 @@ class FallbackDirectory(Directory): # Example of an entry... # # "5.175.233.86:80 orport=443 id=5525D0429BFE5DC4F1B0E9DE47A4CFA169661E33" + # " ipv6=[2a03:b0c0:0:1010::a4:b001]:9001" # " weight=43680",
- results = {} + results, attr = {}, {}
for line in fallback_dir_page.splitlines(): if line.startswith('"'): addr_line_match = re.match('"([\d.]+):(\d+) orport=(\d+) id=([\dA-F]{40}).*', line) + ipv6_line_match = re.match('" ipv6=[([\da-f:]+)]:(\d+)"', line)
if addr_line_match: address, dir_port, or_port, fingerprint = addr_line_match.groups()
if not connection.is_valid_ipv4_address(address): - raise IOError('%s has an invalid address: %s' % (fingerprint, address)) + raise IOError('%s has an invalid IPv4 address: %s' % (fingerprint, address)) elif not connection.is_valid_port(or_port): raise IOError('%s has an invalid or_port: %s' % (fingerprint, or_port)) elif not connection.is_valid_port(dir_port): @@ -1024,15 +1039,44 @@ class FallbackDirectory(Directory): elif not tor_tools.is_valid_fingerprint(fingerprint): raise IOError('%s has an invalid fingerprint: %s' % (fingerprint, fingerprint))
- results[fingerprint] = FallbackDirectory( - address = address, - or_port = int(or_port), - dir_port = int(dir_port), - fingerprint = fingerprint, + attr = { + 'address': address, + 'or_port': int(or_port), + 'dir_port': int(dir_port), + 'fingerprint': fingerprint, + } + elif ipv6_line_match: + address, port = ipv6_line_match.groups() + + if not connection.is_valid_ipv6_address(address): + raise IOError('%s has an invalid IPv6 address: %s' % (fingerprint, address)) + elif not connection.is_valid_port(port): + raise IOError('%s has an invalid ORPort for its IPv6 endpoint: %s' % (fingerprint, port)) + + attr['orport_v6'] = (address, int(port)) + elif line.startswith('" weight=') and 'fingerprint' in attr: + results[attr.get('fingerprint')] = FallbackDirectory( + address = attr.get('address'), + or_port = attr.get('or_port'), + dir_port = attr.get('dir_port'), + fingerprint = attr.get('fingerprint'), + orport_v6 = attr.get('orport_v6'), )
+ attr = {} + return results
+ def __eq__(self, other): + if not isinstance(other, FallbackDirectory): + return False + elif not super(FallbackDirectory, self).__eq__(other): + return False + elif self.orport_v6 != other.orport_v6: + return False + + return True +
def _fallback_directory_differences(previous_directories, new_directories): """ @@ -1052,6 +1096,7 @@ def _fallback_directory_differences(previous_directories, new_directories): ' address: %s' % directory.address, ' or_port: %s' % directory.or_port, ' dir_port: %s' % directory.dir_port, + ' orport_v6: %s' % directory.orport_v6 if directory.orport_v6 else '[none]', '', ]
@@ -1066,7 +1111,7 @@ def _fallback_directory_differences(previous_directories, new_directories): new_directory = new_directories[fp]
if previous_directory != new_directory: - for attr in ('address', 'or_port', 'dir_port', 'fingerprint'): + for attr in ('address', 'or_port', 'dir_port', 'fingerprint', 'orport_v6'): old_attr = getattr(previous_directory, attr) new_attr = getattr(new_directory, attr)
diff --git a/test/unit/descriptor/remote.py b/test/unit/descriptor/remote.py index 7309b57..8193cc3 100644 --- a/test/unit/descriptor/remote.py +++ b/test/unit/descriptor/remote.py @@ -190,6 +190,7 @@ class TestDescriptorDownloader(unittest.TestCase): or_port = 9101, dir_port = 9130, fingerprint = '2EBD117806EE43C3CC885A8F1E4DC60F207E7D3E', + orport_v6 = ('2001:bc8:3f23:100::1', 9101), ), }