私はオープンソースのタラを持っていました(これはリンクです) タラのこの部分でhttps://github.com/jtRIPper/dns-tcp-socks-proxy/blob/master/dns_proxy.cにアクセスしてください
while(1)
{
// receive a dns request from the client
printf("wait for a dns request from the client\n");
len = recvfrom(sock, buffer->buffer, 2048, 0, (struct sockaddr *)&dns_client, &dns_client_size);
printf("dns request received\n");
// fork so we can keep receiving requests
if (fork() != 0) { continue; }
// the tcp query requires the length to precede the packet, so we put the length there
query = malloc(len + 3);
query[0] = 0;
query[1] = len;
memcpy(query + 2, buffer->buffer, len);
// forward the packet to the tcp dns server
fprintf(LOG_FILE, "tcp query call\n");
tcp_query(query, buffer, len + 2);
// send the reply back to the client (minus the length at the beginning)
sendto(sock, buffer->buffer + 2, buffer->length - 2, 0, (struct sockaddr *)&dns_client, sizeof(dns_client));
free(buffer->buffer);
free(buffer);
free(query);
exit(0);
、recvfrom() 関数が機能せず、続行できず、「dns request received\n」と表示されます。何が問題なのですか? そして、netstat -upan inn コマンド lin を使用すると、これが表示されます
アクティブなインターネット接続 (サーバーおよび確立済み) Proto Recv-Q Send-Q ローカル アドレス 外部アドレス 状態 PID/プログラム名 udp 0 0 127.0.0.1:951 0.0.0.0:* 1623/rpc.statd
udp 0 0 0.0.0.0:54721 0.0.0.0:* 2214/avahi-daemon: udp 0 0 0.0.0.0:45085 0.0.0.0:* 1623/rpc.statd
udp 0 0 127.0.0.1:53 0.0.0.0:* 4084/dns_proxy
udp 0 0 0.0. 0.0:68 0.0.0.0:* 1628/dhclient
udp 0 0 0.0.0.0:111 0.0.0.0:* 1582/rpcbind
udp 0 0 0.0.0.0:631 0.0.0.0:* 2323/cupsd
udp 0 0 0.0.0.0:5353 0.0.0.0:* 2214/avahi-daemon: udp 0 0 0.0.0.0:42756 0.0.0.0:* 1628/ dhclient
udp 0 0 0.0.0.0:1900 0.0.0.0:* 3306/minissdpd
udp 0 0 0.0.0.0:908 0.0.0.0:* 1582/rpcbind
udp6 0 0 :::111 :::* 1582/rpcbind
udp6 0 0 :::34443 :::* 1623/rpc.statd
udp6 0 0 :::5353 :::* 2214/avahi-daemon: udp6 0 0 :::62844 :::* 1628/dhclient
udp6 0 0 :::54654 :::* 2214/avahi-daemon: udp6 0 0 :::908 :::* 1582/rpcbind