#ifndef fooserverhfoo #define fooserverhfoo enum server_type { SERVER_TYPE_UNDEFINED, SERVER_TYPE_ANNOUNCE, SERVER_TYPE_PROXY }; enum server_stop_method { SERVER_STOP_METHOD_UNDEFINED, SERVER_STOP_METHOD_RCON, SERVER_STOP_METHOD_SYSTEMD, SERVER_STOP_METHOD_EXEC }; enum server_start_method { SERVER_START_METHOD_UNDEFINED, SERVER_START_METHOD_SYSTEMD, SERVER_START_METHOD_EXEC }; struct server { enum server_type type; char *name; char *pretty_name; uint16_t announce_port; struct list_head locals; struct list_head remotes; struct list_head proxys; struct list_head rcons; bool running; enum server_stop_method stop_method; enum server_start_method start_method; /* For calling external start/stop executables */ char *stop_exec; char *start_exec; struct uring_task exec_task; /* For systemd services */ char *systemd_service; char *systemd_obj; /* For rcon connections */ struct rcon *rcon; char *rcon_password; /* For announce messages */ struct iovec mcast_iov; struct msghdr mcast_msg; char mcast_buf[4096]; /* For checking idle status */ struct idle *idle; unsigned idle_timeout; unsigned idle_count; /* For reading config files */ struct uring_task_buf tbuf; struct uring_task task; struct list_head list; }; void server_refdump(struct server *server); void server_delete(struct cfg *cfg, struct server *scfg); void server_delete_by_name(struct cfg *cfg, const char *name); bool server_start(struct cfg *cfg, struct server *scfg); bool server_stop(struct cfg *cfg, struct server *scfg); bool server_commit(struct cfg *cfg, struct server *scfg); bool server_add_remote(struct cfg *cfg, struct server *scfg, struct sockaddr_in46 *addr); bool server_add_local(struct cfg *cfg, struct server *scfg, struct sockaddr_in46 *addr); bool server_add_rcon(struct cfg *cfg, struct server *scfg, struct sockaddr_in46 *addr); bool server_set_rcon_password(struct cfg *cfg, struct server *scfg, const char *password); bool server_set_systemd_service(struct cfg *cfg, struct server *scfg, const char *service); bool server_set_stop_method(struct cfg *cfg, struct server *scfg, enum server_stop_method stop_method); bool server_set_start_method(struct cfg *cfg, struct server *scfg, enum server_start_method start_method); bool server_set_stop_exec(struct cfg *cfg, struct server *scfg, const char *cmd); bool server_set_start_exec(struct cfg *cfg, struct server *scfg, const char *cmd); bool server_set_idle_timeout(struct cfg *cfg, struct server *scfg, uint16_t timeout); bool server_set_port(struct cfg *cfg, struct server *scfg, uint16_t port); bool server_set_type(struct cfg *cfg, struct server *scfg, enum server_type type); bool server_set_pretty_name(struct cfg *cfg, struct server *scfg, const char *pretty_name); struct server *server_new(struct cfg *cfg, const char *name); #endif