Skip to content

Commit

Permalink
Add Sentry (#370)
Browse files Browse the repository at this point in the history
* Add Sentry

* add curl dep

* add recursive

* try to fix ci

* try again

* update linux ci
  • Loading branch information
MisterTea committed Jan 3, 2021
1 parent 5a5636a commit b3512b6
Show file tree
Hide file tree
Showing 12 changed files with 163 additions and 53 deletions.
26 changes: 13 additions & 13 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ jobs:
command: mkdir -p ~/.ssh/ && echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
- run:
name: Install system dependencies
command: apt-get update; apt-get install -y libunwind-dev git cmake protobuf-compiler libsodium-dev libgflags-dev libprotobuf-dev libutempter-dev g++ openssh-server
command: apt-get update; apt-get install -y libcurl4-openssl-dev libunwind-dev git cmake protobuf-compiler libsodium-dev libgflags-dev libprotobuf-dev libutempter-dev g++ openssh-server
- checkout
- run:
name: Set up ssh & known_hosts
command: /etc/init.d/ssh start; rm -f ~/.ssh/id_rsa*; ssh-keygen -q -N "" -f ~/.ssh/id_rsa; cp ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys; rm -f ~/.ssh/known_hosts; ssh -o "StrictHostKeyChecking no" localhost ls
- run:
name: Init submodules
command: if [ $CIRCLE_BRANCH != "release" ]; then git submodule update --init; fi
command: if [ $CIRCLE_BRANCH != "release" ]; then git submodule update --init --recursive; fi
- run:
name: Build the root version of the project
command: mkdir ../root_version; cp -Rf .git * ../root_version/; cd ../root_version; git checkout v6; mkdir build; cd build; cmake ../; make -j4
Expand Down Expand Up @@ -45,14 +45,14 @@ jobs:
command: mkdir -p ~/.ssh/ && echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
- run:
name: Install system dependencies
command: apt-get update; apt-get install -y libunwind-dev git cmake protobuf-compiler libsodium-dev libgflags-dev libprotobuf-dev libutempter-dev g++ openssh-server
command: apt-get update; apt-get install -y libcurl4-openssl-dev libunwind-dev git cmake protobuf-compiler libsodium-dev libgflags-dev libprotobuf-dev libutempter-dev g++ openssh-server
- checkout
- run:
name: Set up ssh & known_hosts
command: /etc/init.d/ssh start; rm -f ~/.ssh/id_rsa*; ssh-keygen -q -N "" -f ~/.ssh/id_rsa; cp ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys; rm -f ~/.ssh/known_hosts; ssh -o "StrictHostKeyChecking no" localhost ls
- run:
name: Init submodules
command: if [ $CIRCLE_BRANCH != "release" ]; then git submodule update --init; fi
command: if [ $CIRCLE_BRANCH != "release" ]; then git submodule update --init --recursive; fi
- run:
name: Build the project
command: mkdir build; cd build; cmake -DCMAKE_INSTALL_PREFIX=/usr ../; make -j4 install
Expand All @@ -72,11 +72,11 @@ jobs:
command: mkdir -p ~/.ssh/ && echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
- run:
name: Install system dependencies
command: apt-get update; apt-get install -y libunwind-dev git cmake protobuf-compiler libsodium-dev libgflags-dev libprotobuf-dev libutempter-dev g++
command: apt-get update; apt-get install -y libcurl4-openssl-dev libunwind-dev git cmake protobuf-compiler libsodium-dev libgflags-dev libprotobuf-dev libutempter-dev g++
- checkout
- run:
name: Init submodules
command: git submodule update --init
command: git submodule update --init --recursive
- run:
name: Build the project with test
command: mkdir build; cd build; cmake -DSANITIZE_MEMORY=ON ../; make -j4
Expand All @@ -92,11 +92,11 @@ jobs:
command: mkdir -p ~/.ssh/ && echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
- run:
name: Install system dependencies
command: apt-get update; apt-get install -y libunwind-dev git cmake protobuf-compiler libsodium-dev libgflags-dev libprotobuf-dev libutempter-dev g++
command: apt-get update; apt-get install -y libcurl4-openssl-dev libunwind-dev git cmake protobuf-compiler libsodium-dev libgflags-dev libprotobuf-dev libutempter-dev g++
- checkout
- run:
name: Init submodules
command: if [ $CIRCLE_BRANCH != "release" ]; then git submodule update --init; fi
command: if [ $CIRCLE_BRANCH != "release" ]; then git submodule update --init --recursive; fi
- run:
name: Build the project with test
command: mkdir build; cd build; cmake -DSANITIZE_ADDRESS=ON ../; make -j4
Expand All @@ -112,11 +112,11 @@ jobs:
command: mkdir -p ~/.ssh/ && echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
- run:
name: Install system dependencies
command: apt-get update; apt-get install -y libunwind-dev git cmake protobuf-compiler libsodium-dev libgflags-dev libprotobuf-dev libutempter-dev g++
command: apt-get update; apt-get install -y libcurl4-openssl-dev libunwind-dev git cmake protobuf-compiler libsodium-dev libgflags-dev libprotobuf-dev libutempter-dev g++
- checkout
- run:
name: Init submodules
command: if [ $CIRCLE_BRANCH != "release" ]; then git submodule update --init; fi
command: if [ $CIRCLE_BRANCH != "release" ]; then git submodule update --init --recursive; fi
- run:
name: Build the project with test
command: mkdir build; cd build; cmake -DSANITIZE_THREAD=ON ../; make -j4
Expand All @@ -132,11 +132,11 @@ jobs:
command: mkdir -p ~/.ssh/ && echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
- run:
name: Install system dependencies
command: apt-get update; apt-get install -y libunwind-dev git cmake protobuf-compiler libsodium-dev libgflags-dev libprotobuf-dev libutempter-dev g++
command: apt-get update; apt-get install -y libcurl4-openssl-dev libunwind-dev git cmake protobuf-compiler libsodium-dev libgflags-dev libprotobuf-dev libutempter-dev g++
- checkout
- run:
name: Init submodules
command: if [ $CIRCLE_BRANCH != "release" ]; then git submodule update --init; fi
command: if [ $CIRCLE_BRANCH != "release" ]; then git submodule update --init --recursive; fi
- run:
name: Build the project with test
command: mkdir build; cd build; cmake -DSANITIZE_UNDEFINED=ON ../; make -j4
Expand All @@ -156,7 +156,7 @@ jobs:
- checkout
- run:
name: Init submodules
command: if [ $CIRCLE_BRANCH != "release" ]; then git submodule update --init; fi
command: if [ $CIRCLE_BRANCH != "release" ]; then git submodule update --init --recursive; fi
- run:
name: Build the project with test
command: mkdir build; cd build; cmake -DSANITIZE_THREAD=ON ../; make -j4
Expand Down
20 changes: 8 additions & 12 deletions .github/workflows/linux_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@ jobs:
mkdir -p ~/.ssh/
echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
sudo apt-get update
sudo apt-get install -y libunwind-dev git cmake gdb protobuf-compiler libsodium-dev libgflags-dev libprotobuf-dev libutempter-dev g++
sudo apt-get install -y libcurl4-openssl-dev libunwind-dev git cmake gdb protobuf-compiler libsodium-dev libgflags-dev libprotobuf-dev libutempter-dev g++
ACCEPT_EULA=Y sudo apt-get -y upgrade
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
git submodule sync --recursive
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
git submodule update --init
git submodule update --init --force --recursive
- name: Test with ubsan
run: |
Expand All @@ -44,12 +43,11 @@ jobs:
mkdir -p ~/.ssh/
echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
sudo apt-get update
sudo apt-get install -y libunwind-dev git cmake gdb protobuf-compiler libsodium-dev libgflags-dev libprotobuf-dev libutempter-dev g++
sudo apt-get install -y libcurl4-openssl-dev libunwind-dev git cmake gdb protobuf-compiler libsodium-dev libgflags-dev libprotobuf-dev libutempter-dev g++
ACCEPT_EULA=Y sudo apt-get -y upgrade
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
git submodule sync --recursive
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
git submodule update --init
git submodule update --init --force --recursive
- name: Test with asan
run: |
Expand All @@ -72,12 +70,11 @@ jobs:
mkdir -p ~/.ssh/
echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
sudo apt-get update
sudo apt-get install -y libunwind-dev git cmake gdb protobuf-compiler libsodium-dev libgflags-dev libprotobuf-dev libutempter-dev g++
sudo apt-get install -y libcurl4-openssl-dev libunwind-dev git cmake gdb protobuf-compiler libsodium-dev libgflags-dev libprotobuf-dev libutempter-dev g++
ACCEPT_EULA=Y sudo apt-get -y upgrade
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
git submodule sync --recursive
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
git submodule update --init
git submodule update --init --force --recursive
- name: Test with msan
run: |
Expand All @@ -100,12 +97,11 @@ jobs:
mkdir -p ~/.ssh/
echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
sudo apt-get update
sudo apt-get install -y libunwind-dev git cmake gdb protobuf-compiler libsodium-dev libgflags-dev libprotobuf-dev libutempter-dev g++
sudo apt-get install -y libcurl4-openssl-dev libunwind-dev git cmake gdb protobuf-compiler libsodium-dev libgflags-dev libprotobuf-dev libutempter-dev g++
ACCEPT_EULA=Y sudo apt-get -y upgrade
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
git submodule sync --recursive
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
git submodule update --init
git submodule update --init --force --recursive
- name: Test with tsan
run: |
Expand Down
16 changes: 6 additions & 10 deletions .github/workflows/mac_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ jobs:
- name: Setup
shell: bash
run: |
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
git submodule sync --recursive
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
git submodule update --init
mkdir -p ~/.ssh/
echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
brew install cmake; brew install protobuf libsodium
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
git submodule sync --recursive
git submodule update --init --force --recursive
- name: Test with ubsan
run: |
Expand All @@ -41,8 +40,7 @@ jobs:
run: |
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
git submodule sync --recursive
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
git submodule update --init
git submodule update --init --force --recursive
mkdir -p ~/.ssh/
echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
brew install cmake; brew install protobuf libsodium
Expand All @@ -67,8 +65,7 @@ jobs:
run: |
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
git submodule sync --recursive
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
git submodule update --init
git submodule update --init --force --recursive
mkdir -p ~/.ssh/
echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
brew install cmake; brew install protobuf libsodium
Expand All @@ -93,8 +90,7 @@ jobs:
run: |
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
git submodule sync --recursive
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
git submodule update --init
git submodule update --init --force --recursive
mkdir -p ~/.ssh/
echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
brew install cmake; brew install protobuf libsodium
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@
[submodule "external/vcpkg"]
path = external/vcpkg
url = https://github.com/microsoft/vcpkg.git
[submodule "external/sentry-native"]
path = external/sentry-native
url = https://github.com/getsentry/sentry-native.git
57 changes: 39 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
cmake_minimum_required (VERSION 3.0.2)
project (EternalTCP VERSION 6.0.13)

include(CMakeFindDependencyMacro)

# Add cmake script directory.
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/external/sanitizers-cmake/cmake" ${CMAKE_MODULE_PATH})
FIND_PACKAGE(Sanitizers)

# Required packages
FIND_PACKAGE(Sanitizers REQUIRED)
find_package(Threads REQUIRED)
find_package(sodium REQUIRED)
find_package(Protobuf REQUIRED)

# Optional packages
find_package(UTempter)
IF(LINUX)
find_package(SELinux)
ENDIF()

add_subdirectory("external/sentry-native")

SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/external/cotire/CMake" ${CMAKE_MODULE_PATH})
INCLUDE(cotire)
Expand All @@ -15,7 +32,7 @@ option(DISABLE_CRASH_LOG "Disable installing easylogging crash handler" OFF)

add_definitions(-DET_VERSION="${PROJECT_VERSION}")
# For easylogging, disable default log file, enable crash log, ensure thread safe, and catch c++ exceptions
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DELPP_NO_DEFAULT_LOG_FILE -DELPP_FEATURE_CRASH_LOG -DELPP_THREAD_SAFE")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DELPP_NO_DEFAULT_LOG_FILE -DELPP_FEATURE_CRASH_LOG -DELPP_THREAD_SAFE -DSENTRY_BUILD_STATIC")
IF(CODE_COVERAGE)
if(UNIX)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
Expand Down Expand Up @@ -52,25 +69,19 @@ if (CMAKE_SYSTEM_NAME MATCHES "NetBSD")
set(NETBSD TRUE)
endif (CMAKE_SYSTEM_NAME MATCHES "NetBSD")

