xref: /PHP-7.0/sapi/fpm/tests/005.phpt (revision ad7ed6fe)
1--TEST--
2FPM: Test IPv4 allowed clients
3--SKIPIF--
4<?php include "skipif.inc";
5      @stream_socket_client('tcp://[::1]:0', $errno);
6      if ($errno != 111) die('skip IPv6 not supported.');
7?>
8--FILE--
9<?php
10
11include "include.inc";
12
13$logfile = dirname(__FILE__).'/php-fpm.log.tmp';
14$port = 9000+PHP_INT_SIZE;
15
16$cfg = <<<EOT
17[global]
18error_log = $logfile
19[unconfined]
20listen = [::]:$port
21listen.allowed_clients = 127.0.0.1
22pm = dynamic
23pm.max_children = 5
24pm.start_servers = 2
25pm.min_spare_servers = 1
26pm.max_spare_servers = 3
27EOT;
28
29$fpm = run_fpm($cfg, $tail);
30if (is_resource($fpm)) {
31    fpm_display_log($tail, 2);
32    try {
33		run_request('127.0.0.1', $port);
34		echo "IPv4 ok\n";
35	} catch (Exception $e) {
36		echo "IPv4 error\n";
37	}
38    try {
39		run_request('[::1]', $port);
40		echo "IPv6 ok\n";
41	} catch (Exception $e) {
42		echo "IPv6 error\n";
43	}
44    proc_terminate($fpm);
45    stream_get_contents($tail);
46    fclose($tail);
47    proc_close($fpm);
48}
49
50?>
51--EXPECTF--
52[%d-%s-%d %d:%d:%d] NOTICE: fpm is running, pid %d
53[%d-%s-%d %d:%d:%d] NOTICE: ready to handle connections
54IPv4 ok
55IPv6 error
56--CLEAN--
57<?php
58    $logfile = dirname(__FILE__).'/php-fpm.log.tmp';
59    @unlink($logfile);
60?>
61