Пример #1
0
static void initTunnel(Dict* args, void* vcontext, String* txid)
{
    struct Context* const ctx = (struct Context*) vcontext;
    #define BUFFERSZ 1024
    uint8_t buffer[BUFFERSZ];
    struct Allocator* const alloc = BufferAllocator_new(buffer, BUFFERSZ);

    struct Jmp jmp;
    Jmp_try(jmp) {
        Core_initTunnel(Dict_getString(args, String_CONST("desiredTunName")),
                        ctx->ipAddr,
                        8,
                        ctx->ducttape,
                        ctx->logger,
                        ctx->ipTunnel,
                        ctx->eventBase,
                        ctx->alloc,
                        &jmp.handler);
    } Jmp_catch {
        String* error = String_printf(alloc, "Failed to configure tunnel [%s]", jmp.message);
        sendResponse(error, ctx->admin, txid, alloc);
        return;
    }

    sendResponse(String_CONST("none"), ctx->admin, txid, alloc);
}
Пример #2
0
static void initTunnel(Dict* args, void* vcontext, String* txid, struct Allocator* requestAlloc)
{
    struct Core_Context* const ctx = (struct Core_Context*) vcontext;

    struct Jmp jmp;
    Jmp_try(jmp) {
        Core_initTunnel(Dict_getString(args, String_CONST("desiredTunName")),
                        ctx->ipAddr,
                        8,
                        ctx->ducttape,
                        ctx->logger,
                        ctx->ipTunnel,
                        ctx->eventBase,
                        ctx->alloc,
                        &jmp.handler);
    } Jmp_catch {
        String* error = String_printf(requestAlloc, "Failed to configure tunnel [%s]", jmp.message);
        sendResponse(error, ctx->admin, txid, requestAlloc);
        return;
    }

    sendResponse(String_CONST("none"), ctx->admin, txid, requestAlloc);
}