|
44 | 44 |
|
45 | 45 | namespace arangodb {
|
46 | 46 | namespace rest {
|
47 |
| - |
48 |
| -//////////////////////////////////////////////////////////////////////////////// |
49 |
| -/// @brief endpoint specification |
50 |
| -//////////////////////////////////////////////////////////////////////////////// |
51 |
| - |
52 | 47 | class Endpoint {
|
53 | 48 | public:
|
54 |
| - ////////////////////////////////////////////////////////////////////////////// |
55 |
| - /// @brief endpoint types |
56 |
| - ////////////////////////////////////////////////////////////////////////////// |
57 |
| - |
58 | 49 | enum EndpointType { ENDPOINT_SERVER, ENDPOINT_CLIENT };
|
59 | 50 |
|
60 |
| - ////////////////////////////////////////////////////////////////////////////// |
61 |
| - /// @brief endpoint types |
62 |
| - ////////////////////////////////////////////////////////////////////////////// |
63 |
| - |
64 |
| - enum DomainType { DOMAIN_UNKNOWN = 0, DOMAIN_UNIX, DOMAIN_IPV4, DOMAIN_IPV6 }; |
65 |
| - |
66 |
| - ////////////////////////////////////////////////////////////////////////////// |
67 |
| - /// @brief encryption used when talking to endpoint |
68 |
| - ////////////////////////////////////////////////////////////////////////////// |
| 51 | + enum DomainType { |
| 52 | + DOMAIN_UNKNOWN = 0, |
| 53 | + DOMAIN_UNIX, |
| 54 | + DOMAIN_IPV4, |
| 55 | + DOMAIN_IPV6, |
| 56 | + DOMAIN_SRV |
| 57 | + }; |
69 | 58 |
|
70 | 59 | enum EncryptionType { ENCRYPTION_NONE = 0, ENCRYPTION_SSL };
|
71 | 60 |
|
72 | 61 | protected:
|
73 |
| - ////////////////////////////////////////////////////////////////////////////// |
74 |
| - /// @brief creates an endpoint |
75 |
| - ////////////////////////////////////////////////////////////////////////////// |
76 |
| - |
77 |
| - Endpoint(EndpointType, DomainType, EncryptionType, |
78 |
| - std::string const&, int); |
| 62 | + Endpoint(EndpointType, DomainType, EncryptionType, std::string const&, int); |
79 | 63 |
|
80 | 64 | public:
|
81 |
| - ////////////////////////////////////////////////////////////////////////////// |
82 |
| - /// @brief destroys an endpoint |
83 |
| - ////////////////////////////////////////////////////////////////////////////// |
84 |
| - |
85 | 65 | virtual ~Endpoint();
|
86 | 66 |
|
87 | 67 | public:
|
88 |
| - ////////////////////////////////////////////////////////////////////////////// |
89 |
| - /// @brief return the endpoint specification in a unified form |
90 |
| - ////////////////////////////////////////////////////////////////////////////// |
91 |
| - |
92 | 68 | static std::string getUnifiedForm(std::string const&);
|
93 |
| - |
94 |
| - ////////////////////////////////////////////////////////////////////////////// |
95 |
| - /// @brief creates a server endpoint from a string value |
96 |
| - ////////////////////////////////////////////////////////////////////////////// |
97 |
| - |
98 | 69 | static Endpoint* serverFactory(std::string const&, int, bool reuseAddress);
|
99 |
| - |
100 |
| - ////////////////////////////////////////////////////////////////////////////// |
101 |
| - /// @brief creates a client endpoint from a string value |
102 |
| - ////////////////////////////////////////////////////////////////////////////// |
103 |
| - |
104 | 70 | static Endpoint* clientFactory(std::string const&);
|
105 |
| - |
106 |
| - ////////////////////////////////////////////////////////////////////////////// |
107 |
| - /// @brief creates an endpoint from a string value |
108 |
| - ////////////////////////////////////////////////////////////////////////////// |
109 |
| - |
110 | 71 | static Endpoint* factory(const EndpointType type, std::string const&, int,
|
111 | 72 | bool);
|
112 |
| - |
113 |
| - ////////////////////////////////////////////////////////////////////////////// |
114 |
| - /// @brief compare two endpoints |
115 |
| - ////////////////////////////////////////////////////////////////////////////// |
116 |
| - |
117 |
| - bool operator==(Endpoint const&) const; |
118 |
| - |
119 |
| - ////////////////////////////////////////////////////////////////////////////// |
120 |
| - /// @brief return the default endpoint |
121 |
| - ////////////////////////////////////////////////////////////////////////////// |
122 |
| - |
123 | 73 | static std::string const getDefaultEndpoint();
|
124 | 74 |
|
125 |
| - ////////////////////////////////////////////////////////////////////////////// |
126 |
| - /// @brief connect the endpoint |
127 |
| - ////////////////////////////////////////////////////////////////////////////// |
| 75 | + public: |
| 76 | + bool operator==(Endpoint const&) const; |
| 77 | + EndpointType getType() const { return _type; } |
| 78 | + EncryptionType getEncryption() const { return _encryption; } |
| 79 | + std::string getSpecification() const { return _specification; } |
128 | 80 |
|
| 81 | + public: |
129 | 82 | virtual TRI_socket_t connect(double, double) = 0;
|
130 |
| - |
131 |
| - ////////////////////////////////////////////////////////////////////////////// |
132 |
| - /// @brief disconnect the endpoint |
133 |
| - ////////////////////////////////////////////////////////////////////////////// |
134 |
| - |
135 | 83 | virtual void disconnect() = 0;
|
136 | 84 |
|
137 |
| - ////////////////////////////////////////////////////////////////////////////// |
138 |
| - /// @brief init an incoming connection |
139 |
| - ////////////////////////////////////////////////////////////////////////////// |
140 |
| - |
141 | 85 | virtual bool initIncoming(TRI_socket_t) = 0;
|
142 |
| - |
143 |
| - ////////////////////////////////////////////////////////////////////////////// |
144 |
| - /// @brief set socket timeout |
145 |
| - ////////////////////////////////////////////////////////////////////////////// |
146 |
| - |
147 | 86 | virtual bool setTimeout(TRI_socket_t, double);
|
148 |
| <
F438
code class="diff-text syntax-highlighted-line deletion">- |
149 |
| - ////////////////////////////////////////////////////////////////////////////// |
150 |
| - /// @brief initialize socket flags |
151 |
| - ////////////////////////////////////////////////////////////////////////////// |
152 |
| - |
| 87 | + virtual bool isConnected() const { return _connected; } |
153 | 88 | virtual bool setSocketFlags(TRI_socket_t);
|
154 |
| - |
155 |
| - ////////////////////////////////////////////////////////////////////////////// |
156 |
| - /// @brief return whether the endpoint is connected |
157 |
| - ////////////////////////////////////////////////////////////////////////////// |
158 |
| - |
159 |
| - bool isConnected() const { return _connected; } |
160 |
| - |
161 |
| - ////////////////////////////////////////////////////////////////////////////// |
162 |
| - /// @brief get the type of an endpoint |
163 |
| - ////////////////////////////////////////////////////////////////////////////// |
164 |
| - |
165 |
| - EndpointType getType() const { return _type; } |
166 |
| - |
167 |
| - ////////////////////////////////////////////////////////////////////////////// |
168 |
| - /// @brief get the domain type of an endpoint |
169 |
| - ////////////////////////////////////////////////////////////////////////////// |
170 |
| - |
171 |
| - DomainType getDomainType() const { return _domainType; } |
172 |
| - |
173 |
| - ////////////////////////////////////////////////////////////////////////////// |
174 |
| - /// @brief get the encryption used |
175 |
| - ////////////////////////////////////////////////////////////////////////////// |
176 |
| - |
177 |
| - EncryptionType getEncryption() const { return _encryption; } |
178 |
| - |
179 |
| - ////////////////////////////////////////////////////////////////////////////// |
180 |
| - /// @brief get the original endpoint specification |
181 |
| - ////////////////////////////////////////////////////////////////////////////// |
182 |
| - |
183 |
| - std::string getSpecification() const { return _specification; } |
184 |
| - |
185 |
| - ////////////////////////////////////////////////////////////////////////////// |
186 |
| - /// @brief get endpoint domain |
187 |
| - ////////////////////////////////////////////////////////////////////////////// |
188 |
| - |
| 89 | + virtual DomainType getDomainType() const { return _domainType; } |
189 | 90 | virtual int getDomain() const = 0;
|
190 |
| - |
191 |
| - ////////////////////////////////////////////////////////////////////////////// |
192 |
| - /// @brief get port number |
193 |
| - ////////////////////////////////////////////////////////////////////////////// |
194 |
| - |
195 | 91 | virtual int getPort() const = 0;
|
196 |
| - |
197 |
| - ////////////////////////////////////////////////////////////////////////////// |
198 |
| - /// @brief get host name |
199 |
| - ////////////////////////////////////////////////////////////////////////////// |
200 |
| - |
201 | 92 | virtual std::string getHost() const = 0;
|
202 |
| - |
203 |
| - ////////////////////////////////////////////////////////////////////////////// |
204 |
| - /// @brief get address |
205 |
| - ////////////////////////////////////////////////////////////////////////////// |
206 |
| - |
207 | 93 | virtual std::string getHostString() const = 0;
|
208 | 94 |
|
209 | 95 | public:
|
210 |
| - ////////////////////////////////////////////////////////////////////////////// |
211 |
| - /// @brief error message if failure occurred |
212 |
| - ////////////////////////////////////////////////////////////////////////////// |
213 |
| - |
214 | 96 | std::string _errorMessage;
|
215 | 97 |
|
216 | 98 | protected:
|
217 |
| - ////////////////////////////////////////////////////////////////////////////// |
218 |
| - /// @brief whether or not the endpoint is connected |
219 |
| - ////////////////////////////////////////////////////////////////////////////// |
220 |
| - |
221 | 99 | bool _connected;
|
222 |
| - |
223 |
| - ////////////////////////////////////////////////////////////////////////////// |
224 |
| - /// @brief the actual socket |
225 |
| - ////////////////////////////////////////////////////////////////////////////// |
226 |
| - |
227 | 100 | TRI_socket_t _socket;
|
228 |
| - |
229 |
| - ////////////////////////////////////////////////////////////////////////////// |
230 |
| - /// @brief endpoint type |
231 |
| - ////////////////////////////////////////////////////////////////////////////// |
232 |
| - |
233 | 101 | EndpointType _type;
|
234 |
| - |
235 |
| - ////////////////////////////////////////////////////////////////////////////// |
236 |
| - /// @brief endpoint domain type |
237 |
| - ////////////////////////////////////////////////////////////////////////////// |
238 |
| - |
239 | 102 | DomainType _domainType;
|
240 |
| - |
241 |
| - ////////////////////////////////////////////////////////////////////////////// |
242 |
| - /// @brief encryption used |
243 |
| - ////////////////////////////////////////////////////////////////////////////// |
244 |
| - |
245 | 103 | EncryptionType _encryption;
|
246 |
| - |
247 |
| - ////////////////////////////////////////////////////////////////////////////// |
248 |
| - /// @brief original endpoint specification |
249 |
| - ////////////////////////////////////////////////////////////////////////////// |
250 |
| - |
251 | 104 | std::string _specification;
|
252 |
| - |
253 |
| - ////////////////////////////////////////////////////////////////////////////// |
254 |
| - /// @brief listen backlog size |
255 |
| - ////////////////////////////////////////////////////////////////////////////// |
256 |
| - |
257 | 105 | int _listenBacklog;
|
258 | 106 | };
|
259 | 107 | }
|
|
0 commit comments