lan-mouse icon indicating copy to clipboard operation
lan-mouse copied to clipboard

Host name resolving problem for Mac

Open pomelo opened this issue 1 year ago • 7 comments

Hi there, I need help for setting up lan-mouse running on two of my mac devices: an Intel MBP 2014 (macOS 12.7.6) and an M1 Pro MBP (macOS 15.1). I found lan-mouse couldn't resolve the hostname that ends with .lan or .local. If I don't provide the hostname in the configuration files but use ips list, it works. The only problem is both of them are running with DHCP client, so I have to change the IP list from time to time.

The toml file is as below:

# configure release bind
release_bind = [ "KeyA", "KeyS", "KeyD", "KeyF" ]
# port = 4242

# optional frontend -> defaults to gtk if available
# possible values are "cli" and "gtk" 
frontend = "cli"

[left]

# hostname
hostname = "W-Silicon.local"
activate_on_startup = true
ips = ["192.168.1.211"]

And the logs are:

[2024-11-12T09:49:27Z INFO  lan_mouse::config] using config: "/Users/wayne/.config/lan-mouse/config.toml"
[2024-11-12T09:49:27Z INFO  lan_mouse] release bind: [KeyA, KeyS, KeyD, KeyF]
[2024-11-12T09:49:27Z INFO  lan_mouse::config] using config: "/Users/wayne/.config/lan-mouse/config.toml"
[2024-11-12T09:49:27Z INFO  lan_mouse] release bind: [KeyA, KeyS, KeyD, KeyF]
[2024-11-12T09:49:27Z INFO  lan_mouse] Press [KeyA, KeyS, KeyD, KeyF] to release the mouse
[2024-11-12T09:49:27Z INFO  input_capture::macos] Enabling CGEvent tap
[2024-11-12T09:49:27Z INFO  input_capture] using capture backend: MacOS
[2024-11-12T09:49:27Z INFO  lan_mouse::server::emulation_task] creating input emulation...
[2024-11-12T09:49:27Z INFO  input_emulation] using emulation backend: macos
[2024-11-12T09:49:27Z INFO  lan_mouse::dns] resolving (0) `W-Silicon.local` ...
lan-mouse > emulation status: Enabled
lan-mouse > capture status: Enabled
lan-mouse > changed port to 4242
lan-mouse > [2024-11-12T09:49:27Z WARN  lan_mouse::dns] could not resolve host 'W-Silicon.local': no record found for Query { name: Name("w-silicon.local.lan."), query_type: AAAA, query_class: IN }
lan-mouse > [2024-11-12T09:49:28Z WARN  lan_mouse::server::ping_task] client not responding, releasing pointer!
[2024-11-12T09:49:30Z WARN  lan_mouse::server::ping_task] client not responding, releasing pointer!
[2024-11-12T09:49:35Z WARN  lan_mouse::server::ping_task] client not responding, releasing pointer!
[2024-11-12T09:49:36Z WARN  lan_mouse::server::ping_task] client not responding, releasing pointer!
[2024-11-12T09:49:38Z INFO  lan_mouse::server] terminating service
[2024-11-12T09:49:38Z INFO  lan_mouse] service exited!

pomelo avatar Nov 12 '24 09:11 pomelo

I recall that using the .local TLD is discouraged on MacOS because it is used for mDNS. See https://en.wikipedia.org/wiki/.local or https://superuser.com/questions/1828456/macos-cannot-access-custom-local-domain.

With .lan I don't know why that should be a problem though. Could you verify that the .lan domains actually cause problems as well?

feschber avatar Nov 12 '24 10:11 feschber

@feschber Thanks for the replying. The problem is, I can't modify the .local suffix, it is grayed out in the Settings, and if I set W-Silicon.lan for local hostname, then it says 'The Bonjour Name is invalid.' and won't save the changes.

And you are correct, the .lan domain is working, so that I can move the cursor from the Apple Silicon MBP to the old Intel MBP. However, soon after I typed a few letters, the client mac (old intel one) got repeatedly key stroke, and even ctrl-d / ctrl-c wouldn't work to terminate the lan-mouse process, and I can only kill it from Activity Monitor. I thought it was a release bind problem, so I commented it out but the problem was not resolved.

Here are the logs:

