Tor  0.4.3.1-alpha-dev
bridgeauth.c
Go to the documentation of this file.
1 /* Copyright (c) 2001 Matej Pfajfar.
2  * Copyright (c) 2001-2004, Roger Dingledine.
3  * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
4  * Copyright (c) 2007-2020, The Tor Project, Inc. */
5 /* See LICENSE for licensing information */
6 
7 /**
8  * @file bridgeauth.c
9  * @brief Bridge authority code
10  **/
11 
12 #include "core/or/or.h"
16 #include "feature/relay/router.h"
17 #include "app/config/config.h"
18 
20 
21 /** Write out router status entries for all our bridge descriptors. Here, we
22  * also mark routers as running. */
23 void
25 {
26  char *status;
27  char *fname = NULL;
28  char *thresholds = NULL;
29  char *published_thresholds_and_status = NULL;
30  char published[ISO_TIME_LEN+1];
32  char fingerprint[FINGERPRINT_LEN+1];
33  char *fingerprint_line = NULL;
34 
36  status = networkstatus_getinfo_by_purpose("bridge", now);
37 
39  fingerprint, 0) >= 0) {
40  tor_asprintf(&fingerprint_line, "fingerprint %s\n", fingerprint);
41  } else {
42  log_warn(LD_BUG, "Error computing fingerprint for bridge status.");
43  }
44  format_iso_time(published, now);
45  dirserv_compute_bridge_flag_thresholds();
46  thresholds = dirserv_get_flag_thresholds_line();
47  tor_asprintf(&published_thresholds_and_status,
48  "published %s\nflag-thresholds %s\n%s%s",
49  published, thresholds, fingerprint_line ? fingerprint_line : "",
50  status);
51  fname = get_datadir_fname("networkstatus-bridges");
52  if (write_str_to_file(fname,published_thresholds_and_status,0)<0) {
53  log_warn(LD_DIRSERV, "Unable to write networkstatus-bridges file.");
54  }
55  tor_free(thresholds);
56  tor_free(published_thresholds_and_status);
57  tor_free(fname);
58  tor_free(status);
59  tor_free(fingerprint_line);
60 }
crypto_pk_t * identity_pkey
Definition: routerinfo_st.h:43
Router descriptor structure.
Header file for voteflags.c.
char * networkstatus_getinfo_by_purpose(const char *purpose_string, time_t now)
Header file for config.c.
#define tor_free(p)
Definition: malloc.h:52
void dirserv_set_bridges_running(time_t now)
Definition: voteflags.c:656
int write_str_to_file(const char *fname, const char *str, int bin)
Definition: files.c:258
int tor_asprintf(char **strp, const char *fmt,...)
Definition: printf.c:75
Master header file for Tor-specific functionality.
#define LD_DIRSERV
Definition: log.h:90
Header for bridgeauth.c.
int crypto_pk_get_fingerprint(crypto_pk_t *pk, char *fp_out, int add_space)
Definition: crypto_rsa.c:229
void format_iso_time(char *buf, time_t t)
Definition: time_fmt.c:295
const routerinfo_t * router_get_my_routerinfo(void)
Definition: router.c:1624
Header file for router.c.
#define FINGERPRINT_LEN
Definition: crypto_rsa.h:34
char * dirserv_get_flag_thresholds_line(void)
Definition: voteflags.c:433
void bridgeauth_dump_bridge_status_to_file(time_t now)
Definition: bridgeauth.c:24
Header file for networkstatus.c.
#define LD_BUG
Definition: log.h:86