pax_global_header 0000666 0000000 0000000 00000000064 13153561626 0014522 g ustar 00root root 0000000 0000000 52 comment=3a7de454959dca5d07eeca62d01f81560d61c378
measurement-kit-0.7.1/ 0000775 0000000 0000000 00000000000 13153561626 0014641 5 ustar 00root root 0000000 0000000 measurement-kit-0.7.1/.clang-format 0000664 0000000 0000000 00000000105 13153561626 0017210 0 ustar 00root root 0000000 0000000 ---
BasedOnStyle: LLVM
IndentWidth: 4
ContinuationIndentWidth: 6
---
measurement-kit-0.7.1/.gitignore 0000664 0000000 0000000 00000005527 13153561626 0016642 0 ustar 00root root 0000000 0000000 *.a
*.app
*.dll
*.dylib
*.dylib.*
*.exe
*.gcda
*.gcno
*.gcov
*.ko
*.la
*.lib
*.lo
*.log
*.o
*.o-*
*.out
*.pyc
*.so
*.so.*
*.swp
*.trs
.DS_Store
.deps
.dirstamp
.idea
.libs
.vagrant
/*.njson
/GeoIP.dat
/GeoIPASNum.dat
/GeoLiteCity.dat
/build/android/jni/conf
/build/android/jni/spec
/citizenlab-test-lists.*.csv
/example/common/fapply
/example/common/fcompose
/example/dns/ping
/example/dns/query
/example/http/request
/example/libevent/discard
/example/libevent/listen
/example/mlabns/query
/example/net/connect
/example/net/transport
/example/nettests/multithread
/example/nettests/simple
/example/ooni/oonireport
/example/ooni/ooniresources
/example/ooni/oorchestrate
/include.am
/include/measurement_kit/*.hpp
/include/measurement_kit/common/git_version.hpp
/maxmind-geoip.*.dat*
/measurement_kit
/test-driver
/test/common/continuation
/test/common/delegate
/test/common/encoding
/test/common/error
/test/common/error_or
/test/common/every
/test/common/fapply
/test/common/fcar
/test/common/fcdr
/test/common/fcompose
/test/common/fmap
/test/common/freverse
/test/common/json
/test/common/locked
/test/common/logger
/test/common/maybe
/test/common/parallel
/test/common/range
/test/common/sandbox
/test/common/settings
/test/common/utils
/test/common/var
/test/common/version
/test/common/worker
/test/dns/ping
/test/dns/query
/test/dns/query_class
/test/dns/query_type
/test/dns/system_resolver
/test/http/headers
/test/http/parse_url
/test/http/request
/test/http/response_parser
/test/libevent/connection
/test/libevent/dns_error
/test/libevent/poller
/test/mlabns/mlabns
/test/ndt/measure_speed
/test/ndt/messages
/test/ndt/protocol
/test/ndt/run
/test/ndt/test_c2s
/test/ndt/test_meta
/test/ndt/test_s2c
/test/net/buffer
/test/net/builtin_ca_bundle
/test/net/connect
/test/net/emitter
/test/net/evbuffer
/test/net/libssl
/test/net/socks5
/test/net/transport
/test/net/utils
/test/nettests/dash
/test/nettests/dns_injection
/test/nettests/http_header_field_manipulation
/test/nettests/http_invalid_request_line
/test/nettests/meek_fronted_requests
/test/nettests/multi_ndt
/test/nettests/ndt
/test/nettests/runnable
/test/nettests/runner
/test/nettests/tcp_connect
/test/nettests/utils
/test/nettests/web_connectivity
/test/ooni/bouncer
/test/ooni/collector_client
/test/ooni/orchestrate
/test/ooni/resources
/test/ooni/templates
/test/ooni/utils
/test/report/entry
/test/report/file_reporter
/test/report/report
/test/traceroute/android
/tmp
/tor-bridges.tor-bridges-ip-port.csv
Makefile
Makefile.in
__venv__
aclocal.m4
autom4te.cache/
builtin/
compile
config.guess
config.h
config.h.in
config.h.in~
config.log
config.status
config.sub
configure
depcomp
install-sh
libtool
ltmain.sh
m4/*.m4
missing
node_modules/
orchestrator_dummy.json
orchestrator_secrets.json
orchestrator_secrets_*.json
site
src/libmeasurement_kit/ext/Catch/
src/libmeasurement_kit/ext/http-parser/
stamp-h1
third_party/
xx
measurement-kit-0.7.1/.gitlab-ci.yml 0000664 0000000 0000000 00000000347 13153561626 0017301 0 ustar 00root root 0000000 0000000 valgrind-gcc:
image: ubuntu:yakkety
script: ./build/ci/gitlab valgrind-gcc
only:
- master
- stable
valgrind-clang:
image: ubuntu:yakkety
script: ./build/ci/gitlab valgrind-clang
only:
- master
- stable
measurement-kit-0.7.1/.travis.yml 0000664 0000000 0000000 00000000636 13153561626 0016757 0 ustar 00root root 0000000 0000000 language: cpp
script:
- ./build/ci/travis
matrix:
include:
- sudo: required
env: DOCKER_SPEC=valgrind-clang pkg_make_flags="V=0 -j3"
services:
- docker
- sudo: required
env: DOCKER_SPEC=valgrind-gcc pkg_make_flags="V=0 -j3"
services:
- docker
- sudo: required
env: DOCKER_SPEC=coveralls pkg_make_flags="V=0 -j3"
services:
- docker
measurement-kit-0.7.1/AUTHORS 0000664 0000000 0000000 00000000331 13153561626 0015706 0 ustar 00root root 0000000 0000000 Main authors:
Simone Basso
Arturo Filastò
Contributors (in alphabetical order):
Davide Allavena
Carmine D'Amico
Leonid Evdokimov
Joe Landers
Antonio Langiu
Lorenzo Primiterra
Alessandro Quaranta
measurement-kit-0.7.1/BUGS 0000664 0000000 0000000 00000001052 13153561626 0015322 0 ustar 00root root 0000000 0000000 1. As find out in commit 08c5d97550527, the python generator gen_python should
implement the get_foo() methods in a different way. In fact, if the object to
return has been passed to the constructor as a parameter, they should return
this object, instead of calling the wrapper function. [FIXED]
2. The Connection module, when receiving the EOF, closes the connection, even if
there is still something to write.
This file is now historical. Please, see and use GitHub issues:
https://github.com/measurement-kit/measurement-kit/issues
measurement-kit-0.7.1/CMakeLists.txt 0000664 0000000 0000000 00000012331 13153561626 0017401 0 ustar 00root root 0000000 0000000 # Part of measurement-kit .
# Measurement-kit is free software. See AUTHORS and LICENSE for more
# information on the copying conditions.
cmake_minimum_required(VERSION 3.6)
# Definitions:
set(MK_GEOIP "${MK_GEOIP}" CACHE PATH "Path where geoip is installed")
set(MK_LIBEVENT "${MK_LIBEVENT}" CACHE PATH "Path where libevent is installed")
set(MK_OPENSSL "${MK_OPENSSL}" CACHE PATH "Path where openssl is installed")
# Compiler:
set(CMAKE_CXX_STANDARD 14)
set(MK_UNIX_CFLAGS "-Wall -Wextra -pedantic -I${CMAKE_SOURCE_DIR}/include")
set(MK_UNIX_CXXFLAGS "-Wall -Wextra -pedantic -I${CMAKE_SOURCE_DIR}/include")
add_definitions(-DENABLE_INTEGRATION_TESTS)
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} ${MK_UNIX_CXXFLAGS} -Wmissing-prototypes")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MK_UNIX_CXXFLAGS}")
endif()
if("${CMAKE_C_COMPILER_ID}" MATCHES "Clang")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MK_UNIX_CFLAGS} -Wmissing-prototypes")
elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MK_UNIX_CFLAGS}")
endif()
# Set target include directories and link libraries:
if(UNIX)
if(NOT ("${MK_GEOIP}" STREQUAL ""))
list(APPEND MK_INCLUDE_DIRS "${MK_GEOIP}/include")
list(APPEND MK_LINK_DIRS "${MK_GEOIP}/lib")
endif()
if(NOT ("${MK_LIBEVENT}" STREQUAL ""))
list(APPEND MK_INCLUDE_DIRS "${MK_LIBEVENT}/include")
list(APPEND MK_LINK_DIRS "${MK_LIBEVENT}/lib")
endif()
if(NOT ("${MK_OPENSSL}" STREQUAL ""))
list(APPEND MK_INCLUDE_DIRS "${MK_OPENSSL}/include")
list(APPEND MK_LINK_DIRS "${MK_OPENSSL}/lib")
endif()
endif()
# Check dependencies:
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
include(CheckIncludeFiles)
include(CheckFunctionExists)
include(CheckLibraryExists)
if(UNIX)
# libc
CHECK_FUNCTION_EXISTS(err HAVE_ERR)
CHECK_FUNCTION_EXISTS(err HAVE_ERR)
CHECK_FUNCTION_EXISTS(warn HAVE_WARN)
CHECK_FUNCTION_EXISTS(warnx HAVE_WARNX)
CHECK_FUNCTION_EXISTS(getopt HAVE_GETOPT)
CHECK_FUNCTION_EXISTS(getopt_long HAVE_GETOPT_LONG)
CHECK_FUNCTION_EXISTS(getopt_long_only HAVE_GETOPT_LONG_ONLY)
CHECK_FUNCTION_EXISTS(gmtime_r HAVE_GMTIME_R)
CHECK_FUNCTION_EXISTS(strtonum HAVE_STRTONUM)
# geoip
set(CMAKE_REQUIRED_INCLUDES "${MK_INCLUDE_DIRS}")
CHECK_INCLUDE_FILES(GeoIP.h HAVE_GEOIP_H)
CHECK_LIBRARY_EXISTS(GeoIP GeoIP_open "${MK_GEOIP}/lib" HAVE_LIBGEOIP)
set(CMAKE_REQUIRED_INCLUDES "")
if (NOT HAVE_GEOIP_H OR NOT HAVE_LIBGEOIP)
message(FATAL_ERROR "geoip missing; Use -DMK_GEOIP to specify where it is installed (e.g. -DMK_GEOIP=/usr/local if it is installed under /usr/local)")
endif()
# openssl
set(CMAKE_REQUIRED_INCLUDES "${MK_INCLUDE_DIRS}")
CHECK_INCLUDE_FILES(openssl/rsa.h HAVE_OPENSSL_RSA_H)
CHECK_LIBRARY_EXISTS(crypto RSA_new "${MK_OPENSSL}/lib" HAVE_LIBCRYPTO)
CHECK_INCLUDE_FILES(openssl/ssl.h HAVE_OPENSSL_SSL_H)
CHECK_LIBRARY_EXISTS(ssl SSL_new "${MK_OPENSSL}/lib" HAVE_LIBSSL)
set(CMAKE_REQUIRED_INCLUDES "")
if (NOT HAVE_OPENSSL_RSA_H OR NOT HAVE_LIBSSL)
message(FATAL_ERROR "openssl/libressl missing; Use -DMK_OPENSSL to specify where it is installed (e.g. -DMK_OPENSSL=/usr/local if it is installed under /usr/local)")
endif()
# libevent
set(CMAKE_REQUIRED_INCLUDES "${MK_INCLUDE_DIRS}")
CHECK_INCLUDE_FILES(event2/event.h HAVE_EVENT2_EVENT_H)
CHECK_LIBRARY_EXISTS(event event_new "${MK_LIBEVENT}/lib" HAVE_LIBEVENT)
set(CMAKE_REQUIRED_INCLUDES "")
if (NOT HAVE_EVENT2_EVENT_H OR NOT HAVE_LIBEVENT)
message(FATAL_ERROR "libevent missing; Use -DMK_LIBEVENT to specify where it is installed (e.g. -DMK_LIBEVENT=/usr/local if it is installed under /usr/local)")
endif()
# libresolv (required by `./test/common/encoding`)
CHECK_LIBRARY_EXISTS(resolv hstrerror "" HAVE_LIBRESOLV)
if (HAVE_LIBRESOLV)
list(APPEND MK_LIBS resolv)
endif()
list(APPEND MK_LIBS GeoIP crypto ssl event event_openssl event_pthreads)
endif()
# Add targets
link_directories(${MK_LINK_DIRS})
## libmeasurement_kit
file(
GLOB
MK_LIBRARY_SOURCES
"include/measurement_kit/*.hpp"
"include/measurement_kit/*/*.hpp"
"src/libmeasurement_kit/*/*.c"
"src/libmeasurement_kit/*/*.cpp"
)
add_library(
measurement_kit_static
STATIC
${MK_LIBRARY_SOURCES}
)
target_include_directories(
measurement_kit_static
PUBLIC
${MK_INCLUDE_DIRS}
)
target_link_libraries(
measurement_kit_static
${MK_LIBS}
Threads::Threads
)
## measurement_kit
file(
GLOB
MK_PROGRAM_SOURCES
"src/measurement_kit/*.cpp"
"src/measurement_kit/*/*.cpp"
)
add_executable(
measurement_kit_exe
${MK_PROGRAM_SOURCES}
)
target_link_libraries(
measurement_kit_exe
measurement_kit_static
${MK_LIBS}
Threads::Threads
)
## tests
enable_testing()
file(GLOB MK_TESTS_SOURCES RELATIVE "${CMAKE_SOURCE_DIR}" "test/*/*.cpp")
foreach(MK_TEST_SOURCE ${MK_TESTS_SOURCES})
string(REPLACE ".cpp" "" MK_TEST_NAME ${MK_TEST_SOURCE})
string(REPLACE "/" "_" MK_TEST_NAME ${MK_TEST_NAME})
add_executable(${MK_TEST_NAME} ${MK_TEST_SOURCE})
target_link_libraries(
${MK_TEST_NAME}
measurement_kit_static
${MK_LIBS}
Threads::Threads
)
add_test(${MK_TEST_NAME} ${MK_TEST_NAME})
endforeach()
measurement-kit-0.7.1/CONTRIBUTING.md 0000664 0000000 0000000 00000005321 13153561626 0017073 0 ustar 00root root 0000000 0000000 # Contributing to MeasurementKit
MeasurementKit is a Free and Open Source software project that welcomes new contributions.
## How to contribute code
For guidelines on what coding style we follow refer to the [coding style document]
(/doc/coding-style.md).
### 1. Fork
You should first create a fork of measurement-kit by clicking on the fork button and
cloning your fork with:
```
git clone git@github.com:username/measurement-kit.git
cd measurement-kit
git remote add upstream https://github.com/measurement-kit/measurement-kit.git
```
### 2. Branch
Branches should be created from the `master` branch with an accurately labelled name.
If you want to work on a new feature you could name your branch `feature/myfeature`,
if you are fixing a bug you could name it `bug/1234`.
Create your branch from `master` like so:
```
git checkout -b mybranch
```
Then you can start hacking
### 3. Commit
Make sure git knows your username and email address with the following:
```
git config --global user.name "Jane Doe"
git config --global user.email "jane@example.com"
```
Try to keep the commits made on the branch small (a good branch should only address
one specific issue).
### 4. Test
Make sure all the existing unittests for measurement-kit are passing.
```
make check
```
If you add extra code or modify existing code, be sure that it is covered by the existing unittests
and if not write them.
In general, it would be good for pull requests not to reduce the current code coverage of the project.
If you are submitting a branch fixing a bug, you should also be submitting a unittest that is capable
of reproducing the bug you are attempting to fix.
### 5. Open a Pull Request
You can then push your feature branch to your remote and open a pull request.
## Code Review process
Small pull requests should be tagged as `hotfix` and can be self merged. All other
pull request should be reviewed by another core developer who will take responsibility
of the merge. The repository should be configured such that it is not possible to
merge into `master` (or `stable`) if unit tests are not passing.
If the diff is small, squash merge is preferred, otherwise preserve the history.
In general it is a good idea to keep your branches in sync with master and rebase
them from time to time before the review has happenned. However if the review has
already begun it's better to merge and resolve the conflicts locally and push the merge
commit, to allow the reviewer to see how the conflicts were resolved.
Before a release, review the code base, fixing simple bugs directly and opening issues
to describe more complex required fixes and refactoring opportunities. Also during such
review make sure that the documentation is up to date with the code.
measurement-kit-0.7.1/ChangeLog.md 0000664 0000000 0000000 00000100677 13153561626 0017025 0 ustar 00root root 0000000 0000000 # MeasurementKit 0.7.1 [2017-09-05]
- fix(*): use `gpg` rather than `gpg2` (#1320)
- fix(geoip): make cache thread local (#1323)
- Update to Catch v1.10.0 (#1327)
- backport: ssl: refactor [...], fix thread safety (#1313)
- Update tls_verify to v1.19 (#1328)
- fix: ios build (#1331)
# MeasurementKit 0.7.0 [2017-08-05]
- build/ios/archive-library: fix version number
- orchestrate.cpp: serialize also language (#1282)
- ndt: make test progress more smooth
- runnable: stop time tests with 10% tolerance
- Add more parameters to dash
- fix(http): re-renable previously disabled tests
# MeasurementKit 0.7.0-beta [2017-07-17]
- Cherry picks from v0.7.0-beta branch (#1278)
- Fix: ssl verify errors (#1279)
- docker: use libc++ with clang (#1275)
- Integration branch for v0.7.0-beta (#1271)
# MeasurementKit 0.7.0-alpha.3 [2017-07-11]
- cmake: Fix build and register tests as such (#1267)
- var: inherit -> compose (fix android build)
- Fix Android build warnings
- Allow to pass nettests input from command line (#1273)
- connect: simplify access to connect-time stats (#1261)
- Implement Neubot's DASH test (#769)
- docker: exclude `builtin` from coveralls
- FIX test/http/request.cpp for hustmail
- REPAIR test/http/request.cpp build
# MeasurementKit 0.7.0-alpha.2 [2017-06-28]
- Add public API to get platform name
- Simple implementation of fcompose() (#1262)
- orchestration: guess params and other improvements (#1260)
- orchestrator: do not write on disk (#1263)
- `s/contact_bouncer/query_bouncer/`
- [ci skip] update docs
- travis: only build using docker (#1264)
- Cleanup API for v0.7 (#1265)
- Cleanup/move all headers (#1266)
# MeasurementKit 0.7.0-alpha.1 [2017-06-11]
- Implement DNS "ping" (#1256)
- Initial implementation of orchestrator (#1258)
# MeasurementKit 0.7.0-alpha [2017-06-01]
Note: 0.6.x was branched off stable. The release before this release
is therefore v0.5.0-alpha.
- Fix coveralls badge (#1190)
- Allow writing report on the stdout (#1199)
- Bump version number to v0.7.0-dev (#1201)
- Sync master with stable (#1213, #1224, #1236)
- Fix failing regress tests (#1222)
- Force non-strict HTTP parser (#1225)
- Use SSLv2 and SSLv3 with `web_connectivity` (#1228)
- Cherry pick nodejs/http-parser#364 (#1227)
- Changes to logger suggested by @darkk (#1230)
- Remove all refs to `oldstable`
- dns: make system resolver truly async (#1234)
- We don't actually need ReturnType (#1239)
- dns: split dns.hpp into several headers (#1241)
- common/worker.cpp: Fix a possible race condition
- dns: common impl for `query_{class,type}` (#1242)
- Start using bouncer (#1016)
- Start requiring move semantic for callbacks (#1244)
- runner: allow to run arbitrary tasks (#1249)
- Further refine the runner model (#1251)
- Add support for parsing ISO8601
- `parse_iso6801_utc`: add docs and more tests
- Improve our json processing capabilities (#1253)
- d/a/h/request.md: reindent and improve (#1254)
- Fix `json_*_process_and_filter_errors()`
- http/request: start adding JSON helpers
- http/request: finish off json helpers
- json helpers: Fix the order of arguments
- ndt: do not abort if a test phase fails
- Fix bouncer address
# MeasurementKit 0.6.6 [2017-05-15]
- n/connect.cpp: compile with libevent v2.0.x
- logger: stop using deprecated `MK_LOG_JSON`
- improve documentation
- fix t/h/request.cpp regress test
- e/h/request.cpp: fix usage string
- `connect_impl`: Fix regression added in 95e834e9e2
# MeasurementKit 0.6.5 [2017-05-14]
- Reveal SSL "dirty shutdown" errors
- `web_connectivity`: allow dirty SSL shutdown
- e/h/request.cpp: support custom CA bundle
- h/request.cpp: remove a lie
- l/connection.cpp: tweak debug message
# MeasurementKit 0.6.4 [2017-05-14]
- Add script to pretty print a report
- `dns_injection` MUST use libevent engine
- runable.cpp: don't create a null `input_` entry
- `dns_injection`: force timeout to be 3.0 s
- nettests: add support for UUID4
- runnable: make sure empty input becomes null entry
- runnable: add more missing entry fields
- runnable: start adding support for test-helpers
- runnable: add empty `input_hashes` entry
- `http_invalid_request_line`: add backend to result
- runnable.cpp: remove unneeded `input_` hack
- `http_invalid_request_line`: better error reporting
- `multi_ndt`: allow upload during single stream
- Sync `tcp_connect` with ooni-probe
- net/connect: make error result more precise
- ooni/templates: agent consistent w/ ooniprobe
- `web_connectivity`: add support for backend
- Further improve `web_connectivity` report
# MeasurementKit 0.6.3 [2017-05-12]
- test: use DNS libevent engine where needed
- Add script to create iOS binaries archive
# MeasurementKit 0.6.2 [2017-05-12]
- By default use the system engine also in `stable`
# MeasurementKit 0.6.1 [2017-05-12]
- Use also SSLv3 and SSLv3 with `web_connectivity` (#1228)
- Cherry pick nodejs/http-parser#364 (#1227)
- Reliability fixes for web connectivity (#1230)
# MeasurementKit 0.6.0 [2017-05-09]
- Fix iOS build (#1206)
- cocoapod: if possible download precompiled binary (#1207)
- Backport command line improvements from master (#1211)
- Be more precise with version numbers (#1212)
- Sync stable with oldstable branches (#1214, #1221)
- Update to catch v1.9.3 and adjust regress tests (#1215)
- Backport regress test fix from master (see #1222)
# MeasurementKit 0.6.0-beta [2017-05-02]
- Backport build system changes from master
- Sync files in top-level directory with master
- Backport test/net/connect.cpp fix for libevent-2.1
- Add NOTICE file, forgotten in previous PR
- Manually resolve ChangeLog.md conflict
- Add `node_modules` to .gitignore
- Backport `MK_MOCK()` simplification from master
- Backport HHFM and meek tests from master
- Also update .gitignore
# MeasurementKit 0.4.4 [2017-05-02]
- Disable test for bacardi.com
- Backport #1186 to stable branch
- Update to latest stable dependencies
- Backport #1163 to stable branch
- Backport #1179 to stable branch
# MeasurementKit 0.5.0-alpha [2017-04-11]
- Force the library to use the system resolver (#972)
- Add OONI bouncer support (#967)
- Refine and finish bouncer implementation (#1014)
- Add documentation for OONI's bouncer (#1032)
- Move dns resolution function from net to dns (#1022)
- Simple refactoring of system resolver (#1040)
- Forward port patch #1066 to master (#1067)
- build/dependency: implement quick git clone (#1068)
- build/dependency: factor more operations (#1069)
- Start cleaning up docker build system (#1070)
- Finish cleaning up docker build system (#1071)
- README.md: attempt to fix coveralls badge (#1072)
- travis: conditional build depending on branch (#1074)
- More cleanups of the CI subsystem (#1075)
- Increase code coverage a bit (#1036)
- Attempt to fix issue with case sensitive drive (#1076) (#1077)
- Backport simple hotfixes from #1017 (#1091)
- Tweak build/ios/cross (#1094)
- http: extract interesting stuff from #929 (#1095)
- Repair regress tests (#1117)
- Tweak README.md and ChangeLog.md (#1119)
- Fix uninitialized values according to Valgrind (#1118)
- Remove bashism (#1145)
- configure.ac: add /usr/local by default on macOS (#1151)
- test/net/connect.cpp: libevent 2.1.8 compat (#1152)
- Make Transport more OO (#1153)
- net: move most close logic in emitter (#1154)
- ooni/templates http: include all request/responses (#1149)
- replace short PGP key fingerprint with long one (#1157)
- Refactor cmdline to have OONI-like interface (#1156)
- net: further tweak the transport model (#1155)
- Repair broken test/ooni/utils.cpp (#1164)
- Fix `unknown_failure 3` bug (#1162)
- Repair regress tests after travis failure (#1166)
- build/ci/travis: fix branch name detection logic (#1167)
- http: refactor redirect logic (#1168)
- ooni/template.cpp: don't assume `!!response->request` (#1170)
- Finish fixing travis branch handling (#1171)
- common: add {start,end}swith (#1172)
- http::Response: init numbers to know value (#1174)
- http: treat EOF instead of response as error (#1175)
- Fix embarassing mk::endswith() bug (#1173)
- Fix `unknown_error_3009` bug (#1176)
- Fix report/entry.hpp w/ new NDK, nlohmann::json (#1177)
- Only run coveralls if we know the token (#1181)
- meek fronting nettest (#1141)
- Update to nlohmann/json v2.1.1 (#1179)
- mock.hpp: reduce implicit `MK_MOCK_NAMESPACE` magic (#1142)
- Start updating dependencies: the easy part (#1163)
- Update valgrind suppression files (#1186)
- Build and archive dependencies separately (#1185)
- Update README, license, badges (#1188)
- Refactor and improve build scripts (#1017)
- HTTP header fields manipulation test (#1146)
# MeasurementKit 0.4.3 [2017-03-14]
- Backport 5d88cf9ff (#1177) to stable branch
# MeasurementKit 0.4.2 [2017-03-12]
- Backport #1162: fix `unknown_failure 3` bug
- Backport #1163: repair regress tests after travis failure
- Backport #1164: repair broken test/ooni/utils.cpp
- Backport #1168: http: refactor redirect logic
- Backport #1170: ooni/template.cpp: don't assume `!!response->request`
- Backport #1172 and #1173: common: add {start,end}swith
- Backport #1174: http::Response: init numbers to known value
- Backport #1175: http: treat EOF-instead-of-response as error
- Backport #1176: Fix `unknown_error_3009` bug
# MeasurementKit 0.4.1 [2017-03-02]
- Backport #1149: ooni/templates http: include all request/responses
# MeasurementKit 0.4.0 [2017-02-13]
- Repair circle-ci build for stable (#1123)
- connect: support also ipv6 link local with scope (#1102)
- Fix gitlab on stable by using yakkety (#1133)
- Be more specific wrt connect() failure (#1126)
- Add a name to each error (#1134)
# MeasurementKit 0.4.0-beta.4 [2017-02-09]
- .gitlab-ci.yml: also build stable (#1122)
- http: fix EOF-implies-end-of-body logic (#1121)
- http: fix schema less redirect (#1124)
# MeasurementKit 0.4.0-beta.3 [2017-02-01]
- `ip_lookup()`: validate result as IP address (#1108)
- `web_connectivity`: do not `*request` unconditionally
- runnable: progress now accounts for `max_runtime`
- progress: also track opening/closing report
- The header key comparison MUST be done with the lowercase version
- Use std::transform to convert to lowercase
- Use transform also in another place
# MeasurementKit 0.4.0-beta.2 [2017-01-31]
- Start updating documentation for release 0.4.0 (#1082)
- report: Allow to specify application name and version (#1092)
- report: include the platform (#1093)
- Make sure http template produces good json (#1096)
- var.hpp: fix as() to use dynamic cast (#1090)
- test/net/connect.cpp: refactor to avoid global poller (#1099)
- connect: start fixing IPv6 addresses (#1100)
- net: start exposing network errors (#1101)
- Feature: NDT stats (#1089)
- Add regress tests for input processor (#1059)
- Use default backends when it makes sense (#1097)
- Propagate network errors (#1103)
- Fix: web connectivity segfault (#1107)
- `templates::http_request()`: scrub IP address (#1106)
- `web_connectivity`: pass headers to backend (#1111)
# MeasurementKit 0.4.0-beta.1 [2017-01-16]
- net: improve handling of address:port (#1079)
- `clang-format -i ooni/web_connectivity.cpp` (#1078)
- Attempt to fix issue with case sensitive drive (#1076)
- README.md: attempt to fix coveralls badge (#1073)
- travis: fix coveralls (#1066)
# MeasurementKit 0.4.0-beta [2017-01-13]
- Feature: recognize utf8 (#1062)
- Support for country-specific test lists (#1030)
# MeasurementKit 0.4.0-alpha.3 [2017-01-06]
- nettests: randomize input (#1029)
- Add workaround for Android with API < 21 (#1048)
- android build: simple changes backported from #1047 (#1049)
- More hotfix backports from #1047 (#1050)
- Fix API and ABI compatibility for old Androids (#1047)
- `system_resolver.hpp`: do not warn on getaddrinfo failure (#1055)
# MeasurementKit 0.4.0-alpha.2 [2016-12-28]
- runnable: implement `max_runtime` option (#1028)
- Fix libevent clock gettime (#1044)
# MeasurementKit 0.4.0-alpha.1 [2016-12-15]
- Improve `multi_ndt` entry format (#992)
- Fix: libressl ios build (#994)
- Refactor: ssl (#997)
- Write ssl context regress tests (#998)
- Implement mk::slurp() to read files at once (#996)
- BaseTest: add `on_logger_eof()` method (#1004)
- getaddrinfo: android dislikes `AI_V4MAPPED|AI_ALL` (#1005)
- logger: allow multiple `on_eof()` callbacks (#1006)
- runnable: allow multiple on-end callbacks (#1007)
- Use builtin CA file if CA file is missing and we're using libressl (#999)
- runnable: add `on_destroy()` callback (#1008)
# MeasurementKit 0.4.0-alpha [2016-12-07]
- cmdline.hpp: Use macros to simplify code (#858)
- Make `no_collector` / `no_file_report` options really usable (#860)
- Make sure filenames extension is .njson, not .json (#873)
- dns: pass logger to query() (#878)
- don't track njson files (#879)
- dns.hpp: pass a `Var` to the callback (#862)
- ssl: handle errors using callbacks not exceptions (#789)
- Start moving libevent code into a specific folder (#891)
- More abstract reactor API (#894)
- reactor: move more code from poller to here (#895)
- More reactor-related cleanups (#896)
- More maintenance of reactor and poller (#897)
- net: measure connect time during connect (#899)
- Prepare for required successful build only on travis (#902)
- ndt: multi stream test (#710)
- Implement and use `reactor->pollfd()` (#898)
- Add support for submitting reports via cloudfronted collectors (#907)
- http/request: don't redirect if `*max_request <= 0` (#910)
- Log dns debug to the correct logger (#912)
- travis: valgrind: update openssl.supp (#928)
- Move cmdline in src/measurement_kit (#930)
- collector_client.hpp: remove backward compat stuff (#931)
- version: use C linkage function (#932)
- Reactor should come before logger in function args (#933)
- ndt: exchange reactor and logger arguments (#934)
- reactor.hpp: add missing header (#936)
- Do not use `using namespace` in public headers (#937)
- Refactoring of the nettests layer (#938)
- nettests: move code from headers to .cpp files (#939)
- runner: hide implementation details (#940)
- net_test: less inline functions (#941)
- Merge net_test.hpp and ooni_test.hpp (#942)
- ooni_reporter: fix layers violation (#943)
- Divide net_test in base_test and runnable (#944)
- nettests: more refactoring (#945)
- Feature: ignore collector errors (#946)
- Move ooni_reporter in report module (#947)
- nettests: pass `Var` to callback (#948)
- nettests: run() now uses the current thread (#949)
- dns: enums that should not conflict with windows (#951)
- Resolve hosts using the system resolver (#918)
- Support IPv6 link-local resolver (#915)
- logger: add callback for JSON encoded events (#956)
- ndt: print progress of the test (#958)
- Make sure we always store and submit report-id (#950)
- ndt: allow to specify alternative mlabns tool (#959)
- Move network utils code in net directory (#960)
- Always disable the Nagle algorithm (#961)
- Set CFLAGS et al. in configure (#963)
- Improve cmake for Unix (#965)
- Implement single+multiple stream NDT test (#968)
- Update dependencies for v0.4.0 (#982)
- Implement ooni resources downloader (#811)
- Improve the CMakeLists.txt file (#983)
# MeasurementKit 0.3.9 [2016-12-04]
- Revert "Add workaround for macOS"
# MeasurementKit 0.3.8 [2016-12-04]
- Make sure --disable-traceroute actually works
- Add workaround for macOS
# MeasurementKit 0.3.7 [2016-12-02]
- Allow to quickly disable traceroute
# MeasurementKit 0.3.6 [2016-12-01]
- http/request: don't redirect if `*max_request <= 0` (#908)
- Log dns debug to the correct logger (#912) (#914)
- web-connectivity: log errors (#916)
- bufferevent: use `BEV_OPT_DEFER_CALLBACKS` (#924)
- Fix several warnings (#926)
- `ooni_reporter.cpp`: make sure we submit report id (#927)
# MeasurementKit 0.3.5 [2016-11-01]
- a few `web_connectivity` fixes (#880, #889, #890)
- fix progress in emitted progress json (#886)
# MeasurementKit 0.3.4 [2016-10-28]
- switch test collector to b.collector.test.ooni.io (#880)
- remove `./build/android/library` (#870)
- fixing `web_connectivity` bug #867
# MeasurementKit 0.3.3 [2016-10-23]
- `connect.cpp`: increase default net/timeout (#872)
- `web_connectivity`: set the accessible key (#871)
- Make `no_collector`/`no_file_report` really usable (#859)
# MeasurementKit 0.3.2 [2016-10-03]
- `ooni_test`: continue even if we cannot submit an entry
- for testing use the discarding https collector deployed on heroku
- clanups and other small changes
- update android and ios to compile using latest dependencies
# MeasurementKit 0.3.1 [2016-10-03]
- update dependencies (yes, I was optimistic yesterday)
# MeasurementKit 0.3.0 [2016-10-02]
We are now entering in stable land. There are some outstanding issues
like making sure dependencies are up to date and that documentation is
in sync with code, but we can take care of those in subsequent patch
releases, if needed. We have been testing this version of MK for quite
a while now, and it really looks like good.
Compared to previous 0.3.0-beta.3, this release includes some goodies
from master that are very inlikely to impact on stability. Namely:
- flesh out basic contribution guide (#819)
- backport simple portability changes from #820 (#821)
- report: allow to pretty print entry (#825)
- very lite refactoring of runner (#826)
# MeasurementKit 0.3.0-beta.3 [2016-09-19]
- ooni: refactor geoip to cache openned databases (#809)
- reduce tarball size by not shipping geoip
- ooni: allow caller to set probe_{ip,asn,cc} (#816)
- ooni: fix regress by changing collector-url
# MeasurementKit 0.3.0-beta.2 [2016-09-15]
- ooni: allow to disable collector
- geoip: skip compiling binaries
- ooni: count entries and emit progress
- ooni: allow to optionally avoid writing reports to disk
- http: put geoip databases in current working dir
- *: make sure all errors are named Error
# MeasurementKit 0.3.0-beta.1 [2016-09-01]
- Improve .gitignore
- Merge stable branch into release/v0.3.0 branch
- Fix build with --disable-integration-tests
# MeasurementKit 0.3.0-beta [2016-08-31]
- autogen.sh: don't list embedded-mk as dependency (#796)
- teach acinclude.m4 to use brew's OpenSSL (#797)
- sketch out cmake build system (mainly for Windows) (#798)
- implement incremental ooni collector (#765)
- run OONI tests in parallel (#768)
# MeasurementKit 0.2.9 [2016-08-31]
- Make sure install.sh is included when we build release
# MeasurementKit 0.3.0-alpha.1 [2016-08-25]
- fix type of `getopt()` return value
- fix build for Android
- improve docs
- `net_test.hpp`: add `set_error_filepath()`
- change Android output archive name to be `measurement_kit-$version-android_jni${optional_build_version}.tag.bz2`
# MeasurementKit 0.3.0-alpha [2016-08-24]
- Add command line interface and also build binary executable
- Add OONI's web connectivity test
- Improve NDT test implementation: add support for waiting in queue, convert NDT into a real OONI test, fix way in which speed is measured
- `error.hpp`: allows to add an error a list of child errors
- add `fmap.hpp`: allows to map() over a vector
- `logger.hpp`: add EOF handler and allow to write logs on logfile, allow code to specify that the log message is in JSON format
- `net_test.hpp`: pass error to begin() and end(), add `on_entry` handler, add handlers for entering into `begin` and `end` states
- add `parallel.hpp`: allows to run functions in parallel and terminates only when all parallel functions have terminated (this interface is single threaded, not multi threaded, thus parallelism is only achieved when one function pauses waiting for I/O)
- add `range.hpp`: to generate numbers in a given range (such as in Python)
- `version.hpp`: add function to get library version
- `http.hpp`: implement following redirection and case-insensitive headers search
- `report/entry.hpp` now derives from nlohmann/json using public inheritance rather than private inheritance
- Update nlohmann/json.hpp to v2.0.2
- Update `tls_verify.c` to v1.15
- mlabns: allow to specify alternative mlabns base url
- net: add workarounds for when libevent's SSL bufferevents emit EOF before emitting data received before EOF, make emitter code more robust
- ooni: it is now possible to avoid saving autonomous system number and country code, add code to lookup the real IP address of the resolver, refactor code to use GeoIP APIs
- Update external dependencies versions
- Minor changes and bug fixes
# MeasurementKit 0.2.8 [2016-08-18]
- Updated dependencies
- Many improvements and changes in cross build scripts
# MeasurementKit 0.2.7 [2016-08-02]
- By default don't use OONI collector but the testing collector to avoid
submitting integration tests results as OONI tests
- Update ChangeLog
- Bump patch version number
# MeasurementKit 0.2.6 [2016-07-31]
- Use OONI's default collector
- Update ChangeLog
- Bump patch version number
# MeasurementKit 0.2.5 [2016-07-13]
- Allow to `./configure --disable-integration-tests`
- Cherry pick 6d6f118e9 (fix TLS timeout bug)
- Bump patch version number
# MeasurementKit 0.2.4 [2016-07-10]
- Makefile.am: fix -release and -version-info flags
- bump path version number
- Add script to generate source package
- Use https collector by default
- Fix NDT example usage string
# MeasurementKit 0.2.3 [2016-07-08]
- make sure podspec uses up-to-date version number
- bump version number to v0.2.3
# MeasurementKit 0.2.2 [2016-07-08]
- document v0.2.1 release (I forgot to do that)
- properly bump version number (again, I forgot to do that)
- add script to automate release tasks
- and document v0.2.2 release
# MeasurementKit 0.2.1 [2016-07-08]
- use jessie64 rather than trusty64 in Vagrant file to make
sure we work on debian stable
- make sure autogen.sh works ok on jessie64
- fix a bug that prevented headers to be installed when $DESTDIR
wasn't specified
# MeasurementKit 0.2.0 [2016-06-30]
- autogen.sh: with -n do not use the network
- fix net/connect timeout
- update documentation for v0.2.0
- bump version to v0.2.0
# MeasurementKit 0.2.0-beta.2 [2016-06-19]
- http/request_serializer: allow custom path
- refactoring and small fixes
- common/net_test: removed misleading identifier() function
- common/utils: export time related utils functions
- ooni: merge DSL and Impl tests, use functions to implement tests (#677)
- ooni: avoid collisions in test file names
- common/net_test: file_path => filepath
# MeasurementKit 0.2.0-beta.1 [2016-06-08]
- `ip_lookup()`: allow custom settings, reactor, and logger (required
by Android app)
# MeasurementKit 0.2.0-beta [2016-06-07]
- add initial NDT client implementation
- add more continuous integration providers using docker
- add support for setting default CA bundle path
- updated http-parser to v2.7.0
- updated Catch to v1.5.0
- add precompiled dependencies for Android and iOS
- upgrade Android build scripts to NDK r11c
- switch to use libevent's upstream repository instead of our fork
- peg GeoIP to v2.7.9 rather than using the master branch
- update libressl to v2.3.6
- add more documentation for common
- start updating existing docs
- migrate the tree to use templates to mock API calls
- rationalize HTTP and mlabns APIs
- rationalize OONI tests DSL API (this would probably break apps)
- add client for OONI report protocol
- make Delegate more convenient
- make Error way more robust and convenient, e.g. allow to chain errors
- use define to increase robustness of error definitions
- allow to pass flags to logger to convey extended semantic, e.g. state update
- add more helpful MOCK macros
- unify NetTest and NetTestDsl object models (OONI not yet ready for that)
- rename Poller as Reactor (more precise name); Poller is now a React implement.
- Reactor: add `loop_with_initial_event_and_connectivity`
- rename Async as Runner (more precise name)
- make Settings more useful
- add nlohmann/json as external header
- rewrite report::Entry using nlohmann/json via private inheritance
- FIX: make sure `readn()` never consumes too much stack
- export `report` headers as public API now that it uses `report::Entry`
- make sure we don't ignore possible errors when writing report
- remove unused, incomplete Tor controller
- downgrade minimum iOS platform from 9.0 to 7.1
- use `std::promise<>` and `std::future<>` for increased robustness
- Poller: make sure we ignore `SIGPIPE`
- significantly increase code coverage (now greater than 93%)
- make sure we handle `EPIPE`
- FIX: make sure OONI code produces spec compliant reports
- refactor OoniTestImpl replacing InputGenerator with much simpler code
- add to OONI support for geolookup and for automatically submitting reports
# MeasurementKit 0.2.0-alpha [2016-05-12]
We are not ready to declare a stable release yet, because tons of things still need love. However, we've reached a point where we could tag an alpha release. Too many changes, hence listing them in the order in which I see them when reading the huge diff since the previous stable release:
- autogenerate toplevel headers
- rewrite async
- add more functional programming abstractions
- allow to bind context to errors
- rename the Maybe object as ErrorOr
- remove evbuffer wrapper
- introduce lexical_cast
- use templates rather than Libs object to make code testable
- all global objects are now `Var<>` rather than raw pointers
- more granular logger levels
- make logger thread safe
- the Poller is now known as Reactor (but Poller is still an implementation of Reactor)
- removed code to manage global dns resolver, now each test sets its own resolver
- now Settings maps strings to most scalar types
- now it is possible to cast from `Var` to `Var`
- rewritten dns code from scratch to increase memory safety
- rewritten http code from scratch to increase memory safety
- prefix settings with module name, to avoid conflicts
- implement client for mlabns
- remove TransportInterface, make Transport abstract and pass around `Var`
- rewrite from scratch the connect flow to increase memory safety
- implement SSL transport
- verify SSL certificates
- allow to connect many socket at once
- migrated OONI code to use JSON rather than YAML (thus replacing yaml-cpp dependency with nlohmann/json)
- as a consequence of previous change, remove boost from dependencies
- implement GeoIP using the old rather than the new maxmind library (not all free database available for new library)
- removed most dependency from tree and rely now on the `./build/dependency` script
- add ./autogen.sh script to automatically generate parts of the tree that it would be otherwise tedious to maintain
- rewritten from scratch and significantly improved travis.yml
- added more example files
- moved the mobile subtree below build along with the new `./build/dependency` script
- added basic listener
- more cleanups and bug fixes
To speed up cross compiling, this release would also be the first release to contain bits of compiled code (e.g. libressl) that could be downloaded during the cross compilation process.
# MeasurementKit 0.1.2 [2016-02-04]
- cleanups and bug fixes
# MeasurementKit 0.1.1 [2016-01-13]
- allow to specify report file path for OONI tests
- add missing documentation
- add Vagrantfile
- mv ooni::NetTest ooni::NetTest to avoid confusion with common::NetTest
- misc fixes
# MeasurementKit 0.1.0 [2015-12-16]
- allow to clear DNS servers on Android and iOS
- doc: add examples and tutorials
- a few more small fixes here and there
# MeasurementKit 0.1.0-beta.4 [2015-12-12]
- http: avoid throwing runtime-error
- poller: add functions to manipulate default's evdns-base
- updated changelog file
# MeasurementKit 0.1.0-beta.3 [2015-12-09]
- readd documentation of private classes
- add support for mkdocs
- bugfix: make the Connection class non-copyable and non-movable
- fixes to simplify using cross-compiled android libraries
- make OONI tests set_verbose() accept a boolean value (true by default)
- improve iOS build system
# MeasurementKit 0.1.0-beta.2 [2015-12-07]
- install missing traceroute header
- shrink android build in size and create tarballs
- rename and simplify namespaces
- rename measurement_kit to mk
- remove namespace common
- update dependencies to latest version
- simplify transport usage
- rename Transport to TransportInterface
- reintroduce Transport as a proxy for Var
- teach connect() to return Maybe
- other minor changes
# MeasurementKit 0.1.0-beta.1 [2015-12-02]
- implemented code coverage using clang
- misc build system improvements
- make sure that dependencies headers do not appear in measurement-kit public headers
- fix build process to avoid installing dependencies headers for android
- ooni.hpp: more abstract api for running ooni tests (this changed the api of the ooni sublibrary)
- net.hpp: rename Buffer::foreach() to Buffer::for_each()
- net.hpp: modify Buffer::readline() to return Maybestd::string
- net.hpp: modify signature of Transport::on_data()
- net.hpp: modify signature of net::connect()
- common.hpp: add Async::global()
- common.hpp: implement the Maybe template
- moved many headers from include to src to make sure they are not part of the public api
- fix http-parser to throw common::Error subclasses on error
- net/stream.cpp: route common::Error exceptions received when reading/writing
- improve regress tests
- add more documentation
# MeasurementKit 0.1.0-alpha.1 [2015-11-21]
* Project name changed to MeasurementKit
* Most code has been rewritten using C++11
* Cleanup the API in:
* common
* dns
* http
* net
* ooni
* report
* traceroute
* Implemented OONI tests:
* dns injection
* http invalid request line
* tcp connect
* Many more changes with respect to LibNeubot (compared to that
project, MeasurementKit is basically another project)
# LibNeubot 3.0.0 [2014-05-04]
* Rewrite NeubotPollable now that I know that, in C++, a structure can
inherit from a class. As a result, the FooState structure is now gone
and the API now looks like v1.0 again. That is, again the poller is
passed to the Pollable constructor, not to init().
* Related to the previous change: clarified that the Pollable main
purpose is to allow experiments in which Neubot uses LibNeubot.
* Related to the previous change: crank major (we're now at API 3.0).
* Take advantage of the API 3.0 cranking and install the headers
at a different location ( becomes ).
* Add (but do not use yet) joyent/http-parser as submodule.
* Update the OpenBSD port and fix the code accordingly (mainly cases
in which mixed libevent 1.4 and 2.0 headers were being used).
* Related to the previous change: update README to better clarify
which are the dependencies.
* Deprecate gen_cxx and neubot.hh, now that it's clear that the code
will be written in C++ to ease the interaction with SWIG.
* Move testing code in `test/`.
* Significant improvements in gen_python, which now enforces the
type safety (i.e., you can only pass to Pollable_foo() an instance
of the Python Pollable class), and in general produces much
less bloated and more pythonic Python code.
* Related to the previous change: half of the unit test is now gone
because it was not typesafe (we passed integers to functions in
hope that they were pointer to the right C/C++ objects).
* More minor changes, fixes and tweaks.
# LibNeubot 2.0.0 [2014-04-11]
* Add Android.mk to compile a static library for Android
* Remove the unused LibNeubot.java/gen_java thing
* Reimplement NeubotPollable using C++ and write C wrappers to
provide a similar API (however, the arguments of the constructor
and of attach() were changed, hence the API bump)
* Move Java code that was autogenerated with SWIG into the
neubot/neubot_android repository
* Make sure gen_cxx generates code that works on Android: correct
the order of the generated classes, replace the nonworking cast with
the invocation of the ->pointer() method
* Unify gen_py/gen_python and libneubot.py/libneubot1.py: now
gen_python generates a libneubot.py file that contains the old
stuff plus the stuff that was in libneubot1.py, moreover, the
gen_py script and libneubot1.py were removed
* Regen libneubot_python
* Make sure shared C functions (e.g., log.h and utils.h) are
correctly exported to C++
* While bumping the API, unbreak the resolve() API
* While touching the Pollable, reimplement timeouts using
the support provided by libevent
* Realize that the destruction of objects must flow from the
derived classes to the base classes (as C++ does) not the
other way round (as PyNeubot does)
* Add some defines needed to compile on Android
* Export the logs to the logcat to ease the debugging
# LibNeubot 1.0.1 [2014-02-18]
* Tweak gen_cxx to generate code that SWIG can handle
* Use SWIG to generate Java and Python wrappers
# LibNeubot 1.0.0 [2013-12-15]
* Return status_t in NeubotPoller_defer_{read,write}
* Pass opaque, not pollable, to NeubotPollable callbacks
* libneubot.json: Add and use hooks, slots and __destructor__
* Add easier-to-use libneubot1.py wrappers
* Add neubot.hh, wrappers for C++
# LibNeubot 0.1.0 [2013-12-12]
* Initial release
measurement-kit-0.7.1/LICENSE 0000664 0000000 0000000 00000002661 13153561626 0015653 0 ustar 00root root 0000000 0000000 BSD 2-Clause License
Copyright (c) 2013-2017, Simone Basso, Arturo Filastò,
Nexa Center for Internet & Society - Politecnico di Torino (DAUIN),
and the measurement-kit contributors.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
measurement-kit-0.7.1/Makefile.am 0000664 0000000 0000000 00000004313 13153561626 0016676 0 ustar 00root root 0000000 0000000 # Part of measurement-kit .
# Measurement-kit is free software. See AUTHORS and LICENSE for more
# information on the copying conditions.
AUTOMAKE_OPTIONS = foreign 1.9 subdir-objects
ACLOCAL_AMFLAGS = -I m4
VERSION_INFO = -release @VERSION@ -version-info 0
lib_LTLIBRARIES = libmeasurement_kit.la
libmeasurement_kit_la_LDFLAGS = $(VERSION_INFO)
libmeasurement_kit_la_SOURCES = # Empty
measurement_kit_SOURCES = # Empty
if BUILD_BINARIES
bin_PROGRAMS = measurement_kit
measurement_kit_LDADD = libmeasurement_kit.la
endif
noinst_PROGRAMS = # Empty
ALL_TESTS = # Empty
include include.am
# We link with libresolv to have an oracle for our base64 implementation
test_common_encoding_LDADD += -lresolv
TESTS = $(ALL_TESTS)
check_PROGRAMS = $(ALL_TESTS)
#
# Running tests through Valgrind by abusing of the LOG_COMPILER feature
# which is enabled by automake < 1.14 only when parallel tests are forced,
# so you now see why they are enabled explicitly in configure.ac
#
# See http://ansuz.sooke.bc.ca/entry/233
#
# (Yes, of course this means valgrind runs in parallel -- i.e. faster.)
#
# On travis-ci we need on specific suppression for a memory warning that I
# honestly don't understand but that doesn't appear when building using docker
# on circle-ci and gitlab (BTW docker on travis using valgrind was odd since
# there were tons of errors unlike seen on every other docker and so I decided
# it was wiser avoding docker on travis). On other platforms (including my
# own docker on VoidLinux) no suppression file is needed.
#
# See https://travis-ci.org/measurement-kit/measurement-kit/jobs/172742411#L2131
#
VALGRIND = $(LIBTOOL) --mode=execute valgrind --trace-children=yes \
--error-exitcode=1 --dsymutil=yes --leak-check=yes --gen-suppressions=all
VALGRIND_TRAVIS = $(VALGRIND) --suppressions=build/valgrind/openssl.supp
VALGRIND_DOCKER = $(VALGRIND) --suppressions=build/valgrind/strlen.supp
check-am-valgrind:
$(MAKE) $(AM_MAKEFLAGS) check-am LOG_COMPILER='$(VALGRIND_TRAVIS)'
run-valgrind-docker:
$(MAKE) $(AM_MAKEFLAGS) check-am LOG_COMPILER='$(VALGRIND_DOCKER)'
run-valgrind:
$(MAKE) $(AM_MAKEFLAGS) check-am LOG_COMPILER='$(VALGRIND)'
measurement-kit-0.7.1/NOTICE 0000664 0000000 0000000 00000011453 13153561626 0015551 0 ustar 00root root 0000000 0000000 The following copyright statement applies to the scripts in build/ios,
which are a derivative work of ursachec/CPAProxy.
Portions Copyright (c) 2013, Claudiu-Vlad Ursache
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Portions Copyright (c) 2010, Pierre-Olivier Latour
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* The name of Pierre-Olivier Latour may not be used to endorse or
promote products derived from this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- - -
The following copyright statement applies to portions of acinclude.m4 that
search for a default CA bundle; they derive from curl code.
Portions Copyright (c) 1996 - 2016, Daniel Stenberg, daniel@haxx.se, and many
contributors, see the THANKS file.
All rights reserved.
Permission to use, copy, modify, and distribute this software for any purpose
with or without fee is hereby granted, provided that the above copyright notice
and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of a copyright holder shall not be
used in advertising or otherwise to promote the sale, use or other dealings in
this Software without prior written authorization of the copyright holder.
- - -
The following statement applies to src/libmeasurement_kit/ext/sole.{c,h}pp
which is a derivative work of .
Portions Copyright (c) 2015 r-lyeh (https://github.com/r-lyeh)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
measurement-kit-0.7.1/README.md 0000664 0000000 0000000 00000020231 13153561626 0016116 0 ustar 00root root 0000000 0000000 # MeasurementKit
> Portable C++14 network measurement library
[](https://bintray.com/measurement-kit/android/android-libs/_latestVersion) [](https://raw.githubusercontent.com/measurement-kit/measurement-kit/master/LICENSE) [](https://github.com/measurement-kit/measurement-kit/releases) [](https://github.com/measurement-kit/measurement-kit/issues)
- - -
| branch | travis-ci | coveralls | gitlab-ci | circle-ci|
|--------|-----------|-----------|-----------|----------|
| master | [](https://travis-ci.org/measurement-kit/measurement-kit) | [](https://coveralls.io/github/measurement-kit/measurement-kit?branch=master) | [](https://gitlab.com/measurement-kit/measurement-kit/commits/master) | [](https://circleci.com/gh/measurement-kit/measurement-kit) |
| stable | [](https://travis-ci.org/measurement-kit/measurement-kit?branch=stable) | [](https://coveralls.io/github/measurement-kit/measurement-kit?branch=stable) | [](https://gitlab.com/measurement-kit/measurement-kit/commits/stable) | [](https://circleci.com/gh/measurement-kit/measurement-kit/tree/stable) |
MeasurementKit is a library that implements open network measurement methodologies
(performance, censorship, etc.) and targets mobile platforms (Android and iOS).
It is meant to be embedded by third party applications with specific network measurement
needs and/or to be used by researchers as a basis to implement novel tools.
Currently it implements the following high-level tests:
- [OONI](https://ooni.torproject.org/)'s [Web Connectivity](https://github.com/TheTorProject/ooni-spec/blob/master/test-specs/ts-017-web-connectivity.md) test
- the [network diagnostic tool](https://github.com/ndt-project/ndt/wiki/NDTTestMethodology) network performance test
- [OONI](https://ooni.torproject.org/)'s [DNS Injection](https://github.com/TheTorProject/ooni-spec/blob/master/test-specs/ts-012-dns-injection.md) test
- [OONI](https://ooni.torproject.org/)'s [HTTP Invalid Request Line](https://github.com/TheTorProject/ooni-spec/blob/master/test-specs/ts-007-http-invalid-request-line.md) test
- [OONI](https://ooni.torproject.org/)'s [TCP Connect](https://github.com/TheTorProject/ooni-spec/blob/master/test-specs/ts-008-tcpconnect.md) test
- [OONI](https://ooni.torproject.org/)'s [Meek Fronted Requests](https://github.com/TheTorProject/ooni-spec/blob/master/test-specs/ts-014-meek-fronted-requests.md) test
- [OONI](https://ooni.torproject.org/)'s [HTTP Header Field Manipulation](https://github.com/TheTorProject/ooni-spec/blob/master/test-specs/ts-006-header-field-manipulation.md) test
- Neubot's [MPEG DASH test](https://github.com/neubot/neubot/tree/master/mod_dash)
It contains building-block functionalities useful to implement your own
tests. More in detail it currently implements:
- [TCP connection](https://github.com/measurement-kit/measurement-kit/blob/master/include/measurement_kit/net/transport.hpp) (with which you can create a TCP connection towards and
endpoint, receive and send data)
- [DNS client](https://github.com/measurement-kit/measurement-kit/blob/master/include/measurement_kit/dns/dns.hpp) (with which you can resolve and reverse-resolve A and AAAA
records using arbitrary name servers)
- [HTTP client](https://github.com/measurement-kit/measurement-kit/blob/master/include/measurement_kit/http/http.hpp) (with which you can send HTTP/1.1 requests and receive
and parse the corresponding responses)
- [traceroute for Android](https://github.com/measurement-kit/measurement-kit/blob/master/include/measurement_kit/traceroute/android.hpp) (with which you can send individual traceroute
probes with a specified payload and TTL)
- [mlab-ns client](https://github.com/measurement-kit/measurement-kit/blob/master/include/measurement_kit/mlabns/mlabns.hpp) (with which you can interact with Measurement Lab backend to know the server with which to run tests)
- the functionality to communicate with the [OONI collector](https://github.com/TheTorProject/ooni-backend)
- the functionality to communicate with the [OONI bouncer](https://github.com/TheTorProject/ooni-backend)
In the short term we plan to add to MeasurementKit:
- more OONI tests
Other functionalities that we would like to add are building-blocks functionalities
such as [uTP](https://github.com/bittorrent/libutp), and traceroute for iOS.
The following index illustrates the content of the remainder of this file:
- [How to clone the repository](#how-to-clone-the-repository)
- [How to test a specific branch](#how-to-test-a-specific-branch)
- [How to build MeasurementKit](#how-to-build-measurementkit)
- [How to build MeasurementKit on a Unix-like system](#how-to-build-measurementkit-on-a-unix-like-system)
- [How to test MeasurementKit on a Unix-like system](#how-to-test-measurementkit-on-a-unix-like-system)
- [How to build MeasurementKit on Android](#how-to-build-measurementkit-on-android)
- [How to build MeasurementKit on iOS](#how-to-build-measurementkit-on-ios)
- [How to add MeasurementKit to an Xcode project](#how-to-add-measurementkit-to-an-xcode-project)
- [How to use MeasurementKit](#how-to-use-measurementkit)
## How to clone the repository
To clone MeasurementKit repository, do:
git clone https://github.com/measurement-kit/measurement-kit
## How to test a specific branch
If you need to checkout a specific branch (say `feature/foo`) for testing
it, clone the repository and then type:
```
git fetch origin
git checkout feature/foo
```
Then proceed with the instruction to build and test MeasurementKit.
For more detailed instructions see [contributing instructions](
CONTRIBUTING.md).
## How to build MeasurementKit
### How to build MeasurementKit on a Unix-like system
Very briefly, to build from the git repository do:
```
./autogen.sh
./configure
make
```
See [the Unix tutorial](doc/tutorial/unix.md) for more details.
### How to test MeasurementKit on a Unix-like system
Once you have built MeasurementKit, run tests like:
```
make check
```
### How to build MeasurementKit on Android
We have [a specific repository](https://github.com/measurement-kit/android-libs)
for compiling MeasurementKit for Android. You may also want to read the
[documentation explaining how to cross compile MK dependencies for Android](
doc/build/android.md).
### How to build MeasurementKit on iOS
Having Xcode command line tools installed, run:
```
./build/ios/library
```
See the [iOS tutorial](doc/tutorial/ios.md) for more info.
### How to add MeasurementKit to an Xcode project.
Make sure your [Podfile](https://guides.cocoapods.org/syntax/podfile.html)
looks like this:
```ruby
target 'YourTargetNameHere' do
pod 'measurement_kit',
:git => 'https://github.com/measurement-kit/measurement-kit.git',
:branch => 'stable'
end
```
Run `pod install` (or `pod update`) and remember to open the
`.xcworkspace` rather than the `.xcodeproj`. See the [iOS tutorial](
doc/tutorial/ios.md) for more info.
## How to use MeasurementKit
You probably want to start using the [nettests API](doc/api/nettests.md)
that is the high level API for running tests. To this end, see also
the [nettests API examples](example/nettests) and the [Unix
tutorial](doc/tutorial/unix.md).
measurement-kit-0.7.1/TODO.md 0000664 0000000 0000000 00000001012 13153561626 0015722 0 ustar 00root root 0000000 0000000 TODO
====
These tests still need to be implemented:
* [DNS Consistency](https://gitweb.torproject.org/ooni/spec.git/blob/HEAD:/test-specs/ts-002-dnsconsistency.md)
* [HTTP Requests](https://gitweb.torproject.org/ooni/spec.git/blob/HEAD:/test-specs/ts-003-http-requests.md)
* [Header Field Manipulation](https://gitweb.torproject.org/ooni/spec.git/blob/HEAD:/test-specs/ts-006-header-field-manipulation.md)
* [Captive portal](https://gitweb.torproject.org/ooni/spec.git/blob/HEAD:/test-specs/ts-010-captive-portal.md)
measurement-kit-0.7.1/Vagrantfile 0000664 0000000 0000000 00000000354 13153561626 0017030 0 ustar 00root root 0000000 0000000 Vagrant.configure(2) do |config|
config.vm.synced_folder ".", "/mk"
config.vm.define "yakkety" do |yakkety|
yakkety.vm.box = "ubuntu/yakkety64"
yakkety.vm.provider "virtualbox" do |v|
v.memory = 2048
end
end
end
measurement-kit-0.7.1/acinclude.m4 0000664 0000000 0000000 00000022754 13153561626 0017044 0 ustar 00root root 0000000 0000000 dnl Part of measurement-kit .
dnl Measurement-kit is free software. See AUTHORS and LICENSE for more
dnl information on the copying conditions.
AC_DEFUN([MK_AM_ENABLE_COVERAGE], [
AC_ARG_ENABLE([coverage],
AS_HELP_STRING([--enable-coverage, build for coverage]),
[enable_coverage=yes], [])
])
AC_DEFUN([MK_AM_ADD_COVERAGE_FLAGS_IF_NEEDED], [
if test "$enable_coverage" = "yes"; then
CFLAGS="$CFLAGS --coverage -g -O0"
CXXFLAGS="$CXXFLAGS --coverage -g -O0"
LDFLAGS="$LDFLAGS --coverage"
fi
])
AC_DEFUN([MK_AM_DISABLE_EXAMPLES], [
AC_ARG_ENABLE([examples],
AS_HELP_STRING([--disable-examples, skip building of examples programs]),
[], [enable_examples=yes])
AM_CONDITIONAL([BUILD_EXAMPLES], [test "$enable_examples" = "yes"])
])
AC_DEFUN([MK_AM_DISABLE_BINARIES], [
AC_ARG_ENABLE([binaries],
AS_HELP_STRING([--disable-binaries, skip building of binary programs]),
[], [enable_binaries=yes])
AM_CONDITIONAL([BUILD_BINARIES], [test "$enable_binaries" = "yes"])
])
AC_DEFUN([MK_AM_DISABLE_INTEGRATION_TESTS], [
AC_ARG_ENABLE([integration-tests],
AS_HELP_STRING([--disable-integration-tests, skip building of integration tests]),
[], [CPPFLAGS="$CPPFLAGS -DENABLE_INTEGRATION_TESTS"])
])
AC_DEFUN([MK_AM_DISABLE_TRACEROUTE], [
AC_ARG_ENABLE([traceroute],
AS_HELP_STRING([--disable-traceroute, do not build traceroute]),
[], [CPPFLAGS="$CPPFLAGS -DENABLE_TRACEROUTE"])
])
AC_DEFUN([MK_AM_CHECK_LIBC_FUNCS], [
AC_CHECK_FUNCS([ \
err \
errx \
warn \
warnx \
getopt \
getopt_long \
getopt_long_only \
gmtime_r \
strcasecmp \
strtonum \
])
])
AC_DEFUN([MK_AM_LIBEVENT], [
AC_ARG_WITH([libevent],
[AS_HELP_STRING([--with-libevent],
[event I/O library @<:@default=check@:>@])
],
[
CPPFLAGS="$CPPFLAGS -I$withval/include"
LDFLAGS="$LDFLAGS -L$withval/lib"
],
[])
mk_not_found=""
AC_CHECK_HEADERS(event2/event.h, [], [mk_not_found=1])
AC_CHECK_LIB(event, event_new, [], [mk_not_found=1])
AC_CHECK_HEADERS(event2/thread.h, [], [mk_not_found=1])
AC_CHECK_LIB(event_pthreads, evthread_use_pthreads, [], [mk_not_found=1])
AC_CHECK_LIB(event_openssl, bufferevent_openssl_filter_new, [],
[mk_not_found=1])
AC_CHECK_FUNCS([bufferevent_openssl_set_allow_dirty_shutdown])
if test "$mk_not_found" = "1"; then
AC_MSG_WARN([Failed to find dependency: libevent])
echo " - to install on Debian: sudo apt-get install libevent-dev"
echo " - to install on OSX: brew install libevent"
echo " - to compile from sources: ./build/dependency libevent"
AC_MSG_ERROR([Please, install libevent and run configure again])
fi
])
AC_DEFUN([MK_AM_GEOIP], [
AC_ARG_WITH([geoip],
[AS_HELP_STRING([--with-geoip],
[GeoIP library @<:@default=check@:>@])
],
[
CPPFLAGS="$CPPFLAGS -I$withval/include"
LDFLAGS="$LDFLAGS -L$withval/lib"
],
[])
mk_not_found=""
AC_CHECK_HEADERS(GeoIP.h, [], [mk_not_found=1])
AC_CHECK_LIB(GeoIP, GeoIP_open, [], [mk_not_found=1])
if test "$mk_not_found" = "1"; then
AC_MSG_WARN([Failed to find dependency: geoip])
echo " - to install on Debian: sudo apt-get install libgeoip-dev"
echo " - to install on OSX: brew install libgeoip"
echo " - to compile from sources: ./build/dependency geoip"
AC_MSG_ERROR([Please, install geoip and run configure again])
fi
])
AC_DEFUN([MK_AM_OPENSSL], [
AC_ARG_WITH([openssl],
[AS_HELP_STRING([--with-openssl],
[SSL toolkit @<:@default=check@:>@])
],
[
CPPFLAGS="$CPPFLAGS -I$withval/include"
LDFLAGS="$LDFLAGS -L$withval/lib"
],
[
if test -d /usr/local/Cellar/openssl; then
AC_MSG_WARN([Using the OpenSSL installed via brew...])
mk_openssl_v=`ls /usr/local/Cellar/openssl|tail -n1`
mk_openssl_d="/usr/local/Cellar/openssl/$mk_openssl_v"
CPPFLAGS="$CPPFLAGS -I$mk_openssl_d/include"
LDFLAGS="$LDFLAGS -L$mk_openssl_d/lib"
fi
])
mk_not_found=""
AC_CHECK_HEADERS(openssl/ssl.h, [], [mk_not_found=1])
AC_CHECK_LIB(crypto, RSA_new, [], [mk_not_found=1])
AC_CHECK_LIB(ssl, SSL_new, [], [mk_not_found=1])
dnl This test breaks the build with 12.04 on travis because the linker there
dnl requires `LD_RUN_PATH` which sadly is not honoured by this test, still
dnl no worries because actually this check only makes sense for Mac systems
if test "`uname`" = "Darwin"; then
AC_MSG_CHECKING([whether OpenSSL is older than 1.0.0])
AC_RUN_IFELSE([
AC_LANG_SOURCE([
#include
#include
/* Code taken from tor/src/common/crypto.h */
#define OPENSSL_VER(a,b,c,d,e) \
(((a)<<28) | \
((b)<<20) | \
((c)<<12) | \
((d)<< 4) | \
(e))
#define OPENSSL_V_SERIES(a,b,c) OPENSSL_VER((a),(b),(c),0,0)
/* Code taken from tor/src/common/compat_openssl.h */
#if OPENSSL_VERSION_NUMBER < OPENSSL_V_SERIES(1,0,0)
# error "We require OpenSSL >= 1.0.0"
#endif
#if OPENSSL_VERSION_NUMBER >= OPENSSL_V_SERIES(1,1,0) && \
! defined(LIBRESSL_VERSION_NUMBER)
/* We define this macro if we're trying to build with the majorly refactored
* API in OpenSSL 1.1 */
#define OPENSSL_1_1_API
#endif
#ifndef OPENSSL_1_1_API
#define OpenSSL_version_num() SSLeay()
#endif
int main() {
if (OpenSSL_version_num() != OPENSSL_VERSION_NUMBER) {
return 1;
}
if (OpenSSL_version_num() < OPENSSL_V_SERIES(1, 0, 0)) {
return 2;
}
return 0;
}
])
],
[AC_MSG_RESULT([yes])],
[
AC_MSG_RESULT([no])
if test -d /usr/local/Cellar/openssl; then
AC_MSG_WARN([MacOS ships an old system-wide OpenSSL but you seem to])
AC_MSG_WARN([have a new version installed with brew.])
AC_MSG_WARN([So, you should try adding this flag to configure:])
AC_MSG_WARN(['--with-openssl=/usr/local/Cellar/openssl/VERSION/'])
fi
mk_not_found=1
],
[AC_MSG_RESULT([Skip the test because we are cross-compiling])])
fi
if test "$mk_not_found" = "1"; then
AC_MSG_WARN([Failed to find dependency: openssl])
echo " - to install on Debian: sudo apt-get install libssl-dev"
echo " - to install on OSX: brew install openssl"
echo " - to compile from sources: ./build/dependency libressl"
AC_MSG_ERROR([Please, install openssl and run configure again])
fi
])
AC_DEFUN([MK_AM_REQUIRE_C99], [
AC_PROG_CC_C99
if test x"$ac_cv_prog_cc_c99" = xno; then
AC_MSG_ERROR([a C99 compiler is required])
fi
])
AC_DEFUN([MK_AM_REQUIRE_CXX14], [
mk_saved_cxxflags="$CXXFLAGS"
CXXFLAGS=-std=c++14
AC_MSG_CHECKING([whether CXX supports -std=c++14])
AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
[AC_MSG_RESULT([yes])]
[],
[
AC_MSG_RESULT([no])
AC_MSG_ERROR([a C++14 compiler is required])
])
CXXFLAGS="$mk_saved_cxxflags -std=c++14"
AC_LANG_POP([C++])
])
AC_DEFUN([MK_CHECK_CA_BUNDLE], [
AC_MSG_CHECKING([CA bundle path])
AC_ARG_WITH([ca-bundle],
AC_HELP_STRING([--with-ca-bundle=FILE],
[Path to a file containing CA certificates (example: /etc/ca-bundle.crt)]),
[
want_ca="$withval"
],
[want_ca="unset"])
if test "x$want_ca" != "xunset"; then
ca="$want_ca"
else
ca="no"
if test "x$cross_compiling" != "xyes"; then
for a in /etc/ssl/certs/ca-certificates.crt \
/etc/pki/tls/certs/ca-bundle.crt \
/usr/share/ssl/certs/ca-bundle.crt \
/usr/local/share/certs/ca-root.crt \
/etc/ssl/cert.pem \
/usr/local/etc/openssl/cert.pem; do
if test -f "$a"; then
ca="$a"
break
fi
done
fi
fi
if test "x$ca" != "xno"; then
MK_CA_BUNDLE="$ca"
AC_DEFINE_UNQUOTED(MK_CA_BUNDLE, "$ca", [Location of default ca bundle])
AC_SUBST(MK_CA_BUNDLE)
AC_MSG_RESULT([$ca])
elif test "x$cross_compiling" == "xyes"; then
AC_MSG_RESULT([skipped (cross compiling)])
AC_MSG_WARN([skipped the ca-bundle detection when cross-compiling])
AC_DEFINE_UNQUOTED(MK_CA_BUNDLE, "", [Location of default ca bundle])
AC_SUBST(MK_CA_BUNDLE)
else
AC_MSG_RESULT([no])
AC_MSG_ERROR([you should give a ca-bundle location])
fi
])
AC_DEFUN([MK_AM_CXXFLAGS_ADD_WARNINGS], [
AC_MSG_CHECKING([whether compiler is clang to add clang specific warnings])
if test echo | $CXX -dM -E - | grep __clang__ > /dev/null; then
AC_MSG_RESULT([yes])
CXXFLAGS="$CXXFLAGS -Wmissing-prototypes"
else
AC_MSG_RESULT([yes])
fi
])
AC_DEFUN([MK_AM_PRINT_SUMMARY], [
echo "==== configured variables ==="
echo "CPP : $CPP"
echo "CC : $CC"
echo "CXX : $CXX"
echo "CFLAGS : $CFLAGS"
echo "CPPFLAGS : $CPPFLAGS"
echo "CXXFLAGS : $CXXFLAGS"
echo "LDFLAGS : $LDFLAGS"
echo "LIBS : $LIBS"
])
measurement-kit-0.7.1/autogen.sh 0000775 0000000 0000000 00000011470 13153561626 0016645 0 ustar 00root root 0000000 0000000 #!/bin/sh
set -e
export LC_ALL=C # Stable sorting regardless of the locale
. build/autogen.d/geoip
no_geoip=0
cmake=0
while [ $# -gt 0 ]; do
opt=$1; shift
if [ "$opt" = "--no-geoip" -o "$opt" = "-n" ]; then
no_geoip=1
elif [ "$opt" = "--cmake" ]; then
cmake=1
else
echo "usage: $0 [--cmake] [-n|--no-geoip]" 1>&2
exit 1
fi
done
slug() {
echo $(echo $1|tr '/-' '_'|sed 's/^include_measurement_kit/mk/g')
}
gen_automatic_includes() {
hh=include/measurement_kit/common/git_version.hpp
echo "// File autogenerated by \`$0\`, do not edit" > $hh
echo "#ifndef MEASUREMENT_KIT_COMMON_GIT_VERSION_HPP" >> $hh
echo "#define MEASUREMENT_KIT_COMMON_GIT_VERSION_HPP" >> $hh
echo "" >> $hh
echo "#define MK_VERSION_FULL \"`git describe --tags`\"" >> $hh
echo "" >> $hh
echo "#endif" >> $hh
rm -f include/measurement_kit/*.hpp
for name in $(ls include/measurement_kit/|grep -v portable); do
hh=include/measurement_kit/$name.hpp
echo "// File autogenerated by \`$0\`, do not edit" > $hh
echo "#ifndef MEASUREMENT_KIT_$(echo $name|tr 'a-z' 'A-Z')_HPP" >> $hh
echo "#define MEASUREMENT_KIT_$(echo $name|tr 'a-z' 'A-Z')_HPP" >> $hh
for nn in $(ls include/measurement_kit/$name/); do
echo "#include " >> $hh
done
echo "#endif" >> $hh
done
}
gen_headers() {
echo "$(slug $1)_includedir = \${prefix}/$1"
echo "$(slug $1)_include_HEADERS = # Empty"
for name in `ls $1`; do
if [ ! -d $1/$name ]; then
echo "$(slug $1)_include_HEADERS += $1/$name"
fi
done
echo ""
for name in `ls $1`; do
if [ -d $1/$name ]; then
gen_headers $1/$name
fi
done
}
gen_sources() {
for name in `ls $2`; do
if [ ! -d $2/$name ]; then
if echo $name | grep -q '\.c[p]*$'; then
echo "$1 += $2/$name"
fi
fi
done
for name in `ls $2`; do
if [ -d $2/$name ]; then
gen_sources $1 $2/$name
fi
done
}
gen_executables() {
for name in `ls $2`; do
if [ ! -d $2/$name ]; then
if echo $name | grep -q '\.c[p]*$'; then
bin_name=$(echo $name | sed 's/\.c[p]*$//g')
echo ""
echo "if $3"
echo " $1 += $2/$bin_name"
echo "endif"
echo "/$2/$bin_name" >> .gitignore
echo "$(slug $2/$bin_name)_SOURCES = $2/$name"
echo "$(slug $2/$bin_name)_LDADD = libmeasurement_kit.la"
fi
fi
done
for name in `ls $2`; do
if [ -d $2/$name ]; then
gen_executables $1 $2/$name $3
fi
done
}
grep -v -E "^/(test|example){1}/.*" .gitignore > .gitignore.new
echo /GeoIP.dat >> .gitignore.new
echo /GeoIPASNum.dat >> .gitignore.new
echo /GeoLiteCity.dat >> .gitignore.new
mv .gitignore.new .gitignore
echo "* Generating automatic includes: include/measurement_kit/*.hpp"
gen_automatic_includes include/measurement_kit
echo "* Generating include.am"
echo "# Autogenerated by $0 on date $(date)" > include.am
echo "" >> include.am
gen_sources libmeasurement_kit_la_SOURCES src/libmeasurement_kit >> include.am
gen_sources measurement_kit_SOURCES src/measurement_kit >> include.am
echo "" >> include.am
gen_headers include/measurement_kit >> include.am
gen_executables noinst_PROGRAMS example BUILD_EXAMPLES >> include.am
gen_executables ALL_TESTS test BUILD_TESTS >> include.am
echo "* Updating .gitignore"
sort -u .gitignore > .gitignore.new
mv .gitignore.new .gitignore
if [ $no_geoip -ne 1 ]; then
autogen_get_geoip
fi
if [ $cmake -eq 0 ]; then
echo "* Running 'autoreconf -i'"
autoreconf -i
fi
echo ""
echo "=== autogen.sh complete ==="
echo ""
echo "MeasurementKit is now ready to be compiled. To proceed you shall run"
echo "now the './configure' script that adapts the build to your system."
echo ""
echo "The './configure' script shall also check for external dependencies. "
echo "MeasurementKit external dependencies are:"
echo ""
echo " - GeoIP"
echo " - openssl / libressl"
echo " - libevent"
echo ""
echo "If any of these dependencies is missing, the './configure' script shall"
echo "stop and tell you how you could install it."
measurement-kit-0.7.1/build/ 0000775 0000000 0000000 00000000000 13153561626 0015740 5 ustar 00root root 0000000 0000000 measurement-kit-0.7.1/build/android/ 0000775 0000000 0000000 00000000000 13153561626 0017360 5 ustar 00root root 0000000 0000000 measurement-kit-0.7.1/build/android/.gitignore 0000664 0000000 0000000 00000000020 13153561626 0021340 0 ustar 00root root 0000000 0000000 *.tgz
*.tgz.asc
measurement-kit-0.7.1/build/android/archive-deps 0000775 0000000 0000000 00000001132 13153561626 0021655 0 ustar 00root root 0000000 0000000 #!/bin/sh
set -e
ROOTDIR=$(cd $(dirname $0)/../.. && pwd -P)
cd $ROOTDIR/build/android
# Do not ship *.la files that would break the build and, while there, also
# remove directories that we don't need for cross compiling MK
find jni -type f -name \*.la -exec rm {} \;
find jni -type f -name \*.pc -exec rm {} \;
find jni -type d -depth -name share -exec rm -rf {} \;
find jni -type d -depth -name bin -exec rm -rf {} \;
find jni -type d -depth -name pkgconfig -exec rm -rf {} \;
now=`date +%Y%m%dT%H%M%SZ`
tar -czf android-dependencies-$now.tgz jni
$ROOTDIR/build/sign android-dependencies-$now.tgz
measurement-kit-0.7.1/build/android/cross 0000775 0000000 0000000 00000010644 13153561626 0020444 0 ustar 00root root 0000000 0000000 #!/bin/sh
set -e
ROOTDIR=$(cd $(dirname $0) && pwd -P)
if [ $# -lt 1 ]; then
echo "Usage: $0 ARCH" 1>&2
echo "" 1>&2
echo " ARCH: armeabi, armeabi-v7a, arm64, mips, mips64, x86, x86_64" 1>&2
echo "" 1>&2
echo "Example usage:" 1>&2
echo " $0 arm64" 1>&2
exit 1
fi
ARCH=$1
shift
echo ""
echo "Cross compiling for $ARCH"
# Place where make-toolchain creates a standalone toolchain
export ANDROID_TOOLCHAIN=${ROOTDIR}/toolchain/${ARCH}
# Directory under the toolchain where we have headers and libs
export SYSROOT=${ANDROID_TOOLCHAIN}/sysroot
#
# Map the selected architecture to useful variables:
#
# TOOLCHAIN_NAME: name of the toolchain to use.
# DESTDIR_NAME: name of the directory where to install headers and libs.
# CFLAGS: flags to be passed to C compiler.
# CXXFLAGS: flags to be passed to C++ compiler.
# LIB_SUFFIX: unset unless toolchain has lib64 libs directory.
# CONFIG_EXTRA: optional extra flags to be passed to configure script.
#
if [ "$ARCH" = "arm64" ]; then
# Note: arm64 is also known as aarch64 and as armv8
TOOLCHAIN_NAME=aarch64-linux-android
DESTDIR_NAME=arm64-v8a
elif [ "$ARCH" = "armeabi" ]; then
TOOLCHAIN_NAME=arm-linux-androideabi
DESTDIR_NAME=$ARCH
#
# These flags have been copied from the flags used by
# ndk-build when building measurement-kit as a C++ library>.
#
# According to Wikipedia [1], armv5te means v5 of the architecture,
# with thumbs and DSP extensions. Xscale is a processor built by third
# parties compatible with armv5te that doesn't have floating point,
# hence the -msoft-float flag. The -mthumb instructions forces emitting
# instructions using the thumb instruction set where common instructions
# are encoded using 16 bits rather than 32 bits.
#
# [1] https://en.wikipedia.org/wiki/ARM_architecture#Cores
#
# Note: `-Os` was originally part of the flags but this led to
# non working libevent binaries as documented in #1051. Also
# `-fno-integrated-as` is needed to avoid another segfault.
#
CFLAGS="-target armv5te-none-linux-androideabi -march=armv5te -mtune=xscale -msoft-float -mthumb -fno-integrated-as"
CXXFLAGS=$CFLAGS
elif [ "$ARCH" = "armeabi-v7a" ]; then
TOOLCHAIN_NAME=arm-linux-androideabi
DESTDIR_NAME=$ARCH
#
# See above.>
#
CFLAGS="-target armv7-none-linux-androideabi -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb"
CXXFLAGS="$CFLAGS"
elif [ "$ARCH" = "mips" ]; then
# Note: mips is actually mipsel (i.e. little endian)
TOOLCHAIN_NAME=mipsel-linux-android
DESTDIR_NAME=mips
elif [ "$ARCH" = "mips64" ]; then
# Note: this is mips 64bit little endian
TOOLCHAIN_NAME=mips64el-linux-android
DESTDIR_NAME=mips64
LIB_SUFFIX=64
CONFIG_EXTRA="--disable-asm" # See issue 653
elif [ "$ARCH" = "x86" ]; then
TOOLCHAIN_NAME=i686-linux-android
DESTDIR_NAME=x86
elif [ "$ARCH" = "x86_64" ]; then
TOOLCHAIN_NAME=x86_64-linux-android
DESTDIR_NAME=x86_64
LIB_SUFFIX=64
else
echo "$0: invalid $ARCH" 1>&2
exit 1
fi
# Override makefile's defaults with toolchain's tools. We use clang.
TOOL_PREFIX=${ANDROID_TOOLCHAIN}/bin/${TOOLCHAIN_NAME}
export CPP=${TOOL_PREFIX}-cpp
export AR=${TOOL_PREFIX}-ar
export AS=${TOOL_PREFIX}-as
export NM=${TOOL_PREFIX}-nm
export CC=${TOOL_PREFIX}-clang
export CXX=${TOOL_PREFIX}-clang++
export LD=${TOOL_PREFIX}-ld
export RANLIB=${TOOL_PREFIX}-ranlib
export STRIP=${TOOL_PREFIX}-strip
# Teach the preprocessor to find toolchain includes
export CPPFLAGS="${CPPFLAGS} --sysroot=${SYSROOT} -I${SYSROOT}/usr/include -I${ANDROID_TOOLCHAIN}/include"
# Pass specific flags to the C and/or CXX compiler
export CFLAGS="${CFLAGS}"
export CXXFLAGS="${CXXFLAGS}"
# Teach the linker to find toolchain libraries
export LDFLAGS="${LDFLAGS} -L${SYSROOT}/usr/lib${LIB_SUFFIX} -L${ANDROID_TOOLCHAIN}/lib"
# Extra libraries to link with. Should not be needed.
#export LIBS="-lm"
#
# Flags for ./build/dependency (cross-)build system
#
# Tell configure to use the toolchain and build only static libs
export pkg_configure_flags="--host=${TOOLCHAIN_NAME} --disable-shared $CONFIG_EXTRA"
# Where to install headers and libraries
export pkg_prefix="${ROOTDIR}"
# Tell ./build/dependency that we are cross compiling
export pkg_cross="jni"
# Tell ./build/dependency the name of the cross architecture
export pkg_cross_arch="${DESTDIR_NAME}"
if [ $# -gt 0 ]; then
$@
else
env
fi
measurement-kit-0.7.1/build/android/dependency 0000775 0000000 0000000 00000001334 13153561626 0021425 0 ustar 00root root 0000000 0000000 #!/bin/sh
set -e
if [ $# -lt 2 ]; then
echo "usage: $0 NDK_DIR spec" 1>&2
exit 1
fi
ROOTDIR=$(cd $(dirname $0)/../.. && pwd -P)
BUILDDIR=$ROOTDIR/build
ANDROIDDIR=$BUILDDIR/android
NDK_DIR=$1
SPEC=$2
echo ""
echo "Cross-compiling $SPEC for all archs"
ALL_ARCHS="armeabi armeabi-v7a arm64 mips mips64 x86 x86_64"
for ARCH in $ALL_ARCHS; do
echo ""
echo "Cross compiling $SPEC for arch ${ARCH}"
rm -rf $ANDROIDDIR/toolchain/${ARCH}
$ANDROIDDIR/make-toolchain ${NDK_DIR} ${ARCH}
$ANDROIDDIR/cross ${ARCH} $BUILDDIR/dependency $SPEC
done
# Install spec so we know what version was used to build the archive
install -d $ANDROIDDIR/jni/spec
install -m644 $BUILDDIR/spec/$SPEC $ANDROIDDIR/jni/spec/$SPEC
measurement-kit-0.7.1/build/android/fetch-dep 0000775 0000000 0000000 00000000155 13153561626 0021146 0 ustar 00root root 0000000 0000000 #!/bin/sh
set -e
ROOTDIR=$(cd $(dirname $0) && pwd -P)
export pkg_prefix=$ROOTDIR
$ROOTDIR/../fetch-dep "$@"
measurement-kit-0.7.1/build/android/jni/ 0000775 0000000 0000000 00000000000 13153561626 0020140 5 ustar 00root root 0000000 0000000 measurement-kit-0.7.1/build/android/jni/arm64-v8a/ 0000775 0000000 0000000 00000000000 13153561626 0021565 5 ustar 00root root 0000000 0000000 measurement-kit-0.7.1/build/android/jni/arm64-v8a/.gitignore 0000664 0000000 0000000 00000000002 13153561626 0023545 0 ustar 00root root 0000000 0000000 *
measurement-kit-0.7.1/build/android/jni/armeabi-v7a/ 0000775 0000000 0000000 00000000000 13153561626 0022233 5 ustar 00root root 0000000 0000000 measurement-kit-0.7.1/build/android/jni/armeabi-v7a/.gitignore 0000664 0000000 0000000 00000000002 13153561626 0024213 0 ustar 00root root 0000000 0000000 *
measurement-kit-0.7.1/build/android/jni/armeabi/ 0000775 0000000 0000000 00000000000 13153561626 0021540 5 ustar 00root root 0000000 0000000 measurement-kit-0.7.1/build/android/jni/armeabi/.gitignore 0000664 0000000 0000000 00000000002 13153561626 0023520 0 ustar 00root root 0000000 0000000 *
measurement-kit-0.7.1/build/android/jni/mips/ 0000775 0000000 0000000 00000000000 13153561626 0021110 5 ustar 00root root 0000000 0000000 measurement-kit-0.7.1/build/android/jni/mips/.gitignore 0000664 0000000 0000000 00000000002 13153561626 0023070 0 ustar 00root root 0000000 0000000 *
measurement-kit-0.7.1/build/android/jni/mips64/ 0000775 0000000 0000000 00000000000 13153561626 0021262 5 ustar 00root root 0000000 0000000 measurement-kit-0.7.1/build/android/jni/mips64/.gitignore 0000664 0000000 0000000 00000000002 13153561626 0023242 0 ustar 00root root 0000000 0000000 *
measurement-kit-0.7.1/build/android/jni/x86/ 0000775 0000000 0000000 00000000000 13153561626 0020565 5 ustar 00root root 0000000 0000000 measurement-kit-0.7.1/build/android/jni/x86/.gitignore 0000664 0000000 0000000 00000000002 13153561626 0022545 0 ustar 00root root 0000000 0000000 *
measurement-kit-0.7.1/build/android/jni/x86_64/ 0000775 0000000 0000000 00000000000 13153561626 0021076 5 ustar 00root root 0000000 0000000 measurement-kit-0.7.1/build/android/jni/x86_64/.gitignore 0000664 0000000 0000000 00000000002 13153561626 0023056 0 ustar 00root root 0000000 0000000 *
measurement-kit-0.7.1/build/android/make-toolchain 0000775 0000000 0000000 00000002653 13153561626 0022207 0 ustar 00root root 0000000 0000000 #!/bin/sh
set -e
if [ $# -ne 2 -a $# -ne 3 ]; then
echo "" 1>&2
echo "Usage: $0 NDK_DIR ARCH [API]" 1>&2
echo "" 1>&2
echo " NDK_DIR: path where NDK is installed" 1>&2
echo " ARCH: armeabi, armeabi-v7a, arm64, mips, mips64, x86, x86_64" 1>&2
echo " API: 1 ... 25" 1>&2
echo "" 1>&2
echo "If API is omitted, the minimum possible API for the " 1>&2
echo "required architecture is used." 1>&2
echo "" 1>&2
echo "Example usage (on MacOS with Android Studio installed):" 1>&2
echo " $0 ~/Library/Android/sdk/ndk-bundle arm 19" 1>&2
echo "" 1>&2
exit 1
fi
ROOTDIR=$(cd $(dirname $0) && pwd -P)
NDK_DIR=$1
ARCH=$2
API=$3
BASEDIR=$ROOTDIR/toolchain
# Directory where to install the toolchain. This must be done _before_
# mapping the input architecture to a real toolchain architecture.
INSTALL_DIR=$BASEDIR/${ARCH}
# Map input architecture to toolchain architecture (armeabi and
# armeabi-v7a both use the arm toolchain)
if [ "$ARCH" = "armeabi" -o "$ARCH" = "armeabi-v7a" ]; then
ARCH="arm"
fi
if [ "$API" = "" ]; then
if [ "$ARCH" = "arm64" -o "$ARCH" = "mips64" -o "$ARCH" = "x86_64" ]; then
API=21
else
API=14
fi
fi
MAKE_TOOLCHAIN=${NDK_DIR}/build/tools/make_standalone_toolchain.py
echo "Creating toolchain for API ${API} and ARCH ${ARCH} in ${INSTALL_DIR}"
$MAKE_TOOLCHAIN --arch=${ARCH} --api=${API} --install-dir=${INSTALL_DIR} \
--stl=libc++
measurement-kit-0.7.1/build/android/toolchain/ 0000775 0000000 0000000 00000000000 13153561626 0021340 5 ustar 00root root 0000000 0000000 measurement-kit-0.7.1/build/android/toolchain/.gitignore 0000664 0000000 0000000 00000000002 13153561626 0023320 0 ustar 00root root 0000000 0000000 *
measurement-kit-0.7.1/build/autogen.d/ 0000775 0000000 0000000 00000000000 13153561626 0017624 5 ustar 00root root 0000000 0000000 measurement-kit-0.7.1/build/autogen.d/geoip 0000664 0000000 0000000 00000001060 13153561626 0020647 0 ustar 00root root 0000000 0000000 #!/bin/sh
set -e
autogen_get_geoip() {
echo "* Fetching geoip database"
base=https://download.maxmind.com/download/geoip/database
if [ ! -f "GeoIP.dat" ]; then
wget $base/GeoLiteCountry/GeoIP.dat.gz -O GeoIP.dat.gz
gzip -d GeoIP.dat.gz
fi
if [ ! -f "GeoLiteCity.dat" ]; then
wget $base/GeoLiteCity.dat.gz -O GeoLiteCity.dat.gz
gzip -d GeoLiteCity.dat.gz
fi
if [ ! -f "GeoIPASNum.dat" ]; then
wget $base/asnum/GeoIPASNum.dat.gz -O GeoIPASNum.dat.gz
gzip -d GeoIPASNum.dat.gz
fi
}
measurement-kit-0.7.1/build/bundle-ca 0000775 0000000 0000000 00000002536 13153561626 0017526 0 ustar 00root root 0000000 0000000 #!/usr/bin/env python
# Part of measurement-kit .
# Measurement-kit is free software. See AUTHORS and LICENSE for more
# information on the copying conditions.
""" Usage: bundle-ca libressl-version ca-bundle-path output-header-path """
import sys
def main():
""" Main function """
libressl_version = sys.argv[1].encode("ascii")
ca_bundle_path = sys.argv[2]
output_header_path = sys.argv[3]
with open(ca_bundle_path, "rb") as filep:
ca_bundle_data = filep.read()
with open(output_header_path, "wb") as filep:
filep.write(b"""
/*
* Warning: autogenerated file; do not edit!
*
* Returns the CA file shipped with the libressl version we compile with
* as a vector of unsigned characters. This could then be passed to libressl
* specific functions for loading CAs from a memory buffer.
*
* Based on curl cacert-%s
*/
#include "private/net/builtin_ca_bundle.hpp"
namespace mk {
namespace net {
std::vector builtin_ca_bundle() {
static std::vector cav{
""" % libressl_version)
for number in ca_bundle_data:
if sys.version_info.major == 2:
number = ord(number)
filep.write(b"%d," % number)
filep.write(b"""
};
return cav;
}
} // namespace net
} // namespace mk
""")
if __name__ == "__main__":
main()
measurement-kit-0.7.1/build/ci/ 0000775 0000000 0000000 00000000000 13153561626 0016333 5 ustar 00root root 0000000 0000000 measurement-kit-0.7.1/build/ci/circle 0000775 0000000 0000000 00000000132 13153561626 0017516 0 ustar 00root root 0000000 0000000 #!/bin/sh
set -e
export pkg_make_flags="$pkg_make_flags V=0 -j$(nproc)"
./build/docker/$1
measurement-kit-0.7.1/build/ci/gitlab 0000775 0000000 0000000 00000000145 13153561626 0017523 0 ustar 00root root 0000000 0000000 #!/bin/sh
set -e
export pkg_make_flags="$pkg_make_flags V=0 -j$(nproc)"
./build/docker/script/run $1
measurement-kit-0.7.1/build/ci/travis 0000775 0000000 0000000 00000000055 13153561626 0017571 0 ustar 00root root 0000000 0000000 #!/bin/sh
set -e
./build/docker/$DOCKER_SPEC
measurement-kit-0.7.1/build/cmake/ 0000775 0000000 0000000 00000000000 13153561626 0017020 5 ustar 00root root 0000000 0000000 measurement-kit-0.7.1/build/cmake/macos_with_brew 0000775 0000000 0000000 00000000336 13153561626 0022124 0 ustar 00root root 0000000 0000000 #!/bin/sh
set -e
rootdir=$(cd $(dirname $(dirname $0)) && pwd -P)
cmake -D MK_GEOIP=/usr/local -D MK_LIBEVENT=/usr/local \
-D MK_OPENSSL=/usr/local/opt/openssl .
echo ""
echo "Now run 'make'"
measurement-kit-0.7.1/build/dependency 0000775 0000000 0000000 00000011607 13153561626 0020011 0 ustar 00root root 0000000 0000000 #!/bin/sh
print_usage() {
cat << EOF
usage: $0 dependency-name
Clones repository, configure, build and install dependency. By default sources
are below './third_party' and installed software is below './builtin/'.
Override default behavior by setting these environment variables:
- pkg_clone_flags: extra flags for 'git clone' (e.g. '--recursive')
- pkg_configure_flags: extra flags for './configure' (if any)
- pkg_cmake_flags: extra flags for 'cmake .' (if CMakeLists.txt exists)
- pkg_make_check_rule: rule to run tests (default: not set, no tests are run)
- pkg_make_flags: extra flags for 'make' (e.g. 'V=0')
- pkg_make_install_flags: extra flags for 'make install' (e.g. DESTDIR=/opt)
- pkg_prefix: prefix where to install (e.g. '/usr/local')
- pkg_steps: steps to execute (default is: 'init patch_pre_autogen autogen patch_post_autogen configure make make_check make_install')
Examples:
- use four processors to compile libressl:
- pkg_make_flags=-j4 ./build/dependency libressl
EOF
}
apply_patches() {
if [ -d ../../../build/patch/$1 ]; then
for diff in `find ../../../build/patch/$1 -type f`; do
echo "* apply patch: $diff"
git apply -v $diff
done
fi
}
pkg_init() {
if [ -f Makefile ]; then
echo "- make distclean"
make distclean
fi
}
pkg_patch_pre_autogen() {
apply_patches pre-autogen/$pkg_name/common
if [ "$pkg_cross" != "" ]; then
apply_patches pre-autogen/$pkg_name/$pkg_cross
fi
}
pkg_autogen() {
if [ -x ./autogen.sh ]; then
echo "- ./autogen.sh"
./autogen.sh
elif [ -f ./configure.ac ]; then
echo "- autoreconf -i"
autoreconf -i
fi
}
pkg_patch_post_autogen() {
apply_patches post-autogen/$pkg_name/common
if [ "$pkg_cross" != "" ]; then
apply_patches post-autogen/$pkg_name/$pkg_cross
fi
}
pkg_configure() {
if [ -x ./configure ]; then
echo "- ./configure --prefix=/ $pkg_configure_flags"
./configure --prefix=/ $pkg_configure_flags
elif [ -f ./CMakeLists.txt ]; then
echo "- cmake -D CMAKE_INSTALL_PREFIX=/ $pkg_cmake_flags ."
cmake -D CMAKE_INSTALL_PREFIX=/ $pkg_cmake_flags .
fi
}
pkg_make() {
echo "- make $pkg_make_flags"
make $pkg_make_flags
}
pkg_make_check() {
if [ "$pkg_make_check_rule" != "" ]; then
echo "- make $pkg_make_flags $pkg_make_check_rule"
if ! make $pkg_make_flags $pkg_make_check_rule; then
if [ -f ./test-suite.log ]; then
cat ./test-suite.log
fi
exit 1
fi
else
echo 'not running checks because $pkg_make_check_rule is not set'
fi
}
pkg_make_install() {
if [ "$pkg_make_install_rule" = "" ]; then
pkg_make_install_rule=install
fi
vspec=$pkg_branch_or_tag
if [ "$pkg_tip" != "" ]; then
vspec="$pkg_tip"
fi
based=$pkg_rootdir/third_party/tmp/$pkg_name-$vspec
adir=$based/$pkg_cross/$pkg_cross_arch
echo "- make $pkg_make_install_flags $pkg_make_install_rule"
make $pkg_make_install_flags $pkg_make_install_rule DESTDIR=$adir
find $adir -depth -type d -name bin -exec rm -rf {} \;
find $adir -depth -type d -name pkgconfig -exec rm -rf {} \;
find $adir -depth -type d -name sbin -exec rm -rf {} \;
find $adir -depth -type f -name \*.la -exec rm -rf {} \;
tarname=$pkg_rootdir/$pkg_name-$vspec
tarname=$tarname-$pkg_cross-$pkg_cross_arch
tarname=$tarname-`date -u +%Y%m%dT%H%M%SZ`
tarname=$tarname.tgz
echo ""
echo "- create archive $tarname"
(cd $based && tar -cvzf $tarname ./)
rm -rf $pkg_rootdir/third_party/tmp
echo ""
echo "- install from $tarname into $pkg_prefix"
install -d $pkg_prefix
(cd $pkg_prefix && tar -xvzf $tarname)
}
pkg_none() {
echo "- no action"
}
set -e
if [ $# -ne 1 ]; then
print_usage
exit 1
fi
pkg_rootdir=$(cd $(dirname $(dirname $0)) && pwd -P)
if [ -z "$pkg_prefix" ]; then
pkg_prefix=$pkg_rootdir/builtin
fi
export pkg_prefix
cd $pkg_rootdir
# Note that the spec has access to $pkg_rootdir
. build/spec/$1
if [ "$pkg_repository" != "" ]; then
rm -rf third_party/src/$pkg_name
git clone $pkg_clone_flags --single-branch --depth 2 \
--branch $pkg_branch_or_tag $pkg_repository third_party/src/$pkg_name
cd third_party/src/$pkg_name
if [ "$pkg_tip" != "" ]; then
if [ "`git rev-parse HEAD`" != "$pkg_tip" ]; then
# Mainly because this allows us to know which commit was the
# tip of the branch when we compiled a dependency
echo "FATAL: unexpected HEAD commit SHA-1" 1>&2
exit 1
fi
fi
fi
if [ -z "$pkg_steps" ]; then
pkg_steps="init patch_pre_autogen autogen patch_post_autogen configure make make_check make_install"
fi
for step in $pkg_steps; do
echo ""
echo "./build/dependency: $step"
echo ""
pkg_$step
done
echo ""
measurement-kit-0.7.1/build/docker/ 0000775 0000000 0000000 00000000000 13153561626 0017207 5 ustar 00root root 0000000 0000000 measurement-kit-0.7.1/build/docker/coveralls 0000775 0000000 0000000 00000000213 13153561626 0021123 0 ustar 00root root 0000000 0000000 #!/bin/sh
set -e
REPOROOT=$(cd $(dirname $(dirname $(dirname $0))) && pwd -P)
$REPOROOT/build/docker/script/setup ubuntu:yakkety coveralls
measurement-kit-0.7.1/build/docker/script/ 0000775 0000000 0000000 00000000000 13153561626 0020513 5 ustar 00root root 0000000 0000000 measurement-kit-0.7.1/build/docker/script/init 0000775 0000000 0000000 00000000070 13153561626 0021401 0 ustar 00root root 0000000 0000000 #!/bin/sh
set -e
cd /mk
./build/docker/script/run "$@"
measurement-kit-0.7.1/build/docker/script/run 0000775 0000000 0000000 00000001520 13153561626 0021243 0 ustar 00root root 0000000 0000000 #!/bin/sh
set -e
if [ $# -lt 1 ]; then
echo "usage: $0 spec-name [phase ...]" 1>&2
exit 1
fi
spec_name=$1
shift
subr_depend() {
echo "- install debian deps: $debian_deps"
apt-get update
apt-get upgrade -y
apt-get install -y $debian_deps
if [ "$pip_deps" != "" ]; then
echo "- install pip deps: $pip_deps"
pip install --user $pip_deps
fi
}
subr_start_over() {
if [ -f Makefile ]; then
make distclean
fi
}
subr_build() {
./build/dependency mk
}
subr_finalize() {
echo "- finalize"
}
. build/docker/spec/$spec_name
env | sed 's/^COVERALLS_REPO_TOKEN=.*$/COVERALLS_REPO_TOKEN=[secure]/g'
sleep 5
if [ $# -eq 0 ]; then
set -- depend start_over build finalize
fi
while [ $# -gt 0 ]; do
echo ""
echo "docker/script/run: $1"
echo ""
subr_$1
shift
done
measurement-kit-0.7.1/build/docker/script/setup 0000775 0000000 0000000 00000001437 13153561626 0021606 0 ustar 00root root 0000000 0000000 #!/bin/sh
set -e
REPOROOT=$(cd $(dirname $(dirname $(dirname $(dirname $0)))) && pwd -P)
docker_image=$1
if [ "$docker_image" = "" ]; then
echo "usage: $0 docker-image-name docker-spec-name" 1>&2
exit 1
fi
shift
docker run \
-e "pkg_configure_flags=$pkg_configure_flags" \
-e "pkg_make_flags=$pkg_make_flags" \
-e "COVERALLS_REPO_TOKEN=$COVERALLS_REPO_TOKEN" \
-e "TRAVIS_BRANCH=$TRAVIS_BRANCH" \
-v $REPOROOT:/mk \
$docker_image \
/mk/build/docker/script/init "$@"
measurement-kit-0.7.1/build/docker/spec/ 0000775 0000000 0000000 00000000000 13153561626 0020141 5 ustar 00root root 0000000 0000000 measurement-kit-0.7.1/build/docker/spec/coveralls 0000664 0000000 0000000 00000002767 13153561626 0022072 0 ustar 00root root 0000000 0000000 #!/bin/sh
set -e
export pkg_configure_flags="$pkg_configure_flags --enable-coverage"
export pkg_make_check_rule="check"
debian_deps="$debian_deps autoconf"
debian_deps="$debian_deps automake"
debian_deps="$debian_deps g++"
debian_deps="$debian_deps git"
debian_deps="$debian_deps libevent-dev"
debian_deps="$debian_deps libgeoip-dev"
debian_deps="$debian_deps libssl-dev"
debian_deps="$debian_deps libtool"
debian_deps="$debian_deps make"
debian_deps="$debian_deps python"
debian_deps="$debian_deps python-pip"
debian_deps="$debian_deps wget"
pip_deps="$pip_deps cpp-coveralls"
subr_finalize() {
if [ "$COVERALLS_REPO_TOKEN" != "" ]; then
$HOME/.local/bin/coveralls \
--gcov-options '\-lp' \
--build-root . \
--exclude include/measurement_kit/ext \
--exclude include/private/ext \
--exclude src/libmeasurement_kit/ext \
--exclude src/libmeasurement_kit/portable \
--exclude src/measurement_kit \
--exclude example \
--exclude third_party \
--exclude builtin \
> /dev/null;
fi
}
measurement-kit-0.7.1/build/docker/spec/valgrind-clang 0000664 0000000 0000000 00000001166 13153561626 0022760 0 ustar 00root root 0000000 0000000 #!/bin/sh
set -e
export CPP="clang -E"
export CC="clang"
export CXX="clang++"
export CXXFLAGS="-stdlib=libc++"
export pkg_make_check_rule="run-valgrind-docker"
debian_deps="$debian_deps autoconf"
debian_deps="$debian_deps automake"
debian_deps="$debian_deps clang"
debian_deps="$debian_deps git"
debian_deps="$debian_deps libc++-dev"
debian_deps="$debian_deps libc++abi-dev"
debian_deps="$debian_deps libevent-dev"
debian_deps="$debian_deps libgeoip-dev"
debian_deps="$debian_deps libssl-dev"
debian_deps="$debian_deps libtool"
debian_deps="$debian_deps make"
debian_deps="$debian_deps valgrind"
debian_deps="$debian_deps wget"
measurement-kit-0.7.1/build/docker/spec/valgrind-gcc 0000664 0000000 0000000 00000000774 13153561626 0022434 0 ustar 00root root 0000000 0000000 #!/bin/sh
set -e
export CPP="gcc -E"
export CC="gcc"
export CXX="g++"
export pkg_make_check_rule="run-valgrind-docker"
debian_deps="$debian_deps autoconf"
debian_deps="$debian_deps automake"
debian_deps="$debian_deps g++"
debian_deps="$debian_deps git"
debian_deps="$debian_deps libevent-dev"
debian_deps="$debian_deps libgeoip-dev"
debian_deps="$debian_deps libssl-dev"
debian_deps="$debian_deps libtool"
debian_deps="$debian_deps make"
debian_deps="$debian_deps valgrind"
debian_deps="$debian_deps wget"
measurement-kit-0.7.1/build/docker/valgrind-clang 0000775 0000000 0000000 00000000216 13153561626 0022024 0 ustar 00root root 0000000 0000000 #!/bin/sh
set -e
REPOROOT=$(cd $(dirname $(dirname $(dirname $0))) && pwd -P)
$REPOROOT/build/docker/script/setup ubuntu:zesty valgrind-clang
measurement-kit-0.7.1/build/docker/valgrind-gcc 0000775 0000000 0000000 00000000216 13153561626 0021474 0 ustar 00root root 0000000 0000000 #!/bin/sh
set -e
REPOROOT=$(cd $(dirname $(dirname $(dirname $0))) && pwd -P)
$REPOROOT/build/docker/script/setup ubuntu:yakkety valgrind-gcc
measurement-kit-0.7.1/build/fetch-dep 0000775 0000000 0000000 00000001753 13153561626 0017533 0 ustar 00root root 0000000 0000000 #!/bin/sh
args=`getopt ps: $*`
if [ $? -ne 0 ]; then
echo "usage: $0 [-p] [-s regex]" 1>&2
exit 1
fi
set -- $args
while [ $# -ne 0 ]; do
case "$1" in
-p)
arguments="$arguments -p"
shift
;;
-s)
arguments="$arguments -s $2"
shift
shift
;;
--)
shift
break
;;
*)
echo "usage: $0 [-p] [-s regex]" 1>&2
exit 1
esac
done
if [ $# -ne 0 ]; then
echo "usage: $0 [-p] [-s regex]" 1>&2
exit 1
fi
set -e
pkg_rootdir=$(cd $(dirname $(dirname $0)) && pwd -P)
cd $pkg_rootdir
if [ "$pkg_prefix" = "" ]; then
pkg_prefix="$pkg_rootdir/builtin"
fi
npm install download-github-release
./node_modules/.bin/download-github-release $arguments \
measurement-kit dependencies
for file in *.tgz; do
gpg --verify $file.asc $file
install -d $pkg_prefix
tar -C $pkg_prefix -xf $file
done
measurement-kit-0.7.1/build/get-geoip 0000775 0000000 0000000 00000000075 13153561626 0017550 0 ustar 00root root 0000000 0000000 #!/bin/sh
set -e
. ./build/autogen.d/geoip
autogen_get_geoip
measurement-kit-0.7.1/build/ios/ 0000775 0000000 0000000 00000000000 13153561626 0016532 5 ustar 00root root 0000000 0000000 measurement-kit-0.7.1/build/ios/.gitignore 0000664 0000000 0000000 00000000032 13153561626 0020515 0 ustar 00root root 0000000 0000000 .DS_Store
*.tgz
*.tgz.asc
measurement-kit-0.7.1/build/ios/Frameworks/ 0000775 0000000 0000000 00000000000 13153561626 0020652 5 ustar 00root root 0000000 0000000 measurement-kit-0.7.1/build/ios/Frameworks/.gitignore 0000664 0000000 0000000 00000000002 13153561626 0022632 0 ustar 00root root 0000000 0000000 *
measurement-kit-0.7.1/build/ios/archive-deps 0000775 0000000 0000000 00000001116 13153561626 0021031 0 ustar 00root root 0000000 0000000 #!/bin/sh
set -e
ROOTDIR=$(cd $(dirname $0)/../.. && pwd -P)
cd $ROOTDIR/build/ios
# Do not ship *.la files that would break the build and, while there, also
# remove directories that we don't need for cross compiling MK
find tmp -type f -name \*.la -exec rm {} \;
find tmp -type f -name \*.pc -exec rm {} \;
find tmp -type d -depth -name share -exec rm -rf {} \;
find tmp -type d -depth -name bin -exec rm -rf {} \;
find tmp -type d -depth -name pkgconfig -exec rm -rf {} \;
now=`date +%Y%m%dT%H%M%SZ`
tar -czf ios-dependencies-$now.tgz tmp
$ROOTDIR/build/sign ios-dependencies-$now.tgz
measurement-kit-0.7.1/build/ios/archive-library 0000775 0000000 0000000 00000001103 13153561626 0021536 0 ustar 00root root 0000000 0000000 #!/bin/sh
set -e
ROOTDIR=$(cd $(dirname $0)/../.. && pwd -P)
cd $ROOTDIR
D=build/ios
V=0.7.1
# Do not ship *.la files that would break the build and, while there, also
# remove directories that we don't need for cross compiling MK
find $D/tmp -type f -name \*.la -exec rm {} \;
find $D/tmp -type f -name \*.pc -exec rm {} \;
find $D/tmp -type d -depth -name share -exec rm -rf {} \;
find $D/tmp -type d -depth -name bin -exec rm -rf {} \;
find $D/tmp -type d -depth -name pkgconfig -exec rm -rf {} \;
tar -czf ios_binaries-$V.tgz $D/tmp
$ROOTDIR/build/sign ios_binaries-$V.tgz
measurement-kit-0.7.1/build/ios/build-frameworks 0000775 0000000 0000000 00000003460 13153561626 0021740 0 ustar 00root root 0000000 0000000 #!/bin/sh
set -e
ROOTDIR=$(cd $(dirname $0) && pwd -P)
EXTLIBRARIES="libevent libevent_pthreads libevent_openssl libcrypto libssl libGeoIP"
list_libs() {
input_lib=$1
libs=""
for arch in i386 x86_64; do
if [ -f tmp/iphonesimulator/$arch/lib/$input_lib.a ]; then
libs="$libs tmp/iphonesimulator/$arch/lib/$input_lib.a"
fi
done
for arch in arm64 armv7s armv7; do
if [ -f tmp/iphoneos/$arch/lib/$input_lib.a ]; then
libs="$libs tmp/iphoneos/$arch/lib/$input_lib.a"
fi
done
echo $libs
}
(
cd "$ROOTDIR"
# Clean old frameworks (if any)
rm -rf Frameworks/*
# Create framework folders
for lib in $EXTLIBRARIES measurement_kit; do
mkdir Frameworks/$lib.framework
done
# Copying first headers we find. This has no implications because
# measurement-kit uses no machine-dependent headers.
for platform in iphoneos iphonesimulator; do
for arch in i386 x86_64 armv7 armv7s arm64; do
if [ -d tmp/$platform/$arch/include/measurement_kit ]; then
cp -Rp tmp/$platform/$arch/include/measurement_kit \
Frameworks/measurement_kit.framework/Headers
break
fi
done
done
# Lipo external libraries
for lib in $EXTLIBRARIES; do
lipo -create -output Frameworks/$lib.framework/$lib `list_libs $lib`
done
# Lipo measurement-kit library
lipo -create -output Frameworks/measurement_kit.framework/measurement_kit \
`list_libs libmeasurement_kit`
# Create fake header to make CocoaPod happy
for lib in $EXTLIBRARIES; do
install -d Frameworks/$lib.framework/Headers
echo "/* Make CocoaPod happy */" > \
Frameworks/$lib.framework/Headers/dummy_header.h
done
)
measurement-kit-0.7.1/build/ios/cross 0000775 0000000 0000000 00000003232 13153561626 0017611 0 ustar 00root root 0000000 0000000 #!/bin/sh
set -e
if [ $# -lt 2 ]; then
echo "$0 iphonesimulator i386|x86_64 [command [args...]]" 1>&2
echo "$0 iphoneos armv7|armv7s|arm64 [command [args...]]" 1>&2
exit 1
fi
PLATFORM=$1
shift
ARCH=$1
shift
MINIOSVERSION="9.0"
if [ "$PLATFORM" = "iphoneos" ]; then
EXTRA_CONFIG="--host=arm-apple-darwin --target=arm-apple-darwin --disable-shared"
MINVERSION="-miphoneos-version-min=$MINIOSVERSION"
elif [ "$ARCH" = "i386" ]; then
EXTRA_CONFIG="--host=i386-apple-darwin --target=i386-apple-darwin --disable-shared"
MINVERSION="-mios-simulator-version-min=$MINIOSVERSION"
elif [ "$ARCH" = "x86_64" ]; then
EXTRA_CONFIG="--host=x86_64-apple-darwin --target=x86_64-apple-darwin --disable-shared"
MINVERSION="-mios-simulator-version-min=$MINIOSVERSION"
else
echo "$0: unsupported configuration" 1>&2
exit 1
fi
echo ""
echo "Cross compiling for $PLATFORM and $ARCH"
ROOTDIR=$(cd $(dirname $0) && pwd -P)
SOURCEDIR="$ROOTDIR/../../"
DESTDIR="$ROOTDIR/tmp"
export CC="$(xcrun -find -sdk ${PLATFORM} cc)"
export CXX="$(xcrun -find -sdk ${PLATFORM} g++)"
export CPPFLAGS="-arch ${ARCH} -isysroot $(xcrun -sdk ${PLATFORM} --show-sdk-path)"
export CFLAGS="-arch ${ARCH} $MINVERSION -isysroot $(xcrun -sdk ${PLATFORM} --show-sdk-path)"
export CXXFLAGS="-arch ${ARCH} $MINVERSION -isysroot $(xcrun -sdk ${PLATFORM} --show-sdk-path)"
export LDFLAGS="-arch ${ARCH} $MINVERSION -isysroot $(xcrun -sdk ${PLATFORM} --show-sdk-path)"
export pkg_configure_flags="$EXTRA_CONFIG"
export pkg_make_flags="V=0 $pkg_make_flags"
export pkg_prefix="$DESTDIR"
export pkg_cross="${PLATFORM}"
export pkg_cross_arch="${ARCH}"
if [ $# -gt 0 ]; then
$@
else
env
fi
measurement-kit-0.7.1/build/ios/dependency 0000775 0000000 0000000 00000001237 13153561626 0020601 0 ustar 00root root 0000000 0000000 #!/bin/sh
set -e
if [ "$1" = "" ]; then
echo "usage: $0 spec" 1>&2
exit 1
fi
ROOTDIR=$(cd $(dirname $0)/../.. && pwd -P)
BUILDDIR=$ROOTDIR/build
IOSDIR=$BUILDDIR/ios
echo ""
echo "Cross-compiling $1 for all platforms and archs"
$IOSDIR/cross iphonesimulator i386 $BUILDDIR/dependency $1
$IOSDIR/cross iphonesimulator x86_64 $BUILDDIR/dependency $1
$IOSDIR/cross iphoneos armv7 $BUILDDIR/dependency $1
$IOSDIR/cross iphoneos armv7s $BUILDDIR/dependency $1
$IOSDIR/cross iphoneos arm64 $BUILDDIR/dependency $1
# Install spec so we know what version was used to build the archive
install -d $IOSDIR/tmp/spec
install -m644 $BUILDDIR/spec/$1 $IOSDIR/tmp/spec/$1
measurement-kit-0.7.1/build/ios/fetch-dep 0000775 0000000 0000000 00000000161 13153561626 0020315 0 ustar 00root root 0000000 0000000 #!/bin/sh
set -e
ROOTDIR=$(cd $(dirname $0) && pwd -P)
export pkg_prefix=$ROOTDIR/tmp
$ROOTDIR/../fetch-dep "$@"
measurement-kit-0.7.1/build/ios/library 0000775 0000000 0000000 00000001607 13153561626 0020130 0 ustar 00root root 0000000 0000000 #!/bin/sh
set -e
ROOTDIR=$(cd `dirname "$0"` && pwd -P)
RELEASE_URL=https://github.com/measurement-kit/measurement-kit/releases/download/v0.7.1/ios_binaries-0.7.1.tgz
RELEASE_FILE=$(basename $RELEASE_URL)
if wget $RELEASE_URL; then
wget $RELEASE_URL.asc
gpg --verify $RELEASE_FILE.asc
tar xzf $RELEASE_FILE
rm $RELEASE_FILE $RELEASE_FILE.asc
$ROOTDIR/build-frameworks
exit 0
fi
echo "Downloading and verifying precompiled dependencies from github"
(
set -e # just in case
cd $ROOTDIR
DEPS_URL=https://github.com/measurement-kit/dependencies/releases/download/2017-07-12/ios-dependencies-20170714T172936Z.tgz
DEPS_FILE=$(basename $DEPS_URL)
curl --progress-bar -LO $DEPS_URL
curl --progress-bar -LO $DEPS_URL.asc
gpg --verify $DEPS_FILE.asc
tar -xzf $DEPS_FILE
rm $DEPS_FILE $DEPS_FILE.asc
)
$ROOTDIR/dependency mk
$ROOTDIR/build-frameworks
measurement-kit-0.7.1/build/ios/tmp/ 0000775 0000000 0000000 00000000000 13153561626 0017332 5 ustar 00root root 0000000 0000000 measurement-kit-0.7.1/build/ios/tmp/.gitignore 0000664 0000000 0000000 00000000073 13153561626 0021322 0 ustar 00root root 0000000 0000000 # Directory used to compile, ignore everything inside it
*
measurement-kit-0.7.1/build/patch/ 0000775 0000000 0000000 00000000000 13153561626 0017037 5 ustar 00root root 0000000 0000000 measurement-kit-0.7.1/build/patch/pre-autogen/ 0000775 0000000 0000000 00000000000 13153561626 0021265 5 ustar 00root root 0000000 0000000 measurement-kit-0.7.1/build/patch/pre-autogen/geoip/ 0000775 0000000 0000000 00000000000 13153561626 0022370 5 ustar 00root root 0000000 0000000 measurement-kit-0.7.1/build/patch/pre-autogen/geoip/common/ 0000775 0000000 0000000 00000000000 13153561626 0023660 5 ustar 00root root 0000000 0000000 measurement-kit-0.7.1/build/patch/pre-autogen/geoip/common/000.patch 0000664 0000000 0000000 00000000471 13153561626 0025202 0 ustar 00root root 0000000 0000000 diff --git a/Makefile.am b/Makefile.am
index ad9b1ea..28c35c0 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -4,10 +4,7 @@ ACLOCAL_AMFLAGS = -I m4
AUTOMAKE_OPTIONS = foreign
SUBDIRS = \
- libGeoIP \
- apps \
- test \
- man
+ libGeoIP
pkgconfigdir = $(libdir)/pkgconfig/
nodist_pkgconfig_DATA = geoip.pc
measurement-kit-0.7.1/build/patch/pre-autogen/libevent/ 0000775 0000000 0000000 00000000000 13153561626 0023075 5 ustar 00root root 0000000 0000000 measurement-kit-0.7.1/build/patch/pre-autogen/libevent/common/ 0000775 0000000 0000000 00000000000 13153561626 0024365 5 ustar 00root root 0000000 0000000 measurement-kit-0.7.1/build/patch/pre-autogen/libevent/common/000.patch 0000664 0000000 0000000 00000007217 13153561626 0025714 0 ustar 00root root 0000000 0000000 diff --git a/Makefile.am b/Makefile.am
index 0f741bc..3a3eee0 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -91,10 +91,6 @@ VERSION_INFO = 6:2:0
# is user-visible, and so we can pretty much guarantee that release
# series won't be binary-compatible.
-if INSTALL_LIBEVENT
-dist_bin_SCRIPTS = event_rpcgen.py
-endif
-
pkgconfigdir=$(libdir)/pkgconfig
LIBEVENT_PKGCONFIG=libevent.pc libevent_core.pc libevent_extra.pc
@@ -130,7 +126,6 @@ endif
if INSTALL_LIBEVENT
lib_LTLIBRARIES = $(LIBEVENT_LIBS_LA)
-pkgconfig_DATA = $(LIBEVENT_PKGCONFIG)
else
noinst_LTLIBRARIES = $(LIBEVENT_LIBS_LA)
endif
@@ -143,8 +138,6 @@ CLEANFILES=
DISTCLEANFILES=
BUILT_SOURCES =
include include/include.am
-include sample/include.am
-include test/include.am
if BUILD_WIN32
diff --git a/configure.ac b/configure.ac
index 7528d37..24b65dc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -121,10 +121,6 @@ AC_ARG_ENABLE([function-sections],
AC_ARG_ENABLE([verbose-debug],
AS_HELP_STRING([--enable-verbose-debug, verbose debug logging]),
[], [enable_verbose_debug=no])
-AC_ARG_ENABLE([clock-gettime],
- AS_HELP_STRING(--disable-clock-gettime, do not use clock_gettime even if it is available),
- [], [enable_clock_gettime=yes])
-
AC_PROG_LIBTOOL
@@ -141,10 +137,6 @@ dnl Checks for libraries.
AC_SEARCH_LIBS([inet_ntoa], [nsl])
AC_SEARCH_LIBS([socket], [socket])
AC_SEARCH_LIBS([inet_aton], [resolv])
-if test "x$enable_clock_gettime" = "xyes"; then
- AC_SEARCH_LIBS([clock_gettime], [rt])
- AC_CHECK_FUNCS([clock_gettime])
-fi
AC_SEARCH_LIBS([sendfile], [sendfile])
dnl - check if the macro _WIN32 is defined on this compiler.
@@ -342,6 +334,7 @@ AC_CHECK_FUNCS([ \
accept4 \
arc4random \
arc4random_buf \
+ arc4random_addrandom \
eventfd \
epoll_create1 \
fcntl \
diff --git a/evutil_rand.c b/evutil_rand.c
index 046a14b..3aef9cb 100644
--- a/evutil_rand.c
+++ b/evutil_rand.c
@@ -184,6 +184,24 @@ ev_arc4random_buf(void *buf, size_t n)
arc4random_buf(buf, n);
}
+/*
+ * The arc4random included in libevent implements arc4random_addrandom().
+ *
+ * OpenBSD libc/crypt/arc4random.c migrated to ChaCha20 since 1.25 and
+ * have removed arc4random_addrandom() since 1.26. Since then, other libcs
+ * followed suit (e.g. Android's own libc). But libevent's arc4random.c
+ * copy still implement arc4random_addrandom().
+ *
+ * See also:
+ *
+ * - https://github.com/measurement-kit/libevent/commit/8b275d967d7ffd95d5cc12069aef35669126c6d9
+ * - https://bugzilla.mozilla.org/show_bug.cgi?id=931354
+ * - https://bug931354.bmoattachments.org/attachment.cgi?id=829728
+ */
+#ifndef EVENT__HAVE_ARC4RANDOM_ADDRANDOM
+#define EVENT__HAVE_ARC4RANDOM_ADDRANDOM 1
+#endif
+
#endif /* } !EVENT__HAVE_ARC4RANDOM */
void
@@ -195,8 +213,10 @@ evutil_secure_rng_get_bytes(void *buf, size_t n)
void
evutil_secure_rng_add_bytes(const char *buf, size_t n)
{
+#if defined EVENT__HAVE_ARC4RANDOM_ADDRANDOM
arc4random_addrandom((unsigned char*)buf,
n>(size_t)INT_MAX ? INT_MAX : (int)n);
+#endif
}
void
diff --git a/openssl-compat.h b/openssl-compat.h
index 69afc71..8e3556a 100644
--- a/openssl-compat.h
+++ b/openssl-compat.h
@@ -1,7 +1,7 @@
#ifndef OPENSSL_COMPAT_H
#define OPENSSL_COMPAT_H
-#if OPENSSL_VERSION_NUMBER < 0x10100000L
+#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined LIBRESSL_VERSION_NUMBER
static inline BIO_METHOD *BIO_meth_new(int type, const char *name)
{
@@ -30,6 +30,6 @@ static inline BIO_METHOD *BIO_meth_new(int type, const char *name)
#define TLS_method SSLv23_method
-#endif /* OPENSSL_VERSION_NUMBER < 0x10100000L */
+#endif /* OPENSSL_VERSION_NUMBER < 0x10100000L || defined LIBRESSL_VERSION_NUMBER */
#endif /* OPENSSL_COMPAT_H */
measurement-kit-0.7.1/build/patch/pre-autogen/libressl/ 0000775 0000000 0000000 00000000000 13153561626 0023104 5 ustar 00root root 0000000 0000000 measurement-kit-0.7.1/build/patch/pre-autogen/libressl/common/ 0000775 0000000 0000000 00000000000 13153561626 0024374 5 ustar 00root root 0000000 0000000 measurement-kit-0.7.1/build/patch/pre-autogen/libressl/common/000.patch 0000664 0000000 0000000 00000001062 13153561626 0025713 0 ustar 00root root 0000000 0000000 From f9e21798fb795188a21ac7dd5ed0d9b6adf29f8c Mon Sep 17 00:00:00 2001
From: AntonioLangiu
Date: Fri, 22 Apr 2016 16:29:36 +0200
Subject: [PATCH 505/505] build just needed subdir
---
Makefile.am | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile.am b/Makefile.am
index 48da18b..9164e20 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = crypto ssl tls include apps tests man
+SUBDIRS = crypto ssl include
ACLOCAL_AMFLAGS = -I m4
pkgconfigdir = $(libdir)/pkgconfig
--
2.8.1
measurement-kit-0.7.1/build/patch/pre-autogen/libressl/common/002.patch 0000664 0000000 0000000 00000001170 13153561626 0025715 0 ustar 00root root 0000000 0000000 diff --git a/update.sh b/update.sh
index 0853c6b..b734773 100755
--- a/update.sh
+++ b/update.sh
@@ -5,16 +5,8 @@ openbsd_branch=`cat OPENBSD_BRANCH`
# pull in latest upstream code
echo "pulling upstream openbsd source"
-if [ ! -d openbsd ]; then
- if [ -z "$LIBRESSL_GIT" ]; then
- git clone https://github.com/libressl-portable/openbsd.git
- else
- git clone $LIBRESSL_GIT/openbsd
- fi
-fi
-(cd openbsd
- git checkout $openbsd_branch
- git pull --rebase)
+git clone --single-branch --depth 2 --branch $openbsd_branch \
+ https://github.com/libressl-portable/openbsd.git
# setup source paths
CWD=`pwd`
measurement-kit-0.7.1/build/patch/pre-autogen/libressl/common/003.patch 0000664 0000000 0000000 00000002263 13153561626 0025722 0 ustar 00root root 0000000 0000000 diff --git a/m4/check-libc.m4 b/m4/check-libc.m4
index 3e4d3af..ab42f77 100644
--- a/m4/check-libc.m4
+++ b/m4/check-libc.m4
@@ -2,10 +2,26 @@ AC_DEFUN([CHECK_LIBC_COMPAT], [
# Check for libc headers
AC_CHECK_HEADERS([err.h readpassphrase.h])
# Check for general libc functions
-AC_CHECK_FUNCS([asprintf getpagesize inet_ntop inet_pton memmem readpassphrase])
+AC_CHECK_FUNCS([asprintf inet_ntop inet_pton memmem readpassphrase])
AC_CHECK_FUNCS([reallocarray recallocarray])
AC_CHECK_FUNCS([strlcat strlcpy strndup strnlen strsep strtonum])
AC_CHECK_FUNCS([timegm _mkgmtime])
+
+dnl Note: in Android < 21 getpagesize() is defined inline. As such, the test
+dnl for getpagesize() should include .
+AC_MSG_CHECKING([for getpagesize])
+AC_LINK_IFELSE([AC_LANG_PROGRAM([
+ #include
+], [
+ return getpagesize();
+])], [
+ ac_cv_func_getpagesize="yes"
+ AC_MSG_RESULT([yes])
+], [
+ ac_cv_func_getpagesize="no"
+ AC_MSG_RESULT([no])
+])
+
AM_CONDITIONAL([HAVE_ASPRINTF], [test "x$ac_cv_func_asprintf" = xyes])
AM_CONDITIONAL([HAVE_GETPAGESIZE], [test "x$ac_cv_func_getpagesize" = xyes])
AM_CONDITIONAL([HAVE_INET_NTOP], [test "x$ac_cv_func_inet_ntop" = xyes])
measurement-kit-0.7.1/build/release 0000775 0000000 0000000 00000001302 13153561626 0017302 0 ustar 00root root 0000000 0000000 #!/bin/sh
set -e
if [ $# -ne 2 ]; then
echo "usage: $0 old-version new-version" 1>&2
exit 1
fi
old_version=$1
new_version=$2
for file in configure.ac doc/api/common/version.md doc/index.md \
include/measurement_kit/common/version.h build/spec/mk \
measurement_kit.podspec build/ios/library \
build/ios/archive-library; do
cp $file $file.old
sed "s/$old_version/$new_version/g" $file.old > $file
rm $file.old
done
mv ChangeLog.md ChangeLog.md.old
echo "# MeasurementKit $new_version [`date +%Y-%m-%d`]" > ChangeLog.md
echo "" >> ChangeLog.md
cat ChangeLog.md.old >> ChangeLog.md
rm ChangeLog.md.old
measurement-kit-0.7.1/build/sign 0000775 0000000 0000000 00000000171 13153561626 0016625 0 ustar 00root root 0000000 0000000 #!/bin/sh
set -e
while [ $# -gt 0 ]; do
gpg -u 738877AA6C829F26A431C5F480B691277733D95B -b --armor $1
shift
done
measurement-kit-0.7.1/build/spec/ 0000775 0000000 0000000 00000000000 13153561626 0016672 5 ustar 00root root 0000000 0000000 measurement-kit-0.7.1/build/spec/Catch 0000664 0000000 0000000 00000000413 13153561626 0017635 0 ustar 00root root 0000000 0000000 pkg_name=Catch
pkg_repository=https://github.com/philsquared/Catch.git
pkg_branch_or_tag=v1.10.0
pkg_steps=install
pkg_install() {
echo "Installing $pkg_name header $pkg_branch_or_tag in MK sources"
cp single_include/catch.hpp ../../../include/private/ext
}
measurement-kit-0.7.1/build/spec/builtin_ca_bundle 0000664 0000000 0000000 00000001040 13153561626 0022252 0 ustar 00root root 0000000 0000000
pkg_name=builtin_ca_bundle
pkg_repository=""
pkg_branch_or_tag="2017-06-07"
pkg_steps="install"
pkg_install() {
wget https://curl.haxx.se/ca/cacert-$pkg_branch_or_tag.pem
ofile="src/libmeasurement_kit/net/builtin_ca_bundle.cpp"
echo "Installing cacert-$pkg_branch_or_tag.pem in MK sources"
./build/bundle-ca $pkg_branch_or_tag cacert-$pkg_branch_or_tag.pem $ofile
clang-format -i $ofile
# Also save a copy that would be used for regress testing
cp cacert-$pkg_branch_or_tag.pem test/fixtures/saved_ca_bundle.pem
}
measurement-kit-0.7.1/build/spec/citrus 0000664 0000000 0000000 00000000422 13153561626 0020124 0 ustar 00root root 0000000 0000000 pkg_name=citrus
pkg_repository=https://github.com/openbsd/src
pkg_branch_or_tag=master
pkg_steps=install
pkg_install() {
cp lib/libc/citrus/citrus_ctype.h ../../../include/private/portable
cp lib/libc/citrus/citrus_utf8.c ../../../src/libmeasurement_kit/portable
}
measurement-kit-0.7.1/build/spec/geoip 0000664 0000000 0000000 00000000527 13153561626 0017724 0 ustar 00root root 0000000 0000000 pkg_name=geoip
pkg_repository=https://github.com/maxmind/geoip-api-c.git
pkg_branch_or_tag=v1.6.11
# Fix for the "missing _rpl_malloc() symbol" issue when cross-linking
# See
export ac_cv_func_malloc_0_nonnull=yes
export ac_cv_func_realloc_0_nonnull=yes
measurement-kit-0.7.1/build/spec/http-parser 0000664 0000000 0000000 00000000476 13153561626 0021075 0 ustar 00root root 0000000 0000000 pkg_name=http-parser
pkg_repository=https://github.com/nodejs/http-parser.git
pkg_branch_or_tag=v2.7.1
pkg_steps=install
pkg_install() {
echo "Installing $pkg_name files $pkg_branch_or_tag in MK sources"
cp http_parser.h ../../../include/private/ext
cp http_parser.c ../../../src/libmeasurement_kit/ext
}
measurement-kit-0.7.1/build/spec/json 0000664 0000000 0000000 00000000367 13153561626 0017574 0 ustar 00root root 0000000 0000000 pkg_name=json
pkg_repository=https://github.com/nlohmann/json.git
pkg_branch_or_tag=v2.1.1
pkg_steps=install
pkg_install() {
echo "Installing $pkg_name header $pkg_tag in MK sources"
cp src/json.hpp ../../../include/measurement_kit/ext
}
measurement-kit-0.7.1/build/spec/libevent 0000664 0000000 0000000 00000000451 13153561626 0020425 0 ustar 00root root 0000000 0000000 pkg_name=libevent
pkg_repository=https://github.com/libevent/libevent
pkg_branch_or_tag=patches-2.1
pkg_tip=e7ff4ef2b4fc950a765008c18e74281cdb5e7668
export CPPFLAGS="$CPPFLAGS -I$pkg_prefix/$pkg_cross/$pkg_cross_arch/include"
export LDFLAGS="$LDFLAGS -L$pkg_prefix/$pkg_cross/$pkg_cross_arch/lib"
measurement-kit-0.7.1/build/spec/libressl 0000664 0000000 0000000 00000000154 13153561626 0020434 0 ustar 00root root 0000000 0000000 pkg_name=libressl
pkg_repository=https://github.com/libressl-portable/portable.git
pkg_branch_or_tag=v2.5.5
measurement-kit-0.7.1/build/spec/mk 0000664 0000000 0000000 00000000452 13153561626 0017225 0 ustar 00root root 0000000 0000000 pkg_name=measurement-kit
pkg_branch_or_tag=v0.7.1
_dd=${pkg_prefix}/${pkg_cross}/${pkg_cross_arch}
pkg_configure_flags="--disable-examples --disable-shared --disable-binaries --with-openssl=${_dd} --with-libevent=${_dd} --with-geoip=${_dd} $pkg_configure_flags"
pkg_make_install_rule=install-strip
measurement-kit-0.7.1/build/spec/strtonum 0000664 0000000 0000000 00000000722 13153561626 0020511 0 ustar 00root root 0000000 0000000
# Note: here the pkg_name is libressl such that we only need to clone once
# the library rather than multiple times for each "package" based on it
pkg_name=libressl
pkg_repository=https://github.com/libressl-portable/portable.git
pkg_branch_or_tag=v2.5.5
pkg_steps="autogen install"
pkg_install() {
echo "Installing strtonum.c $pkg_branch_or_tag in MK sources"
cp openbsd/src/lib/libc/stdlib/strtonum.c \
../../../src/libmeasurement_kit/portable
}
measurement-kit-0.7.1/build/spec/tls_verify 0000664 0000000 0000000 00000000544 13153561626 0021006 0 ustar 00root root 0000000 0000000 pkg_name=tls_verify
pkg_repository=""
pkg_branch_or_tag=master
pkg_steps="install"
pkg_install() {
echo "Installing tls/tls_verify.c $pkg_branch_or_tag in MK sources"
prefix=https://raw.githubusercontent.com/libressl-portable/openbsd
wget $prefix/$pkg_branch_or_tag/src/lib/libtls/tls_verify.c
mv tls_verify.c src/libmeasurement_kit/ext
}
measurement-kit-0.7.1/build/tarball 0000775 0000000 0000000 00000001431 13153561626 0017306 0 ustar 00root root 0000000 0000000 #!/bin/sh
set -e
if [ $# -ne 1 ]; then
echo "usage: $0 tag" 1>&2
exit 1
fi
tag=$1
if echo $tag | grep -q '^v'; then
v=`echo $tag | sed 's/^v//g'`
else
v=$tag
fi
# Nested directories so we're sure also install-sh is installed because it
# is not found in the parent or parent parent directory
git archive --prefix=measurement-kit-$v/ $tag > _mk.tgz
install -d a/b/c
(
cd a/b/c
tar -xf ../../../_mk.tgz
rm ../../../_mk.tgz
cd measurement-kit-$v
./autogen.sh --no-geoip # do not distribute the GeoIP database
cd ..
tar -czf measurement-kit-$v.tar.gz measurement-kit-$v
gpg -u 738877AA6C829F26A431C5F480B691277733D95B -b --armor measurement-kit-$v.tar.gz
)
mv a/b/c/measurement-kit-$v.tar.gz.asc .
mv a/b/c/measurement-kit-$v.tar.gz .
rm -rf a/b/c
measurement-kit-0.7.1/build/valgrind/ 0000775 0000000 0000000 00000000000 13153561626 0017546 5 ustar 00root root 0000000 0000000 measurement-kit-0.7.1/build/valgrind/openssl.supp 0000664 0000000 0000000 00000003011 13153561626 0022135 0 ustar 00root root 0000000 0000000 {
Memcheck:Addr4
fun:tls_check_name
fun:_ZNSt17_Function_handlerIFvN2mk5ErrorEP11buffereventEZNS0_3net11connect_sslES3_P6ssl_stSsSt8functionIS4_ENS0_3VarINS0_7ReactorEEENSA_INS0_6LoggerEEEEUlS1_S3_E_E9_M_invokeERKSt9_Any_dataOS1_OS3_
fun:mk_bufferevent_on_event
fun:bufferevent_run_deferred_callbacks_locked
fun:event_process_active_single_queue
fun:event_base_loop
fun:_ZN2mk8libevent11poller_loopIXadL_Z9event_newEEXadL_Z10event_freeEEXadL_Z9event_addEEXadL_Z19event_base_dispatchEEEEvNS_3VarI10event_baseEEPNS0_6PollerE
fun:_ZN2mk8libevent6Poller3runEv
fun:_ZL31____C_A_T_C_H____T_E_S_T____*
fun:_ZN5Catch8runTestsERKNS_3PtrINS_6ConfigEEE
fun:main
}
{
Memcheck:Addr4
fun:tls_check_name
fun:_ZNSt17_Function_handlerIFvN2mk5ErrorEP11buffereventEZNS0_3net11connect_sslES3_P6ssl_stSsSt8functionIS4_ENS0_3VarINS0_7ReactorEEENSA_INS0_6LoggerEEEEUlS1_S3_E_E9_M_invokeERKSt9_Any_dataOS1_OS3_
fun:mk_bufferevent_on_event
fun:bufferevent_run_deferred_callbacks_locked
fun:event_process_active_single_queue
fun:event_base_loop
fun:_ZN2mk8libevent11poller_loopIXadL_Z9event_newEEXadL_Z10event_freeEEXadL_Z9event_addEEXadL_Z19event_base_dispatchEEEEvNS_3VarI10event_baseEEPNS0_6PollerE
fun:_ZN2mk8libevent6Poller3runEv
fun:_ZN2mk7Reactor23loop_with_initial_eventESt8functionIFvvEE
fun:_ZL31____C_A_T_C_H____T_E_S_T____*
fun:_ZN5Catch8runTestsERKNS_3PtrINS_6ConfigEEE
fun:main
}
measurement-kit-0.7.1/build/valgrind/strlen.supp 0000664 0000000 0000000 00000006613 13153561626 0021774 0 ustar 00root root 0000000 0000000 {
Memcheck:Cond
fun:strlen
fun:length
fun:_ZSt13regex_replaceISt20back_insert_iteratorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEN9__gnu_cxx17__normal_iteratorIPKcS6_EENS1_12regex_traitsIcEEcET_SF_T0_SG_RKNS1_11basic_regexIT2_T1_EEPKSI_NSt15regex_constants15match_flag_typeE
fun:regex_replace >, __gnu_cxx::__normal_iterator >, std::__cxx11::regex_traits, char, std::char_traits, std::allocator >
fun:regex_replace, char, std::char_traits, std::allocator, std::char_traits, std::allocator >
fun:process_input_filepaths_impl<&check_variable_expanded, &mk::nettests::readline_, &mk::nettests::randomize_input_>
fun:_ZL30____C_A_T_C_H____T_E_S_T____37v
fun:invoke
fun:_ZN5Catch10RunContext20invokeActiveTestCaseEv
fun:_ZN5Catch10RunContext14runCurrentTestERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES7_
fun:_ZN5Catch10RunContext7runTestERKNS_8TestCaseE
fun:_ZN5Catch8runTestsERKNS_3PtrINS_6ConfigEEE
fun:_ZN5Catch7Session3runEv
fun:run
fun:main
}
{
Memcheck:Cond
fun:strlen
fun:length
fun:_ZSt13regex_replaceISt20back_insert_iteratorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEN9__gnu_cxx17__normal_iteratorIPKcS6_EENS1_12regex_traitsIcEEcET_SF_T0_SG_RKNS1_11basic_regexIT2_T1_EEPKSI_NSt15regex_constants15match_flag_typeE
fun:regex_replace >, __gnu_cxx::__normal_iterator >, std::__cxx11::regex_traits, char, std::char_traits, std::allocator >
fun:regex_replace, char, std::char_traits, std::allocator, std::char_traits, std::allocator >
fun:process_input_filepaths_impl
fun:_ZL30____C_A_T_C_H____T_E_S_T____37v
fun:invoke
fun:invoke
fun:invokeActiveTestCase
fun:runCurrentTest
fun:runTest
fun:_ZN5Catch8runTestsERKNS_3PtrINS_6ConfigEEE
fun:run
fun:run
fun:main
}
{
Memcheck:Cond
fun:strlen
fun:length
fun:_ZSt13regex_replaceISt20back_insert_iteratorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEN9__gnu_cxx17__normal_iteratorIPKcS6_EENS1_12regex_traitsIcEEcET_SF_T0_SG_RKNS1_11basic_regexIT2_T1_EEPKSI_NSt15regex_constants15match_flag_typeE
fun:regex_replace >, __gnu_cxx::__normal_iterator >, std::__cxx11::regex_traits, char, std::char_traits, std::allocator >
fun:regex_replace, char, std::char_traits, std::allocator, std::char_traits, std::allocator >
fun:process_input_filepaths_impl<&check_variable_expanded, &mk::nettests::readline_, &mk::nettests::randomize_input_>
fun:_ZL29____C_A_T_C_H____T_E_S_T____0v
fun:invoke
fun:invokeActiveTestCase
fun:_ZN5Catch10RunContext14runCurrentTestERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES7_
fun:_ZN5Catch10RunContext7runTestERKNS_8TestCaseE
fun:_ZN5Catch8runTestsERKNS_3PtrINS_6ConfigEEE
fun:_ZN5Catch7Session3runEv
fun:run
fun:main
}
measurement-kit-0.7.1/circle.yml 0000664 0000000 0000000 00000000232 13153561626 0016622 0 ustar 00root root 0000000 0000000 machine:
services:
- docker
general:
branches:
only:
- master
- stable
test:
override:
- ./build/ci/circle valgrind-clang
measurement-kit-0.7.1/configure.ac 0000664 0000000 0000000 00000004464 13153561626 0017137 0 ustar 00root root 0000000 0000000 # Part of measurement-kit .
# Measurement-kit is free software. See AUTHORS and LICENSE for more
# information on the copying conditions.
# Autoconf requirements
AC_INIT(measurement_kit, 0.7.1, bassosimone@gmail.com)
# information on the package
AC_CONFIG_SRCDIR([Makefile.am])
AC_CONFIG_MACRO_DIR([m4])
# Travis uses Ubuntu 12.04 where the default automake was 1.11 in which
# by default tests were run in serial mode; as such, the LOG_COMPILER hack
# used to run tests using Valgrind was not working because automake 1.11
# wasn't honouring the LOG_COMPILER definition in the Makefile.
#
# Force parallel tests to make sure we can run tests through Valgrind.
AM_INIT_AUTOMAKE([parallel-tests 1.11])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES])
LT_INIT
AC_CONFIG_HEADERS([config.h])
AM_CONDITIONAL([BUILD_TESTS], [test "yes" = "yes"]) # for now, build always
AC_CANONICAL_HOST
AC_PROG_INSTALL
# Must be before AC_PROG_CXX (see http://stackoverflow.com/questions/11703709)
MK_AM_ENABLE_COVERAGE
MK_AM_ADD_COVERAGE_FLAGS_IF_NEEDED
MK_AM_DISABLE_BINARIES
MK_AM_DISABLE_EXAMPLES
MK_AM_DISABLE_INTEGRATION_TESTS
MK_AM_DISABLE_TRACEROUTE
# See above comment
AC_PROG_CXX
if test "`uname`" != "Darwin"; then
# Must set -pthread before testing for -levent_pthreads
CFLAGS="$CFLAGS -pthread"
CXXFLAGS="$CXXFLAGS -pthread"
LDFLAGS="$LDFLAGS -pthread"
elif test "$cross_compiling" != yes; then
# On my macOS, /usr/local is not added automatically
CPPFLAGS="$CPPFLAGS -I/usr/local/include"
LDFLAGS="$LDFLAGS -L/usr/local/lib"
fi
MK_AM_CHECK_LIBC_FUNCS
MK_AM_OPENSSL
MK_AM_LIBEVENT
MK_AM_GEOIP
# checks for header files
# checks for types
# checks for structures
# checks for ca-bundle
MK_CHECK_CA_BUNDLE
# checks for compiler characteristics
CPPFLAGS="-I \$(top_srcdir)/include $CPPFLAGS"
CFLAGS="-Wall -Wextra -pedantic $CFLAGS"
CXXFLAGS="-Wall -Wextra -pedantic $CXXFLAGS"
# Force compiling the http_parser in non-strict mode. This allows us to test
# partially broken sites like mail.voila.fr that send spaces between the header
# key and the separator (i.e. ':').
CPPFLAGS="-DHTTP_PARSER_STRICT=0 $CPPFLAGS"
MK_AM_REQUIRE_C99
MK_AM_REQUIRE_CXX14
MK_AM_CXXFLAGS_ADD_WARNINGS
# checks for library functions
# checks for system services
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
MK_AM_PRINT_SUMMARY
measurement-kit-0.7.1/doc/ 0000775 0000000 0000000 00000000000 13153561626 0015406 5 ustar 00root root 0000000 0000000 measurement-kit-0.7.1/doc/api/ 0000775 0000000 0000000 00000000000 13153561626 0016157 5 ustar 00root root 0000000 0000000 measurement-kit-0.7.1/doc/api/common.md 0000664 0000000 0000000 00000003547 13153561626 0020002 0 ustar 00root root 0000000 0000000 # NAME
common — common functionality used by other modules
# LIBRARY
MeasurementKit (libmeasurement_kit, -lmeasurement_kit).
# SYNOPSIS
```C++
#include
```
# DESCRIPTION
The `common` module contains contains the following submodules:
- [aaa_base](common/aaa_base.md): include headers we always need
- [callback](common/callback.md): alias for writing callback functions more compactly
- [continuation](common/continuation.md): type of function used to restart a function that paused
- [delegate](common/delegate.md): member function overridable at runtime
- [error](common/error.md): definition of error class and of shared error codes
- [error_or](common/error_or.md): maybe-like object containing either a result or an error
- [every](common/every.md): call a functor every N seconds
- [has_global_factory](common/has_global_factory.md): template decorator to add a global, singleton factory to a class
- [lexical_cast](common/lexical_cast.md): lexical cast between scalar values
- [maybe](common/maybe.md): maybe-like monad
- [locked](common/locked.md): run function with mutex held
- [logger](common/logger.md): log messages
- [non_copyable](common/non_copyable.md): non copyable class
- [non_movable](common/non_movable.md): non movable class
- [parallel](common/parallel.md): allows to run continuations in parallel
- [platform](common/platform.md): get platform name
- [reactor](common/reactor.md): class for dispatching I/O events and timeouts
- [settings](common/settings.md): class containing test settings
- [settings_entry](common/settings_entry.md): an entry contained by the settings class
- [utils](common/utils.md): generic utility functions
- [var](common/var.md): shared smart pointer with null pointer checks
- [version](common/version.md): MeasurementKit version macro
# HISTORY
The `common` module appeared in MeasurementKit 0.1.0.
measurement-kit-0.7.1/doc/api/common/ 0000775 0000000 0000000 00000000000 13153561626 0017447 5 ustar 00root root 0000000 0000000 measurement-kit-0.7.1/doc/api/common/aaa_base.md 0000664 0000000 0000000 00000000560 13153561626 0021506 0 ustar 00root root 0000000 0000000 # NAME
aaa_base — Headers we always want to include.
# LIBRARY
MeasurementKit (libmeasurement_kit, -lmeasurement_kit).
# SYNOPSIS
```C++
#include
```
# STABILITY
2 - Stable
# DESCRIPTION
This module just pulls basic C/C++ headers needed by all other modules.
# HISTORY
The `aaa_base` header appeared in MeasurementKit 0.3.0.
measurement-kit-0.7.1/doc/api/common/callback.md 0000664 0000000 0000000 00000001031 13153561626 0021520 0 ustar 00root root 0000000 0000000 # NAME
Callback — Syntactic sugar for writing callbacks.
# LIBRARY
MeasurementKit (libmeasurement_kit, -lmeasurement_kit).
# SYNOPSIS
```C++
#include
namespace mk {
template using Callback = std::function;
}
```
# STABILITY
2 - Stable
# DESCRIPTION
The `Callback` alias allows to more compactly writing callbacks and SHOULD be
used to indicate one-shot callbacks instead of `std::function`.
# HISTORY
The `Callback` alias appeared in MeasurementKit 0.2.0.
measurement-kit-0.7.1/doc/api/common/continuation.md 0000664 0000000 0000000 00000001105 13153561626 0022500 0 ustar 00root root 0000000 0000000 # NAME
Continuation — Syntactic sugar for functions that resume a paused function.
# LIBRARY
MeasurementKit (libmeasurement_kit, -lmeasurement_kit).
# SYNOPSIS
```C++
#include
namespace mk {
template
using Continuation = std::function)>;
}
```
# STABILITY
2 - Stable
# DESCRIPTION
The `Continuation` alias allows to more compactly express a function that
resumes another function that has paused waiting for explicit continuation.
# HISTORY
The `Continuation` alias appeared in MeasurementKit 0.2.0.
measurement-kit-0.7.1/doc/api/common/delegate.md 0000664 0000000 0000000 00000005000 13153561626 0021536 0 ustar 00root root 0000000 0000000 # NAME
Delegate — Function that can modify itself when used as a method.
# LIBRARY
MeasurementKit (libmeasurement_kit, -lmeasurement_kit).
# SYNOPSIS
```C++
#include
namespace mk {
template class Delegate_ {
public:
Delegate_();
template Delegate_(F);
Delegate_(std::function);
void operator=(std::function);
template void operator=(F);
void operator=(std::nullptr_t);
operator bool();
template void operator()(Args&& ...);
};
template
using Delegate = Delegate_;
}
```
# STABILITY
2 - Stable
# DESCRIPTION
The `Delegate` template class is a `std::function` like class that [can
change itself without triggering memory errors](https://github.com/measurement-kit/measurement-kit/issues/111).
The class is actually implemented using the `Delegate_` class that implements a
`std::function<>` with the possibility of changing itself and by the `Delegate` alias
that provides syntactic sugar for writing less when declaring delegates.
Constructors allow to construct the `Delegate`. The empty constructor creates an
empty function that raises `std::bad_function_call` if called. The templated
constructor allows to assign a lambda expression to this `Delegate`. Finally, the
function constructor allows to assign a `std::function<>` to this `Delegate`. Both
the templated and the function constructor shall fail at compile time if it is
not possible to initialize the `Delegate` using the lambda or the function.
The assignment operators allow to reassign the underlying function wrapped by
a `Delegate`. It is safe to call these operators to override the function that
the `Delegate` wraps from within the body of the delegate itself. The function
assignment operator overrides the underlying function with a newly specified
`std::function<>`. The templated assignment operator overrides the underlying
function with a lambda expression. The `nullptr` assignment operator resets
the underlying function; calling again the `Delegate` would then result into
a `std::bad_function_call` exception. Both the templated and the lambda assignments
would fail at compile time if types are not compatible.
The bool operator returns true if the underlying function is callable and false
if attempting to call the delegate would raise `std::bad_function_call`.
The call operator allows to call the `Delegate`.
# HISTORY
The `Delegate` template class appeared in MeasurementKit 0.2.0.
measurement-kit-0.7.1/doc/api/common/error.md 0000664 0000000 0000000 00000016522 13153561626 0021130 0 ustar 00root root 0000000 0000000 # NAME
Error — Represent and handle errors.
# LIBRARY
MeasurementKit (libmeasurement_kit, -lmeasurement_kit).
# SYNOPSIS
```C++
#include
namespace mk {
class Error : public std::exception {
public:
Error();
Error(int code);
Error(int code, std::string reason);
Error(int code, std::string reason, Error child);
operator bool() const;
bool operator==(int code);
bool operator==(Error error);
bool operator!=(int code);
bool operator!=(Error error);
std::string as_ooni_error();
const chat *what() const noexcept override;
std::vector> child_errors;
int code = 0;
std::string reason;
};
#define MK_DEFINE_ERR(code_, ClassName_, reason_) \
class ClassName_ : public Error { \
public: \
ClassName_() : Error(code_, reason_) {} \
ClassName_(std::string s) : Error(code_, reason_) { \
this->reason += " "; \
this->reason += s; \
} \
};
MK_DEFINE_ERR(0, NoError, "")
MK_DEFINE_ERR(1, GenericError, "")
MK_DEFINE_ERR(2, NotInitializedError, "")
MK_DEFINE_ERR(3, ValueError, "")
MK_DEFINE_ERR(4, MockedError, "")
MK_DEFINE_ERR(5, JsonParseError, "")
MK_DEFINE_ERR(6, JsonKeyError, "")
MK_DEFINE_ERR(7, JsonDomainError, "")
MK_DEFINE_ERR(8, FileEofError, "")
MK_DEFINE_ERR(9, FileIoError, "")
#define MK_ERR_NET(x) (1000 + x)
#define MK_ERR_DNS(x) (2000 + x)
#define MK_ERR_HTTP(x) (3000 + x)
#define MK_ERR_TRACEROUTE(x) (4000 + x)
#define MK_ERR_MLABNS(x) (5000 + x)
#define MK_ERR_OONI(x) (6000 + x)
#define MK_ERR_REPORT(x) (7000 + x)
#define MK_ERR_NDT(x) (8000 + x)
}
```
# STABILITY
2 - Stable
# DESCRIPTION
The `Error` class represents an error. It is a derived class of `std::exception`
so that it could be thrown and catched as an exception. (In general in MeasurementKit
we prefer passing errors to callbacks rather than throwing them as exceptions, but
there are some cases where throwing makes sense.)
The `Error` class has four constructors. The empty constructor constructs an error
with error code equal to zero (a special value used to indicate that no error has
actually occurred). The constructor with error code allows to set the error code that
is wrapped by an error; a nonzero error code indicates failure. The constructor
with error code and reason allows to set both error code and a reason string; at the
moment the reason string MUST be a [OONI error string](https://github.com/TheTorProject/ooni-spec/blob/master/data-formats/df-000-base.md#error-strings),
but this MAY change in the future. The constructor with error code, reason, and
underlying error allows also to specify that the current error was triggered by
another, underlying error.
The bool operator returns true if the `Error` code is nonzero and false if instead
the error code is zero. It can be used to quickly check whether an error occurred
as in the following snippet of code:
```C++
func([=](Error err, Result result) {
if (err) {
callback(err);
return;
}
process_result(result);
});
```
The equality and inequality operators allow to compare errors with error codes and
with errors. Currently, the comparison is *only* performed on the grounds of the
error code, hence different error classes having the same error code would be equal,
as shown in the following snippet of code:
```C++
MK_DEFINE_ERR(7, FooError, "");
MK_DEFINE_ERR(7, FoobarError, "");
REQUIRE((FooError() == FoobarError()));
```
The `as_ooni_error()` method allows to obtain the [OONI error string](https://github.com/TheTorProject/ooni-spec/blob/master/data-formats/df-000-base.md#error-strings) corresponding
to a specific MeasurementKit error. In the future the error returned by `as_ooni_error()`
MAY be different from the error stored in the `reason` field.
The `what()` method overrides the corresponding method of `std::exception`. It
returns the same string that `as_ooni_error()` returns.
The `child_errors` field is vector of smart pointers that MAY be set to
indicate that the current error was triggered by one or more underlying errors.
This should allow the programmer to properly layer errors. Thus, one could
learn that, say, a specific call to an API failed, and that the reason why that
failed was that it was not possible to establish a network connection, and
that the reason why that was not possible is that the DNS lookup failed.
The `code` and `reason` fields are, respectively, the integer error code
uniquely identifying the error and the related textual description. The latter
MAY NOT necessarily be equal to the value returned by `as_ooni_error()`.
The `MK_DEFINE_ERR` macro allows to compactly define a derived class Error by
specifying the error code, the class name, and the reason. In addition to
the vanilla error, a derived error has one extra constructor allowing to pass
additional textual context to be added to the reason.
The `measurement_kit/common.hpp` header uses `MK_DEFINE_ERR` to define *at least*
also the following generic error codes:
- *NoError*: this class MUST have error code equal to zero and SHOULD be used
to indicate that no error occurred
- *GenericError*: this class MAY be used to indicate a generic error but it
SHOULD NOT be widely used and specific errors SHOULD be preferred
- *NotInitializedError*: this is the error that SHOULD be used when accessing
a contained that requires initialization and was not primed
- *ValueError*: this error SHOULD be returned when it is not possible to convert
a specific value from one form to another (e.g. a string to integer)
- *MockedError*: this error SHOULD be used in regress tests when mocking the
failure of an API, unless specific other errors are required
- *JsonParseError*: indicates that it was not possible to parse a JSON
- *JsonKeyError*: indicates that a JSON object does not contain a specific key
To make sure that errors belonging to different MeasurementKit libraries are
disjoint, `measurement_kit/common.hpp` also defines offsets at which errors of each library
SHOULD start, as well as useful macros that takes codes relative to a specific
library and yields absolute error codes. Each MeasurementKit library is given
room for up to 1,000 error codes. At least the following offsets SHOULD be
defined by the `measurement_kit/common.hpp` header:
- 0 for the *common* lib
- 1,000 for the *net* lib
- 2,000 for the *dns* lib
- 3,000 for the *http* lib
- 4,000 for the *traceroute* lib
- 5,000 for the *mlabns* lib
- 6,000 for the *ooni* lib
- 7,000 for the *report* lib
- 8,000 for the *ndt* lib
# BUGS
Since the only integral value to which `Error` could be converted is `bool` there
are odd cases where the following statement:
```C++
REQUIRE(err == SomeError());
```
may fail because the two errors are different but `Catch` may still print as
reason for the failed error `1 == 1` because both classes evaluate to `true` (i.e. `1`)
even though they internally contain two different errors.
# HISTORY
The `Error` class appeared in MeasurementKit 0.1.0. The `ErrorContext` class, the
`MK_DEFINE_ERR` macro, and the macros to compute absolute error codes all appeared
in MeasurementKit 0.2.0. The `ErrorContext` class was removed in MK v0.7.0.
measurement-kit-0.7.1/doc/api/common/error_or.md 0000664 0000000 0000000 00000007144 13153561626 0021630 0 ustar 00root root 0000000 0000000 # NAME
ErrorOr — Maybe-like object containing type or error.
# LIBRARY
MeasurementKit (libmeasurement_kit, -lmeasurement_kit).
# SYNOPSIS
```C++
#include
namespace mk {
template class ErrorOr {
public:
ErrorOr();
ErrorOr(T);
ErrorOr(Error);
operator bool() const;
const T &as_value() const;
T &as_value();
Error as_error() const;
const T &operator*() const;
T &operator*();
const T *operator->() const;
T *operator->();
};
}
```
# STABILITY
2 - Stable
# DESCRIPTION
The `ErrorOr` template class wraps either a type `T` or an `Error`. It is
commonly used in MeasurementKit to return an error in synchronous functions
as shown in the following snippet:
```C++
ErrorOr res = get_result();
if (!res) {
callback(res.as_error());
return;
}
use_result(*res);
```
The first form of the constructor creates an `ErrorOr` object initialized
with error equal to `NotInitializedError`. This constructor allows
to write code like the following:
```C++
ErrorOr res;
// ...
/* Note that until assigned:
REQUIRE_THROWS_AS(*res, NotInitializedError());
REQUIRE(res.as_error() == NotInitializedError()); */
// ...
res = some_operation();
```
The second form of the constructor initializes the `ErrorOr` template
with a value. The third form of the constructor initialized the `ErrorOr`
template with an error.
The `operator bool()` method returns true if the underlying error object
has error code equal to zero, false otherwise. In the former case, we say
the `ErrorOr` contains a value, otherwise it contains an error.
The `as_value()` method returns a reference to the (possibly `const`)
underlying value, if the `ErrorOr` contains a value; otherwise, the
contained error is thrown.
The `as_error()` method returns the error field. Calling this method never
throws, regardless of whether the `ErrorOr` contains an error or
a value. This method is typically called to access the underlying error
once `operator bool()` has been used to ascertain that the `ErrorOr`
contains an error, as shown in the above snippet.
The `operator*()` method is an alias for `as_value()`.
The `operator->()` method returns a (possibly `const`) pointer to the
underlying field, if the `ErrorOr` contains a value; otherwise, the
contained error is thrown. This method could be useful to access fields
of a structure directly.
# EXAMPLE
```C++
#include
using namespace mk;
class Result {
public:
unsigned int foo = 17;
double bar = 3.14;
};
static ErrorOr generate_seventeen() {
return 17;
}
static ErrorOr generate_result() {
return Result{};
}
static ErrorOr generate_error() {
return MockedError();
}
int main() {
ErrorOr seventeen = generate_seventeen();
REQUIRE(!!seventeen);
REQUIRE(*seventeen == 17);
*seventeen = 42;
REQUIRE(*seventeen == 42);
ErrorOr result = generate_result();
REQUIRE(!!result);
REQUIRE(result->foo == 17);
REQUIRE(result->bar = 3.14);
result->foo = 42;
REQUIRE(result->foo == 42);
ErrorOr error = generate_error();
REQUIRE(!error);
REQUIRE_THROWS(*error);
REQUIRE_THROWS(error->foo);
REQUIRE(error.as_error() == MockedError());
}
```
# HISTORY
The `ErrorOr` template class appeared in MeasurementKit 0.2.0. This template class
was originally called `Maybe` but it was later renamed `ErrorOr` because there is
[a namesake class with similar purpose in LLVM](http://llvm.org/docs/doxygen/html/classllvm_1_1ErrorOr.html).
measurement-kit-0.7.1/doc/api/common/every.md 0000664 0000000 0000000 00000002125 13153561626 0021123 0 ustar 00root root 0000000 0000000 # NAME
every — call a functor every N seconds
# LIBRARY
MeasurementKit (libmeasurement_kit, -lmeasurement_kit).
# SYNOPSIS
```C++
#include
namespace mk {
template
void every(double delay, Var reactor, Callback callback,
StopPredicate stop_predicate, Callable callable);
}
```
# STABILITY
2 - Stable
# DESCRIPTION
The `every` template function calls `callable` (equivalent to
`std::function`) every `delay` seconds using the specified `reactor`
as long as `stop_predicate` (equivalent to `std::function`)
returns `false`. When `stop_predicate` returns `true`, the final `callback`
(equivalent to `std::function`) will be called with a value
of `NoError`. In case `delay` is negative, `callback` will be called
with a value of `ValueError()`.
In no event `callback` will be called immediately. Even in case of error,
its execution will be scheduled as deferred with the `reactor`.
# HISTORY
The `every` template class appeared in MeasurementKit 0.7.0.
measurement-kit-0.7.1/doc/api/common/has_global_factory.md 0000664 0000000 0000000 00000001243 13153561626 0023613 0 ustar 00root root 0000000 0000000 # NAME
HasGlobalFactory — Decorator to add global factory to a class
# LIBRARY
MeasurementKit (libmeasurement_kit, -lmeasurement_kit).
# SYNOPSIS
```C++
#include
namespace mk {
template typename class HasGlobalFactory {
public:
template static Var global(Args &&... args);
};
}
```
# STABILITY
2 - Stable
# DESCRIPTION
Given class `T`, you can make `T` inherit from `HasGlobalFactory` to add
the implementation of a global factory called `global()` to `T`.
The `Var` returned by `global` will be a singleton.
# HISTORY
The `HasGlobalFactory` template class appeared in MeasurementKit 0.7.0.
measurement-kit-0.7.1/doc/api/common/lexical_cast.md 0000664 0000000 0000000 00000003056 13153561626 0022430 0 ustar 00root root 0000000 0000000 # NAME
lexical_cast — Smart cast between different types.
# LIBRARY
MeasurementKit (libmeasurement_kit, -lmeasurement_kit).
# SYNOPSIS
```C++
#include
namespace mk {
template To lexical_cast(From f);
template ErrorOr lexical_cast_noexcept(From f);
}
```
# STABILITY
2 - Stable
# DESCRIPTION
The `lexical_cast` function template converts from scalar type `To` to scalar
type `From`, throwing `ValueError` if conversion could not be performed.
The `lexical_cast_noexcept` function template is like `lexical_cast` except that
it returns `ErrorOr` rather than throwing exception.
The underlying implementation of `lexical_cast` uses `std::stringstream` to
convert back and forth from types; hence, the possible conversions are limited
to the ones that are implemented by `std::stringstream`'s `<<` and `>>`.
# EXAMPLE
```C++
#include
int main() {
int num = lexical_cast("1024");
REQUIRE_THROWS(lexical_cast("foobar"));
ErrorOr eo = lexical_cast_noexcept("foobar");
REQUIRE(!eo);
REQUIRE_THROWS(*eo);
}
```
# BUGS
Since `std::stringstream` represents `true` using `1` and `false` using `0`, the
commonly established semantic that any nonzero value is `true` does not hold.
# HISTORY
The `lexical_cast` function template class appeared in MeasurementKit 0.2.0. There is
[a function template with similar functionality in
BOOST](http://www.boost.org/doc/libs/1_61_0/doc/html/boost_lexical_cast.html).
measurement-kit-0.7.1/doc/api/common/locked.md 0000664 0000000 0000000 00000001550 13153561626 0021233 0 ustar 00root root 0000000 0000000 # NAME
locked — Run callable with lock held
# LIBRARY
MeasurementKit (libmeasurement_kit, -lmeasurement_kit).
# SYNOPSIS
```C++
#include
namespace mk {
template auto locked(std::mutex &mutex, F &&fun);
template auto locked_global(F &&fun);
}
```
# STABILITY
2 - Stable
# DESCRIPTION
Syntactic sugar templates that held the lock on some mutex and then call
`fun` with the lock held. Any exception will be propagated.
The `locked` template function uses a specific mutex. The `locked_global`
function uses a global mutex.
The return value of `fun`, if any, will be propagated. For example:
```C++
int x = locked_global([]() { return 17; });
```
Both template functions take single ownership of the passed function.
# HISTORY
This family of template functions appeared in MeasurementKit 0.7.0.
measurement-kit-0.7.1/doc/api/common/logger.md 0000664 0000000 0000000 00000020502 13153561626 0021247 0 ustar 00root root 0000000 0000000 # NAME
Logger — Log messages processor
# LIBRARY
MeasurementKit (libmeasurement_kit, -lmeasurement_kit).
# SYNOPSIS
```C++
#include
// The numbers [0-31] are reserved for verbosity levels.
#define MK_LOG_WARNING 0
#define MK_LOG_INFO 1
#define MK_LOG_DEBUG 2
#define MK_LOG_DEBUG2 3
#define MK_LOG_VERBOSITY_MASK 31
// Number above 31 have different semantics:
#define MK_LOG_EVENT 32 // Event occurred (encoded as JSON)
namespace mk {
class Logger : public NonCopyable, public NonMovable {
public:
static Var make();
void logv(uint32_t level, const char *fmt, va_list ap);
void log(uint32_t level, const char *fmt, ...);
void warn(const char *fmt, ...);
void info(const char *fmt, ...);
void debug(const char *fmt, ...);
void set_verbosity(uint32_t v);
void increase_verbosity();
uint32_t get_verbosity();
void on_log(Delegate fn);
void on_eof(Delegate<> fn);
void on_event(Delegate fn);
void on_progress(Delegate fn);
void set_logfile(std::string path);
void progress(double);
void set_progress_offset(double offset);
void set_progress_scale(double offset);
static Var global();
~Logger();
};
/* Functions using the default logger: */
void log(uint32_T level, const char *fmt, ...);
void warn(const char *fmt, ...);
void info(const char *fmt, ...);
void debug(const char *fmt, ...);
void set_verbosity(uint32_t v);
void increase_verbosity();
uint32_t get_verbosity();
void on_log(Delegate fn);
void set_logfile(std::string path);
}
```
# DESCRIPTION
The `MK_LOG_XXX` macros allow to set verbosity levels and other
reserved values. Only the first four bits are used to represent levels
of verbosity, while other bits are used for other purposes.
The `Logger` class specifies how logs are processed. You can change the
function that receives logs. You can change the verbosity level. And
of course you can log messages as well.
The `make()` factory creates a logger wrapped by a shared pointer.
The `logv()`, `log()`, `warn()`, `info()`, and `debug()` methods allow to write
log messages. Specifically, `logv()` and `log()` take an explicit logging
level argument, while other functions provide it implicitly. Messages
are only written if the current verbosity level is not lower than the verbosity
level of the currently logged message. That is,
```C++
Var logger = Logger::make();
logger->set_verbosity(MK_LOG_INFO);
logger->info("This message will be printed");
logger->debug("This one won't");
```
The `set_verbosity()`, `increase_verbosity()` and `get_verbosity()` methods
allow to manage the verbosity level of the logger. The default verbosity
level is `MK_LOG_WARNING` meaning that messages with verbosity greater than
that are not logged by default.
The `on_log` method allow to either set or reset the function called
for each logging message. Such function is a delegate (i.e. the delegate
body can safely change the delegate itself) and takes in input the
verbosity level of the message and the message itself. The default log
function prints on the standard error output the severity (unless the
severity is INFO, in which case nothing is printed) followed by the log
message. For example:
```
warning: A warning message
A info message
debug: A debug message
debug: A debug2 message
```
To disable the log callback, pass `nullptr` to it.
The `on_eof()` method allows to register a function to be called when the
logger is about to be destroyed. You can call this function multiple times
to register multiple callbacks, if you wish.
By default `MK_LOG_EVENT` messages are passed to the log callback. But you
can route them to the event callback by specifying it using `on_event()`. In
such case, those messages will be passed to the event callback only,
meaning that the log callback will not be called for them and they will
not be written on the logfile. This behavior is meant to transition between
when events where passed to the log callback and a future where they will
be either ignored or passed to the event callback.
The `on_progress` method allows to register a delegate to receive
progress notifications from measurement-kit tests. A progress notification
is a tuple composed of a double (between 0.0 and 1.0) and a string: the
double represents the overall percentage of completion whereas the string
represents the operation currently in progress.
The `set_logfile` method instructs the logger to write a copy of each log
message into the specified log file. Setting the logfile has no impact on
logs written using `on_log` and *viceversa*. By default no log file is
specified. It is legal (albeit useless) to have a logger not attached to
any log file and whose `on_log` callback is `nullptr`.
The `progress` method is used to emit progress notifications.
The `set_progress_offset` and `set_progress_scale` methods allow to define,
respectively, the offset to be added to progress notifications and the
scale value to multiply the progress notification for. By default the offset
is 0.0 and the scale is 1.0. These two methods are useful to normalize the
progress emitted by individual operations (which see _their_ progress as
a number between 0.0 and 1.0) in the context of a more general progress; e.g.,
the `MultiNdt` test runs two NDT tests, one using a single TCP stream and
the other using three TCP streams. Both NDT tests sees their progress as
between 0.0 and 1.0 but the parent `MultiNdt` class sets the scale equal to
0.5 and the offset of the second NDT test equal to 0.5, so to normalize
the progress emitted by the child NDT tests.
The `global()` factory returns the default logger.
The destructor calls the functions registered using `on_eof`.
This module also includes syntactic sugar functions named like `Logger`
methods that call the namesake method of the default logger. That is:
```C++
mk::debug("Foobar"); // == mk::Logger::global()->debug("Foobar");
```
Internally, the logger implementation MUST be implemented to be thread
safe, i.e. it MUST be safe to invoke concurrently the logger from multiple
threads, *as far as* the consistency of the logger internals is
concerned. Note that this *does not mean at all* that the logger delegate
can safely access resources owned by another thread. In such case, it is
the programmer's responsibility than any relevant shared resources are
locked before they are used, i.e., you MUST use this pattern:
```C++
mk::on_log([=](uint32_t level, const char *message) {
resource.acquire_lock();
// Then you can process the message
});
```
Also note that the implementation MAY use a shared internal buffer meaning that
log messages SHOULD either immediately consumed or cached if delayed consumption
is planned. Failure to do so would possibly lead to the latest produced log
message printed more than once. Instead use this pattern:
```C++
mk::on_log([=](uint32_t level, const char *message) {
resource.acquire_lock();
std::string copy{message};
resource.sched_deferred_consumption(level, copy);
});
```
Also, note that, being thread safe, the logger MUST lock its internals before
emitting a log message. Thus, you MUST NOT call the logger from a logger callback
because this MAY result in deadlock or internal buffer corruption, depending on
the mutex implementation. Ideally, the log message should be printed on some
file, or you should save it as described above and then schedule a delayed call to
properly process the message, if processing it is going to be slow.
You MUST NOT set up the logger from multiple thread contexts, because methods
that set callbacks, change the logger behavior, etc., are not thread safe.
# EXAMPLE
```C++
#include
using namespace mk;
int main() {
Var logger = Logger::make();
logger->set_verbosity(MK_LOG_DEBUG);
logger->on_log([](uint32_t level, const char *log_line) {
printf("<%d> %s\n", level, log_line);
});
logger->debug("Format string: %s", "but also arguments");
logger->info("Just like printf");
logger->warn("Use this for important messages");
}
```
# BUGS
If the logfile could not be open, or written, the error is silently
discarded (i.e. no exceptions thrown, no return values).
# HISTORY
The `Logger` class appeared in MeasurementKit 0.1.0.
measurement-kit-0.7.1/doc/api/common/maybe.md 0000664 0000000 0000000 00000002213 13153561626 0021064 0 ustar 00root root 0000000 0000000 # NAME
Maybe — The Maybe monad is back
# LIBRARY
MeasurementKit (libmeasurement_kit, -lmeasurement_kit).
# SYNOPSIS
```C++
#include
namespace mk {
template typename class Maybe {
public:
Maybe();
Maybe(T &&t);
T &operator*();
operator bool() const;
};
} // namespace mk
```
# STABILITY
2 - Stable
# DESCRIPTION
The `Maybe` monad either contains an instance of `T` or is empty.
The first form of the constructor creates an empty monad.
The second form of the constructor creates a monad that owns the value `t`.
If you dereference a monad and the monad contains a value, such value is
returned. Otherwise a runtime exception is thrown.
To check whether the monad contains a value of not, evaluate it in a
boolean context. If the result of such evaluation is true, the monad
contains a type, otherwise it is empty.
# HISTORY
The `Maybe` template class was part of earlier version of MK and such
implementation was later renamed `ErrorOr`, because it was more similar
to an `ErrorOr` than to a proper `Maybe` monad. We have added back the
`Maybe` monad with its proper semantic in MK v0.7.0.
measurement-kit-0.7.1/doc/api/common/non_copyable.md 0000664 0000000 0000000 00000001723 13153561626 0022444 0 ustar 00root root 0000000 0000000 # NAME
NonCopyable — Forbids copyability
# LIBRARY
MeasurementKit (libmeasurement_kit, -lmeasurement_kit).
# SYNOPSIS
```C++
#include
namespace mk {
class NonCopyable {
public:
NonCopyable(NonCopyable &) = delete;
NonCopyable &operator=(NonCopyable &) = delete;
};
}
```
# DESCRIPTION
Forbids copyability. You should in general
forbid copyability when you hold low-level pointers that should
be `free()`d just once. To do this, just inherit from
`NonCopyable` as in:
```C++
/* Here inheriting from NonCopyable you guarantee that you cannot make
by mistake copies of the raw pointer `bar`. Doing that would cause
`delete` to be called more than once, which is a memory error. */
public class Foo : public mk::NonCopyable {
public:
Foo() {
bar = new Bar;
}
~Foo() {
delete bar;
}
private:
Bar *bar = nullptr;
};
```
# HISTORY
`NonCopyable` appeared in MeasurementKit 0.1.0.
measurement-kit-0.7.1/doc/api/common/non_movable.md 0000664 0000000 0000000 00000002445 13153561626 0022275 0 ustar 00root root 0000000 0000000 # NAME
NonMovable — Forbids movability
# LIBRARY
MeasurementKit (libmeasurement_kit, -lmeasurement_kit).
# SYNOPSIS
```C++
#include
namespace mk {
class NonMovable {
public:
NonMovable(NonMovable &&) = delete;
NonMovable &operator=(NonMovable &&) = delete;
};
}
```
# DESCRIPTION
Forbids movability. You should
forbid movability for example when under the hood the object's
`this` is passed to a C callback as an opaque pointer, thus binding
the specific value of `this` to the registered low-level callback.
To do this, just inherit from `NonMovable` as in:
```C++
/* Setting the class as non movable is crucial here because the
constructor passes `this` to a low level API which would presumably
use it to call `low_level_notification()`. Therefore, we should
not allow to move this object, because moving implies destroying
the previous object and moving its content to a new one. This would
invalidate the `this` pointer passed to the low level API and thus
after the move code of a delected object would be invoked. */
public class Foo : public mk::NonMovable {
public:
Foo() {
low_level_api(this);
}
void low_level_notification() { /* do something */ }
};
```
# HISTORY
`NonMovable` appeared in MeasurementKit 0.1.0.
measurement-kit-0.7.1/doc/api/common/parallel.md 0000664 0000000 0000000 00000002073 13153561626 0021567 0 ustar 00root root 0000000 0000000 # NAME
Parallel — allows running Continuations in parallel
# LIBRARY
MeasurementKit (libmeasurement_kit, -lmeasurement_kit).
# SYNOPSIS
```C++
#include
namespace mk {
void parallel(srd::vector> input, Callback cb);
}
```
# STABILITY
2 - Stable
# DESCRIPTION
The `parallel` function runs all the continuations in the input vector in
parallel and invokes the final callback when all the continuations have
terminated their job (i.e. each continuation's callback was called).
The overall error passed to the callback `cb` is `NoError` only if all the
continuation's callbacks succeeded, `ParallelOperationError` otherwise. Check
the `child_errors` field of the `Error` passed to `cb` to know whether each
continuation failed (and why) or succeeded.
# BUGS
The `parallel` implementation assumes that all the continuations will run
in the same thread, therefore the state used to decide when all continuations
have completed is not thread safe.
# HISTORY
The `parallel` function appeared in MeasurementKit 0.3.0.
measurement-kit-0.7.1/doc/api/common/platform.md 0000664 0000000 0000000 00000000740 13153561626 0021616 0 ustar 00root root 0000000 0000000 # NAME
platform — Get current platform
# LIBRARY
MeasurementKit (libmeasurement_kit, -lmeasurement_kit).
# SYNOPSIS
```C++
#include
const char *mk_platform(void);
```
# STABILITY
2 - Stable
# DESCRIPTION
The `mk_platform` C-linkage function returns the name of the current
platform. The name will be one of:
- android
- ios
- linux
- macos
- unknown
- windows
# HISTORY
The `platform.h` header appeared in MeasurementKit 0.7.0.
measurement-kit-0.7.1/doc/api/common/reactor.md 0000664 0000000 0000000 00000020567 13153561626 0021442 0 ustar 00root root 0000000 0000000 # NAME
Reactor — Dispatcher of I/O events
# LIBRARY
MeasurementKit (libmeasurement_kit, -lmeasurement_kit).
# SYNOPSIS
```C++
#include
namespace mk {
#define MK_POLLIN /* Unspecified; used by pollfd() */
#define MK_POLLOUT /* Unspecified; used by pollfd() */
class Reactor {
public:
static Var make();
static Var global();
void call_later(double delay, Callback<> &&cb);
void call_soon(Callback<> &&cb);
void run_with_initial_event(Callback<> &&cb);
void run();
void stop();
void pollfd(
socket_t sockfd,
short events,
double timeout,
Callback &&callback,
);
// Backward compatibility aliases
void loop() { run(); }
void break_loop() { stop(); }
void loop_with_initial_event(Callback<> &&func) {
run_with_initial_event(std::move(func));
}
void pollfd(socket_t sockfd, short events, Callback &&cb,
double timeout = -1.0) {
pollfd(sockfd, events, timeout, std::move(cb));
}
}
/* Functional interface (by default using the global reactor): */
void call_later(
double delay,
Callback<> callback,
Var reactor = Reactor::global()
);
void call_soon(
Callback<> callback,
Var reactor = Reactor::global()
);
// Syntactic sugar
void run(Var reactor = Reactor::global()) {
reactor->run();
}
void stop(Var reactor = Reactor::global()) {
reactor->stop();
}
void run_with_initial_event(Callback<> &&func,
Var reactor = Reactor::global()) {
reactor->run_with_initial_event(std::move(func));
}
// Backward compatibility aliases
void loop(Var reactor = Reactor::global()) {
run(reactor);
}
void break_loop(Var reactor = Reactor::global()) {
stop(reactor);
}
void loop_with_initial_event(Callback<> &&func,
Var reactor = Reactor::global()) {
run_with_initial_event(std::move(func));
}
```
# STABILITY
2 - Stable
# DESCRIPTION
The `Reactor` abstract interface dispatches I/O events. Most MeasurementKit
objects refer to a specific `Reactor` object.
The `make()` and `global()` factories return a reactor allocated
on the heap whose lifecycle is manager using a `Var<>` smart pointer.
Specifically, `make()` allocates a new reactor and `global()` returns
a reference to the global reactor.
You can schedule a callback to be called immediately using the `call_soon`
method that takes such callback as its first argument.
You can schedule a callback to be called after a specific number
of seconds using `call_later`. The first argument is the number of
seconds to wait before calling the callback. The second argument
is the callback itself.
You can ask the reactor to wait for I/O on a specific socket
descriptor using `pollfd`. In general, beware that this MAY be less
efficient than using the `Transport` API (see the `net` package)
for doing asynchronous I/O. To do so, use the `pollfd` overloaded
family of methods:
The first overload of `pollfd` is the preferred form and takes the
following arguments. The first argument is a socket file descriptor.
The second argument is the bitmaks of events you want to monitor
for; it can be `MK_POLLIN`, to wait for the socket being readable,
`MK_POLLOUT` to wait for the socket being writable, or `MK_POLLIN
| MK_POLLOUT` to wait for both. The third argument is the timeout
after which you want to stop waiting for I/O. Pass a negative value
to indicate that you don't want any timeout checking. The fourth
argument is the callback to be called when either the socket is
ready for I/O or there has been a timeout. The first argument passed
to the callback indicates whether there was an error (typically
`TimeoutError`) or not (in such case the error will be `NoError`).
The second argument passed to the callback indicate whether the
socket is readable (`MK_POLLIN`), writable (`MK_POLLOUT`), or both
(`MK_POLLIN | MK_POLLOUT`).
In second overload of `pollfd` the callback is the third argument and
the timeout is optional and is the fourth argument. This overload is
implemented by calling the previous overload with swapped third and fourth
arguments. This overload is meant as a convenience when you don't want
to specify any timeout. It also preserves backward compatibility with
versions of MeasurementKit lower than v0.7.0.
Other available methods (typically to be called in `main()`) are:
The `run_with_initial_event` method runs the reactor and calls the specified
callback when the reactor is running. This is a blocking method that does
not return until you call the `stop` method. Calling this method when the
reactor is already running causes an exception to be thrown.
The `run` method runs the reactor. This is a blocking method that does not
return until you call the `stop` method. Calling this method when the reactor
is already running causes an exception to be thrown.
The `stop` method stop the reactor. This is an idempotent method that you
can call many times. This method MAY return while the reactor is still
running. That is, it only tells the reactor to stop but it does not provide
the guarantee that, when it returns, the reactor is already stopped.
The `loop_with_initial_event`, `loop`, and `break_loop` methods are deprecated
aliases for, respectively, `run_with_initial_event`, `run`, and `stop`.
The `get_event_base` is a deprecated method that returns the underlying
`event_base` used by the reactor. It is deprecated because it exposes in
great detail our dependency on libevent. Ideally, this method should be
a method of the specific implementation of the reactor, available only
when you downcast from reactor to its specific implementation.
In addition, this module exposes also syntactic sugar functions:
The `call_soon`, `call_later`, `loop_with_initial_event`, `loop`, `loop_once`,
`break_loop`, `run_with_initial_event`, `run`, and `stop` functions are
syntactic sugar that call the respective method of the global reactor (i.e.
the one obtained with `Reactor::make()`.
# GUARANTEES
1. it is safe to call `global` and `global_remote` concurrently from
multiple threads.
2. all reactor methods are thread safe.
3. the reactor MAY actually be a proxy for a real reactor multiplexing I/O
running from a background thread. In such case, disposing of the foreground
object has no effect on the callbacks scheduled in the real reactor. To
guarantee this, the signature of functions taking callbacks is such that
they must be moved (explicitly or implicitly), thus giving their ownership
to the (possibly running in a background thread) reactor. As a result,
once a callback is scheduled, there should be no shared state between
different threads. We recommend, in such case, to move any state you
might need into the callback closure, e.g.:
```C++
reactor->call_soon([state = std::move(state)]() {
// Possibly running in the background I/O thread. Has single
// ownership of the shared state.
});
```
# CAVEATS
1. the `pollfd` interface is typically less efficient that using the
`Transport` based interface implemented in `net`.
2. callbacks MAY be called from another thread context.
3. there is currently no way to know whether the reactor will run the
callbacks in the same or in another thread context.
4. calling `stop` before calling `run` has no effect and will typically lead
to your program hanging for an infinite amount of time. When you want to
run "initialization" actions in the context of the I/O loop you should use
instead the following pattern:
```C++
int main(int argc, char **argv) {
Reactor reactor = Reactor::make();
// Allocate objects on the stack before calling the blocking
// `run_with_initial_event` method of `reactor`.
Object obj{reactor};
Foo bar;
// Capture by reference (`&`) because this method is blocking
reactor->run_with_initial_event([&]() {
obj.action([&]() {
bar.baz();
reactor->stop();
});
});
}
```
# HISTORY
The `Reactor` class appeared in MeasurementKit 0.1.0, named `Poller`.
It was renamed `Reactor` in MeasurementKit 0.2.0. As of MK v0.2.0,
the `Poller` still exists as a specific implementation of the
`Reactor` interface described in this manual page. The `Reactor`
was significantly improved as part of MK v0.4.0 and MK v0.7.0.
measurement-kit-0.7.1/doc/api/common/settings.md 0000664 0000000 0000000 00000002272 13153561626 0021634 0 ustar 00root root 0000000 0000000 # NAME
Settings — Map from string to scalar type
# LIBRARY
MeasurementKit (libmeasurement_kit, -lmeasurement_kit).
# SYNOPSIS
```C++
namespace mk {
class Settings : public std::map {
public:
using std::map::map;
template T get(std::string key, T defval);
template ErrorOr get_noexcept(std::string key, T defval);
};
}
```
# STABILITY
1 - Experimental
# DESCRIPTION
`Settings` is an extended `std::map` able to map string to any scalar type. We
use `SettingsEntry` to implement a generic scalar type container.
In addition to the typical methods of `std::map`, `Settings` also features
the `get()` and the `get_noexcept()` method.
The `get()` method returns the value
at `key` if available, otherwise the default value `defval`. An exception may
be raised if it is not possible to convert the value associated to `key`
to type `T`.
The `get_noexcept()` method is like `get()` except that it does
not throw exceptions and instead it returns a `ErrorOr` type.
# HISTORY
The `Settings` class appeared in MeasurementKit 0.1.0. Support for mapping to
any type was added in MeasurementKit 0.2.0.
measurement-kit-0.7.1/doc/api/common/settings_entry.md 0000664 0000000 0000000 00000003136 13153561626 0023055 0 ustar 00root root 0000000 0000000 # NAME
SettingsEntry — Generic scalar type
# LIBRARY
MeasurementKit (libmeasurement_kit, -lmeasurement_kit).
# SYNOPSIS
```C++
namespace mk {
class SettingsEntry : public std::string {
public:
template SettingsEntry(In value);
template Out as();
template ErrorOr as_noexcept();
};
}
```
# STABILITY
1 - Experimental
# DESCRIPTION
`SettingsEntry` holds a generic scalar type. Under the hood, `SettingsEntry`
is a string and `std::stringstream` is used to convert to/from types; this is
similar to what we also do with `mk::lexical_cast()`.
The constructor takes in input a scalar type and internally serializes it
as a string. Conversion errors should be detected at compile time, hence this
method should not throw any exception.
The `as()` method allows to convert the internally serialized value to
the specified `Out` type. This would raise `ValueError` if either conversion
is not possible or not all the internally serialized string is consumed
by the conversion.
The `as_noexcept()` method is just like `as()` except that it returns `ErrorOr`
rather than throwing exception on error.
# BUGS
Since `std::stringstream` represents `true` using `1` and `false` using `0`, the
commonly established semantic that any nonzero value is `true` does not hold.
Additionally, this means that the string `"true"` is not going to be parsed
as a true value and likewise `"false"` is not going to be parsed as a false
value. This behavior is not what one whould expect.
# HISTORY
The `SettingsEntry` class appeared in MeasurementKit 0.2.0.
measurement-kit-0.7.1/doc/api/common/utils.md 0000664 0000000 0000000 00000005163 13153561626 0021136 0 ustar 00root root 0000000 0000000 # NAME
utils — Utility functions
# LIBRARY
MeasurementKit (libmeasurement_kit, -lmeasurement_kit).
# SYNOPSIS
```C++
namespace mk {
void timeval_now(timeval *);
double time_now();
void utc_time_now(struct tm *);
ErrorOr timestamp(const struct tm *);
timeval *timeval_init(timeval *, double);
Error parse_iso8601_utc(std::string ts, std::tm *tmb);
ErrorOr> slurpv(std::string);
ErrorOr slurp(std::string);
Error overwrite_file(std::string path, std::string content);
bool startswith(std::string s, std::string p);
bool endswith(std::string s, std::string p);
}
```
# STABILITY
1 - Experimental
# DESCRIPTION
The `timeval_now` function fills the `timeval` structure passed as
argument with the current time. The precision should be up to the microsecond
on most Unix systems.
The `time_now` function returns the current time as double. The double is
obtained converting a `timeval` struct to double and hence should have
precision of the microsecond on most Unix systems.
The `utc_time_now()` function should fill the `tm` structure passed as
argument with the current time in UTC.
The `timestamp()` function should convert the `tm` structure passed as
argument into a string properly formatted according to ISO8601. The return
value is wrapped using `ErrorOr<>` because converting to string may fail.
The `timeval_init()` function initializes the `timeval` structure passed
as argument using the `double` passed as argument. This is often used
to arm timers passed internally to libevent. For this reason, in accordance
with libevent conventions, if the `double` argument is negative, `nullptr`
is returned. Typical safe usage looks like this:
```C++
timeval tv, *tvp = timeval_init(&tv, delta);
libevent_api(/* some args... */, tvp);
```
The `parse_iso8601_utc()` function parses the string
`ts` formatted as ISO8601 (e.g. `"2012-01-02T03:04:05Z"`) into a `std::tm`
structure, which MUST NOT be `nullptr`. On success, `NoError()` is returned,
otherwise the code returns `ValueError()`.
The slurpv() and slurp() functions read the content of the file specified
as argument and return, respectively, a vector of chars containing the content
of the file and a string containing the content of the file, on success, and
an error in case of failure.
The `overwrite_file()` function creates (or truncates) the file at `path`
and writes `content` inside it. The return value is `NoError()` on success
or an error on failure.
The `startswith()` and `endswith()` functions tell you, respectively, whether
`s` starts (or ends) with `p`.
# HISTORY
The `utils.hpp` header was added in MeasurementKit 0.2.0.
measurement-kit-0.7.1/doc/api/common/var.md 0000664 0000000 0000000 00000004475 13153561626 0020573 0 ustar 00root root 0000000 0000000 # NAME
Var — Shared-pointer with null pointer check
# LIBRARY
MeasurementKit (libmeasurement_kit, -lmeasurement_kit).
# SYNOPSIS
```C++
#include
namespace mk {
template typename class Var : public std::shared_ptr {
public:
Var(T ptr);
Var();
void reset(T *ptr);
T *get();
T *operator->() const;
T &operator*() const;
template Var as();
static template Var make(Args &&... args);
};
}
```
# STABILITY
2 - Stable
# DESCRIPTION
`Var` template class is a drop-in replacement for the
standard library `std::shared_ptr` template. It reimplements common
`std::shared_ptr` operations by checking that the pointee is not
`nullptr`. Otherwise, a runtime exception is raised.
The first form of the constructor *owns* `ptr` and manages its life
cycle. The second form of the constructor initializes to `nullptr` the
internal pointer; attempting to dereference a `Var<>` initialized
by this form of the constructor raises a `std::runtime_error`.
The `reset()` method releases the previously pointed object and then
*owns* the object pointed by `ptr` and manages its life cycle. It is legal
to pass `nullptr` to this function; in such case further attempts to
access the pointee would result in `std::runtime_error` being raised.
The `get()` and `operator->()` methods return the pointee if non null and
throw `std::runtime_error` otherwise.
The `operator*()` method returns a reference to `*ptr` where `ptr` is the
pointee if the pointee is non null and throws `std::runtime_error` otherwise.
The `as()` method casts the pointee to type `R` if possible. If conversion
is not possible, the returned `Var<>` would point to a null pointer and hence
attempting to dereference it would result in `std::runtime_error`.
The static `make()` method is equivalent to:
```C++
Var t{new T{arguments...}};
```
except that, like for `std::make_shared`, only one allocation is performed
to allocate both the shared pointer control block and the pointee.
# CAVEAT
The `as()` method does not seem to preserve any custom deleter that may
have been passed to the original `Var<>`; this seems reasonable since the
new `Var<>` will delete another type of object (if the cast worked).
# HISTORY
The `Var` template class appeared in MeasurementKit 0.1.0.
measurement-kit-0.7.1/doc/api/common/version.md 0000664 0000000 0000000 00000003273 13153561626 0021463 0 ustar 00root root 0000000 0000000 # NAME
version — MeasurementKit version
# LIBRARY
MeasurementKit (libmeasurement_kit, -lmeasurement_kit).
# SYNOPSIS
```C++
#include
#define MK_VERSION "0.7.1"
#define MK_VERSION_FULL "v0.7.1-6-abcdef"
#define MEASUREMENT_KIT_VERSION MK_VERSION /* Backward compat. */
const char *mk_version(void);
const char *mk_version_full(void);
const char *mk_openssl_version(void);
const char *mk_libevent_version(void);
```
# STABILITY
2 - Stable
# DESCRIPTION
This header defines the `MK_VERSION` macro that allows the programmer
to know MeasurementKit version number. The `MK_VERSION_FULL` macro
contains the output of `git describe --tags` and is hence more precise
than the version contained by `MK_VERSION`. Note that the two version numbers
will be equal if the current build is a specific tag; otherwise, the version
with git tag will contain more precise information. Specifically it will
indicate the closest tag, the number of commits since that tag, and the HEAD
from which the current release has been built.
It also contains a *C linkage* function, `mk_version()` that can be used
to programmatically retrieve the library version number. The function has C
linkage so that it can be easily used from languages with foreign functions
interface. There is also `mk_version_full()` that returns the more
precise version containing the output of `git describe --tags`.
It also contains *C linkage* functions that tell you the version of OpenSSL
and libevent we are compiling measurement-kit with.
# HISTORY
The `version.h` header appeared in MeasurementKit 0.2.0. Support for
knowing the precise git tag and dependencies versions was added during the
v0.6 release cycle.
measurement-kit-0.7.1/doc/api/dns.md 0000664 0000000 0000000 00000016162 13153561626 0017273 0 ustar 00root root 0000000 0000000 # NAME
dns — DNS module
# LIBRARY
MeasurementKit (libmeasurement_kit, -lmeasurement_kit).
# SYNOPSIS
```C++
#include
namespace mk {
namespace dns {
void query(QueryClass dns_class,
QueryType dns_type,
std::string query_name,
Callback> callback,
Settings settings = {},
Var reactor = Reactor::global());
void resolve_hostname(std::string hostname,
Callback cb,
Settings settings = {},
Var reactor = Reactor::global(),
Var logger = Logger::global());
} // namespace dns
} // namespace mk
```
# STABILITY
2 - Stable
# DESCRIPTION
The `query()` function allows you to send DNS queries
and receive the corresponding responses.
The `dns_class` argument indicates the query class. At least
the following query classes are defined:
- *QueryClassId::IN*: this class represents the "internet" domain
Note that you can also pass the query class as string; e.g.,
the following would compile and run as expected:
```C++
mk::dns::query("IN", ...);
```
The `dns_type` argument indicates the query type. The following
query types are defined:
- *QueryTypeId::A*: the `query_name` argument must be a domain name and the result
would be the corresponding IPv4 address, if any.
- *QueryTypeId::AAAA*: the `query_name` argument must be a domain name and the result
would be the corresponding IPv6 address. if any.
- *QueryTypeId::PTR*: the `query_name` argument should be an IP address expressed
using the reverse `IN-ADDR` representation and the result would the corresponding
domain name, if any (see `EXAMPLES` section for examples).
- *QueryTypeId::REVERSE_A*: the `query_name` argument should be an IPv4 address and the
result would be the corresponding domain name, if any. This is a nonstandard
DNS query type and basically instructs the DNS library to create for you
the reverse `IN-ADDR` representation of the `query_name` field and issue a `PTR`
query.
- *QueryTypeId::REVERSE_AAAA*: same as `REVERSE_A` except that here the input shall be
a IPv6 address.
Note that you can also pass the query type as string; e.g. the following
would also work as expected:
```C++
mk::dns::query("IN", "A", "www.google.com", ...);
```
The `callback` argument is a lambda to be called when the DNS response is available
or an error occurs. In case of success, error would be equal to `NoError()`. Otherwise,
the error that occurred is reported. Among all the possible errors, the following are
defined by MeasurementKit DNS implementation:
- `FormatError`: invalid response format
- `ServerFailedError`: server failure
- `NotExistError`: the name does not exist
- `NotImplementedError`: query not implemented
- `RefusedError`: the server refuses to reply
- `TruncatedError`: response truncated
- `UknownError`: internal evnds error
- `TimeoutError`: query timed out
- `ShutdownError`: evdns library was shut down
- `CancelError`: user cancelled query
- `NoDataError`: no data in the response
In case of success, the `Message` argument passed to the callback would
contain details on the response. The `Message` structure contains at least
the following fields:
```C++
class Message {
public:
double rtt = 0.0;
std::vector queries;
std::vector answers;
};
```
where `rtt` is the time elapsed since issuing the query until receiving
the response; `queries` is the list of queries issued; `answers` is the list
of answers received.
The `Query` class contains at least the following fields:
```C++
class Query {
public:
QueryType type;
QueryClass qclass;
uint32_t ttl = 0;
std::string name;
};
```
where `type` is the type of the query, `qclass` is the class of the
query, `ttl` is the time to live, and `name` is the name for which the
query was issued.
The `Answer` class contains at least the following fields:
```C++
class Answer {
public:
QueryType type;
QueryClass qclass;
uint32_t ttl = 0;
std::string ipv4; // For A records
std::string ipv6; // For AAAA records
std::string hostname; // For PTR, SOA and CNAME records
std::string responsible_name; // For SOA records
uint32_t serial_number; // For SOA records
uint32_t refresh_interval; // For SOA records
uint32_t retry_interval; // For SOA records
uint32_t minimum_ttl; // For SOA records
uint32_t expiration_limit; // For SOA records
};
```
where `type` and `qclass` represent respectively the query type and the
query class, `ttl` is the response time to live, and the following fields
are only set for specific query types.
The optional `Settings` argument contains settings modifying the behavior of
the `query` function. The following setting keys are available:
- *"dns/attempts"*: how many attempts before erroring out (default is three)
- *"dns/nameserver"*: address of the name server to use. If you
don't specify this, the default name server is used. On Unix systems the default DNS
server is obtained parsing `/etc/resolv.conf`; on mobile devices where such file
is not available, the default DNS name server is `127.0.0.1` which typically is not
correct. Hence with mobile devices you SHOULD typically supply the DNS server
you would like to use.
- *"dns/port"*: port of the name server to use. If you don't specify this, the
default is `53`.
- *"dns/randomize_case"*: whether to [randomize request case to make DNS
poisoning more complex](https://lists.torproject.org/pipermail/tor-commits/2008-October/026025.html)
(by default this is not done)
- *"dns/timeout"*: time after which we stop waiting for a response (by
default this is five seconds)
The optional `reactor` argument is the reactor to use to issue the query
and receive the corresponding response.
The `resolve_hostname()` function should be used to perform dns queries
for connection purposes and not to perform tests on a dns server.
In both cases of success or failure, it will invoke the callback passing an instance
of `ResolveHostnameResult`.
The `ResolveHostnameResult` class is like:
```C++
struct ResolveHostnameResult {
bool inet_pton_ipv4 = false;
bool inet_pton_ipv6 = false;
Error ipv4_err;
dns::Message ipv4_reply;
Error ipv6_err;
dns::Message ipv6_reply;
std::vector addresses;
};
```
where `inet_pton_ipv4` is `true` if `address` is an IPv4 address and similarly
`inet_pton_ipv6` is `true` if `address` is an IPv6 address; `ipv4_err` and `ipv4_reply`
are the values returned by resolving `address` as a FQDN into a list of addresses;
`ipv6_err` and `ipv6_reply` have the same semantic of their IPv4 counterparts; `addresses`
is the list of the addresses that `connect()` will try to connect to. This list will
only contain a IPv4 (or IPv6) address if `address` is an IPv4 (or IPv6) address and it
will contain IPv4 addresses before IPv6 addresses (if any) when `address` instead is
a FQDN (fully qualified domain name).
# EXAMPLE
See files in `example/dns/`.
# HISTORY
The DNS module appeared in MeasurementKit 0.1.0.
measurement-kit-0.7.1/doc/api/ext.md 0000664 0000000 0000000 00000000656 13153561626 0017310 0 ustar 00root root 0000000 0000000 # NAME
ext — module containing third parties' code
# LIBRARY
MeasurementKit (libmeasurement_kit, -lmeasurement_kit).
# SYNOPSIS
```C++
// DO NOT INCLUDE THIS HEADER FILE DIRECTLY
/*#include */
```
# STABILITY
1 - Experimental
# DESCRIPTION
The `ext` module contains functionality implemented in headers
provided by third parties.
# HISTORY
The `ext` module appeared in MeasurementKit 0.2.0.
measurement-kit-0.7.1/doc/api/http.md 0000664 0000000 0000000 00000000721 13153561626 0017460 0 ustar 00root root 0000000 0000000 # NAME
http — HTTP module
# LIBRARY
MeasurementKit (libmeasurement_kit, -lmeasurement_kit).
# SYNOPSIS
```C++
#include
```
# DESCRIPTION
The `http` module contains HTTP related functionality. It is currently
composed by the following submodules:
- [parse_url](http/parse_url.md): URL parsing
- [request](http/request.md): sending requests and receiving responses
# HISTORY
The `http` module appeared in MeasurementKit 0.1.0.
measurement-kit-0.7.1/doc/api/http/ 0000775 0000000 0000000 00000000000 13153561626 0017136 5 ustar 00root root 0000000 0000000 measurement-kit-0.7.1/doc/api/http/parse_url.md 0000664 0000000 0000000 00000002012 13153561626 0021447 0 ustar 00root root 0000000 0000000 # NAME
parse_url — URL parsing
# LIBRARY
MeasurementKit (libmeasurement_kit, -lmeasurement_kit).
# SYNOPSIS
```C++
#include
mk::http::Url mk::http::parse_url(std::string url);
mk::ErrorOr mk::http::parse_url_noexcept(std::string url);
```
# STABILITY
2 - Stable
# DESCRIPTION
The `parse_url()` function parses the `url` argument into a `Url` structure:
```C++
class Url {
public:
std::string schema;
std::string address;
int port = 80;
std::string path;
std::string query;
std::string pathquery;
};
```
On error one of the following exceptions could be thrown:
- `mk::http::UrlParserError`: error in URL parser
- `mk::http::MissingUrlSchemaError`: missing schema in parsed URL
- `mk::http::MissingUrlHostError`: missing host in parsed URL
The `parse_url_noexcept()` is equal to `parse_url()` except that rather
than throwing an exception of error it returns an `ErrorOr` wrapper.
# HISTORY
The `parse_url` module appeared in MeasurementKit 0.2.0.
measurement-kit-0.7.1/doc/api/http/request.md 0000664 0000000 0000000 00000020041 13153561626 0021145 0 ustar 00root root 0000000 0000000 # NAME
request — issue HTTP requests
# LIBRARY
MeasurementKit (libmeasurement_kit, -lmeasurement_kit).
# SYNOPSYS
```C++
#include
void request(Settings settings,
Headers headers,
std::string body,
Callback> callback,
Var reactor = Reactor::global(),
Var = Logger::global());
void get(std::string url,
Callback> callback,
Headers headers = {},
Settings settings = {},
Var reactor = Reactor::global(),
Var logger = Logger::global());
void request_json_string(
std::string method, std::string url, std::string data,
http::Headers headers,
Callback, nlohmann::json> cb, Settings settings,
Var reactor, Var logger);
void request_json_no_body(
std::string method, std::string url, http::Headers headers,
Callback, nlohmann::json> cb, Settings settings,
Var reactor, Var logger);
void request_json_object(
std::string method, std::string url, nlohmann::json jdata,
http::Headers headers,
Callback, nlohmann::json> cb, Settings settings,
Var reactor, Var logger);
void request_connect(Settings settings,
Callback> callback,
Var reactor = Reactor::global(),
Var logger = Logger::global());
void request_send(Var txp,
Settings settings,
Headers headers,
std::string body,
Callback callback);
void request_recv_response(Var txp,
Callback> callback,
Var reactor = Reactor::global(),
Var logger = Logger::global());
void request_sendrecv(Var txp,
Settings settings,
Headers headers,
std::string body,
Callback> callback,
Var reactor = Reactor::global(),
Var logger = Logger::global());
ErrorOr redirect(const Url &orig_url, const std::string &location);
```
# STABILITY
1 - Experimental
# DESCRIPTION
The `request()` function issues the asynchronous `HTTP` request
specified by the `settings` argument. The following settings are
available:
- *http/max_redirects*: maximum number of redirects to follow, defaults to zero
- *http/url*: the URL to use
- *http/ignore_body*: does not save response body (this is currently
not implemented)
- *http/method*: the method to use (default: "GET")
- *http/http_version*: specify HTTP version (otherwise `HTTP/1.1` is used)
- *http/path*: path to use (if not specified the one inside the URL
is used instead)
The `body` argument is either the request body or an empty string
to send no request body. The `callback` function is called when
done; it receives the error that occurred — or `NoError()`
— as first argument and the `Response` as second argument.
Optionally you can also specify the `reactor` and the `logger` to
be used.
The `get()` function is a wrapper for `request()` that sets for you
`http/url` using as input the `url` argument and `http/method` as
`GET`. Unlike `request()` you cannot set the body, because `GET`
requests SHOULD NOT carry a body. All other arguments have equal
semantic.
The `request_json_string()` function is a wrapper for `request()`
that sends a JSON request (serialized as a string as the `data`
argument) and gives back a JSON response (as a `nlohmann::json`).
The `request_json_no_body()` function is a wrapper for `request()`
that expects the response to be a JSON.
The `request_json_object()` function is a wrapper for `request()`
that sends a JSON request (represented by a `nlohmann::json`)
and gives back a JSON response (again represented by a `nlohmann::json`).
Both `request()` and `get()` support `SSL` if the URL schema is
`https` and SOCKS5 proxying as described below for `request_connect()`.
Also, both functions close the established connection when the
response is received. To implement keep-alive semantic, use the
following, lower-level functions:
The `request_connect()` function establishes a TCP (and possibly
SSL) connection towards an HTTP (or HTTPS) server. It uses as input
the specified `settings` and, when done, it invokes `callback` with
the error that occurred — or `NoError()` — as the first
argument and the connected transport wrapped by a `Var` as the
second argument. In case of error, the transport SHOULD be `nullptr`.
You can also specify an optional `reactor` and `logger`. The
`settings` that matter to this function are the following:
- *http/url*: used to find out the address to connect to and whether
to connect using TCP (if schema is `http`) or SSL (if schema is
`https`). Additionally, if schema is `httpo` (for `HTTP onion`),
this function MAY set SOCKS5 proxy settings ot use locally running
instance of `tor`.
- *net/tor_socks_port*: if this setting is present, this function would pass
`127.0.0.1:${net/tor_socks_port}` as SOCKS5 proxy to `net/connect()`.
- *net/socks5_proxy*: if this setting is present and *net/tor_socks_port* is
not present, then this setting is passed verbatim to `net/connect()`.
- all other settings that matter to `net/connect()`.
The `request_send()` function send an HTTP request asynchronously
over the `txp` transport, using `settings`, `headers`, and `body`
to construct the request, and calls `callback` when done. The
settings that matter to this function are `http/url`, `http/http_version`,
`http/method`, and `http/path` — all already described above.
The callback receives the error that occurred or `NoError()` in
case of success.
The `request_recv_response()` function receives an HTTP response
asynchronously using the `txp` transport and calling `callback`
when done. You can optionally specify a `reactor` and a `logger`
to use. On error, the callback receives it as its first argument;
otherwise, the first argument is `NoError()` and the second argument
is the received HTTP response wrapped by a `Var`.
The `request_sendrecv()` function combines the `request_send()` and
the `request_recv_response()` functions into a single call.
Beware that, in case of early error, the callback MAY be called
immediately by any of the above functions. The following errors may
occurr:
- `UpgradeError`: received unexpected UPGRADE message
- `ParserError`: error in HTTP parser
- `UrlParserError`: error in URL parser
- `MissingUrlSchemaError`: missing schema in parsed URL
- `MissingUrlHostError`: missing host in parsed URL
- `MissingUrlError`: no URL was passed to a function that required it
- `HeaderParserInternalError`: the response headers parser encountered an error
HTTP headers are represented by the `http::Headers` typedef that
currently is alias for `std::map` where
the comparison of header keys is case insensitive.
The HTTP response object returned by several callbacks is like:
```C++
class Response {
public:
std::string response_line;
unsigned short http_major = 0;
unsigned short http_minor = 0;
unsigned int status_code = 0;
std::string reason;
Headers headers;
std::string body;
};
```
The `redirect()` function will construct a new URL from the existing
URL and a location header, basically implementing MK redirection
logic.
# EXAMPLE
See `example/http/request.cpp`.
# BUGS
- The `http/ignore_body` setting is not implemented.
- The `Var` returned by the various callbacks MAY be pointing
to `nullptr` and, moreover, there MAY be cases where `Var response`
is pointing to a valid response but `response->request` is `nullptr`.
# HISTORY
The `request` module appeared in MeasurementKit 0.2.0. Support for calling
JSON APIs was added in MK v0.7.0.
measurement-kit-0.7.1/doc/api/mlabns.md 0000664 0000000 0000000 00000007220 13153561626 0017756 0 ustar 00root root 0000000 0000000 # NAME
mlabns — module for querying mlab name service (mlabns)
# LIBRARY
MeasurementKit (libmeasurement_kit, -lmeasurement_kit).
# SYNOPSIS
```C++
#include
void mk::mlabns::query(std::string mlab_tool,
mk::Callback callback,
mk::Settings settings = {},
mk::Var reactor = mk::Reactor::global(),
mk::Var logger = mk::Logger::global());
```
# STABILITY
2 - Stable
# DESCRIPTION
The `query` function allows to query the mlab naming service (mlabns). The first argument
is the tool for which you are querying mlabns (e.g. `ndt`). The second argument is a callback
function called when done, with an error — or `NoError()` in case of success —
passed as the first argument and the reply passed as second argument. You can also pass
the following, optional settings:
- *"mlabns/base_url"*: base URL of the mlab-ns service. By default this URL is `https://mlab-ns.appspot.com/`.
- *"mlabns/policy"*: one of `"random"`, `"metro"`, or `"country`". The random policy asks mlabns
to return a random server for the specified tool. The metro policy asks mlabns a server close to
the city code passed as *mlabns/metro*. The country policy asks mlabns to return a suitable server
in the country where the requesting client is located.
- *"mlabns/metro"*: used together with *mlabns/policy* equal to *metro*, this setting specifies
which city should the returned server be close to. For example, *ath* (for Athens) or *trn* (for
Turin).
- *"mlabns/family"*: when this setting is unspecified, mlabns returns results valid for both IPv4
and IPv6. Set *mlabns/family* to *ipv4* or *ipv6* to restrict the results respectively only
to IPv4 or IPv6.
Optionally you can also pass a nondefault `reactor` and `logger`.
The `Reply` structure is like:
```C++
class Reply {
public:
std::string city; // City where server is.
std::string url; // URL to access server using HTTP.
std::vector ip; // List of IP addresses of server.
std::string fqdn; // FQDN of server.
std::string site; // Code of the city where the server is (e.g. `ath`).
std::string country; // Country where sliver is.
};
```
In addition to `NoError()`, the following errors could be returned by the callback:
- *mk::mlabns::InvalidPolicyError*: you passed in an invalid policy setting
- *mk::mlabns::InvalidAddressFamilyError*: you passed in an invalid address family setting
- *mk::mlabns::InvalidMetroError*: you passed in an invalid metro setting
- *mk::mlabns::InvalidToolNameError*: you passed in an invalid tool name
# EXAMPLE
```C++
#include
#include
using namespace mk;
mlabns::query(
"ndt", [](Error error, mlabns::Reply reply) {
if (error) {
throw error;
}
std::cout << "< city: " << reply.city << "\n";
std::cout << "< url: " << reply.url << "\n";
std::cout << "< ip: [\n";
for (auto s : reply.ip) {
std::cout << "< " << s << "\n";
}
std::cout << "< ]\n";
std::cout << "< fqdn: " << reply.fqdn << "\n";
std::cout << "< site: " << reply.site << "\n";
std::cout << "< country: " << reply.country << "\n";
/* ... */
},
{
{"mlabns/metro", "ath"},
{"mlabns/policy", "metro"},
{"mlabns/family", "ipv4"},
});
```
# HISTORY
The `mlabns` module appeared in MeasurementKit 0.2.0.
measurement-kit-0.7.1/doc/api/ndt.md 0000664 0000000 0000000 00000006155 13153561626 0017275 0 ustar 00root root 0000000 0000000 # NAME
ndt — Network Diagnostic Tool client
# LIBRARY
MeasurementKit (libmeasurement_kit, -lmeasurement_kit).
# SYNOPSIS
```C++
#include
namespace mk {
namespace ndt {
class NdtTest : public NetTest {
public:
using NetTest::NetTest;
};
} // namespace ndt
} // namespace mk
void mk::ndt::run(Callback callback,
Settings settings = {},
Var logger = Logger::global(),
Var reactor = Reactor::global());
void mk::ndt::run_with_specific_server(std::string address,
int port,
Callback callback,
Settings settings = {},
Var logger = Logger::global(),
Var reactor = Reactor::global());
```
# STABILITY
1 - Experimental
# DESCRIPTION
The `NdtTest` class is a subclass of `mk::NetTest` that runs a NDT test. Hence you
can run a NDT test as follows:
```C++
#include
using namespace mk::ndt;
NdtTest()
.set_options("test_suite", MK_NDT_DOWNLOAD)
.increase_verbosity()
.run();
```
More options than the one displayed above are available; see the documentation of
`mk::NetTest` for more information on how to run a NetTest and on what options are
available.
The `run()` function runs a NDT test and calls the `callback` specified as its first
argument when done, passing it the error that occurred — or `NoError()` in case
of success. The behavior of the function may be futher specified by passing it the
following `settings`:
- *"address"*: address (or domain name) of the NDT server. If this argument is not
specified, mlabns is used to find out a suitable server.
- *"port"*: port of the NDT server as integer. Only used if *address* is specified.
- *"test_suite"*: integer mask indicating which tests to run among all the available
tests as defined by the following `define`s:
```C++
#define MK_NDT_UPLOAD 2 // Run NDT's download test
#define MK_NDT_DOWNLOAD 4 // Run NDT's upload test
```
If you don't specify a *test_suite* setting, both the download and the upload NDT
tests will be run. Additionally, you can also specify an optional `reactor` and
an optional `logger`.
The `run_with_specific_server()` function is a wrapper that sets *address* and *port*
in its settings according to its first two arguments and then calls `run()`. All other
arguments have the same semantic as their `run()` equivalents.
# EXAMPLE
Runs NDT test in the context of the default runner and breaks out of the event loop
when the NDT test is complete, whatever the test result.
```C++
#include
using namespace mk;
mk::loop_with_initial_event([]() {
ndt::run([](Error /*err*/) { break_loop(); });
});
```
You can also achieve the same results more compactly and in a more abstract way by using
the `mk::NetTest` interface as shown above.
# BUGS
Only NDT's download and upload tests are implemented.
# HISTORY
The `ndt` module appeared in MeasurementKit 0.2.0.
measurement-kit-0.7.1/doc/api/net.md 0000664 0000000 0000000 00000001124 13153561626 0017265 0 ustar 00root root 0000000 0000000 # NAME
net — Networking module
# LIBRARY
MeasurementKit (libmeasurement_kit, -lmeasurement_kit).
# SYNOPSIS
```C++
#include
```
# DESCRIPTION
The `net` module contains the following networking functionality:
- [buffer](net/buffer.md): Buffer for incoming/outgoing data
- [connect](net/connect.md): Functions to establish connections
- [error](net/error.md): Network-level errors
- [transport](net/transport.md): Abstract interface for connected sockets
- [utils](net/utils.md): Utility functions
# HISTORY
The `net` module appeared in MeasurementKit 0.1.0.
measurement-kit-0.7.1/doc/api/net/ 0000775 0000000 0000000 00000000000 13153561626 0016745 5 ustar 00root root 0000000 0000000 measurement-kit-0.7.1/doc/api/net/buffer.md 0000664 0000000 0000000 00000013222 13153561626 0020540 0 ustar 00root root 0000000 0000000 # NAME
Buffer — Buffer containing data.
# LIBRARY
MeasurementKit (libmeasurement_kit, -lmeasurement_kit).
# SYNOPSIS
```C++
#include
namespace mk {
namespace net {
class Buffer {
public:
Buffer();
Buffer(evbuffer *b);
Buffer(std::string);
Buffer(const void *, size_t);
Buffer &operator<<(evbuffer *source);
Buffer &operator>>(evbuffer *dest);
Buffer &operator<<(Buffer &source);
Buffer &operator>>(Buffer &source);
size_t length();
void for_each(std::function fn);
void discard(size_t count);
void discard();
std::string read(size_t upto);
std::string read();
std::string peek(size_t upto);
std::string peek();
std::string readn(size_t n);
ErrorOr readline(size_t maxline);
void write(std::string in);
Buffer &operator<<(std::string in);
void write(const char *in);
Buffer &operator<<(const char *in);
void write(const void *buf, size_t count);
ErrorOr read_uint8();
void write_uint8(uint8_t);
ErrorOr read_uint16();
void write_uint16(uint16_t);
ErrorOr read_uint32();
void write_uint32(uint32_t);
void write_rand(size_t count);
void write(size_t count, std::function func);
} // namespace net
} // namespace mk
```
# DESCRIPTION
The `Buffer` type contains a list of strings either read from a socket or
to be written into a socket. It MAY be implemented using libevent's `evbuffer`.
The constructors allow to initialize, respectively, an empty `Buffer`, a
buffer from an existing libevent's `evbuffer` (this operation MAY be zero
copy if the `Buffer` is implemented using libevent's `evbuffer`), a C++
string, and a C style buffer (i.e. `void *` and `size_t`).
There are insertion and extraction operators from/to respectively a libevent's
`evbuffer` and a Buffer. Insertion and extraction to/from `Buffer` is always
zero copy, while insertion and extraction to/from libevent's `evbuffer` MAY be
zero copy if the `Buffer` is implemented using libevent's `evbuffer`.
The `length()` method returns the number of bytes in the `Buffer`.
The `for_each()` function allows to call a function on every string contained
by the `Buffer` object. To stop iterating earlier, the called function returns
`false`. Otherwise all the buffered strings are visited. This is useful to
inspect the content of the `Buffer` without triggering copies; e.g.:
```C++
size_t total = 0;
buffer.for_each([&](const void *ptr, size_t size) {
process_data((char *)ptr, size);
total += size;
return (total <= 1024); /* Do not process more than 1,024 bytes */
});
buffer.discard(total);
```
Note that you MUST NOT modify the `Buffer` while iterating over it. The example
above shows the optimal pattern to discard data from the buffer after you have
finished iterating over it.
The `discard()`, `read()`, and `peek()` families of functions read from the
`Buffer`. As the name implies, the `discard()` functions discard data from
the `Buffer`; if the amount of bytes to discard is not specified, the whole
content of the buffer is discared. The `read()` functions extract data from the
buffer and returns is serialized as string; if the amount of bytes to read is
not specified, the whole content of the buffer would be extracted. The `peek()`
functions are like `read()` expect that the buffer content would not be
discared; as such, they are optimal to inspect (portions of) the buffer content
to decide whether special actions should be carried out. For example:
```C++
std::string data = buffer.peek(4);
if (data.size() < 4) {
return -2; /* I.e. try again */
}
if (data == "HELO") {
std::string helo = buffer.read(HELO_MESSAGE_LENGTH);
if (helo.size() < HELO_MESSAGE_LENGTH) {
return -2; /* I.e. try again */
}
/* Now process HELO's message content... */
return 0;
}
/* Other cases... */
```
The `readn()` function returns either a N bytes string (where N is the number
of bytes passed as argument) or the empty string. This is useful to parse
protocol messages having a fixed width. For example, part of the previous example
could be rewritten as:
```C++
if (data == "HELO") {
std::string helo = buffer.readn(HELO_MESSAGE_LENGTH);
if (helo == "") {
return -2; /* I.e. try again */
}
/* Now process HELO's message content... */
return 0;
}
```
The `readline()` function reads a line no longer than the number of bytes
passed as its first argument. It returns the read line on success and an
error in case of failure.
The `Buffer` class contains write and insert operators that allow to queue
respectively a C++ string, a C string, and a C-style buffer.
The `Buffer` class also contains functionalities to read and write integers
of typical sizes (16 and 32 bits). In such case integers are automatically
converted from the host to network representation when writing and from network
to host representation when reading. Because read operations could fail, they
return `ErrorOr` rather than just `T`.
The `write_rand()` method writes the specified number of random bytes
into the buffer.
The `write(size, callback)` allocates a buffer of size `size` and calls the
callback specified as second argument to fill it. Such callback MAY return
less than `size` bytes to indicate that less than `size` bytes have been
initialized by it. This is useful, for example, to allocate a buffer large
as the maximum message size but allowing, at the same time, to send smaller
messages.
# HISTORY
The `Buffer` class appeared in MeasurementKit 0.1.0.
measurement-kit-0.7.1/doc/api/net/connect.md 0000664 0000000 0000000 00000006725 13153561626 0020732 0 ustar 00root root 0000000 0000000 # NAME
connect — Routines to connect to remote hosts
# LIBRARY
MeasurementKit (libmeasurement_kit, -lmeasurement_kit).
# SYNOPSIS
```C++
#include
void mk::net::connect(std::string address, int port,
Callback> callback,
Settings settings = {},
Var logger = Logger::global(),
Var reactor = Reactor::global());
using ConnectManyCb = Callback>>;
void mk::net::connect_many(std::string address, int port, int num,
ConnectManyCb callback, Settings settings = {},
Var logger = Logger::global(),
Var reactor = Reactor::global());
```
# STABILITY
2 - Stable
# DESCRIPTION
The `connect()` function creates a connection to the remote `address` (which
typically is a FQDN) and `port` and calls `callback` when done. On failure,
an error is passed to the callback as its first argument, while a valid, but
not connected, `Var` is passed as its second argument.
On success, the first
callback argument is `NoError` and the second argument is a `Transport` instance
wrapped by a `Var<>` smart pointer. Optionally you can also specify `settings`,
a specific `logger` and a specific `reactor`.
If `address` is a FQDN, this implementation of `connect()` will try all the
addresses obtained by resolving `address` before declaring the connect attempt
failed. In doing that, `connect()` would give preference to IPv4 addresses over
IPv6 addresses. Conversely, if `address` is already an IPv4 or IPv6 address, this
function would not attempt to resolve it and would try to connect it directly.
The behavior of `connect()` and of `Transport` s created using `connect()` can be
modified using the following `settings`:
- *"net/ca_bundle_path"* (string): path of the CA bundle to be used to verify
SSL certificates. The default value is selected by `./configure` inspecting
the local system when compiling. If the path is the empty string and we
link against libressl (as is typically the case for mobile devices) we load
libressl default CA from memory (i.e. you don't need anymore to include a
CA file when setting up an application using measurement-kit).
- *"net/ssl_allow_dirty_shutdown"* (bool): if true, this setting treats EOF
received on the socket without receiving a clean SSL shutdown message as a
normal EOF. If false, this situation is reported as `SslDirtyShutdownError`.
By default, this flag is false.
- *"net/dumb_transport"*: if this key is present a dumb transport is created (i.e. a
transport that is not connected to any socket).
- *"net/socks5_proxy"* (string): address and port (separated by colon) of the SOCKS5
proxy to be used for establishing the requested connection (this feature is
still experimental as of v0.2.0).
- *"net/ssl"* (bool): whether to establish a SSL connection (default: false).
- *"net/timeout"* (double): timeout for connect and I/O operations (default: `5.0` seconds).
- *"net/allow_ssl23"* (bool): whether to enable SSLv2 and SSLv3 (default: false)
The `connect_many()` function is similar to `connect()`. The main different is
that `num` parallel connections are established and passed to the callback on success. Of
course, this function would return `NoError()` only if all the parallel connect attempts
were successful, and it would close all the open connections if only some connect attempts
were successful.
# HISTORY
The `connect` submodule appeared in MeasurementKit 0.2.0.
measurement-kit-0.7.1/doc/api/net/error.md 0000664 0000000 0000000 00000000553 13153561626 0020423 0 ustar 00root root 0000000 0000000 # NAME
Error — A network error.
# LIBRARY
MeasurementKit (libmeasurement_kit, -lmeasurement_kit).
# SYNOPSIS
```C++
#include
// ERROR CODES DEFINED IN