Skip to content

Add option --bind-interface

Suhas K S requested to merge suhasks123/wget2:addBindInterface into master

Design:

--bind-interface is a download option which involves binding the socket of the TCP connection to a particular network interface on the local machine.

This is implemented in the function set_socket_options() in libwget/net.c which is called by wget_tcp_connect() in the same file. The interface to bind to is stored in config.bind_interface in src/wget_options.h. This is made accessible to wget_tcp_connect() by passing it to a function wget_tcp_bind_interface() which sets the value of the variable bind_interface of the struct global_tcp to the parameter passed to it. This way, all the functions of net.c can access bind_interface, including wget_tcp_connect() and set_socket_options() which use it to bind the created socket to it.

One particular thing to note is that wget2 has to be run with elevated privileges for the option to work. Also, as of now, there are no tests for this option in the test-suite.

Approver's checklist:

  • The author has submitted the FSF Copyright Assignment and is listed in AUTHORS
  • There is a test suite reasonably covering new functionality or modifications
  • Function naming, parameters, return values, types, etc., are consistent with existing code
  • This feature/change has adequate documentation added (if appropriate)
  • No obvious mistakes / misspelling in the code
Edited by Suhas K S

Merge request reports