CI / test (push) Failing after 1m7s
The web UI now sends key events without opening the KB bar, and releases held keys on blur, hide or disconnect. The first remote keystroke (web or VNC) turns the on-screen keyboard off; it comes back when the last typing client disconnects, unless the user toggled it by hand. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
120 lines
3.6 KiB
C
120 lines
3.6 KiB
C
#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;
|
|
pthread_mutex_t osk_mu;
|
|
int osk_suppress_refs;
|
|
int osk_restore_on_end;
|
|
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);
|
|
void remote_osk_suppress_acquire(RemoteApp *app, int *client_flag);
|
|
void remote_osk_suppress_release(RemoteApp *app, int *client_flag);
|
|
void remote_osk_manual_override(RemoteApp *app);
|
|
|
|
/* 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_codepoint(CtlConn *ctl, uint32_t uc);
|
|
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 */
|