spiped 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/ext/spiped/extconf.rb +3 -0
- data/ext/spiped/spiped-source/BUILDING +46 -0
- data/ext/spiped/spiped-source/CHANGELOG +44 -0
- data/ext/spiped/spiped-source/COPYRIGHT +33 -0
- data/ext/spiped/spiped-source/Makefile +47 -0
- data/ext/spiped/spiped-source/Makefile.POSIX +27 -0
- data/ext/spiped/spiped-source/Makefile.inc +20 -0
- data/ext/spiped/spiped-source/Makefile.prog +23 -0
- data/ext/spiped/spiped-source/POSIX/README +10 -0
- data/ext/spiped/spiped-source/POSIX/posix-cflags.sh +10 -0
- data/ext/spiped/spiped-source/POSIX/posix-clock_realtime.c +3 -0
- data/ext/spiped/spiped-source/POSIX/posix-l.c +1 -0
- data/ext/spiped/spiped-source/POSIX/posix-l.sh +14 -0
- data/ext/spiped/spiped-source/POSIX/posix-msg_nosignal.c +3 -0
- data/ext/spiped/spiped-source/README +198 -0
- data/ext/spiped/spiped-source/STYLE +151 -0
- data/ext/spiped/spiped-source/lib/dnsthread/dnsthread.c +464 -0
- data/ext/spiped/spiped-source/lib/dnsthread/dnsthread.h +45 -0
- data/ext/spiped/spiped-source/libcperciva/alg/sha256.c +442 -0
- data/ext/spiped/spiped-source/libcperciva/alg/sha256.h +95 -0
- data/ext/spiped/spiped-source/libcperciva/cpusupport/Build/cpusupport-X86-AESNI.c +13 -0
- data/ext/spiped/spiped-source/libcperciva/cpusupport/Build/cpusupport-X86-CPUID.c +8 -0
- data/ext/spiped/spiped-source/libcperciva/cpusupport/Build/cpusupport.sh +37 -0
- data/ext/spiped/spiped-source/libcperciva/cpusupport/cpusupport.h +63 -0
- data/ext/spiped/spiped-source/libcperciva/cpusupport/cpusupport_x86_aesni.c +30 -0
- data/ext/spiped/spiped-source/libcperciva/crypto/crypto_aes.c +166 -0
- data/ext/spiped/spiped-source/libcperciva/crypto/crypto_aes.h +31 -0
- data/ext/spiped/spiped-source/libcperciva/crypto/crypto_aes_aesni.c +229 -0
- data/ext/spiped/spiped-source/libcperciva/crypto/crypto_aes_aesni.h +31 -0
- data/ext/spiped/spiped-source/libcperciva/crypto/crypto_aesctr.c +124 -0
- data/ext/spiped/spiped-source/libcperciva/crypto/crypto_aesctr.h +41 -0
- data/ext/spiped/spiped-source/libcperciva/crypto/crypto_dh.c +293 -0
- data/ext/spiped/spiped-source/libcperciva/crypto/crypto_dh.h +43 -0
- data/ext/spiped/spiped-source/libcperciva/crypto/crypto_dh_group14.c +46 -0
- data/ext/spiped/spiped-source/libcperciva/crypto/crypto_dh_group14.h +9 -0
- data/ext/spiped/spiped-source/libcperciva/crypto/crypto_entropy.c +215 -0
- data/ext/spiped/spiped-source/libcperciva/crypto/crypto_entropy.h +14 -0
- data/ext/spiped/spiped-source/libcperciva/crypto/crypto_verify_bytes.c +21 -0
- data/ext/spiped/spiped-source/libcperciva/crypto/crypto_verify_bytes.h +14 -0
- data/ext/spiped/spiped-source/libcperciva/datastruct/elasticarray.c +276 -0
- data/ext/spiped/spiped-source/libcperciva/datastruct/elasticarray.h +167 -0
- data/ext/spiped/spiped-source/libcperciva/datastruct/mpool.h +85 -0
- data/ext/spiped/spiped-source/libcperciva/datastruct/ptrheap.c +334 -0
- data/ext/spiped/spiped-source/libcperciva/datastruct/ptrheap.h +89 -0
- data/ext/spiped/spiped-source/libcperciva/datastruct/timerqueue.c +241 -0
- data/ext/spiped/spiped-source/libcperciva/datastruct/timerqueue.h +60 -0
- data/ext/spiped/spiped-source/libcperciva/events/events.c +203 -0
- data/ext/spiped/spiped-source/libcperciva/events/events.h +106 -0
- data/ext/spiped/spiped-source/libcperciva/events/events_immediate.c +149 -0
- data/ext/spiped/spiped-source/libcperciva/events/events_internal.h +95 -0
- data/ext/spiped/spiped-source/libcperciva/events/events_network.c +347 -0
- data/ext/spiped/spiped-source/libcperciva/events/events_network_selectstats.c +106 -0
- data/ext/spiped/spiped-source/libcperciva/events/events_timer.c +273 -0
- data/ext/spiped/spiped-source/libcperciva/network/network.h +95 -0
- data/ext/spiped/spiped-source/libcperciva/network/network_accept.c +103 -0
- data/ext/spiped/spiped-source/libcperciva/network/network_connect.c +258 -0
- data/ext/spiped/spiped-source/libcperciva/network/network_read.c +155 -0
- data/ext/spiped/spiped-source/libcperciva/network/network_write.c +188 -0
- data/ext/spiped/spiped-source/libcperciva/util/asprintf.c +49 -0
- data/ext/spiped/spiped-source/libcperciva/util/asprintf.h +16 -0
- data/ext/spiped/spiped-source/libcperciva/util/daemonize.c +134 -0
- data/ext/spiped/spiped-source/libcperciva/util/daemonize.h +10 -0
- data/ext/spiped/spiped-source/libcperciva/util/entropy.c +76 -0
- data/ext/spiped/spiped-source/libcperciva/util/entropy.h +13 -0
- data/ext/spiped/spiped-source/libcperciva/util/imalloc.h +33 -0
- data/ext/spiped/spiped-source/libcperciva/util/insecure_memzero.c +19 -0
- data/ext/spiped/spiped-source/libcperciva/util/insecure_memzero.h +33 -0
- data/ext/spiped/spiped-source/libcperciva/util/monoclock.c +52 -0
- data/ext/spiped/spiped-source/libcperciva/util/monoclock.h +14 -0
- data/ext/spiped/spiped-source/libcperciva/util/noeintr.c +54 -0
- data/ext/spiped/spiped-source/libcperciva/util/noeintr.h +14 -0
- data/ext/spiped/spiped-source/libcperciva/util/sock.c +472 -0
- data/ext/spiped/spiped-source/libcperciva/util/sock.h +56 -0
- data/ext/spiped/spiped-source/libcperciva/util/sock_internal.h +14 -0
- data/ext/spiped/spiped-source/libcperciva/util/sock_util.c +271 -0
- data/ext/spiped/spiped-source/libcperciva/util/sock_util.h +51 -0
- data/ext/spiped/spiped-source/libcperciva/util/sysendian.h +146 -0
- data/ext/spiped/spiped-source/libcperciva/util/warnp.c +76 -0
- data/ext/spiped/spiped-source/libcperciva/util/warnp.h +59 -0
- data/ext/spiped/spiped-source/proto/proto_conn.c +362 -0
- data/ext/spiped/spiped-source/proto/proto_conn.h +25 -0
- data/ext/spiped/spiped-source/proto/proto_crypt.c +396 -0
- data/ext/spiped/spiped-source/proto/proto_crypt.h +102 -0
- data/ext/spiped/spiped-source/proto/proto_handshake.c +330 -0
- data/ext/spiped/spiped-source/proto/proto_handshake.h +30 -0
- data/ext/spiped/spiped-source/proto/proto_pipe.c +202 -0
- data/ext/spiped/spiped-source/proto/proto_pipe.h +23 -0
- data/ext/spiped/spiped-source/spipe/Makefile +90 -0
- data/ext/spiped/spiped-source/spipe/README +24 -0
- data/ext/spiped/spiped-source/spipe/main.c +178 -0
- data/ext/spiped/spiped-source/spipe/pushbits.c +101 -0
- data/ext/spiped/spiped-source/spipe/pushbits.h +10 -0
- data/ext/spiped/spiped-source/spipe/spipe.1 +60 -0
- data/ext/spiped/spiped-source/spiped/Makefile +98 -0
- data/ext/spiped/spiped-source/spiped/README +62 -0
- data/ext/spiped/spiped-source/spiped/dispatch.c +214 -0
- data/ext/spiped/spiped-source/spiped/dispatch.h +27 -0
- data/ext/spiped/spiped-source/spiped/main.c +267 -0
- data/ext/spiped/spiped-source/spiped/spiped.1 +112 -0
- data/lib/spiped.rb +3 -0
- metadata +143 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#ifndef _PROTO_PIPE_H_
|
|
2
|
+
#define _PROTO_PIPE_H_
|
|
3
|
+
|
|
4
|
+
struct proto_keys;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* proto_pipe(s_in, s_out, decr, k, status, callback, cookie):
|
|
8
|
+
* Read bytes from ${s_in} and write them to ${s_out}. If ${decr} is non-zero
|
|
9
|
+
* then use ${k} to decrypt the bytes; otherwise use ${k} to encrypt them.
|
|
10
|
+
* If EOF is read, set ${status} to 0, and if an error is encountered set
|
|
11
|
+
* ${status} to -1; in either case, invoke ${callback}(${cookie}). Return a
|
|
12
|
+
* cookie which can be passed to proto_pipe_cancel.
|
|
13
|
+
*/
|
|
14
|
+
void * proto_pipe(int, int, int, struct proto_keys *, int *,
|
|
15
|
+
int (*)(void *), void *);
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* proto_pipe_cancel(cookie):
|
|
19
|
+
* Shut down the pipe created by proto_pipe for which ${cookie} was returned.
|
|
20
|
+
*/
|
|
21
|
+
void proto_pipe_cancel(void *);
|
|
22
|
+
|
|
23
|
+
#endif /* !_PROTO_PIPE_H_ */
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# Program name.
|
|
2
|
+
PROG = spipe
|
|
3
|
+
MAN1 = ${PROG}.1
|
|
4
|
+
|
|
5
|
+
# Libraries which are sometimes merged into libc
|
|
6
|
+
LDADD = -lrt
|
|
7
|
+
#LDADD += -lxnet # Missing on FreeBSD
|
|
8
|
+
|
|
9
|
+
# Library code required
|
|
10
|
+
LDADD_REQ = -lcrypto
|
|
11
|
+
LDADD_REQ += -lpthread
|
|
12
|
+
|
|
13
|
+
# spipe code
|
|
14
|
+
SRCS = main.c
|
|
15
|
+
SRCS += pushbits.c
|
|
16
|
+
|
|
17
|
+
# spipe protocol
|
|
18
|
+
.PATH.c : ../proto
|
|
19
|
+
SRCS += proto_conn.c
|
|
20
|
+
SRCS += proto_crypt.c
|
|
21
|
+
SRCS += proto_handshake.c
|
|
22
|
+
SRCS += proto_pipe.c
|
|
23
|
+
IDIRS += -I ../proto
|
|
24
|
+
|
|
25
|
+
# Fundamental algorithms
|
|
26
|
+
.PATH.c : ../libcperciva/alg
|
|
27
|
+
SRCS += sha256.c
|
|
28
|
+
IDIRS += -I ../libcperciva/alg
|
|
29
|
+
|
|
30
|
+
# Data structures
|
|
31
|
+
.PATH.c : ../libcperciva/datastruct
|
|
32
|
+
SRCS += elasticarray.c
|
|
33
|
+
SRCS += ptrheap.c
|
|
34
|
+
SRCS += timerqueue.c
|
|
35
|
+
IDIRS += -I ../libcperciva/datastruct
|
|
36
|
+
|
|
37
|
+
# Utility functions
|
|
38
|
+
.PATH.c : ../libcperciva/util
|
|
39
|
+
SRCS += asprintf.c
|
|
40
|
+
SRCS += entropy.c
|
|
41
|
+
SRCS += insecure_memzero.c
|
|
42
|
+
SRCS += monoclock.c
|
|
43
|
+
SRCS += noeintr.c
|
|
44
|
+
SRCS += sock.c
|
|
45
|
+
SRCS += warnp.c
|
|
46
|
+
IDIRS += -I ../libcperciva/util
|
|
47
|
+
|
|
48
|
+
# CPU features detection
|
|
49
|
+
.PATH.c : ../libcperciva/cpusupport
|
|
50
|
+
SRCS += cpusupport_x86_aesni.c
|
|
51
|
+
IDIRS += -I ../libcperciva/cpusupport
|
|
52
|
+
|
|
53
|
+
# Event loop
|
|
54
|
+
.PATH.c : ../libcperciva/events
|
|
55
|
+
SRCS += events_immediate.c
|
|
56
|
+
SRCS += events_network.c
|
|
57
|
+
SRCS += events_network_selectstats.c
|
|
58
|
+
SRCS += events_timer.c
|
|
59
|
+
SRCS += events.c
|
|
60
|
+
IDIRS += -I ../libcperciva/events
|
|
61
|
+
|
|
62
|
+
# Event-driven networking
|
|
63
|
+
.PATH.c : ../libcperciva/network
|
|
64
|
+
SRCS += network_connect.c
|
|
65
|
+
SRCS += network_read.c
|
|
66
|
+
SRCS += network_write.c
|
|
67
|
+
IDIRS += -I ../libcperciva/network
|
|
68
|
+
|
|
69
|
+
# Crypto code
|
|
70
|
+
.PATH.c : ../libcperciva/crypto
|
|
71
|
+
SRCS += crypto_aes.c
|
|
72
|
+
SRCS += crypto_aes_aesni.c
|
|
73
|
+
SRCS += crypto_aesctr.c
|
|
74
|
+
SRCS += crypto_dh.c
|
|
75
|
+
SRCS += crypto_dh_group14.c
|
|
76
|
+
SRCS += crypto_entropy.c
|
|
77
|
+
SRCS += crypto_verify_bytes.c
|
|
78
|
+
IDIRS += -I ../libcperciva/crypto
|
|
79
|
+
|
|
80
|
+
crypto_aes_aesni.o: crypto_aes_aesni.c cpusupport-config.h
|
|
81
|
+
. ./cpusupport-config.h; ${CC} ${CFLAGS} $${CFLAGS_X86_AESNI} -c $< -o $@
|
|
82
|
+
cflags-crypto_aes_aesni.o=$${CFLAGS_X86_AESNI}
|
|
83
|
+
|
|
84
|
+
# Debugging options
|
|
85
|
+
CFLAGS += -g
|
|
86
|
+
#CFLAGS += -DNDEBUG
|
|
87
|
+
#CFLAGS += -DDEBUG
|
|
88
|
+
#CFLAGS += -pg
|
|
89
|
+
|
|
90
|
+
.include <bsd.prog.mk>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
spipe usage
|
|
2
|
+
===========
|
|
3
|
+
|
|
4
|
+
usage: spipe -t <target socket> -k <key file> [-f | -g] [-j]
|
|
5
|
+
[-o <connection timeout>]
|
|
6
|
+
|
|
7
|
+
Options:
|
|
8
|
+
-t <target socket>
|
|
9
|
+
Address to which spipe should connect.
|
|
10
|
+
-k <key file>
|
|
11
|
+
Use the provided key file to authenticate and encrypt.
|
|
12
|
+
-f
|
|
13
|
+
Use fast/weak handshaking: This reduces the CPU time spent in the
|
|
14
|
+
initial connection setup, at the expense of losing perfect forward
|
|
15
|
+
secrecy.
|
|
16
|
+
-g
|
|
17
|
+
Require perfect forward secrecy by dropping connections if the other
|
|
18
|
+
host is using the -f option.
|
|
19
|
+
-j
|
|
20
|
+
Disable transport layer keep-alives. (By default they are enabled.)
|
|
21
|
+
-o <connection timeout>
|
|
22
|
+
Timeout, in seconds, after which an attempt to connect to the target
|
|
23
|
+
or a protocol handshake will be aborted (and the connection dropped)
|
|
24
|
+
if not completed. Defaults to 5s.
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
#include <sys/socket.h>
|
|
2
|
+
|
|
3
|
+
#include <inttypes.h>
|
|
4
|
+
#include <stdio.h>
|
|
5
|
+
#include <stdlib.h>
|
|
6
|
+
#include <string.h>
|
|
7
|
+
#include <unistd.h>
|
|
8
|
+
|
|
9
|
+
#include "asprintf.h"
|
|
10
|
+
#include "events.h"
|
|
11
|
+
#include "sha256.h"
|
|
12
|
+
#include "sock.h"
|
|
13
|
+
#include "warnp.h"
|
|
14
|
+
|
|
15
|
+
#include "proto_conn.h"
|
|
16
|
+
#include "proto_crypt.h"
|
|
17
|
+
|
|
18
|
+
#include "pushbits.h"
|
|
19
|
+
|
|
20
|
+
static int
|
|
21
|
+
callback_conndied(void * cookie)
|
|
22
|
+
{
|
|
23
|
+
|
|
24
|
+
(void)cookie; /* UNUSED */
|
|
25
|
+
|
|
26
|
+
/* We're done! */
|
|
27
|
+
exit(0);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
static void
|
|
31
|
+
usage(void)
|
|
32
|
+
{
|
|
33
|
+
|
|
34
|
+
fprintf(stderr, "usage: spipe -t <target socket> -k <key file>"
|
|
35
|
+
" [-f | -g] [-j] [-o <connection timeout>]\n");
|
|
36
|
+
exit(1);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/* Simplify error-handling in command-line parse loop. */
|
|
40
|
+
#define OPT_EPARSE(opt, arg) do { \
|
|
41
|
+
warnp("Error parsing argument: -%c %s", opt, arg); \
|
|
42
|
+
exit(1); \
|
|
43
|
+
} while (0)
|
|
44
|
+
|
|
45
|
+
int
|
|
46
|
+
main(int argc, char * argv[])
|
|
47
|
+
{
|
|
48
|
+
/* Command-line parameters. */
|
|
49
|
+
int opt_f = 0;
|
|
50
|
+
int opt_g = 0;
|
|
51
|
+
int opt_j = 0;
|
|
52
|
+
const char * opt_k = NULL;
|
|
53
|
+
double opt_o = 0.0;
|
|
54
|
+
const char * opt_t = NULL;
|
|
55
|
+
|
|
56
|
+
/* Working variables. */
|
|
57
|
+
struct sock_addr ** sas_t;
|
|
58
|
+
struct proto_secret * K;
|
|
59
|
+
int ch;
|
|
60
|
+
int s[2];
|
|
61
|
+
|
|
62
|
+
WARNP_INIT;
|
|
63
|
+
|
|
64
|
+
/* Parse the command line. */
|
|
65
|
+
while ((ch = getopt(argc, argv, "fgjk:o:t:")) != -1) {
|
|
66
|
+
switch (ch) {
|
|
67
|
+
case 'f':
|
|
68
|
+
if (opt_f)
|
|
69
|
+
usage();
|
|
70
|
+
opt_f = 1;
|
|
71
|
+
break;
|
|
72
|
+
case 'g':
|
|
73
|
+
if (opt_g)
|
|
74
|
+
usage();
|
|
75
|
+
opt_g = 1;
|
|
76
|
+
break;
|
|
77
|
+
case 'j':
|
|
78
|
+
if (opt_j)
|
|
79
|
+
usage();
|
|
80
|
+
opt_j = 1;
|
|
81
|
+
break;
|
|
82
|
+
case 'k':
|
|
83
|
+
if (opt_k)
|
|
84
|
+
usage();
|
|
85
|
+
opt_k = optarg;
|
|
86
|
+
break;
|
|
87
|
+
case 'o':
|
|
88
|
+
if (opt_o != 0.0)
|
|
89
|
+
usage();
|
|
90
|
+
if ((opt_o = strtod(optarg, NULL)) == 0.0) {
|
|
91
|
+
warn0("Invalid option: -o %s", optarg);
|
|
92
|
+
exit(1);
|
|
93
|
+
}
|
|
94
|
+
break;
|
|
95
|
+
case 't':
|
|
96
|
+
if (opt_t)
|
|
97
|
+
usage();
|
|
98
|
+
opt_t = optarg;
|
|
99
|
+
break;
|
|
100
|
+
default:
|
|
101
|
+
usage();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/* We should have processed all the arguments. */
|
|
106
|
+
if (argc != optind)
|
|
107
|
+
usage();
|
|
108
|
+
|
|
109
|
+
/* Set defaults. */
|
|
110
|
+
if (opt_o == 0.0)
|
|
111
|
+
opt_o = 5.0;
|
|
112
|
+
|
|
113
|
+
/* Sanity-check options. */
|
|
114
|
+
if (opt_f && opt_g)
|
|
115
|
+
usage();
|
|
116
|
+
if (opt_k == NULL)
|
|
117
|
+
usage();
|
|
118
|
+
if (!(opt_o > 0.0))
|
|
119
|
+
usage();
|
|
120
|
+
if (opt_t == NULL)
|
|
121
|
+
usage();
|
|
122
|
+
|
|
123
|
+
/* Resolve target address. */
|
|
124
|
+
if ((sas_t = sock_resolve(opt_t)) == NULL) {
|
|
125
|
+
warnp("Error resolving socket address: %s", opt_t);
|
|
126
|
+
exit(1);
|
|
127
|
+
}
|
|
128
|
+
if (sas_t[0] == NULL) {
|
|
129
|
+
warn0("No addresses found for %s", opt_t);
|
|
130
|
+
exit(1);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/* Load the keying data. */
|
|
134
|
+
if ((K = proto_crypt_secret(opt_k)) == NULL) {
|
|
135
|
+
warnp("Error reading shared secret");
|
|
136
|
+
exit(1);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/*
|
|
140
|
+
* Create a socket pair to push bits through. The spiped protocol
|
|
141
|
+
* code expects to be handed a socket to read/write bits to, and our
|
|
142
|
+
* stdin/stdout might not be sockets (in fact, almost certainly aren't
|
|
143
|
+
* sockets); so we'll hand one end of the socket pair to the spiped
|
|
144
|
+
* protocol code and shuttle bits between stdin/stdout and the other
|
|
145
|
+
* end of the socket pair ourselves.
|
|
146
|
+
*/
|
|
147
|
+
if (socketpair(AF_UNIX, SOCK_STREAM, 0, s)) {
|
|
148
|
+
warnp("socketpair");
|
|
149
|
+
exit(1);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/* Set up a connection. */
|
|
153
|
+
if (proto_conn_create(s[1], sas_t, 0, opt_f, opt_g, opt_j, K, opt_o,
|
|
154
|
+
callback_conndied, NULL)) {
|
|
155
|
+
warnp("Could not set up connection");
|
|
156
|
+
exit(1);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/* Push bits from stdin into the socket. */
|
|
160
|
+
if (pushbits(STDIN_FILENO, s[0]) || pushbits(s[0], STDOUT_FILENO)) {
|
|
161
|
+
warnp("Could not push bits");
|
|
162
|
+
exit(1);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/* Loop until we die. */
|
|
166
|
+
do {
|
|
167
|
+
if (events_run()) {
|
|
168
|
+
warnp("Error running event loop");
|
|
169
|
+
exit(1);
|
|
170
|
+
}
|
|
171
|
+
} while (1);
|
|
172
|
+
|
|
173
|
+
/* NOTREACHED */
|
|
174
|
+
/*
|
|
175
|
+
* If we could reach this point, we would free memory, close sockets,
|
|
176
|
+
* and otherwise clean up here.
|
|
177
|
+
*/
|
|
178
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
#include <sys/socket.h>
|
|
2
|
+
|
|
3
|
+
#include <pthread.h>
|
|
4
|
+
#include <stdint.h>
|
|
5
|
+
#include <stdio.h>
|
|
6
|
+
#include <stdlib.h>
|
|
7
|
+
#include <string.h>
|
|
8
|
+
#include <unistd.h>
|
|
9
|
+
|
|
10
|
+
#include "noeintr.h"
|
|
11
|
+
#include "warnp.h"
|
|
12
|
+
|
|
13
|
+
#include "pushbits.h"
|
|
14
|
+
|
|
15
|
+
struct push {
|
|
16
|
+
uint8_t buf[BUFSIZ];
|
|
17
|
+
int in;
|
|
18
|
+
int out;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/* Bit-pushing thread. */
|
|
22
|
+
static void *
|
|
23
|
+
workthread(void * cookie)
|
|
24
|
+
{
|
|
25
|
+
struct push * P = cookie;
|
|
26
|
+
ssize_t readlen;
|
|
27
|
+
|
|
28
|
+
/* Infinite loop unless we hit EOF or an error. */
|
|
29
|
+
do {
|
|
30
|
+
/* Read data and die on error. */
|
|
31
|
+
if ((readlen = read(P->in, P->buf, BUFSIZ)) == -1) {
|
|
32
|
+
if (errno == EINTR)
|
|
33
|
+
continue;
|
|
34
|
+
warnp("Error reading");
|
|
35
|
+
exit(1);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/* If we hit EOF, exit the loop. */
|
|
39
|
+
if (readlen == 0)
|
|
40
|
+
break;
|
|
41
|
+
|
|
42
|
+
/* Write the data back out. */
|
|
43
|
+
if (noeintr_write(P->out, &P->buf, readlen) != readlen) {
|
|
44
|
+
warnp("Error writing");
|
|
45
|
+
exit(1);
|
|
46
|
+
}
|
|
47
|
+
} while (1);
|
|
48
|
+
|
|
49
|
+
/* Close the descriptor we hit EOF on. */
|
|
50
|
+
close(P->in);
|
|
51
|
+
|
|
52
|
+
/*
|
|
53
|
+
* Try to shut down the descriptor we're writing to. Ignore ENOTSOCK,
|
|
54
|
+
* since it might, indeed, not be a socket.
|
|
55
|
+
*/
|
|
56
|
+
if (shutdown(P->out, SHUT_WR)) {
|
|
57
|
+
if (errno != ENOTSOCK) {
|
|
58
|
+
warnp("Error shutting down socket");
|
|
59
|
+
exit(1);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/* Free our parameters. */
|
|
64
|
+
free(P);
|
|
65
|
+
|
|
66
|
+
/* We're done. */
|
|
67
|
+
return (NULL);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* pushbits(in, out):
|
|
72
|
+
* Create a thread which copies data from ${in} to ${out}.
|
|
73
|
+
*/
|
|
74
|
+
int
|
|
75
|
+
pushbits(int in, int out)
|
|
76
|
+
{
|
|
77
|
+
struct push * P;
|
|
78
|
+
pthread_t thr;
|
|
79
|
+
int rc;
|
|
80
|
+
|
|
81
|
+
/* Allocate structure. */
|
|
82
|
+
if ((P = malloc(sizeof(struct push))) == NULL)
|
|
83
|
+
goto err0;
|
|
84
|
+
P->in = in;
|
|
85
|
+
P->out = out;
|
|
86
|
+
|
|
87
|
+
/* Create thread. */
|
|
88
|
+
if ((rc = pthread_create(&thr, NULL, workthread, P)) != 0) {
|
|
89
|
+
warn0("pthread_create: %s", strerror(rc));
|
|
90
|
+
goto err1;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/* Success! */
|
|
94
|
+
return (0);
|
|
95
|
+
|
|
96
|
+
err1:
|
|
97
|
+
free(P);
|
|
98
|
+
err0:
|
|
99
|
+
/* Failure! */
|
|
100
|
+
return (-1);
|
|
101
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
.\"-
|
|
2
|
+
.\" Copyright (c) 2012 Andreas Olsson
|
|
3
|
+
.\"
|
|
4
|
+
.\" Redistribution and use in source and binary forms, with or without
|
|
5
|
+
.\" modification, are permitted provided that the following conditions
|
|
6
|
+
.\" are met:
|
|
7
|
+
.\" 1. Redistributions of source code must retain the above copyright
|
|
8
|
+
.\" notice, this list of conditions and the following disclaimer.
|
|
9
|
+
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
10
|
+
.\" notice, this list of conditions and the following disclaimer in the
|
|
11
|
+
.\" documentation and/or other materials provided with the distribution.
|
|
12
|
+
.\"
|
|
13
|
+
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
14
|
+
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
15
|
+
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
16
|
+
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
17
|
+
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
18
|
+
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
19
|
+
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
20
|
+
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
21
|
+
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
22
|
+
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
23
|
+
.\" SUCH DAMAGE.
|
|
24
|
+
.TH SPIPE 1 "April 2, 2013" "spiped 1.3.0" "spipe README"
|
|
25
|
+
.SH NAME
|
|
26
|
+
spipe \- spiped client utility
|
|
27
|
+
.SH SYNOPSIS
|
|
28
|
+
.B spipe
|
|
29
|
+
\-t <target socket>
|
|
30
|
+
\-k <key file>
|
|
31
|
+
[\-f | \-g]
|
|
32
|
+
[\-j]
|
|
33
|
+
[\-o <connection timeout>]
|
|
34
|
+
.SH OPTIONS
|
|
35
|
+
.TP
|
|
36
|
+
.B \-t <target socket>
|
|
37
|
+
Address to which spipe should connect.
|
|
38
|
+
.TP
|
|
39
|
+
.B \-k <key file>
|
|
40
|
+
Use the provided key file to authenticate and encrypt.
|
|
41
|
+
.TP
|
|
42
|
+
.B \-f
|
|
43
|
+
Use fast/weak handshaking: This reduces the CPU time spent in the
|
|
44
|
+
initial connection setup, at the expense of losing perfect forward
|
|
45
|
+
secrecy.
|
|
46
|
+
.TP
|
|
47
|
+
.B \-g
|
|
48
|
+
Require perfect forward secrecy by dropping connections if the other
|
|
49
|
+
host is using the -f option.
|
|
50
|
+
.TP
|
|
51
|
+
.B \-j
|
|
52
|
+
Disable transport layer keep-alives.
|
|
53
|
+
(By default they are enabled.)
|
|
54
|
+
.TP
|
|
55
|
+
.B \-o <connection timeout>
|
|
56
|
+
Timeout, in seconds, after which an attempt to connect to the target
|
|
57
|
+
or a protocol handshake will be aborted (and the connection dropped)
|
|
58
|
+
if not completed. Defaults to 5s.
|
|
59
|
+
.SH SEE ALSO
|
|
60
|
+
.BR spiped (1).
|