File: debug_server

package info (click to toggle)
nsca-ng 1.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,948 kB
  • sloc: ansic: 14,447; sh: 633; makefile: 231; perl: 137; python: 15
file content (77 lines) | stat: -rwxr-xr-x 1,833 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/sh
#
# Copyright (c) 2013 Holger Weiss <holger@weiss.in-berlin.de>
#
# This file is free software; Holger Weiss gives unlimited permission to copy
# and/or distribute it, with or without modifications, as long as this notice is
# preserved.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY, to the extent permitted by law; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

set -e
set -u

default_config_file='/etc/send_nsca.cfg'
default_port='5668'

die()
{
	echo >&2 "$@"
	exit 1
}

usage()
{
	die "Usage: $0 [-c <config-file>] [-H <server>] [-p <port>]"
}

xxd </dev/null >/dev/null 2>&1 || die "$0: xxd(1) is required"

while getopts c:H:hp: option
do
	case $option in
	c)
		config_file=$OPTARG
		;;
	H)
		opt_server=$OPTARG
		;;
	h|\?)
		usage
		;;
	p)
		opt_port=$OPTARG
		;;
	esac
done

shift `expr $OPTIND - 1`
test $# -eq 0 || usage

config_file=${config_file:-$default_config_file}

if [ -r "$config_file" ]
then
	eval "`sed 's/[[:space:]]*=[[:space:]]*/=/' "$config_file"`"
else
	echo >&2 "Cannot read $config_file (continuing anyway)"
fi

server=${server:-'localhost'}
server=${opt_server:-$server}
port=${port:-$default_port}
port=${opt_port:-$port}
identity=${identity:-`hostname -s`}
password=${password:-'change-me'}
ciphers=${tls_ciphers:-'PSK-AES256-CBC-SHA:PSK-AES128-CBC-SHA:PSK-3DES-EDE-CBC-SHA:PSK-RC4-SHA'}

exec openssl s_client                                           \
    -crlf                                                       \
    -cipher "$ciphers"                                          \
    -psk_identity "$identity"                                   \
    -psk `printf '%s' "$password" | xxd -p | tr -d '\n'`        \
    -connect "$server:$port"

# vim:set joinspaces noexpandtab textwidth=80: