summaryrefslogtreecommitdiff
path: root/server.h
blob: d06658899fd3f8ec4c4bab1070ccaae6b03bc814 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#ifndef fooserverhfoo
#define fooserverhfoo

enum server_type {
	SERVER_TYPE_UNDEFINED,
	SERVER_TYPE_ANNOUNCE,
	SERVER_TYPE_PROXY
};

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;
	bool running;
	
	struct uring_task task;
	char buf[4096];
	size_t len;
	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_commit(struct cfg *cfg, struct server *scfg);

bool server_add_remote(struct cfg *cfg, struct server *scfg,
		       struct sockaddr_in46 *remote);

bool server_add_local(struct cfg *cfg, struct server *scfg,
		      struct sockaddr_in46 *local);

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