Workerman-DNS/.history/start2_20220909192023.php

20 lines
491 B
PHP
Raw Normal View History

2022-12-15 18:09:24 +08:00
<?php
use Workerman\Worker;
use Workerman\Connection\TcpConnection;
use Workerman\Protocols\Http\Request;
require_once __DIR__ . '/vendor/autoload.php';
$worker = new Worker('Dns://0.0.0.0:53');
// 注意直接udp协议是有效的使用自定义协议无效
$worker->transport = 'udp';
$worker->onMessage = function($connection, $data){
$data=explode('|||', $data);
$type=$data[0];
$name=$data[1];
$rip=$connection->getRemoteIp();
#echo "$type\n$name\n$rip\n";
};
Worker::runAll();