wayne@Waynes-MBP ~> lan-mouse                                                                                                                                                                [2024-11-13T09:29:46Z INFO  lan_mouse::config] using config: "/Users/wayne/.config/lan-mouse/config.toml"
[2024-11-13T09:29:46Z INFO  lan_mouse] release bind: [KeyLeftCtrl, KeyLeftShift, KeyLeftMeta, KeyLeftAlt]
[2024-11-13T09:29:46Z INFO  lan_mouse::config] using config: "/Users/wayne/.config/lan-mouse/config.toml"
[2024-11-13T09:29:46Z INFO  lan_mouse] release bind: [KeyLeftCtrl, KeyLeftShift, KeyLeftMeta, KeyLeftAlt]
[2024-11-13T09:29:46Z INFO  lan_mouse] Press [KeyLeftCtrl, KeyLeftShift, KeyLeftMeta, KeyLeftAlt] to release the mouse
[2024-11-13T09:29:46Z INFO  input_capture::macos] Enabling CGEvent tap
[2024-11-13T09:29:46Z INFO  input_capture] using capture backend: MacOS
[2024-11-13T09:29:46Z INFO  lan_mouse::server::emulation_task] creating input emulation...
[2024-11-13T09:29:46Z INFO  input_emulation] using emulation backend: macos
[2024-11-13T09:29:46Z INFO  lan_mouse::dns] resolving (0) `W-Silicon.local` ...
lan-mouse > emulation status: Enabled
lan-mouse > capture status: Enabled
lan-mouse > changed port to 4242
lan-mouse > [2024-11-13T09:29:46Z WARN  lan_mouse::dns] could not resolve host 'W-Silicon.local': no record found for Query { name: Name("w-silicon.local.lan."), query_type: AAAA, query_class: IN }
lan-mouse > aasdf[2024-11-13T09:29:59Z WARN  lan_mouse::server::ping_task] device not responding, releasing keys!
fffffffffffffff[2024-11-13T09:29:59Z WARN  lan_mouse::server::ping_task] device not responding, releasing keys!
fffffffffffffff[2024-11-13T09:30:00Z WARN  lan_mouse::server::ping_task] device not responding, releasing keys!
fffffffffffffff[2024-11-13T09:30:00Z WARN  lan_mouse::server::ping_task] device not responding, releasing keys!
fffffffffffffff[2024-11-13T09:30:01Z WARN  lan_mouse::server::ping_task] device not responding, releasing keys!
fffffffffffffff[2024-11-13T09:30:01Z WARN  lan_mouse::server::ping_task] device not responding, releasing keys!
fffffffffffffff[2024-11-13T09:30:02Z WARN  lan_mouse::server::ping_task] device not responding, releasing keys!
fffffffffffffff[2024-11-13T09:30:02Z WARN  lan_mouse::server::ping_task] device not responding, releasing keys!
fffffffffffffff[2024-11-13T09:30:03Z WARN  lan_mouse::server::ping_task] device not responding, releasing keys!
fffffffffffffff[2024-11-13T09:30:03Z WARN  lan_mouse::server::ping_task] device not responding, releasing keys!
fffffffffffffff[2024-11-13T09:30:04Z WARN  lan_mouse::server::ping_task] device not responding, releasing keys!
fffffffffffffff[2024-11-13T09:30:04Z WARN  lan_mouse::server::ping_task] device not responding, releasing keys!
fffffffffffffff[2024-11-13T09:30:05Z WARN  lan_mouse::server::ping_task] device not responding, releasing keys!

pomelo avatar Nov 13 '24 09:11 pomelo

I have a similar problem. The '.local. is what Bonjour normally uses but even setting the correct hostname lan-mouse doesn't seem able to resolve while dig can... It seems like lan-mouse only wants to connect to an IPv6?

[2024-11-19T15:02:12Z INFO  lan_mouse::dns] resolving (0) `mac1.my-domain.com` ...
[2024-11-19T15:02:42Z WARN  lan_mouse::dns] could not resolve host 'mac1.my-domain.com': no record found for Query { name: Name("mac1.my-domain.com.my-domain.com."), query_type: AAAA, query_class: IN }
 ~ > dig mac1.my-domain.com 

; <<>> DiG 9.10.6 <<>> mac1.my-domain.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 48285
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;mac1.my-domain.com. IN	A

;; ANSWER SECTION:
mac1.my-domain.com. 0 IN	A	192.168.1.2

;; Query time: 3 msec
;; SERVER: 192.168.1.1#53(192.168.1.1)
;; WHEN: Tue Nov 19 07:03:00 PST 2024
;; MSG SIZE  rcvd: 78

porelli avatar Nov 19 '24 15:11 porelli

Having this problem atm. Anyone find a solution or workaround? I can't seem to find a way to change the .local on my macbook. Nor an option to change it from my router.

SMQuazi avatar Oct 19 '25 05:10 SMQuazi

As a workaround, you should be able to use an IP address instead @SMQuazi

feschber avatar Oct 19 '25 13:10 feschber

I can't seem to find a way to change the .local on my macbook.

I normally use .lan (for the reasons @feschber mentioned) but actually it seemed to revert to .local today (maybe a recent macOS update forced it?)

Anyway, I ran sudo scutil --set HostName whirlyjig.lan (replace whirlyjig with your hostname) and it changed the output of hostname correctly.

nbolton avatar Oct 21 '25 11:10 nbolton

#!/bin/bash set -e

HOST_NAME="omarchy.local" CONFIG_PATH="/tmp/lan-mouse-server.toml" PORT=4242 echo "🔍 正在解析 $HOST_NAME 的 IP..."

用 ping -c1 方式快速解析 mDNS(只发 1 个包,1 秒超时)

SERVER_IP=$(ping -c1 -t1 "$HOST_NAME" 2>/dev/null | grep -oE '([0-9]+.[0-9]+.[0-9]+.[0-9]+)' | tr -d '()')

if [ -z "$SERVER_IP" ]; then echo "❌ 无法解析 $HOST_NAME,请检查 Linux 端是否开启 mDNS(avahi-daemon)。" exit 1 fi

echo "✅ 对方 IP: $SERVER_IP"

=== 生成配置文件 ===

mkdir -p "$(dirname "$CONFIG_PATH")" cat > "$CONFIG_PATH" <<EOF port = $PORT release_bind = ["KeyA", "KeyS", "KeyD", "KeyF"]

[[clients]] position = "$POSITION" hostname = "$PEER_HOSTNAME" ips = ["$SERVER_IP"] activate_on_startup = true EOF

echo "✅ 已生成配置文件: $CONFIG_PATH"

=== 启动 lan-mouse ===

echo "🚀 启动 lan-mouse ..." /Applications/lan-mouse-macos-aarch64 --frontend cli --config "$CONFIG_PATH"

reasonz avatar Oct 24 '25 04:10 reasonz