Coder Social home page Coder Social logo

UDP usage about nntp-proxy HOT 4 CLOSED

nieluj avatar nieluj commented on August 22, 2024
UDP usage

from nntp-proxy.

Comments (4)

lkmikkel avatar lkmikkel commented on August 22, 2024

Hmm... nntp-proxy doesn't use UDP weird?? maybe some libevent voodo?

from nntp-proxy.

lkmikkel avatar lkmikkel commented on August 22, 2024

libevent before version 2.1 is using UDP socket to detect IPv6 WTF see 1.7
https://raw.github.com/libevent/libevent/master/whatsnew-2.1.txt

from nntp-proxy.

nieluj avatar nieluj commented on August 22, 2024

The nntp-proxy does not explicitly open an UDP socket. The bufferevent_socket_connect_hostname function will open such a socket when contacting a DNS server during a hostname resolution.

Using strace, you can observe the following behaviour:

open("/etc/resolv.conf", O_RDONLY|O_CLOEXEC) = 6
fstat64(6, {st_mode=S_IFREG|0644, st_size=71, ...}) = 0
read(6, "nameserver 127.0.0.1\nnameserver "..., 71) = 71
close(6)                                = 0
socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 6
fcntl64(6, F_GETFD)                     = 0
fcntl64(6, F_SETFD, FD_CLOEXEC)         = 0
fcntl64(6, F_GETFL)                     = 0x2 (flags O_RDWR)
fcntl64(6, F_SETFL, O_RDWR|O_NONBLOCK)  = 0
epoll_ctl(3, EPOLL_CTL_ADD, 6, {EPOLLIN, {u32=6, u64=6}}) = 0
socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 7
fcntl64(7, F_GETFD)                     = 0
fcntl64(7, F_SETFD, FD_CLOEXEC)         = 0
fcntl64(7, F_GETFL)                     = 0x2 (flags O_RDWR)
fcntl64(7, F_SETFL, O_RDWR|O_NONBLOCK)  = 0
epoll_ctl(3, EPOLL_CTL_ADD, 7, {EPOLLIN, {u32=7, u64=7}}) = 0
socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 8
fcntl64(8, F_GETFD)                     = 0
fcntl64(8, F_SETFD, FD_CLOEXEC)         = 0
fcntl64(8, F_GETFL)                     = 0x2 (flags O_RDWR)
fcntl64(8, F_SETFL, O_RDWR|O_NONBLOCK)  = 0
epoll_ctl(3, EPOLL_CTL_ADD, 8, {EPOLLIN, {u32=8, u64=8}}) = 0

So I suppose that libevent opens a SOCK_DGRAM socket for each DNS server in /etc/resolv.conf, then calls epoll on those sockets for providing asynchronous DNS resolution.

You can try to comment one of the three servers in /etc/resolv.conf, restart nntp-proxy and see if the number of opened UDP sockets has diminished.

from nntp-proxy.

nomandera avatar nomandera commented on August 22, 2024

So I went the other way and added a 4th nameserver to /etc/resolv.conf.

This seems to confirm the proposed answer:

netstat -lnptu | grep nntp-proxy | grep udp
udp 0 0 0.0.0.0:53134 0.0.0.0:* 32614/nntp-proxy
udp 0 0 0.0.0.0:56476 0.0.0.0:* 32614/nntp-proxy
udp 0 0 0.0.0.0:36920 0.0.0.0:* 32614/nntp-proxy
udp 0 0 0.0.0.0:36569 0.0.0.0:* 32614/nntp-proxy

from nntp-proxy.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.