1# The syslogd binds multiple UDP, TCP, TLS sockets on localhost.
2# The client writes messages into a all localhost sockets.
3# The syslogd writes it into a file and through a pipe.
4# The syslogd passes it via UDP to the loghost.
5# The server receives the messages on its UDP socket.
6# Find the messages in client, file, syslogd log.
7# Check that fstat contains all bound sockets.
8# Check that the file log contains all messages.
9# Check that client used expected protocol.
10
11use strict;
12use warnings;
13use Socket;
14
15our %args = (
16    client => {
17	connectproto => "none",
18	redo => [
19	    { connect => {
20		proto  => "udp",
21		domain => AF_INET,
22		addr   => "127.0.0.1",
23		port   => 514,
24	    }},
25	    { connect => {
26		proto  => "udp",
27		domain => AF_INET,
28		addr   => "127.0.0.1",
29		port   => 513,
30	    }},
31	    { connect => {
32		proto  => "udp",
33		domain => AF_INET6,
34		addr   => "::1",
35		port   => 514,
36	    }},
37	    { connect => {
38		proto  => "tcp",
39		domain => AF_INET,
40		addr   => "127.0.0.1",
41		port   => 514,
42	    }},
43	    { connect => {
44		proto  => "tcp",
45		domain => AF_INET6,
46		addr   => "::1",
47		port   => 513,
48	    }},
49	    { connect => {
50		proto  => "tcp",
51		domain => AF_INET6,
52		addr   => "::1",
53		port   => 514,
54	    }},
55	    { connect => {
56		proto  => "tls",
57		domain => AF_INET6,
58		addr   => "::1",
59		port   => 6514,
60	    }},
61	    { connect => {
62		proto  => "tls",
63		domain => AF_INET,
64		addr   => "127.0.0.1",
65		port   => 6514,
66	    }},
67	    { connect => {
68		proto  => "tls",
69		domain => AF_INET,
70		addr   => "127.0.0.1",
71		port   => 6515,
72	    }},
73	],
74	func => sub { redo_connect(shift, sub {
75	    my $self = shift;
76	    write_message($self, "client proto: ". $self->{connectproto});
77	})},
78	loggrep => {
79	    qr/connect sock: (127.0.0.1|::1) \d+/ => 9,
80	    get_testgrep() => 1,
81	},
82    },
83    syslogd => {
84	options => [qw(-rr
85	    -U 127.0.0.1 -U [::1] -U 127.0.0.1:513
86	    -T 127.0.0.1:514 -T [::1]:514 -T [::1]:513
87	    -S [::1]:6514 -S 127.0.0.1 -S 127.0.0.1:6515
88	)],
89	fstat => {
90	    qr/ internet6? dgram udp (127.0.0.1):513$/ => 1,
91	    qr/ internet6? dgram udp (127.0.0.1):514$/ => 1,
92	    qr/ internet6? dgram udp (\[::1\]):514$/ => 1,
93	    qr/ internet6? stream tcp \w+ (127.0.0.1):514$/ => 1,
94	    qr/ internet6? stream tcp \w+ (\[::1\]):513$/ => 1,
95	    qr/ internet6? stream tcp \w+ (\[::1\]):514$/ => 1,
96	    qr/ internet6? stream tcp \w+ (\[::1\]):6514$/ => 1,
97	    qr/ internet6? stream tcp \w+ (127.0.0.1):6514$/ => 1,
98	    qr/ internet6? stream tcp \w+ (127.0.0.1):6515$/ => 1,
99	},
100    },
101    file => {
102	loggrep => {
103	    qr/client proto: udp/ => '>=1',
104	    qr/client proto: tcp/ => 3,
105	    qr/client proto: tls/ => 3,
106	    get_testgrep() => 1,
107	}
108    },
109);
110
1111;
112