- remote/: shared-memory framebuffer mirror served as RFB 3.8 (VNC, port 5900) and an HTTP/WebSocket PWA (port 6080), bound to the Tailscale interface and loopback by default - Compositor: remote pointer, button, scroll, modifier, key, key-tap, text and clipboard input, routed past OLED blanking - chandra-ctl: add status, refresh and osk commands; add input-* and clipboard-set for remote control - Camera: debayer 10-bit CSI-2 Quad-Bayer frames for imx371 and high-quality still capture - Camera: rotate frames by the libcamera mounting angle (CCW for 90), fix the expected test values, and restyle the UI for a dark theme
This commit is contained in:
1 parent
de39b74282
commit
bfc60ee0e5
24 files changed
+5310
-79
No files matched your search
@@ -0,0 +1,112 @@
|
||||
#ifndef CHANDRA_REMOTE_INTERNAL_H
|
||||
#define CHANDRA_REMOTE_INTERNAL_H
|
||||
|
||||
#define _POSIX_C_SOURCE 200809L
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <pthread.h>
|
||||
#include <signal.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include "chandra_fb_shm.h"
|
||||
|
||||
#define REMOTE_AUTH_NONE 0
|
||||
#define REMOTE_AUTH_PASSWORD 1
|
||||
|
||||
typedef struct {
|
||||
int enabled;
|
||||
char bind[64]; /* "tailscale", "127.0.0.1", "0.0.0.0", or IP */
|
||||
int bind_loopback; /* 1 to also bind 127.0.0.1 when bind == "tailscale" */
|
||||
int auth_mode; /* REMOTE_AUTH_NONE or REMOTE_AUTH_PASSWORD */
|
||||
int vnc_port;
|
||||
int web_port;
|
||||
int jpeg_quality;
|
||||
int max_fps;
|
||||
char password[64];
|
||||
int allow_insecure_open;
|
||||
} RemoteConfig;
|
||||
|
||||
typedef struct {
|
||||
pthread_mutex_t mu;
|
||||
int fd;
|
||||
char sock_path[512];
|
||||
uint64_t last_try_ms;
|
||||
} CtlConn;
|
||||
|
||||
typedef struct {
|
||||
int fd;
|
||||
ChandraFbHeader *hdr;
|
||||
char shm_path[512];
|
||||
uint64_t last_open_try_ms;
|
||||
} FbReader;
|
||||
|
||||
typedef struct {
|
||||
RemoteConfig cfg;
|
||||
pthread_mutex_t cfg_mu;
|
||||
char config_path[512];
|
||||
char web_dir[512];
|
||||
CtlConn ctl;
|
||||
uint8_t hmac_key[32];
|
||||
volatile sig_atomic_t *running;
|
||||
pthread_mutex_t ping_mu;
|
||||
char shm_path[512];
|
||||
} RemoteApp;
|
||||
|
||||
/* Time helper */
|
||||
uint64_t remote_now_ms(void);
|
||||
void remote_sleep_ms(int ms);
|
||||
|
||||
/* Config & auth (auth.c) */
|
||||
void remote_default_config(RemoteConfig *cfg);
|
||||
int remote_bind_is_loopback(const char *bind_str);
|
||||
int remote_bind_is_tailscale(const char *bind_str);
|
||||
int remote_load_or_init_config(const char *path, RemoteConfig *cfg);
|
||||
int remote_save_config(const char *path, const RemoteConfig *cfg);
|
||||
void remote_generate_password(char *out, size_t len);
|
||||
int remote_ct_equal(const uint8_t hmac_key[32], const char *a, const char *b);
|
||||
void vnc_des_encrypt_challenge(const char *password, const uint8_t challenge[16], uint8_t out[16]);
|
||||
void web_token_sign(const uint8_t key[32], uint64_t now_sec, char *out, size_t cap);
|
||||
int web_token_verify(const uint8_t key[32], const char *tok, uint64_t now_sec);
|
||||
int ws_compute_accept(const char *client_key, char *out, size_t cap);
|
||||
|
||||
/* Control socket & compositor I/O (chandra-remote.c) */
|
||||
void ctl_init(CtlConn *c, const char *sock_path);
|
||||
void ctl_close(CtlConn *c);
|
||||
int ctl_cmd(CtlConn *c, const char *line, char *reply, size_t reply_cap);
|
||||
int ctl_fire(CtlConn *c, const char *line);
|
||||
|
||||
/* Shared framebuffer reader (chandra-remote.c) */
|
||||
void fb_reader_init(FbReader *r, const char *shm_path);
|
||||
void fb_reader_close(FbReader *r);
|
||||
void fb_reader_ping(FbReader *r);
|
||||
int fb_reader_grab(
|
||||
FbReader *r,
|
||||
uint64_t last_seq,
|
||||
uint32_t last_w,
|
||||
uint32_t last_h,
|
||||
int *out_full,
|
||||
uint32_t *out_w,
|
||||
uint32_t *out_h,
|
||||
int *out_x0,
|
||||
int *out_y0,
|
||||
int *out_x1,
|
||||
int *out_y1,
|
||||
uint64_t *out_seq,
|
||||
uint8_t **scratch,
|
||||
size_t *scratch_cap);
|
||||
|
||||
/* Peer & socket helpers (chandra-remote.c) */
|
||||
int remote_peer_allowed(const RemoteConfig *cfg, const struct sockaddr_storage *ss, socklen_t slen);
|
||||
int remote_find_tailscale_ipv4(char *out, size_t cap);
|
||||
|
||||
/* Keysym & UTF-8 translation (keysym.c) */
|
||||
int keysym_to_evdev(uint32_t keysym, uint32_t *out_evdev, int *out_shift, int *out_mod_bit, uint32_t *out_unicode);
|
||||
void remote_send_utf8_text(CtlConn *ctl, const char *utf8);
|
||||
void hex_encode(const uint8_t *in, size_t len, char *out);
|
||||
|
||||
/* RFB & Web servers (rfb.c, web.c) */
|
||||
void rfb_handle_client(RemoteApp *app, int fd);
|
||||
void web_handle_client(RemoteApp *app, int fd);
|
||||
|
||||
#endif /* CHANDRA_REMOTE_INTERNAL_H */
|
||||
Reference in new issue
Block a user