#pragma once
#include "common.hpp"
#include "acl.hpp"
#include "hooks.hpp"
#include "poll.hpp"
#include "certs.hpp"
#include "ipc.hpp"
#include "stats.hpp"
typedef enum {
BUMP_NONE=0, ///< untouched traffic to original destination
BUMP_PARENT=1, ///< decrypt and send HTTP to parent
#if (SPLICE)
BUMP_SPLICE=2, ///< decrypt, splice to disk, and encrypt traffic to original destination
#endif
BUMP_BUMP=3 ///< decrypt and encrypt traffic to original destination (mostly useful for debugging)
} bump_op_t;
bump_op_t bump_ruleset_lookup(const char*, const sockaddr_t&, const sockaddr_t&);
class Bump {
private:
const int fd;
ssl_ctx_t* ssl_ctx;
bool pending;
static void handler(int, void*, char*, size_t); ///< @see ipc_handler_t
static void handler(int, void*, ssl_ctx_t*);
Bump(int); ///< enqueued operation
Bump(int, ssl_ctx_t*); ///< immediate cache-hit
public:
static Bump* getInst(int, const char*, size_t); ///< dispatch cert generation. NULL upon error. result could be immediately available due to cache-hit -> check ready() and/or get()
~Bump(); ///< abort pending cert generation or frees unfetched result
tristate_t ready() const; ///< none: in progress; false: finished, but no result (anymore); true: get() will return something
ssl_ctx_t* get(); ///< get result (once!)
};