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
Container Registry
Model registry
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
The Tor Project
Core
Tor
Commits
9c24ceeb
Commit
9c24ceeb
authored
5 years ago
by
Nick Mathewson
Browse files
Options
Downloads
Patches
Plain Diff
Make tor_addr_lookup_host_impl mockable.
parent
ac8f6d51
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/lib/net/resolve.c
+7
-7
7 additions, 7 deletions
src/lib/net/resolve.c
src/lib/net/resolve.h
+15
-0
15 additions, 0 deletions
src/lib/net/resolve.h
with
22 additions
and
7 deletions
src/lib/net/resolve.c
+
7
−
7
View file @
9c24ceeb
...
...
@@ -8,6 +8,7 @@
* \brief Use the libc DNS resolver to convert hostnames into addresses.
**/
#define RESOLVE_PRIVATE
#include
"lib/net/resolve.h"
#include
"lib/net/address.h"
...
...
@@ -70,10 +71,10 @@ tor_lookup_hostname,(const char *name, uint32_t *addr))
*
* See tor_addr_lookup() for details.
*/
static
int
tor_addr_lookup_host_impl
(
const
char
*
name
,
MOCK_IMPL
(
STATIC
int
,
tor_addr_lookup_host_impl
,
(
const
char
*
name
,
uint16_t
family
,
tor_addr_t
*
addr
)
tor_addr_t
*
addr
)
)
{
int
err
;
struct
addrinfo
*
res
=
NULL
,
*
res_p
;
...
...
@@ -125,10 +126,10 @@ tor_addr_lookup_host_impl(const char *name,
*
* See tor_addr_lookup() for details.
*/
static
int
tor_addr_lookup_host_impl
(
const
char
*
name
,
MOCK_IMPL
(
STATIC
int
,
tor_addr_lookup_host_impl
,
(
const
char
*
name
,
uint16_t
family
,
tor_addr_t
*
addr
)
tor_addr_t
*
addr
)
)
{
(
void
)
family
;
struct
hostent
*
ent
;
...
...
@@ -172,7 +173,6 @@ tor_addr_lookup_host_impl(const char *name,
return
(
err
==
TRY_AGAIN
)
?
1
:
-
1
;
#endif
}
#endif
/* defined(HAVE_GETADDRINFO) */
/** Similar behavior to Unix gethostbyname: resolve <b>name</b>, and set
...
...
This diff is collapsed.
Click to expand it.
src/lib/net/resolve.h
+
15
−
0
View file @
9c24ceeb
...
...
@@ -24,12 +24,18 @@
struct
tor_addr_t
;
/*
* Primary lookup functions.
*/
MOCK_DECL
(
int
,
tor_lookup_hostname
,(
const
char
*
name
,
uint32_t
*
addr
));
MOCK_DECL
(
int
,
tor_addr_lookup
,(
const
char
*
name
,
uint16_t
family
,
struct
tor_addr_t
*
addr_out
));
int
tor_addr_port_lookup
(
const
char
*
s
,
struct
tor_addr_t
*
addr_out
,
uint16_t
*
port_out
);
/*
* Sandbox helpers
*/
struct
addrinfo
;
#ifdef USE_SANDBOX_GETADDRINFO
/** Pre-calls getaddrinfo in order to pre-record result. */
...
...
@@ -55,4 +61,13 @@ void tor_free_getaddrinfo_cache(void);
void
sandbox_disable_getaddrinfo_cache
(
void
);
void
tor_make_getaddrinfo_cache_active
(
void
);
/*
* Internal resolver wrapper; exposed for mocking.
*/
#ifdef RESOLVE_PRIVATE
MOCK_DECL
(
STATIC
int
,
tor_addr_lookup_host_impl
,
(
const
char
*
name
,
uint16_t
family
,
struct
tor_addr_t
*
addr
));
#endif
#endif
/* !defined(TOR_RESOLVE_H) */
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