Tor 0.4.9.0-alpha-dev
Functions | Variables
netstatus.c File Reference

Track whether the network is disabled, dormant, etc. More...

#include "core/or/or.h"
#include "core/mainloop/netstatus.h"
#include "core/mainloop/mainloop.h"
#include "core/mainloop/mainloop_state_st.h"
#include "app/config/config.h"
#include "feature/hibernate/hibernate.h"
#include "app/config/or_state_st.h"

Go to the source code of this file.

Functions

int net_is_disabled (void)
 
int net_is_completely_disabled (void)
 
void note_user_activity (time_t now)
 
void reset_user_activity (time_t now)
 
time_t get_last_user_activity_time (void)
 
void set_network_participation (bool participation)
 
bool is_participating_on_network (void)
 
void netstatus_flush_to_state (mainloop_state_t *state, time_t now)
 
void netstatus_load_from_state (const mainloop_state_t *state, time_t now)
 
void netstatus_note_clock_jumped (time_t seconds_diff)
 

Variables

static time_t last_user_activity_seen = 0
 
static bool participating_on_network = false
 

Detailed Description

Track whether the network is disabled, dormant, etc.

Definition in file netstatus.c.

Function Documentation

◆ get_last_user_activity_time()

time_t get_last_user_activity_time ( void  )

Return the most recent time at which we recorded "user activity".

Definition at line 91 of file netstatus.c.

Referenced by check_network_participation_callback(), and netstatus_note_clock_jumped().

◆ is_participating_on_network()

bool is_participating_on_network ( void  )

Return true iff we are currently participating on the network.

Definition at line 110 of file netstatus.c.

◆ net_is_completely_disabled()

int net_is_completely_disabled ( void  )

Return true iff our network is in some sense "completely disabled" either we're fully hibernating or the network is turned off with DisableNetwork.

Definition at line 34 of file netstatus.c.

Referenced by connection_connect_sockaddr().

◆ net_is_disabled()

int net_is_disabled ( void  )

◆ netstatus_flush_to_state()

void netstatus_flush_to_state ( mainloop_state_t state,
time_t  now 
)

Update 'state' with the last time at which we were active on the network.

Definition at line 119 of file netstatus.c.

◆ netstatus_load_from_state()

void netstatus_load_from_state ( const mainloop_state_t state,
time_t  now 
)

Update our current view of network participation from an or_state_t object.

Definition at line 134 of file netstatus.c.

◆ netstatus_note_clock_jumped()

void netstatus_note_clock_jumped ( time_t  seconds_diff)

Adjust the time at which the user was last active by seconds_diff in response to a clock jump.

Definition at line 168 of file netstatus.c.

◆ note_user_activity()

void note_user_activity ( time_t  now)

Record the fact that we have seen "user activity" at the time now. Move "last activity seen" time forwards, but never backwards.

If we were previously not participating on the network, set our participation status to true, and launch periodic events as appropriate.

Definition at line 63 of file netstatus.c.

Referenced by connection_edge_flushed_some(), connection_edge_process_inbuf(), and dnsserv_launch_request().

◆ reset_user_activity()

void reset_user_activity ( time_t  now)

Change the time at which "user activity" was last seen to now.

Unlike note_user_actity, this function sets the time without checking whether it is in the past, and without causing any rescan of periodic events or change in participation status.

Definition at line 82 of file netstatus.c.

Referenced by netstatus_load_from_state(), and netstatus_note_clock_jumped().

◆ set_network_participation()

void set_network_participation ( bool  participation)

Set the field that remembers whether we are currently participating on the network. Does not schedule or un-schedule periodic events.

Definition at line 101 of file netstatus.c.

Variable Documentation

◆ last_user_activity_seen

time_t last_user_activity_seen = 0
static

The time at which we've last seen "user activity" – that is, any activity that should keep us as a participant on the network.

This is not actually the true time. We will adjust this forward if our clock jumps, or if Tor is shut down for a while, so that the time since our last activity remains as it was before the jump or shutdown.

Definition at line 47 of file netstatus.c.

Referenced by get_last_user_activity_time(), netstatus_flush_to_state(), note_user_activity(), and reset_user_activity().

◆ participating_on_network

bool participating_on_network = false
static

True iff we are currently a "network participant" – that is, we are building circuits, fetching directory information, and so on.

Definition at line 53 of file netstatus.c.

Referenced by is_participating_on_network(), netstatus_flush_to_state(), netstatus_load_from_state(), note_user_activity(), and set_network_participation().