tor  0.4.2.0-alpha-dev
bridgeauth.c
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-2019, The Tor Project, Inc. */
5 /* See LICENSE for licensing information */
6 
7 #include "core/or/or.h"
8 #include "feature/dirauth/bridgeauth.h"
11 #include "feature/relay/router.h"
12 #include "app/config/config.h"
13 
14 #include "feature/nodelist/routerinfo_st.h"
15 
18 void
19 bridgeauth_dump_bridge_status_to_file(time_t now)
20 {
21  char *status;
22  char *fname = NULL;
23  char *thresholds = NULL;
24  char *published_thresholds_and_status = NULL;
25  char published[ISO_TIME_LEN+1];
26  const routerinfo_t *me = router_get_my_routerinfo();
27  char fingerprint[FINGERPRINT_LEN+1];
28  char *fingerprint_line = NULL;
29 
31  status = networkstatus_getinfo_by_purpose("bridge", now);
32 
34  fingerprint, 0) >= 0) {
35  tor_asprintf(&fingerprint_line, "fingerprint %s\n", fingerprint);
36  } else {
37  log_warn(LD_BUG, "Error computing fingerprint for bridge status.");
38  }
39  format_iso_time(published, now);
40  dirserv_compute_bridge_flag_thresholds();
41  thresholds = dirserv_get_flag_thresholds_line();
42  tor_asprintf(&published_thresholds_and_status,
43  "published %s\nflag-thresholds %s\n%s%s",
44  published, thresholds, fingerprint_line ? fingerprint_line : "",
45  status);
46  fname = get_datadir_fname("networkstatus-bridges");
47  if (write_str_to_file(fname,published_thresholds_and_status,0)<0) {
48  log_warn(LD_DIRSERV, "Unable to write networkstatus-bridges file.");
49  }
50  tor_free(thresholds);
51  tor_free(published_thresholds_and_status);
52  tor_free(fname);
53  tor_free(status);
54  tor_free(fingerprint_line);
55 }
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:648
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:88
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
Header file for router.c.
#define FINGERPRINT_LEN
Definition: crypto_rsa.h:34
char * dirserv_get_flag_thresholds_line(void)
Definition: voteflags.c:427
crypto_pk_t * identity_pkey
Definition: routerinfo_st.h:38
Header file for networkstatus.c.
#define LD_BUG
Definition: log.h:84