26 "Duplicate peer: %s:%d, not added", ip, port);
36 "Peer queue is full, cannot add peer: %s:%d", ip, port);
44 char* colon_pos = strrchr(ip,
':');
45 if (colon_pos != NULL)
47 port = atoi(colon_pos + 1);
54 "Invalid IP format, cannot extract port: %s", ip);
133 Peer* peers = malloc(size *
sizeof(
Peer));
void log_message(log_level level, const char *filename, const char *source_file, const char *format,...)
Log a message used to log a message to the console or a file.
Peer * get_peer_queue(int *count)
Get the peer queue.
static int peer_queue_end
bool get_peer_from_queue(char *buffer, size_t buffer_size)
Get a peer from the queue.
void add_peer_to_queue(const char *ip, int port)
Add a peer to the queue.
static int peer_queue_start
void clear_peer_queue()
Clear the peer queue.
void print_peer_queue()
Print the peer queue.
static pthread_mutex_t peer_queue_mutex
static Peer peer_queue[MAX_PEERS]
bool is_peer_queue_empty()
Check if the peer queue is empty.
The peer structure used to store the peer information obtained by peer discovery process.
void guarded_print_line(const char *format,...)
Guarded print line function.