mirror of
				https://github.com/optim-enterprises-bv/nDPId.git
				synced 2025-10-31 02:07:47 +00:00 
			
		
		
		
	Experimental systemd support.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
This commit is contained in:
		
							
								
								
									
										11
									
								
								.github/workflows/build.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										11
									
								
								.github/workflows/build.yml
									
									
									
									
										vendored
									
									
								
							| @@ -57,7 +57,7 @@ jobs: | ||||
|       - name: Configure nDPId | ||||
|         run: | | ||||
|           mkdir build && cd build | ||||
|           cmake .. -DENABLE_COVERAGE=ON -DBUILD_EXAMPLES=ON -DBUILD_NDPI=ON -DENABLE_SANITIZER=ON ${{ matrix.ndpid_zlib }} ${{ matrix.ndpid_gcrypt }} | ||||
|           cmake .. -DENABLE_SYSTEMD=ON -DENABLE_COVERAGE=ON -DBUILD_EXAMPLES=ON -DBUILD_NDPI=ON -DENABLE_SANITIZER=ON ${{ matrix.ndpid_zlib }} ${{ matrix.ndpid_gcrypt }} | ||||
|       - name: Build nDPId | ||||
|         run: | | ||||
|           make -C build all VERBOSE=1 | ||||
| @@ -81,7 +81,14 @@ jobs: | ||||
|           make -C ./build dist | ||||
|       - name: CPack DEB | ||||
|         run: | | ||||
|           cd ./build && cpack -G DEB && cd .. | ||||
|           cd ./build && cpack -G DEB && sudo dpkg -i nDPId-*.deb && cd .. | ||||
|       - name: systemd test | ||||
|         run: | | ||||
|           sudo systemctl daemon-reload | ||||
|           sudo systemctl enable ndpid@lo | ||||
|           sudo systemctl start ndpid@lo | ||||
|           sudo systemctl status ndpisrvd.service ndpid@lo.service | ||||
|           sudo systemctl stop ndpid@lo | ||||
|       - name: Build against libnDPI-${{ matrix.ndpi_min_version }} | ||||
|         run: | | ||||
|           mkdir build-local-ndpi && cd build-local-ndpi | ||||
|   | ||||
| @@ -23,12 +23,18 @@ build_and_test: | ||||
|     # static linked build | ||||
|     - mkdir build-cmake-submodule | ||||
|     - cd build-cmake-submodule | ||||
|     - env CMAKE_C_FLAGS='-Werror' cmake .. -DENABLE_COVERAGE=ON -DBUILD_EXAMPLES=ON -DBUILD_NDPI=ON -DENABLE_SANITIZER=ON -DENABLE_ZLIB=ON | ||||
|     - env CMAKE_C_FLAGS='-Werror' cmake .. -DENABLE_SYSTEMD=ON -DENABLE_COVERAGE=ON -DBUILD_EXAMPLES=ON -DBUILD_NDPI=ON -DENABLE_SANITIZER=ON -DENABLE_ZLIB=ON | ||||
|     - make libnDPI | ||||
|     - tree libnDPI | ||||
|     - make install VERBOSE=1 DESTDIR="$(realpath ../_install)" | ||||
|     - cpack -G DEB | ||||
|     - sudo dpkg -i nDPId-*.deb | ||||
|     - cd .. | ||||
|     - test -x /bin/systemctl && sudo systemctl daemon-reload | ||||
|     - test -x /bin/systemctl && sudo systemctl enable ndpid@lo | ||||
|     - test -x /bin/systemctl && sudo systemctl start ndpid@lo | ||||
|     - test -x /bin/systemctl && sudo systemctl status ndpisrvd.service ndpid@lo.service | ||||
|     - test -x /bin/systemctl && sudo systemctl stop ndpid@lo | ||||
|     - ./test/run_tests.sh ./libnDPI ./build-cmake-submodule/nDPId-test | ||||
|     # generate coverage report | ||||
|     - make -C ./build-cmake-submodule coverage | ||||
|   | ||||
| @@ -45,6 +45,7 @@ option(ENABLE_SANITIZER "Enable ASAN/LSAN/UBSAN." OFF) | ||||
| option(ENABLE_SANITIZER_THREAD "Enable TSAN (does not work together with ASAN)." OFF) | ||||
| option(ENABLE_MEMORY_PROFILING "Enable dynamic memory tracking." OFF) | ||||
| option(ENABLE_ZLIB "Enable zlib support for nDPId (experimental)." OFF) | ||||
| option(ENABLE_SYSTEMD "Install systemd components." OFF) | ||||
| option(BUILD_EXAMPLES "Build C examples." ON) | ||||
| option(BUILD_NDPI "Clone and build nDPI from github." OFF) | ||||
| if(BUILD_NDPI) | ||||
| @@ -324,6 +325,11 @@ if(BUILD_EXAMPLES) | ||||
|     install(DIRECTORY examples/c-collectd/www DESTINATION share/nDPId/nDPIsrvd-collectd) | ||||
| endif() | ||||
|  | ||||
| if(ENABLE_SYSTEMD) | ||||
|     install(FILES packages/systemd/ndpisrvd.service DESTINATION lib/systemd/system) | ||||
|     install(FILES packages/systemd/ndpid@.service DESTINATION lib/systemd/system) | ||||
| endif() | ||||
|  | ||||
| install(TARGETS nDPId DESTINATION sbin) | ||||
| install(TARGETS nDPIsrvd nDPId-test DESTINATION bin) | ||||
| install(FILES dependencies/nDPIsrvd.py examples/py-flow-dashboard/plotly_dash.py | ||||
|   | ||||
							
								
								
									
										2
									
								
								config.h
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								config.h
									
									
									
									
									
								
							| @@ -45,7 +45,7 @@ | ||||
|  | ||||
| /* nDPIsrvd default config options */ | ||||
| #define nDPIsrvd_PIDFILE "/tmp/ndpisrvd.pid" | ||||
| #define nDPIsrvd_MAX_REMOTE_DESCRIPTORS 32 | ||||
| #define nDPIsrvd_MAX_REMOTE_DESCRIPTORS 128 | ||||
| #define nDPIsrvd_MAX_WRITE_BUFFERS 1024 | ||||
|  | ||||
| #endif | ||||
|   | ||||
							
								
								
									
										2
									
								
								nDPId.c
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								nDPId.c
									
									
									
									
									
								
							| @@ -5109,7 +5109,7 @@ static int validate_options(void) | ||||
|         else | ||||
|         { | ||||
|             nDPId_options.instance_alias = strdup(hname); | ||||
|             logger_early(0, "No instance alias given, using your hostname '%s'", nDPId_options.instance_alias); | ||||
|             logger_early(1, "No instance alias given, using your hostname '%s'", nDPId_options.instance_alias); | ||||
|             if (nDPId_options.instance_alias == NULL) | ||||
|             { | ||||
|                 retval = 1; | ||||
|   | ||||
| @@ -95,7 +95,8 @@ static struct | ||||
|     int bufferbloat_fallback_to_blocking; | ||||
| } nDPIsrvd_options = {.max_remote_descriptors = nDPIsrvd_MAX_REMOTE_DESCRIPTORS, | ||||
|                       .max_write_buffers = nDPIsrvd_MAX_WRITE_BUFFERS, | ||||
|                       .bufferbloat_fallback_to_blocking = 1}; | ||||
|                       .bufferbloat_fallback_to_blocking = 1, | ||||
|                       .user = "nobody"}; | ||||
|  | ||||
| static void logger_nDPIsrvd(struct remote_desc const * const remote, | ||||
|                             char const * const prefix, | ||||
| @@ -1599,11 +1600,13 @@ int main(int argc, char ** argv) | ||||
|     } | ||||
|  | ||||
|     errno = 0; | ||||
|     if (nDPIsrvd_options.user != NULL && change_user_group(nDPIsrvd_options.user, | ||||
|     if (nDPIsrvd_options.user != NULL && | ||||
|         change_user_group(nDPIsrvd_options.user, | ||||
|                           nDPIsrvd_options.group, | ||||
|                           nDPIsrvd_options.pidfile, | ||||
|                           nDPIsrvd_options.collector_un_sockpath, | ||||
|                                                            nDPIsrvd_options.distributor_un_sockpath) != 0) | ||||
|                           nDPIsrvd_options.distributor_un_sockpath) != 0 && | ||||
|         errno != EPERM) | ||||
|     { | ||||
|         if (errno != 0) | ||||
|         { | ||||
|   | ||||
							
								
								
									
										12
									
								
								packages/systemd/ndpid@.service
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								packages/systemd/ndpid@.service
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,12 @@ | ||||
| [Unit] | ||||
| Description=nDPId Service on interface %i | ||||
| After=ndpisrvd.service | ||||
| Requires=ndpisrvd.service | ||||
|  | ||||
| [Service] | ||||
| Type=simple | ||||
| ExecStart=/usr/sbin/nDPId -i %i -l -A -z -c /var/run/ndpisrvd-collector | ||||
| Restart=on-failure | ||||
|  | ||||
| [Install] | ||||
| WantedBy=multi-user.target | ||||
							
								
								
									
										11
									
								
								packages/systemd/ndpisrvd.service
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								packages/systemd/ndpisrvd.service
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,11 @@ | ||||
| [Unit] | ||||
| Description=nDPIsrvd Service | ||||
| After=network.target | ||||
|  | ||||
| [Service] | ||||
| Type=simple | ||||
| ExecStart=/usr/bin/nDPIsrvd -l -c /var/run/ndpisrvd-collector | ||||
| Restart=on-failure | ||||
|  | ||||
| [Install] | ||||
| WantedBy=multi-user.target | ||||
		Reference in New Issue
	
	Block a user
	 Toni Uhlig
					Toni Uhlig