Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ZerXes
Tor
Commits
0957ffeb
Commit
0957ffeb
authored
May 09, 2003
by
Nick Mathewson
👁
Browse files
work on versioning; new log_fn function
svn:r288
parent
9f38ba19
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/common/fakepoll.h
View file @
0957ffeb
...
...
@@ -9,6 +9,9 @@
/*
* Changes :
* $Log$
* Revision 1.2 2003/05/09 02:25:37 nickm
* work on versioning; new log_fn function
*
* Revision 1.1 2002/09/03 18:43:50 nickm
* Add function to fake a poll call using select
*
...
...
@@ -17,7 +20,6 @@
#define __FAKEPOLL_H
#include
"orconfig.h"
#undef VERSION
#ifndef HAVE_POLL_H
#ifndef HAVE_SYS_POLL_H
...
...
src/common/log.h
View file @
0957ffeb
...
...
@@ -8,8 +8,11 @@
/*
* Changes :
* $Log$
* Revision 1.1 2002/06/26 22:45:50 arma
* Initial revision
* Revision 1.2 2003/05/09 02:25:37 nickm
* work on versioning; new log_fn function
*
* Revision 1.1.1.1 2002/06/26 22:45:50 arma
* initial commit: current code
*
* Revision 1.5 2002/01/26 18:52:00 mp292
* Reviewed according to Secure-Programs-HOWTO.
...
...
@@ -36,5 +39,12 @@
/* Outputs a message to stdout and also logs the same message using syslog. */
void
log
(
int
severity
,
const
char
*
format
,
...);
#ifdef __GNUCC__
#define log_fn(severity, format, args...) \
log((severity), __PRETTY_FUNCTION__ # "(): " # format, ##args)
#else
#define log_fn log
#endif
# define __LOG_H
#endif
src/or/directory.c
View file @
0957ffeb
...
...
@@ -157,7 +157,7 @@ int connection_dir_process_inbuf(connection_t *conn) {
log
(
LOG_DEBUG
,
"connection_dir_process_inbuf(): and got a %s directory; updated routers."
,
conn
->
pkey
?
"authenticated"
:
"unauthenticated"
);
}
if
(
options
.
ORPort
)
{
/* connect to them all */
router_retry_connections
();
}
...
...
src/or/main.c
View file @
0957ffeb
...
...
@@ -708,8 +708,7 @@ dump_signed_directory_to_string_impl(char *s, int maxlen, directory_t *dir,
eos
=
s
+
maxlen
;
strncpy
(
s
,
"signed-directory
\n
"
"client-software x y z
\n
"
/* XXX make this real */
"server-software a b c
\n\n
"
/* XXX make this real */
"recommended-software 0.0.2pre4,0.0.2pre5,0.0.2pre6
\n
"
/* XXX make this real */
,
maxlen
);
i
=
strlen
(
s
);
...
...
src/or/or.h
View file @
0957ffeb
...
...
@@ -330,6 +330,7 @@ typedef struct {
typedef
struct
{
routerinfo_t
**
routers
;
int
n_routers
;
char
*
software_versions
;
}
directory_t
;
struct
crypt_path_t
{
...
...
src/or/routers.c
View file @
0957ffeb
...
...
@@ -44,20 +44,20 @@ int learn_my_address(struct sockaddr_in *me) {
/* obtain local host information */
if
(
gethostname
(
localhostname
,
512
)
<
0
)
{
log
(
LOG_ERR
,
"Error obtaining local hostname."
);
log
_fn
(
LOG_ERR
,
"Error obtaining local hostname."
);
return
-
1
;
}
log
(
LOG_DEBUG
,
"
learn_my_address():
localhostname is '%s'."
,
localhostname
);
log
_fn
(
LOG_DEBUG
,
"localhostname is '%s'."
,
localhostname
);
localhost
=
gethostbyname
(
localhostname
);
if
(
!
localhost
)
{
log
(
LOG_ERR
,
"Error obtaining local host info."
);
log
_fn
(
LOG_ERR
,
"Error obtaining local host info."
);
return
-
1
;
}
memset
(
me
,
0
,
sizeof
(
struct
sockaddr_in
));
me
->
sin_family
=
AF_INET
;
memcpy
((
void
*
)
&
me
->
sin_addr
,(
void
*
)
localhost
->
h_addr
,
sizeof
(
struct
in_addr
));
me
->
sin_port
=
htons
(
options
.
ORPort
);
log
(
LOG_DEBUG
,
"
learn_my_address():
chose address as '%s'."
,
inet_ntoa
(
me
->
sin_addr
));
log
_fn
(
LOG_DEBUG
,
"chose address as '%s'."
,
inet_ntoa
(
me
->
sin_addr
));
return
0
;
}
...
...
@@ -69,7 +69,7 @@ void router_retry_connections(void) {
for
(
i
=
0
;
i
<
directory
->
n_routers
;
i
++
)
{
router
=
directory
->
routers
[
i
];
if
(
!
connection_exact_get_by_addr_port
(
router
->
addr
,
router
->
or_port
))
{
/* not in the list */
log
(
LOG_DEBUG
,
"
retry_all_connections():
connecting to OR %s:%u."
,
router
->
address
,
router
->
or_port
);
log
_fn
(
LOG_DEBUG
,
"connecting to OR %s:%u."
,
router
->
address
,
router
->
or_port
);
connection_or_connect_as_or
(
router
);
}
}
...
...
@@ -199,19 +199,19 @@ int router_get_list_from_file(char *routerfile)
assert
(
routerfile
);
if
(
strcspn
(
routerfile
,
CONFIG_LEGAL_FILENAME_CHARACTERS
)
!=
0
)
{
log
(
LOG_ERR
,
"
router_get_list_from_file():
Filename %s contains illegal characters."
,
routerfile
);
log
_fn
(
LOG_ERR
,
"Filename %s contains illegal characters."
,
routerfile
);
return
-
1
;
}
if
(
stat
(
routerfile
,
&
statbuf
)
<
0
)
{
log
(
LOG_ERR
,
"
router_get_list_from_file():
Could not stat %s."
,
routerfile
);
log
_fn
(
LOG_ERR
,
"Could not stat %s."
,
routerfile
);
return
-
1
;
}
/* open the router list */
fd
=
open
(
routerfile
,
O_RDONLY
,
0
);
if
(
fd
<
0
)
{
log
(
LOG_ERR
,
"
router_get_list_from_file():
Could not open %s."
,
routerfile
);
log
_fn
(
LOG_ERR
,
"Could not open %s."
,
routerfile
);
return
-
1
;
}
...
...
@@ -244,11 +244,10 @@ int router_get_list_from_file(char *routerfile)
typedef
enum
{
K_ACCEPT
,
K_CLIENT_SOFTWARE
,
K_DIRECTORY_SIGNATURE
,
K_RECOMMENDED_SOFTWARE
,
K_REJECT
,
K_ROUTER
,
K_SERVER_SOFTWARE
,
K_SIGNED_DIRECTORY
,
K_SIGNING_KEY
,
_SIGNATURE
,
...
...
@@ -261,11 +260,10 @@ struct token_table_ent { char *t; int v; };
static
struct
token_table_ent
token_table
[]
=
{
{
"accept"
,
K_ACCEPT
},
{
"client-software"
,
K_CLIENT_SOFTWARE
},
{
"directory-signature"
,
K_DIRECTORY_SIGNATURE
},
{
"reject"
,
K_REJECT
},
{
"router"
,
K_ROUTER
},
{
"
server
-software"
,
K_
SERVER
_SOFTWARE
},
{
"
recommended
-software"
,
K_
RECOMMENDED
_SOFTWARE
},
{
"signed-directory"
,
K_SIGNED_DIRECTORY
},
{
"signing-key"
,
K_SIGNING_KEY
},
{
NULL
,
-
1
}
...
...
@@ -395,11 +393,10 @@ router_dump_token(directory_token_t *tok) {
puts
(
"EOF"
);
return
;
case
K_ACCEPT
:
printf
(
"Accept"
);
break
;
case
K_CLIENT_SOFTWARE
:
printf
(
"Client-Software"
);
break
;
case
K_DIRECTORY_SIGNATURE
:
printf
(
"Directory-Signature"
);
break
;
case
K_REJECT
:
printf
(
"Reject"
);
break
;
case
K_RECOMMENDED_SOFTWARE
:
printf
(
"Server-Software"
);
break
;
case
K_ROUTER
:
printf
(
"Router"
);
break
;
case
K_SERVER_SOFTWARE
:
printf
(
"Server-Software"
);
break
;
case
K_SIGNED_DIRECTORY
:
printf
(
"Signed-Directory"
);
break
;
case
K_SIGNING_KEY
:
printf
(
"Signing-Key"
);
break
;
default:
...
...
@@ -518,6 +515,7 @@ int router_get_dir_from_string(char *s, crypto_pk_env_t *pkey)
log
(
LOG_ERR
,
"Error resolving directory"
);
return
-
1
;
}
/* XXXX Check version number */
return
0
;
}
...
...
@@ -528,6 +526,7 @@ int router_get_dir_from_string_impl(char *s, directory_t **dest,
char
digest
[
20
];
char
signed_digest
[
128
];
directory_t
*
new_dir
=
NULL
;
char
*
versions
;
#define NEXT_TOK() \
do { \
...
...
@@ -551,16 +550,19 @@ int router_get_dir_from_string_impl(char *s, directory_t **dest,
TOK_IS
(
K_SIGNED_DIRECTORY
,
"signed-directory"
);
NEXT_TOK
();
TOK_IS
(
K_CLIENT_SOFTWARE
,
"client-software"
);
NEXT_TOK
();
TOK_IS
(
K_SERVER_SOFTWARE
,
"server-software"
);
TOK_IS
(
K_RECOMMENDED_SOFTWARE
,
"recommended-software"
);
if
(
tok
.
val
.
cmd
.
n_args
!=
1
)
{
log
(
LOG_ERR
,
"Invalid recommded-software line"
);
return
-
1
;
}
versions
=
strdup
(
tok
.
val
.
cmd
.
args
[
0
]);
NEXT_TOK
();
if
(
router_get_list_from_string_tok
(
&
s
,
&
new_dir
,
&
tok
))
{
log
(
LOG_ERR
,
"Error reading routers from directory"
);
return
-
1
;
}
new_dir
->
software_versions
=
versions
;
TOK_IS
(
K_DIRECTORY_SIGNATURE
,
"directory-signature"
);
NEXT_TOK
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment