Thrift C++ Software Library
# License
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
# Using Thrift with C++
The Thrift C++ libraries are built using the GNU tools. Follow the instructions
in the top-level README.md
In case you do not want to open another README.md file, do this thrift src:
./bootstrap.sh
./configure (--with-boost=/usr/local)
make
sudo make install
Thrift is divided into two libraries.
* libthrift - The core Thrift library contains all the core Thrift code. This requires
openssl, pthreads, and librt.
* libthriftnb - This library contains the Thrift nonblocking server, which uses libevent.
To link this library you will also need to link libevent.
## Linking Against Thrift
After you build and install Thrift the libraries are installed to
/usr/local/lib by default. Make sure this is in your LDPATH.
On Linux, the best way to do this is to ensure that /usr/local/lib is in
your /etc/ld.so.conf and then run /sbin/ldconfig.
Depending upon whether you are linking dynamically or statically and how
your build environment it set up, you may need to include additional
libraries when linking against thrift, such as librt and/or libpthread. If
you are using libthriftnb you will also need libevent.
## Dependencies
C++11 is required at a minimum. C++03/C++98 are not supported after version 0.12.0.
Boost is required to run the C++ unit tests. It is not necessary to link against
the runtime library.
libevent (for libthriftnb only) - most linux distributions have dev packages for this:
http://monkey.org/~provos/libevent/
# Using Thrift with C++ on Windows
Both the autoconf and cmake build systems are able to automatically detect many
system configurations without the need to specify library locations, however if
you run into problems or want to redirect thrift to build and link against your
own provided third party libraries:
BOOST_ROOT : For boost, e.g. D:\boost_1_55_0
OPENSSL_ROOT_DIR : For OpenSSL, e.g. D:\OpenSSL-Win32
only required by libthriftnb:
LIBEVENT_ROOT_DIR : For Libevent e.g. D:\libevent-2.0.21-stable
See /3rdparty.user for more details.
The same linking guidelines described above for libthriftnb apply to windows as well.
## Linking Against Thrift
You need to link your project that uses thrift against all the thrift
dependencies; in the case of libthrift, openssl, pthreads, and librt and for
libthriftnb, libevent.
In the project properties you must also set HAVE_CONFIG_H as force include
the config header: "windows/config.h"
## Dependencies
libevent (for libthriftnb only)
http://monkey.org/~provos/libevent/
## Windows version compatibility
The Thrift library targets Windows 7 or latter versions. The supports for windows XP and Vista are avaiable until 0.12.0.
## Thrift and the VCPKG Package manager
You can download and install thrift using the
[vcpkg](https://github.com/Microsoft/vcpkg) dependency manager:
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg integrate install
./vcpkg install thrift
The thrift port in vcpkg is kept up to date by Microsoft team members
and community contributors. The Apache Thrift project is *not* responsible
for the vcpkg port. Therefore, if the version is out of date, please
[create an issue or pull request](https://github.com/Microsoft/vcpkg)
on the vcpkg repository.
## Named Pipes
Named Pipe transport has been added in the TPipe and TPipeServer classes. This
is currently Windows-only. Named pipe transport for *NIX has not been
implemented. Domain sockets are a better choice for local IPC under non-Windows
OS's. *NIX named pipes only support 1:1 client-server connection.
# Thrift/SSL
## Scope
This SSL only supports blocking mode socket I/O. It can only be used with
TSimpleServer, TThreadedServer, and TThreadPoolServer.
## Implementation
There are two main classes TSSLSocketFactory and TSSLSocket. Instances of
TSSLSocket are always created from TSSLSocketFactory.
## How to use SSL APIs
See the TestClient.cpp and TestServer.cpp files for examples.
### AccessManager (certificate validation)
An example of certificate validation can be found in TestServer.cpp.
AccessManager defines a callback interface. It has three callback methods:
(a) Decision verify(const sockaddr_storage& sa);
(b) Decision verify(const string& host, const char* name, int size);
(c) Decision verify(const sockaddr_storage& sa, const char* data, int size);
After SSL handshake completes, additional checks are conducted. Application
is given the chance to decide whether or not to continue the conversation
with the remote. Application is queried through the above three "verify"
method. They are called at different points of the verification process.
Decisions can be one of ALLOW, DENY, and SKIP. ALLOW and DENY means the
conversation should be continued or disconnected, respectively. ALLOW and
DENY decision stops the verification process. SKIP means there's no decision
based on the given input, continue the verification process.
First, (a) is called with the remote IP. It is called once at the beginning.
"sa" is the IP address of the remote peer.
Then, the certificate of remote peer is loaded. SubjectAltName extensions
are extracted and sent to application for verification. When a DNS
subjectAltName field is extracted, (b) is called. When an IP subjectAltName
field is extracted, (c) is called.
The "host" in (b) is the value from TSocket::getHost() if this is a client
side socket, or TSocket::getPeerHost() if this is a server side socket. The
reason is client side socket initiates the connection. TSocket::getHost()
is the remote host name. On server side, the remote host name is unknown
unless it's retrieved through TSocket::getPeerHost(). Either way, "host"
should be the remote host name. Keep in mind, if TSocket::getPeerHost()
failed, it would return the remote host name in numeric format.
If all subjectAltName extensions were "skipped", the common name field would
be checked. It is sent to application through (c), where "sa" is the remote
IP address. "data" is the IP address extracted from subjectAltName IP
extension, and "size" is the length of the extension data.
If any of the above "verify" methods returned a decision ALLOW or DENY, the
verification process would be stopped.
If any of the above "verify" methods returned SKIP, that decision would be
ignored and the verification process would move on till the last item is
examined. At that point, if there's still no decision, the connection is
terminated.
Thread safety, an access manager should not store state information if it's
to be used by many SSL sockets.
## SIGPIPE signal
Applications running OpenSSL over network connections may crash if SIGPIPE
is not ignored. This happens when they receive a connection reset by remote
peer exception, which somehow triggers a SIGPIPE signal. If not handled,
this signal would kill the application.
## How to run test client/server in SSL mode
The server and client expects the followings from the directory /test/
- keys/server.crt
- keys/server.key
- keys/CA.pem
The file names are hard coded in the source code. You need to create these
certificates before you can run the test code in SSL mode. Make sure at least
one o
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
Thrift RPC Java、Go、PHP使用例子 (2000个子文件)
_oasis 556B
Makefile.am 23KB
Makefile.am 12KB
Makefile.am 11KB
Makefile.am 7KB
Makefile.am 6KB
Makefile.am 6KB
Makefile.am 3KB
Makefile.am 3KB
Makefile.am 3KB
Makefile.am 3KB
Makefile.am 2KB
Makefile.am 2KB
Makefile.am 2KB
Makefile.am 2KB
Makefile.am 2KB
Makefile.am 2KB
Makefile.am 2KB
Makefile.am 2KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 999B
Makefile.am 985B
Makefile.am 985B
Makefile.am 970B
Makefile.am 970B
Makefile.am 915B
Makefile.am 839B
make_all.bat 2KB
test_client.c 58KB
testcompactprotocol.c 55KB
thrift_compact_protocol.c 45KB
testbinaryprotocol.c 32KB
testdebugproto.c 27KB
thrift_ssl_socket.c 27KB
thrift_zlib_transport.c 27KB
thrift_binary_protocol.c 25KB
thrift_protocol_decorator.c 24KB
thrift_test_handler.c 23KB
compact_protocol.c 23KB
thrift_protocol.c 22KB
struct.c 22KB
testcontainertest.c 18KB
c_glib_server.c 18KB
thrift_buffered_transport.c 16KB
thrift_framed_transport.c 16KB
binary_protocol_accelerated.c 15KB
thrift_socket.c 15KB
testtransportsslsocket.c 15KB
thrift_server_socket.c 13KB
thrift_memory_buffer.c 11KB
thrift_transport.c 11KB
test_server.c 11KB
luasocket.c 11KB
thrift_multiplexed_processor.c 11KB
usocket.c 11KB
thrift_fd_transport.c 10KB
testthriftbinaryreadcheck.c 10KB
testtransportsocket.c 10KB
testbufferedtransport.c 10KB
testthriftcompactreadcheck.c 9KB
testframedtransport.c 9KB
thrift_server_transport.c 9KB
thrift_application_exception.c 8KB
luabpack.c 8KB
thrift_native.c 8KB
thrift_server.c 7KB
testthriftframedreadcheck.c 7KB
testzlibtransport.c 7KB
testthriftbufferedreadcheck.c 7KB
testmemorybuffer.c 7KB
thrift_stored_message_protocol.c 6KB
testapplicationexception.c 6KB
testoptionalrequired.c 6KB
c_glib_client.c 6KB
lualongnumber.c 5KB
testthriftfdreadcheck.c 5KB
thrift_simple_server.c 5KB
thrift_dispatch_processor.c 5KB
testfdtransport.c 5KB
thrift_compact_protocol_factory.c 5KB
thrift_multiplexed_protocol.c 5KB
thrift_configuration.c 5KB
memory_buffer.c 4KB
testserialization.c 3KB
testthriftmemorybufferreadcheck.c 3KB
teststruct.c 3KB
testsimpleserver.c 3KB
testthrifttest.c 3KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
penngo
- 粉丝: 1w+
- 资源: 66
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功