Merge pull request #12103 from rick68/ostinato

Ostinato
This commit is contained in:
goibhniu 2016-01-11 00:09:32 +01:00
commit 8b8f864e48
5 changed files with 185 additions and 0 deletions

View File

@ -331,6 +331,7 @@
./services/networking/openfire.nix
./services/networking/openntpd.nix
./services/networking/openvpn.nix
./services/networking/ostinato.nix
./services/networking/polipo.nix
./services/networking/prayer.nix
./services/networking/privoxy.nix

View File

@ -0,0 +1,104 @@
{ config, lib, pkgs, ... }:
with lib;
let
pkg = pkgs.ostinato;
cfg = config.services.ostinato;
configFile = pkgs.writeText "drone.ini" ''
[General]
RateAccuracy=${cfg.rateAccuracy}
[RpcServer]
Address=${cfg.rpcServer.address}
[PortList]
Include=${concatStringsSep "," cfg.portList.include}
Exclude=${concatStringsSep "," cfg.portList.exclude}
'';
in
{
###### interface
options = {
services.ostinato = {
enable = mkEnableOption "Ostinato agent-controller (Drone)";
port = mkOption {
type = types.int;
default = 7878;
description = ''
Port to listen on.
'';
};
rateAccuracy = mkOption {
type = types.enum [ "High" "Low" ];
default = "High";
description = ''
To ensure that the actual transmit rate is as close as possible to
the configured transmit rate, Drone runs a busy-wait loop.
While this provides the maximum accuracy possible, the CPU
utilization is 100% while the transmit is on. You can however,
sacrifice the accuracy to reduce the CPU load.
'';
};
rpcServer = {
address = mkOption {
type = types.string;
default = "0.0.0.0";
description = ''
By default, the Drone RPC server will listen on all interfaces and
local IPv4 adresses for incoming connections from clients. Specify
a single IPv4 or IPv6 address if you want to restrict that.
To listen on any IPv6 address, use ::
'';
};
};
portList = {
include = mkOption {
type = types.listOf types.string;
default = [];
example = ''[ "eth*" "lo*" ]'';
description = ''
For a port to pass the filter and appear on the port list managed
by drone, it be allowed by this include list.
'';
};
exclude = mkOption {
type = types.listOf types.str;
default = [];
example = ''[ "usbmon*" "eth0" ]'';
description = ''
A list of ports does not appear on the port list managed by drone.
'';
};
};
};
};
###### implementation
config = mkIf cfg.enable {
environment.systemPackages = [ pkg ];
systemd.services.drone = {
description = "Ostinato agent-controller";
wantedBy = [ "multi-user.target" ];
script = ''
${pkg}/bin/drone ${toString cfg.port} ${configFile}
'';
};
};
}

View File

@ -0,0 +1,64 @@
{ stdenv, fetchgit, fetchurl, writeText
, qt4, protobuf, libpcap
, wireshark, gzip, diffutils, gawk
}:
stdenv.mkDerivation rec {
name = "ostinato-2015-12-24";
src = fetchgit {
url = "https://github.com/pstavirs/ostinato.git";
rev = "414d89860de0987843295d149bcabeac7c6fd9e5";
sha256 = "0hb78bq51r93p0yr4l1z5xlf1i666v5pa3zkdj7jmpb879kj05dx";
};
ostinato_png = fetchurl {
url = "http://ostinato.org/images/site-logo.png";
sha256 = "f5c067823f2934e4d358d76f65a343efd69ad783a7aeabd7ab4ce3cd03490d70";
};
buildInputs = [ qt4 protobuf libpcap ];
patches = [ ./drone_ini.patch ];
configurePhase = "qmake PREFIX=$out"
+ stdenv.lib.optionalString stdenv.isDarwin " -spec macx-g++";
postInstall = ''
cat > $out/bin/ostinato.ini <<EOF
WiresharkPath=${wireshark}/bin/wireshark
TsharkPath=${wireshark}/bin/tshark
GzipPath=${gzip}/bin/gzip
DiffPath=${diffutils}/bin/diff
AwkPath=${gawk}/bin/awk
EOF
mkdir -p $out/share/pixmaps
cp ${ostinato_png} $out/share/pixmaps/ostinato.png
# Create a desktop item.
mkdir -p $out/share/applications
cat > $out/share/applications/ostinato.desktop <<EOF
[Desktop Entry]
Type=Application
Encoding=UTF-8
Name=Ostinato
GenericName=Packet/Traffic Generator and Analyzer
GenericName[it]=Generatore ed Analizzatore di pacchetti di rete
Comment=Network packet and traffic generator and analyzer with a friendly GUI
Comment[it]=Generatore ed Analizzatore di pacchetti di rete con interfaccia amichevole
Icon=$out/share/pixmaps/ostinato.png
Exec=$out/bin/ostinato
Terminal=false
Categories=Network;
StartupNotify=true
EOF
'';
meta = with stdenv.lib; {
description = "A packet traffic generator and analyzer";
homepage = http://ostinato.org;
license = licenses.gpl3;
maintainers = with maintainers; [ rick68 ];
platforms = platforms.linux; # also OS X and cygwin
};
}

View File

@ -0,0 +1,14 @@
diff -Nru ostinato-414d89860de0987843295d149bcabeac7c6fd9e5/server/drone_main.cpp ostinato-414d89860de0987843295d149bcabeac7c6fd9e5.new/server/drone_main.cpp
--- ostinato-414d89860de0987843295d149bcabeac7c6fd9e5/server/drone_main.cpp 2015-12-24 16:46:35.000000000 +0800
+++ ostinato-414d89860de0987843295d149bcabeac7c6fd9e5.new/server/drone_main.cpp 2015-12-30 20:59:04.319199699 +0800
@@ -62,8 +62,8 @@
/* (Portable Mode) If we have a .ini file in the same directory as the
executable, we use that instead of the platform specific location
and format for the settings */
- QString portableIni = QCoreApplication::applicationDirPath()
- + "/drone.ini";
+ QString portableIni = argc > 2 ? argv[2] :
+ QCoreApplication::applicationDirPath() + "/drone.ini";
if (QFile::exists(portableIni))
appSettings = new QSettings(portableIni, QSettings::IniFormat);
else

View File

@ -12617,6 +12617,8 @@ let
oroborus = callPackage ../applications/window-managers/oroborus {};
ostinato = callPackage ../applications/networking/ostinato { };
panamax_api = callPackage ../applications/networking/cluster/panamax/api {
ruby = ruby_2_1;
};