Files
sovereign_browser/src/net_services.h
T

97 lines
2.4 KiB
C

/*
* net_services.h — Tor and FIPS network-service lifecycle management
*/
#ifndef NET_SERVICES_H
#define NET_SERVICES_H
#include <glib.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
NET_SERVICE_TOR,
NET_SERVICE_FIPS,
NET_SERVICE_COUNT
} net_service_type_t;
typedef enum {
SERVICE_DISABLED,
SERVICE_DISCOVERING,
SERVICE_ATTACHING,
SERVICE_STARTING,
SERVICE_BOOTSTRAPPING,
SERVICE_READY,
SERVICE_STOPPING,
SERVICE_EXITED,
SERVICE_FAILED,
} service_state_t;
typedef enum {
OWNERSHIP_NONE,
OWNERSHIP_ATTACHED,
OWNERSHIP_MANAGED,
} service_ownership_t;
typedef struct {
net_service_type_t type;
service_state_t state;
service_ownership_t ownership;
GPid pid;
char *binary_path;
char *data_dir;
int control_fd;
char *error_msg;
guint child_watch;
guint poll_timer;
guint stop_timer;
guint stdout_watch;
guint stderr_watch;
GIOChannel *stdout_channel;
GIOChannel *stderr_channel;
gboolean stop_requested;
union {
struct {
int bootstrap_progress;
char circuit_info[256];
char socks_endpoint[512];
char control_endpoint[512];
char cookie_path[512];
} tor;
struct {
int peer_count;
char node_npub[80];
char tree_state[32];
gboolean tun_active;
char tun_name[16];
char daemon_state[32];
char control_socket[512];
} fips;
} status;
} net_service_t;
/* Initialize after the shared WebKit context and login are available. */
void net_services_init(void);
int net_service_enable(net_service_type_t type);
int net_service_disable(net_service_type_t type);
int net_service_restart(net_service_type_t type);
const net_service_t *net_service_get_status(net_service_type_t type);
gboolean net_service_is_enabled(net_service_type_t type);
gboolean net_service_is_ready(net_service_type_t type);
/* Rebuild Tor's proxy ignore-host list after FIPS readiness changes. */
void net_services_refresh_proxy(void);
/* Stop owned children and detach from system services. */
void net_services_shutdown(void);
#ifdef __cplusplus
}
#endif
#endif /* NET_SERVICES_H */