这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@sarg
Copy link

@sarg sarg commented May 14, 2025

Fixes #688.

@sarg
Copy link
Author

sarg commented May 14, 2025

Example usage:

# list registrations
../usr/libexec/termux-api Nsd --es command list

# register service
../usr/libexec/termux-api Nsd --es name "termux" --es type "_termux._tcp" --ei port 9090 --es command register

# unregister by id
../usr/libexec/termux-api Nsd --es id "uuid" --es command unregister

# unregister by name and type
../usr/libexec/termux-api Nsd --es name "termux" --es type "_termux._tcp" --es command unregister

The result is a json object.

@rene-descartes2021
Copy link

rene-descartes2021 commented Nov 13, 2025

This would be great for finding IP's when using Android as the hotspot. Currently I ping all 255-1 IP's in the subnet to find the client which takes a few minutes... as no multicast permission for mDNS or whatnot. Termux:API is the place to do this. Thank you very much!

Here's a forward thinking thought on this PR: I remember reading somewhere a Termux maintainer said in Google play reviews that they're very scrutinous of new permissions being added, especially that malware can use. Maybe add a button in the GUI analogous to the current 'GRANT DRAW OVER APPS PERMISSION' button? Forward thinking as Termux isn't currently distributed on Google Play and I guess they're working on getting back, or at least Fornwall's experimental fork was/is. Dunno if this is a good suggestion or not, they could say better.

Well that's all I had to say.

@sarg
Copy link
Author

sarg commented Nov 13, 2025

@rene-descartes2021 the hotspot is the default gateway for connected devices. You can simply get the address from ip route list default

@rene-descartes2021
Copy link

rene-descartes2021 commented Nov 13, 2025

@sarg I appreciate the prompt reply. Sorry my use case was unclear, the client is a headless minipc which auto connects to the hotspot when it sees it. Using it as a compute/storage node on the go.

I'm unable to ssh into it from Termux until I get its IP somehow- it is headless so no screen or keyboard. I guess I could auto run a script on the client which rsync's a file containing its IP to the gateway along the lines as you suggested... Would have to auto run sshd on Termux. Or some other means of communicating/logging I guess... something with netcat maybe. My initial hope was the client advertising itself with mDNS or whatever zero-config avahi service-thing, but you are right something else might work. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mDNS discovery support

2 participants