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
e758d659
Commit
e758d659
authored
7 years ago
by
David Goulet
Browse files
Options
Downloads
Patches
Plain Diff
geoip: Add clientmap_entry_new() function
Signed-off-by:
David Goulet
<
dgoulet@torproject.org
>
parent
4d812e29
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
+26
-6
26 additions, 6 deletions
src/or/geoip.c
with
26 additions
and
6 deletions
src/or/geoip.c
+
26
−
6
View file @
e758d659
...
...
@@ -580,6 +580,31 @@ clientmap_entry_free(clientmap_entry_t *ent)
tor_free
(
ent
);
}
/* Return a newly allocated clientmap entry with the given action and address
* that are mandatory. The transport_name can be optional. This can't fail. */
static
clientmap_entry_t
*
clientmap_entry_new
(
geoip_client_action_t
action
,
const
tor_addr_t
*
addr
,
const
char
*
transport_name
)
{
clientmap_entry_t
*
entry
;
tor_assert
(
action
==
GEOIP_CLIENT_CONNECT
||
action
==
GEOIP_CLIENT_NETWORKSTATUS
);
tor_assert
(
addr
);
entry
=
tor_malloc_zero
(
sizeof
(
clientmap_entry_t
));
entry
->
action
=
action
;
tor_addr_copy
(
&
entry
->
addr
,
addr
);
if
(
transport_name
)
{
entry
->
transport_name
=
tor_strdup
(
transport_name
);
}
/* Allocated and initialized, note down its size for the OOM handler. */
geoip_increment_client_history_cache_size
(
clientmap_entry_size
(
entry
));
return
entry
;
}
/** Clear history of connecting clients used by entry and bridge stats. */
static
void
client_history_clear
(
void
)
...
...
@@ -632,13 +657,8 @@ geoip_note_client_seen(geoip_client_action_t action,
ent
=
HT_FIND
(
clientmap
,
&
client_history
,
&
lookup
);
if
(
!
ent
)
{
ent
=
tor_malloc_zero
(
sizeof
(
clientmap_entry_t
));
tor_addr_copy
(
&
ent
->
addr
,
addr
);
if
(
transport_name
)
ent
->
transport_name
=
tor_strdup
(
transport_name
);
ent
->
action
=
(
int
)
action
;
ent
=
clientmap_entry_new
(
action
,
addr
,
transport_name
);
HT_INSERT
(
clientmap
,
&
client_history
,
ent
);
geoip_increment_client_history_cache_size
(
clientmap_entry_size
(
ent
));
}
if
(
now
/
60
<=
(
int
)
MAX_LAST_SEEN_IN_MINUTES
&&
now
>=
0
)
ent
->
last_seen_in_minutes
=
(
unsigned
)(
now
/
60
);
...
...
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