UlricE / pen

Pen
Other
249 stars 41 forks source link

UDP not working in combination with a configuration file (-U + -F switches) #30

Closed sandervanburken closed 7 years ago

sandervanburken commented 8 years ago

Thank you for creating pen, what a great program!

In the the 0.33 version of pen there is no support for setting pen to use UDP using penctl and/or in a configuration file.

The manpage states:

       -F cfgfile
              Names a configuration file with commands in penctl format (see penctl.1). The file is read after  processing all command line arguments, and also after receiving a HUP signal.

If I run pen with: pen -U -F pen.conf, I expect that my listen and server directives will use UDP. But instead the listen directive binds to a TCP port (and I guess the server directive will send to a TCP port).

For example:

# cat pen.conf
listen 0.0.0.0:9999
server 0 address 10.0.0.1 port 9999
server 1 address 10.0.0.2 port 9999
server 2 address 10.0.0.3 port 9999

# pen -U -F pen.conf
0.0.0.0:9999

# netstat -ltn | grep 9999
tcp        0      0 0.0.0.0:9999            0.0.0.0:*               LISTEN

# netstat -lun | grep 9999

This was tested on Ubuntu 14.04.

UlricE commented 8 years ago

You are right, the initialization tasks were ordered such that a listening socket specified in the configuration file would be created as tcp, despite the -U switch. This has been fixed in git and the fix will be included in the next release.

UlricE commented 8 years ago

ulric@debtest:~/Git/pen$ cat > issue30.cfg listen 0.0.0.0:5353 server 0 address 8.8.8.8 port 53 server 1 address 8.8.4.4 port 53 ulric@debtest:~/Git/pen$ ./pen -U -F issue30.cfg 0.0.0.0:5353 ulric@debtest:~/Git/pen$ netstat -ln | grep 5353 udp 0 0 0.0.0.0:5353 0.0.0.0:* ulric@debtest:~/Git/pen$ dig +short @localhost -p 5353 siag.nu 194.9.95.65

UlricE commented 7 years ago

Closing this since the fix is in 0.34.0.