-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathCBLURLEndpointListener.h
110 lines (79 loc) · 4.65 KB
/
CBLURLEndpointListener.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
//
// CBLURLEndpointListener.h
// CBL_C
//
// Created by Pasin Suriyentrakorn on 2/19/25.
// Copyright © 2025 Couchbase. All rights reserved.
//
#pragma once
#include "CBLBase.h"
#ifdef COUCHBASE_ENTERPRISE
CBL_CAPI_BEGIN
/** An opaque object representing the listener authenticator. */
typedef struct CBLListenerAuthenticator CBLListenerAuthenticator;
/** Password authenticator callback for verifying client credentials when the HTTP Basic Authentication is used. */
typedef bool (*CBLListenerPasswordAuthCallback) (
void* context, ///< URLEndpointListener’s context
FLString username, ///< Username
FLString password ///< Password
);
/** Creates a password authenticatorfor verifying client credentials when the HTTP Basic Authentication is used. */
_cbl_warn_unused CBLListenerAuthenticator* CBLListenerAuth_CreatePassword(CBLListenerPasswordAuthCallback auth) CBLAPI;
/** Certificate authenticator callback for verifying client certificate when the TLS client certificate authentication is used. */
typedef bool (*CBLListenerCertAuthCallback) (
void* context, ///< URLEndpointListener’s context
FLSlice cert ///< Certificate data
);
/** Creates a certificate authenticator for verifying client certificate when the TLS client certificate authentication is used. */
_cbl_warn_unused CBLListenerAuthenticator* CBLListenerAuth_CreateCertificate(CBLListenerCertAuthCallback auth) CBLAPI;
/** Frees a CBLListenerAuthenticator object. */
void CBLListenerAuth_Free(CBLListenerAuthenticator* _cbl_nullable) CBLAPI;
/** The configuration for the URLEndpointListener. */
typedef struct {
/** Arbitrary value that will be passed to the authenticator callback. */
void* _cbl_nullable context;
/** (Required) The collections available for replication . */
CBLCollection* _cbl_nonnull * _cbl_nullable collections;
/** (Required) The number of collections (Required). */
size_t collectionCount;
/** The port that the listener will listen to. Default value is zero which means that the listener will automatically
select an available port to listen to when the listener is started. */
uint16_t port;
/** The network interface in the form of the IP Address or network interface name such as en0 that the listener will
listen to. The default value is null slice which means that the listener will listen to all network interfaces. */
FLString networkInterface;
/** Disable TLS communication. The default value is false which means that TLS will be enabled by default. */
bool disableTLS;
/** The authenticator used by the listener to authenticate clients. */
CBLListenerAuthenticator* authenticator;
/** Allow delta sync when replicating with the listener. The default value is false. */
bool enableDeltaSync;
/** Allow only pull replication to pull changes from the listener. The default value is false. */
bool readOnly;
} CBLURLEndpointListenerConfiguration;
/** An opaque object representing the listener. */
typedef struct CBLURLEndpointListener CBLURLEndpointListener;
CBL_REFCOUNTED(CBLURLEndpointListener*, URLEndpointListener);
/** Creates a URL endpoint listener with the given configuration. */
_cbl_warn_unused CBLURLEndpointListener* _cbl_nullable CBLURLEndpointListener_Create(const CBLURLEndpointListenerConfiguration*, CBLError* _cbl_nullable outError) CBLAPI;
/** Frees a CBLURLEndpointListener object. */
void CBLURLEndpointListener_Free(CBLURLEndpointListener* _cbl_nullable) CBLAPI;
/** Gets the listener's configuration. */
const CBLURLEndpointListenerConfiguration* CBLURLEndpointListener_Config(const CBLURLEndpointListener*) CBLAPI;
/** The listening port of the listener. If the listener is not started, the port will be zero. */
uint16_t CBLURLEndpointListener_Port(const CBLURLEndpointListener*) CBLAPI;
/** The possible URLs of the listener. If the listener is not started, NULL will be returned. */
FLMutableArray CBLURLEndpointListener_Urls(const CBLURLEndpointListener*) CBLAPI;
/** The connection status of the listener */
typedef struct {
uint64_t connectionCount; ///< The total number of connections.
uint64_t activeConnectionCount; ///< The number of the connections that are in active or busy state.
} CBLConnectionStatus;
/** Gets the current connection status of the listener. */
CBLConnectionStatus CBLURLEndpointListener_Status(const CBLURLEndpointListener*) CBLAPI;
/** Starts the listener. */
bool CBLURLEndpointListener_Start(CBLURLEndpointListener*, CBLError* _cbl_nullable outError) CBLAPI;
/** Stops the listener. */
void CBLURLEndpointListener_Stop(CBLURLEndpointListener*) CBLAPI;
CBL_CAPI_END
#endif