diff --git a/CMakeLists.txt b/CMakeLists.txt
index 56a4810..d5f33be 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -6,7 +6,7 @@ set(TARS_VERSION "2.0.0")
add_definitions(-DTARS_VERSION="${TARS_VERSION}")
set(TARS_MYSQL 1)
add_definitions(-DTARS_MYSQL=${TARS_MYSQL})
-set(TARS_SSL 0)
+set(TARS_SSL 1)
add_definitions(-DTARS_SSL=${TARS_SSL})
set(TARS_HTTP2 0)
add_definitions(-DTARS_HTTP2=${TARS_HTTP2})
@@ -53,33 +53,52 @@ set(CMAKE_INSTALL_PREFIX ${INSTALL_PREFIX})
#-------------------------------------------------------------
set(APP_LIBRARIES)
+set(OPEN_MYSQL "OFF")
+set(OPEN_NGHTTP2 "OFF")
+set(OPEN_SSL "OFF")
+set(OPEN_ZLIB "OFF")
+set(OPEN_PROTOBUF "OFF")
set(THIRDPARTY_PATH "${CMAKE_BINARY_DIR}/src")
+if(TARS_MYSQL)
+ set(OPEN_MYSQL "ON")
+ set(MYSQL_DIR_INC "${THIRDPARTY_PATH}/mysql-lib/include")
+ set(MYSQL_DIR_LIB "${THIRDPARTY_PATH}/mysql-lib/libmysql")
+ include_directories(${MYSQL_DIR_INC})
+ link_directories(${MYSQL_DIR_LIB})
+endif()
-set(MYSQL_DIR_INC "${THIRDPARTY_PATH}/mysql-lib/include")
-set(MYSQL_DIR_LIB "${THIRDPARTY_PATH}/mysql-lib/libmysql")
-include_directories(${MYSQL_DIR_INC})
-link_directories(${MYSQL_DIR_LIB})
+if(TARS_PROTOBUF)
+ set(OPEN_PROTOBUF "ON")
+ set(PROTOBUF_DIR_INC "${THIRDPARTY_PATH}/protobuf-lib/src")
+ set(PROTOBUF_DIR_LIB "${THIRDPARTY_PATH}/protobuf-lib")
+ include_directories(${PROTOBUF_DIR_INC})
+ link_directories(${PROTOBUF_DIR_LIB})
+endif()
-set(PROTOBUF_DIR_INC "${THIRDPARTY_PATH}/protobuf-lib/src")
-set(PROTOBUF_DIR_LIB "${THIRDPARTY_PATH}/protobuf-lib")
-include_directories(${PROTOBUF_DIR_INC})
-link_directories(${PROTOBUF_DIR_LIB})
+if(TARS_ZLIB)
+ set(OPEN_ZLIB "ON")
+ set(ZLIB_DIR_INC "${THIRDPARTY_PATH}/z-lib")
+ set(ZLIB_DIR_LIB "${THIRDPARTY_PATH}/z-lib")
+ include_directories(${ZLIB_DIR_INC})
+ link_directories(${ZLIB_DIR_LIB})
+endif()
-set(ZLIB_DIR_INC "${THIRDPARTY_PATH}/z-lib")
-set(ZLIB_DIR_LIB "${THIRDPARTY_PATH}/z-lib")
-include_directories(${ZLIB_DIR_INC})
-link_directories(${ZLIB_DIR_LIB})
+if(TARS_HTTP2)
+ set(OPEN_NGHTTP2 "ON")
+ set(NGHTTP2_DIR_INC "${THIRDPARTY_PATH}/nghttp2-lib/lib/includes/")
+ set(NGHTTP2_DIR_LIB "${THIRDPARTY_PATH}/nghttp2-lib/lib")
+ include_directories(${NGHTTP2_DIR_INC})
+ link_directories(${NGHTTP2_DIR_LIB})
+endif()
-set(NGHTTP2_DIR_INC "${THIRDPARTY_PATH}/nghttp2-lib/lib/includes/")
-set(NGHTTP2_DIR_LIB "${THIRDPARTY_PATH}/nghttp2-lib/lib")
-include_directories(${NGHTTP2_DIR_INC})
-link_directories(${NGHTTP2_DIR_LIB})
-
-set(SSL_DIR_INC "${THIRDPARTY_PATH}/openssl-lib/include/")
-set(SSL_DIR_LIB "${THIRDPARTY_PATH}/openssl-lib")
-include_directories(${SSL_DIR_INC})
-link_directories(${SSL_DIR_LIB})
+if(TARS_SSL)
+ set(OPEN_SSL "ON")
+ set(SSL_DIR_INC "${THIRDPARTY_PATH}/openssl-lib/include/")
+ set(SSL_DIR_LIB "${THIRDPARTY_PATH}/openssl-lib")
+ include_directories(${SSL_DIR_INC})
+ link_directories(${SSL_DIR_LIB})
+endif()
set(LIB_MYSQL)
set(LIB_NGHTTP2)
diff --git a/examples/AuthDemo/CMakeLists.txt b/examples/AuthDemo/CMakeLists.txt
new file mode 100644
index 0000000..6345c28
--- /dev/null
+++ b/examples/AuthDemo/CMakeLists.txt
@@ -0,0 +1,5 @@
+
+include_directories(Server)
+add_subdirectory(Server)
+add_subdirectory(Client)
+
diff --git a/examples/AuthDemo/Client/CMakeLists.txt b/examples/AuthDemo/Client/CMakeLists.txt
new file mode 100644
index 0000000..d32ce92
--- /dev/null
+++ b/examples/AuthDemo/Client/CMakeLists.txt
@@ -0,0 +1 @@
+build_tars_server("AuthClient" "AuthServer")
\ No newline at end of file
diff --git a/examples/AuthDemo/Client/config.conf b/examples/AuthDemo/Client/config.conf
new file mode 100755
index 0000000..9ea7492
--- /dev/null
+++ b/examples/AuthDemo/Client/config.conf
@@ -0,0 +1,33 @@
+
+
+
+
+ #tarsregistry locator
+ locator = tars.tarsregistry.QueryObj@tcp -h 127.0.0.1 -p 17890
+ #max invoke timeout
+ sync-invoke-timeout = 5000
+ #refresh endpoint interval
+ refresh-endpoint-interval = 10000
+ #stat obj
+ stat = tars.tarsstat.StatObj
+ #max send queue length limit
+ sendqueuelimit = 100000
+ #async queue length limit
+ asyncqueuecap = 100000
+ #async callback thread num
+ asyncthread = 3
+ #net thread
+ netthread = 1
+ #merge net and sync thread
+ mergenetasync = 0
+ #module name
+ modulename = TestApp.AuthClient
+ #server crt
+ ca = ../examples/AuthDemo/certs/server.crt
+ #can be empty
+ cert = ../examples/AuthDemo/certs/client.crt
+ #can be empty
+ key = ../examples/AuthDemo/certs/client.key
+
+
+
diff --git a/examples/AuthDemo/Client/main.cpp b/examples/AuthDemo/Client/main.cpp
new file mode 100644
index 0000000..f46d230
--- /dev/null
+++ b/examples/AuthDemo/Client/main.cpp
@@ -0,0 +1,224 @@
+/**
+ * Tencent is pleased to support the open source community by making Tars available.
+ *
+ * Copyright (C) 2016THL A29 Limited, a Tencent company. All rights reserved.
+ *
+ * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * https://opensource.org/licenses/BSD-3-Clause
+ *
+ * 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.
+ */
+
+#include
+#include "servant/Communicator.h"
+#include "Hello.h"
+#include "util/tc_option.h"
+
+using namespace std;
+using namespace tars;
+using namespace TestApp;
+
+Communicator* _comm;
+
+static string helloObj = "TestApp.AuthServer.AuthObj@ssl -h 127.0.0.1 -p 9016";
+
+struct Param
+{
+ int count;
+ string call;
+ int thread;
+ int buffersize;
+ int netthread;
+
+ HelloPrx pPrx;
+};
+
+Param param;
+std::atomic callback_count(0);
+
+struct HelloCallback : public HelloPrxCallback
+{
+ HelloCallback(int64_t t, int i, int c) : start(t), cur(i), count(c)
+ {
+
+ }
+
+ //call back
+ virtual void callback_testHello(int ret, const string &r)
+ {
+ assert(ret == 0);
+ callback_count++;
+
+ if(cur == count-1)
+ {
+ int64_t cost = TC_Common::now2us() - start;
+ cout << "callback_testHello count:" << count << ", " << cost << " us, avg:" << 1.*cost/count << "us" << endl;
+ }
+ }
+
+ virtual void callback_testHello_exception(tars::Int32 ret)
+ {
+ cout << "callback exception:" << ret << endl;
+ }
+
+ int64_t start;
+ int cur;
+ int count;
+};
+
+
+void syncCall(int c)
+{
+ string buffer(param.buffersize, 'a');
+
+ int64_t t = TC_Common::now2us();
+ //发起远程调用
+ for (int i = 0; i < c; ++i)
+ {
+ string r;
+
+ try
+ {
+
+ param.pPrx->testHello(buffer, r);
+ }
+ catch(exception& e)
+ {
+ cout << "exception:" << e.what() << endl;
+ }
+ ++callback_count;
+ }
+
+ int64_t cost = TC_Common::now2us() - t;
+ cout << "syncCall total:" << cost << "us, avg:" << 1.*cost/c << "us" << endl;
+}
+
+
+void asyncCall(int c)
+{
+ int64_t t = TC_Common::now2us();
+
+ string buffer(param.buffersize, 'a');
+
+ //发起远程调用
+ for (int i = 0; i < c; ++i)
+ {
+ HelloPrxCallbackPtr p = new HelloCallback(t, i, c);
+
+ try
+ {
+ param.pPrx->async_testHello(p, buffer);
+ }
+ catch(exception& e)
+ {
+ cout << "exception:" << e.what() << endl;
+ }
+ }
+
+ int64_t cost = TC_Common::now2us() - t;
+ cout << "asyncCall send:" << cost << "us, avg:" << 1.*cost/c << "us" << endl;
+}
+
+int main(int argc, char *argv[])
+{
+ try
+ {
+ if (argc < 6)
+ {
+ cout << "Usage:" << argv[0] << "--config=conf --count=1000 --call=[sync|async] --thread=1 --buffersize=1000 --netthread=1" << endl;
+
+ return 0;
+ }
+
+ TC_Option option;
+ option.decode(argc, argv);
+
+ param.count = TC_Common::strto(option.getValue("count"));
+ if(param.count <= 0) param.count = 1000;
+ param.buffersize = TC_Common::strto(option.getValue("buffersize"));
+ if(param.buffersize <= 0) param.buffersize = 1000;
+ param.call = option.getValue("call");
+ if(param.call.empty()) param.call = "sync";
+ param.thread = TC_Common::strto(option.getValue("thread"));
+ if(param.thread <= 0) param.thread = 1;
+ param.netthread = TC_Common::strto(option.getValue("netthread"));
+ if(param.netthread <= 0) param.netthread = 1;
+
+ _comm = new Communicator();
+
+ TC_Config conf;
+ conf.parseFile(option.getValue("config"));
+ _comm->setProperty(conf);
+
+ TarsRollLogger::getInstance()->logger()->setLogLevel(6);
+
+ _comm->setProperty("sendqueuelimit", "1000000");
+ _comm->setProperty("asyncqueuecap", "1000000");
+
+ _comm->setProperty("netthread", TC_Common::tostr(param.netthread));
+
+ param.pPrx = _comm->stringToProxy(helloObj);
+
+ param.pPrx->tars_connect_timeout(5000);
+ param.pPrx->tars_async_timeout(60*1000);
+ param.pPrx->tars_ping();
+
+ int64_t start = TC_Common::now2us();
+
+ std::function func;
+
+ if (param.call == "sync")
+ {
+ func = syncCall;
+ }
+ else if (param.call == "async")
+ {
+ func = asyncCall;
+ }
+ else
+ {
+ cout << "no func, exits" << endl;
+ exit(0);
+ }
+
+ vector vt;
+ for(int i = 0 ; i< param.thread; i++)
+ {
+ vt.push_back(new std::thread(func, param.count));
+ }
+
+ std::thread print([&]{while(callback_count != param.count * param.thread) {
+ cout << param.call << ": ----------finish count:" << callback_count << endl;
+ std::this_thread::sleep_for(std::chrono::seconds(1));
+ };});
+
+ for(size_t i = 0 ; i< vt.size(); i++)
+ {
+ vt[i]->join();
+ delete vt[i];
+ }
+
+ cout << "(pid:" << std::this_thread::get_id() << ")"
+ << "(count:" << param.count << ")"
+ << "(use ms:" << (TC_Common::now2us() - start)/1000 << ")"
+ << endl;
+
+ while(callback_count != param.count * param.thread) {
+ std::this_thread::sleep_for(std::chrono::seconds(1));
+ }
+ print.join();
+ cout << "----------finish count:" << callback_count << endl;
+ }
+ catch(exception &ex)
+ {
+ cout << ex.what() << endl;
+ }
+ cout << "main return." << endl;
+
+ return 0;
+}
diff --git a/examples/AuthDemo/Server/CMakeLists.txt b/examples/AuthDemo/Server/CMakeLists.txt
new file mode 100644
index 0000000..c22147f
--- /dev/null
+++ b/examples/AuthDemo/Server/CMakeLists.txt
@@ -0,0 +1 @@
+build_tars_server("AuthServer" "")
diff --git a/examples/AuthDemo/Server/Hello.h b/examples/AuthDemo/Server/Hello.h
new file mode 100644
index 0000000..f85e089
--- /dev/null
+++ b/examples/AuthDemo/Server/Hello.h
@@ -0,0 +1,471 @@
+// **********************************************************************
+// This file was generated by a TARS parser!
+// TARS version 2.0.0.
+// **********************************************************************
+
+#ifndef __HELLO_H_
+#define __HELLO_H_
+
+#include