Hi systemd-devel,

Sorry to bug you with another user question.

I have a socket activated daemon, call it mydaemon, and I have trouble finding 
out who connects to it.


mydaemon.socket contains:


  [Socket]
  ListenStream=9999

When I connect using IPv4 using

  nc -4 localhost 9999

then mydaemon does

  sockaddr_in6 peer;
  socklen_t peer_size=sizeof(peer);
  accept(3,(struct sockaddr *)&peer,sizeof(peer))


Afterwards, peer.sin6_family is AF_INET6 and peer.sin6_addr contains some 
gibberish like a00:e5ae::


If I connect more than once, the gibberish changes from connection to 
connection.


Something similar happens if I connect using IPv6.


If I change mydaemon.socket to


  [Socket]
  ListenStream=0.0.0.0:9999

Then peer.sin6_family becomes AF_INET as it should. But if peer is cast to 
struct sockaddr_in then peer.sin_addr still contains gibberish like 2.0.191.150 
(I expected something like 127.0.0.1 or 192.168.0.99).

When I connect from other machines, the peer address still is gibberish.

If mydaemon creates the listening socket, I can easily get the peer address.

I suspect that when systemd creates the listening socket then accept(3,...) 
returns a socket which is connected to a local socket created by systemd.

QUESTION: Is that suspicion correct? And if yes, is there are way to recover 
the address of the actually connecting peer?

Cheers,
Klaus

Reply via email to