Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Tor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sergi
Tor
Commits
0a3e6d81
Commit
0a3e6d81
authored
4 years ago
by
Neel Chauhan
Committed by
Nick Mathewson
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Make routerset_contains_router() support IPv6
parent
3cb77a9c
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/feature/nodelist/routerset.c
+24
-13
24 additions, 13 deletions
src/feature/nodelist/routerset.c
with
24 additions
and
13 deletions
src/feature/nodelist/routerset.c
+
24
−
13
View file @
0a3e6d81
...
...
@@ -223,11 +223,11 @@ routerset_len(const routerset_t *set)
*
* (If country is -1, then we take the country
* from addr.) */
STATIC
int
routerset_contains
(
const
routerset_t
*
set
,
const
tor_addr_t
*
addr
,
uint16_t
orport
,
const
char
*
nickname
,
const
char
*
id_digest
,
country_t
country
)
static
int
routerset_contains
2
(
const
routerset_t
*
set
,
const
tor_addr_t
*
addr
,
uint16_t
orport
,
const
tor_addr_t
*
addr2
,
uint16_t
orport2
,
const
char
*
nickname
,
const
char
*
id_digest
,
country_t
country
)
{
if
(
!
set
||
!
set
->
list
)
return
0
;
...
...
@@ -238,6 +238,9 @@ routerset_contains(const routerset_t *set, const tor_addr_t *addr,
if
(
addr
&&
compare_tor_addr_to_addr_policy
(
addr
,
orport
,
set
->
policies
)
==
ADDR_POLICY_REJECTED
)
return
3
;
if
(
addr2
&&
compare_tor_addr_to_addr_policy
(
addr2
,
orport2
,
set
->
policies
)
==
ADDR_POLICY_REJECTED
)
return
3
;
if
(
set
->
countries
)
{
if
(
country
<
0
&&
addr
)
country
=
geoip_get_country_by_addr
(
addr
);
...
...
@@ -249,6 +252,17 @@ routerset_contains(const routerset_t *set, const tor_addr_t *addr,
return
0
;
}
/** Helper. Like routerset_contains2() but for a single IP/port combo.
*/
STATIC
int
routerset_contains
(
const
routerset_t
*
set
,
const
tor_addr_t
*
addr
,
uint16_t
orport
,
const
char
*
nickname
,
const
char
*
id_digest
,
country_t
country
)
{
return
routerset_contains2
(
set
,
addr
,
orport
,
NULL
,
0
,
nickname
,
id_digest
,
country
);
}
/** If *<b>setp</b> includes at least one country code, or if
* <b>only_some_cc_set</b> is 0, add the ?? and A1 country codes to
* *<b>setp</b>, creating it as needed. Return true iff *<b>setp</b> changed.
...
...
@@ -306,14 +320,11 @@ int
routerset_contains_router
(
const
routerset_t
*
set
,
const
routerinfo_t
*
ri
,
country_t
country
)
{
tor_addr_t
addr
;
tor_addr_from_ipv4h
(
&
addr
,
ri
->
addr
);
return
routerset_contains
(
set
,
&
addr
,
ri
->
or_port
,
ri
->
nickname
,
ri
->
cache_info
.
identity_digest
,
country
);
tor_addr_t
addr_v4
;
tor_addr_from_ipv4h
(
&
addr_v4
,
ri
->
addr
);
return
routerset_contains2
(
set
,
&
addr_v4
,
ri
->
or_port
,
&
ri
->
ipv6_addr
,
ri
->
ipv6_orport
,
ri
->
nickname
,
ri
->
cache_info
.
identity_digest
,
country
);
}
/** Return true iff <b>rs</b> is in <b>set</b>. If country is <b>-1</b>, we
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment