feat: add SSH transport, rsync-style CLI, and --stdio server mode

- Replace send()/recv() with read()/write() + io_set_fds() for fd abstraction
- Add client_connect_ssh() via socketpair + fork/exec; reap child in client_disconnect()
- Add server --stdio flag for SSH invocation
- Replace handle_arg() with rsync-style positional args (fastsync <src> <dest>)
- Add SSH vs TCP auto-detection via is_remote_dest()
- Add TransportType and ssh_destination to Config, fix uninitialized fields in
  config_receive() (pre-existing multithreaded crash)
- Sender threads now wait for server STATUS_OK before disconnecting
- Add --help, error handling for sendfile+SSH combos
- Add pre-flight checks and Posix Args test case to test.py
- Add test_config_ssh_dest() unit test
This commit is contained in:
2026-07-06 18:42:33 +02:00
parent e4ab2a414c
commit fbd7ccf4dd
8 changed files with 347 additions and 40 deletions
+8 -1
View File
@@ -10,6 +10,7 @@
#include "utils.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <threads.h>
File *file_receive(Config *config, int file_descriptor) {
@@ -161,12 +162,18 @@ void handler(int file_descriptor) {
thrd_join(receiver, NULL);
thrd_join(writer, NULL);
pipeline_context_receiver_destroy(context);
send_status(file_descriptor, STATUS_OK);
} else
receive_files(config, file_descriptor);
close(file_descriptor);
}
int main() {
int main(int argc, char *argv[]) {
if (argc > 1 && strcmp(argv[1], "--stdio") == 0) {
io_set_fds(STDIN_FILENO, STDOUT_FILENO);
handler(STDIN_FILENO);
return 0;
}
Server *server = server_create(8080);
server_listen(server, handler);
server_delete(server);