Line data Source code
1 : #ifndef HEADER_fd_src_discof_restore_utils_fd_sshttp_h 2 : #define HEADER_fd_src_discof_restore_utils_fd_sshttp_h 3 : 4 : struct fd_sshttp_private; 5 : typedef struct fd_sshttp_private fd_sshttp_t; 6 : 7 : #include "../../../util/net/fd_net_headers.h" 8 : 9 : FD_PROTOTYPES_BEGIN 10 : 11 : FD_FN_CONST ulong 12 : fd_sshttp_align( void ); 13 : 14 : FD_FN_CONST ulong 15 : fd_sshttp_footprint( void ); 16 : 17 : void * 18 : fd_sshttp_new( void * shmem ); 19 : 20 : fd_sshttp_t * 21 : fd_sshttp_join( void * sshttp ); 22 : 23 : /* fd_sshttp_load_ca_store loads the system CA certificate bundle for 24 : TLS certificate chain validation. If no bundle is found, subsequent 25 : fd_sshttp_init calls with is_https set fail before connecting. */ 26 : 27 : void 28 : fd_sshttp_load_ca_store( fd_sshttp_t * http ); 29 : 30 : char const * 31 : fd_sshttp_snapshot_name( fd_sshttp_t const * http ); 32 : 33 : ulong 34 : fd_sshttp_content_len( fd_sshttp_t const * http ); 35 : 36 : ulong 37 : fd_sshttp_resolved_slot( fd_sshttp_t const * http ); 38 : 39 : uchar const * 40 : fd_sshttp_resolved_hash( fd_sshttp_t const * http ); 41 : 42 : /* fd_sshttp_init initializes an sshttp connection to the given server. 43 : addr is the resolved IP address and port. hostname is a 44 : null-terminated string used for the Host header and TLS SNI. 45 : is_https indicates whether TLS should be used. path points to the 46 : URL path of length path_len. hops is the maximum number of HTTP 47 : redirects to follow, pass ULONG_MAX to preserve the current hops 48 : value (e.g. when following a redirect internally). now is the 49 : current timestamp. Returns 0 on success and -1 on failure. */ 50 : 51 : int 52 : fd_sshttp_init( fd_sshttp_t * http, 53 : fd_ip4_port_t addr, 54 : char const * hostname, 55 : int is_https, 56 : char const * path, 57 : ulong path_len, 58 : ulong hops, 59 : long now ); 60 : 61 : void 62 : fd_sshttp_cancel( fd_sshttp_t * http ); 63 : 64 12 : #define FD_SSHTTP_ADVANCE_ERROR (-1) 65 9 : #define FD_SSHTTP_ADVANCE_AGAIN ( 0) 66 3 : #define FD_SSHTTP_ADVANCE_DATA ( 1) 67 0 : #define FD_SSHTTP_ADVANCE_DONE ( 2) 68 : 69 : int 70 : fd_sshttp_advance( fd_sshttp_t * http, 71 : ulong * data_len, 72 : uchar * data, 73 : int * downloading, 74 : long now ); 75 : 76 : FD_PROTOTYPES_END 77 : 78 : #endif /* HEADER_fd_src_discof_restore_utils_fd_sshttp_h */