Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Tor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
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
Benjamin J. Thompson
Tor
Commits
547635c0
Commit
547635c0
authored
14 years ago
by
Nick Mathewson
Browse files
Options
Downloads
Patches
Plain Diff
Futz with the clang patch a bit and tidy some geoip.c stuff
parent
56bdc844
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/or/geoip.c
+13
-8
13 additions, 8 deletions
src/or/geoip.c
with
13 additions
and
8 deletions
src/or/geoip.c
+
13
−
8
View file @
547635c0
...
...
@@ -278,19 +278,24 @@ geoip_is_loaded(void)
return
geoip_countries
!=
NULL
&&
geoip_entries
!=
NULL
;
}
#define MAX_LAST_SEEN_IN_MINUTES 0x3FFFFFFFu
/** Entry in a map from IP address to the last time we've seen an incoming
* connection from that IP address. Used by bridges only, to track which
* countries have them blocked. */
typedef
struct
clientmap_entry_t
{
HT_ENTRY
(
clientmap_entry_t
)
node
;
uint32_t
ipaddr
;
/** Time when we last saw this IP address, in MINUTES since the epoch.
*
* (This will run out of space around 4011 CE. If Tor is still in use around
* 4000 CE, please remember to add more bits to last_seen_in_minutes.) */
unsigned
int
last_seen_in_minutes
:
30
;
unsigned
int
action
:
2
;
}
clientmap_entry_t
;
#define ACTION_MASK 3
/** Largest allowable value for last_seen_in_minutes. (It's a 30-bit field,
* so it can hold up to (1u<<30)-1, or 0x3fffffffu.
*/
#define MAX_LAST_SEEN_IN_MINUTES 0X3FFFFFFFu
/** Map from client IP address to last time seen. */
static
HT_HEAD
(
clientmap
,
clientmap_entry_t
)
client_history
=
...
...
@@ -415,16 +420,16 @@ geoip_note_client_seen(geoip_client_action_t action,
lookup
.
ipaddr
=
addr
;
lookup
.
action
=
(
int
)
action
;
ent
=
HT_FIND
(
clientmap
,
&
client_history
,
&
lookup
);
tor_assert
(
now
/
60
<=
MAX_LAST_SEEN_IN_MINUTES
);
if
(
ent
)
{
ent
->
last_seen_in_minutes
=
(
unsigned
)(
now
/
60
);
}
else
{
if
(
!
ent
)
{
ent
=
tor_malloc_zero
(
sizeof
(
clientmap_entry_t
));
ent
->
ipaddr
=
addr
;
ent
->
last_seen_in_minutes
=
(
unsigned
)(
now
/
60
);
ent
->
action
=
(
int
)
action
;
HT_INSERT
(
clientmap
,
&
client_history
,
ent
);
}
if
(
now
/
60
<=
MAX_LAST_SEEN_IN_MINUTES
&&
now
>=
0
)
ent
->
last_seen_in_minutes
=
(
unsigned
)(
now
/
60
);
else
ent
->
last_seen_in_minutes
=
0
;
if
(
action
==
GEOIP_CLIENT_NETWORKSTATUS
||
action
==
GEOIP_CLIENT_NETWORKSTATUS_V2
)
{
...
...
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