# Add cmake script directory.
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")

# Required packages
find_package(Threads REQUIRED)
find_package(Protobuf REQUIRED)
find_package(sodium REQUIRED)

# Optional packages
IF(LINUX)
find_package(SELinux)
ENDIF()
find_package(UTempter)

option(FULL_PROTOBUF "Link to full protobuf library instead of protobuf-lite" OFF)
IF(FULL_PROTOBUF)
SET(PROTOBUF_LIBS ${PROTOBUF_LIBRARIES})
IF(WIN32)
SET(PROTOBUF_LIBS protobuf::libprotobuf)
ELSE()
SET(PROTOBUF_LIBS ${PROTOBUF_LIBRARIES})
ENDIF()
ELSE()
SET(PROTOBUF_LIBS ${PROTOBUF_LITE_LIBRARIES})
IF(WIN32)
SET(PROTOBUF_LIBS protobuf::libprotobuf-lite)
ELSE()
SET(PROTOBUF_LIBS ${PROTOBUF_LITE_LIBRARIES})
ENDIF()
ENDIF()

IF(SELINUX_FOUND)
Expand Down Expand Up @@ -132,6 +143,7 @@ include_directories(
external/cxxopts/include
external/msgpack-c/include
external/UniversalStacktrace/ust
external/sentry-native/include
src/base
src/terminal
src/terminal/forwarding
Expand Down Expand Up @@ -241,6 +253,9 @@ add_library(
src/terminal/UserJumphostHandler.hpp
src/terminal/UserJumphostHandler.cpp

src/terminal/TelemetryService.hpp
src/terminal/TelemetryService.cpp

${ETERMINAL_SRCS} ${ETERMINAL_HDRS}
)
add_dependencies(
Expand All @@ -262,6 +277,7 @@ target_link_libraries (
${PROTOBUF_LIBS}
${sodium_LIBRARY_RELEASE}
${UTEMPTER_LIBRARIES}
sentry::sentry
${CORE_LIBRARIES}
)
DECORATE_TARGET(et)
Expand Down Expand Up @@ -289,6 +305,7 @@ target_link_libraries (
${sodium_LIBRARY_RELEASE}
${SELINUX_LIBRARIES}
${UTEMPTER_LIBRARIES}
sentry::sentry
${CORE_LIBRARIES}
)
DECORATE_TARGET(etserver)
Expand All @@ -307,6 +324,7 @@ target_link_libraries (
${sodium_LIBRARY_RELEASE}
${SELINUX_LIBRARIES}
${UTEMPTER_LIBRARIES}
sentry::sentry
${CORE_LIBRARIES}
)
DECORATE_TARGET(etterminal)
Expand Down Expand Up @@ -345,6 +363,7 @@ target_link_libraries (
${sodium_LIBRARY_RELEASE}
${SELINUX_LIBRARIES}
${UTEMPTER_LIBRARIES}
sentry::sentry
${CORE_LIBRARIES}
)
DECORATE_TARGET(htm)
Expand All @@ -365,6 +384,7 @@ target_link_libraries (
${sodium_LIBRARY_RELEASE}
${SELINUX_LIBRARIES}
${UTEMPTER_LIBRARIES}
sentry::sentry
${CORE_LIBRARIES}
)
DECORATE_TARGET(htmd)
Expand All @@ -391,6 +411,7 @@ target_link_libraries(
${sodium_LIBRARY_RELEASE}
${SELINUX_LIBRARIES}
${UTEMPTER_LIBRARIES}
sentry::sentry
${CORE_LIBRARIES}
)
add_test(
Expand Down
1 change: 1 addition & 0 deletions external/sentry-native
Submodule sentry-native added at 04eb4e
2 changes: 2 additions & 0 deletions src/base/Headers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ inline int close(int fd) { return ::closesocket(fd); }
#include <utempter.h>
#endif

#include "sentry.h"

#if WIN32
#define popen _popen
#define pclose _pclose
Expand Down
34 changes: 34 additions & 0 deletions src/terminal/TelemetryService.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include "TelemetryService.hpp"

namespace et {
TelemetryService::TelemetryService(bool _allow, const string& databasePath,
const string& environment)
: allowed(_allow) {
if (allowed) {
sentry_options_t* options = sentry_options_new();

// this is an example. for real usage, make sure to set this explicitly to
// an app specific cache location.
sentry_options_set_database_path(options, databasePath.c_str());
sentry_options_set_dsn(
options,
"https://[email protected]/"
"5574732");
sentry_options_set_symbolize_stacktraces(options, true);
sentry_options_set_release(options, "EternalTerminal@" ET_VERSION);
sentry_options_set_environment(options, environment.c_str());

sentry_init(options);
}
}

TelemetryService::~TelemetryService() { sentry_shutdown(); }

void TelemetryService::log(sentry_level_e level, const std::string& message) {
if (!allowed) return;
sentry_capture_event(
sentry_value_new_message_event(level, "stderr", message.c_str()));
}

shared_ptr<TelemetryService> TelemetryService::telemetryServiceInstance;
} // namespace et
Loading

0 comments on commit b3512b6

Please sign in to comment.