ser2net: support 'host' option in ser2net_proxy() to allow binding to a specific IP (e.g. 127.0.0.1)

Open Beginner friendly
#31,318 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
75/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
shell
Domain
backend

Research direction

Read net/ser2net/files/ser2net.init, especially ser2net_proxy() and ser2net_controlport(). Compare how the proxy validates its port and how the control port handles the optional host, then inspect the generated /tmp/ser2net.yaml. Done means a proxy can bind to a configured host while an unset host keeps the existing behavior.

Written by the indexing model from the issue text.

Description

bug
Package Name

ser2net

Maintainer

@dangowrt

OpenWrt Version

25.12.6

OpenWrt Target/Subtarget

ipq40xx/generic

Steps to Reproduce
  1. Configure a proxy section in /etc/config/ser2net to expose a local USB serial device (e.g. /dev/ttyUSB0) only on the loopback interface (127.0.0.1) so that an encrypted wrapper (stunnel or SSH port forwarding) can front it securely:
uci set ser2net.zigbee='proxy'
uci set ser2net.zigbee.enabled='1'
uci set ser2net.zigbee.port='127.0.0.1,16638'
uci set ser2net.zigbee.protocol='raw'
uci set ser2net.zigbee.device='/dev/ttyUSB0'
uci set ser2net.zigbee.baudrate='115200'
uci commit ser2net
  1. Restart the service using service ser2net restart.
  2. Inspect the standard error output and /tmp/ser2net.yaml.
Actual Behaviour

In /etc/init.d/ser2net (net/ser2net/files/ser2net.init), ser2net_proxy() strictly validates $port as an integer and does not read a host option:

config_get port "$cfg" port
[ "$port" -ge 1 ] && [ "$port" -le 65535 ] || return 1

Passing 127.0.0.1,16638 (or 127.0.0.1:16638) in option port fails with sh: 127.0.0.1,16638: bad number and ser2net_proxy() exits early (return 1), omitting the connection: block from /tmp/ser2net.yaml.

By contrast, ser2net_controlport() in the same init script already supports an optional host parameter:

config_get host "$cfg" host
...
echo "admin:"
echo "  accepter: tcp,${host:+$host,}$port"

Expected Behaviour

`ser2net_proxy()` should support an optional `host` UCI option (matching `ser2net_controlport()`) to generate `accepter: $protocol,${host:+$host,}$port` in `/tmp/ser2net.yaml`, allowing administrators to bind serial proxies to `127.0.0.1` or a specific management IP via UCI while maintaining full backward compatibility when `host` is unset.

Thank you for maintaining LuCI and luci-app-ser2net!!

Confirmation Checklist
Dominant language
Makefile
Stars
4.7k
Forks
4k
Avg merge
2d 5h
Merged PRs (30d)
249

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from openwrt/packages

All issues in openwrt/packages

Similar issues

More Backend & API Design issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.