Skip to content

Restore ListenAndServe error return in Transport.Listen

David Fifield requested to merge dcf/snowflake:40043 into main

This restores an error return that had been lost in !31 (closed). It causes any error resulting from http.ListenAndServe or http.ListenAndServeTLS to be surfaced in an SMETHOD-ERROR, which was the intention behind ea7b9c02 until 70126177 accidentally broke it.

Fixes #40043 (closed).

To see the difference, have snowflake-server try listening on a reserved port. Before this change, notice the bind error on stderr but no SMETHOD-ERROR:

$ TOR_PT_MANAGED_TRANSPORT_VER=1 \
  TOR_PT_SERVER_BINDADDR=snowflake-127.0.0.1:123 \
  TOR_PT_SERVER_TRANSPORTS=snowflake \
  TOR_PT_ORPORT=127.0.0.1:9999 \
  ./server -disable-tls
2023/03/21 21:54:10 snowflake-server 2.5.1
2023/03/21 21:54:10 starting
VERSION 1
2023/03/21 21:54:10 listening with plain HTTP on [scrubbed]
2023/03/21 21:54:10 error in ListenAndServe: listen tcp [scrubbed]: bind: permission denied
SMETHOD snowflake 127.0.0.1:123 ARGS:tls=no
SMETHODS DONE

With this change, notice SMETHOD-ERROR:

$ TOR_PT_MANAGED_TRANSPORT_VER=1 \
  TOR_PT_SERVER_BINDADDR=snowflake-127.0.0.1:123 \
  TOR_PT_SERVER_TRANSPORTS=snowflake \
  TOR_PT_ORPORT=127.0.0.1:9999 \
  ./server -disable-tls
2023/03/21 21:55:21 snowflake-server 2.5.1
2023/03/21 21:55:21 starting
VERSION 1
2023/03/21 21:55:21 listening with plain HTTP on [scrubbed]
2023/03/21 21:55:21 error in ListenAndServe: listen tcp [scrubbed]: bind: permission denied
2023/03/21 21:55:21 error opening listener: listen tcp [scrubbed]: bind: permission denied
SMETHOD-ERROR snowflake listen tcp 127.0.0.1:123: bind: permission denied
SMETHODS DONE

Merge request reports

Loading