Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

umdns gen wrap /wrong json data #1

Open
ptpt52 opened this issue Jul 21, 2022 · 5 comments
Open

umdns gen wrap /wrong json data #1

ptpt52 opened this issue Jul 21, 2022 · 5 comments

Comments

@ptpt52
Copy link

ptpt52 commented Jul 21, 2022

ubus call umdns browse
output:

{
	"_dawn._tcp": {
		"MESH-AGENT_E4671E37EC68": {
			"ipv4": "192.168.15.106",
			"ipv6": "fdd5:d636:7052::1",
			"ipv6": "fe80::e667:1eff:fe37:ec68",
			"port": 1026
		},
		"MESH-AGENT_E4671E37EC54": {
			"ipv4": "192.168.15.236",
			"ipv6": "fd0e:6d62:cc45::1",
			"ipv6": "fe80::e667:1eff:fe37:ec54",
			"port": 1026
		},
		"MESH-AGENT_E4671E37EC95": {
			"ipv4": "192.168.15.151",
			"ipv6": "fd2b:8175:aa9b::1",
			"ipv6": "fe80::e667:1eff:fe37:ec95",
			"port": 1026
		},
		"MESH-AGENT_E4671E37EC8B": {
			"ipv4": "192.168.16.1",
			"ipv6": "fda8:42e8:8129::1",
			"ipv6": "fe80::e667:1eff:fe37:ec8b",
			"ipv4": "192.168.15.141",
			"port": 1026
		}
	},
	"_ssh._tcp": {
		"MESH-AGENT_E4671E37EC68": {
			"ipv4": "192.168.15.106",
			"ipv6": "fdd5:d636:7052::1",
			"ipv6": "fe80::e667:1eff:fe37:ec68",
			"port": 22,
			"txt": "daemon=dropbear"
		},
		"MESH-AGENT_E4671E37EC54": {
			"ipv4": "192.168.15.236",
			"ipv6": "fd0e:6d62:cc45::1",
			"ipv6": "fe80::e667:1eff:fe37:ec54",
			"port": 22,
			"txt": "daemon=dropbear"
		},
		"MESH-AGENT_E4671E37EC95": {
			"ipv4": "192.168.15.151",
			"ipv6": "fd2b:8175:aa9b::1",
			"ipv6": "fe80::e667:1eff:fe37:ec95",
			"port": 22,
			"txt": "daemon=dropbear"
		},
		"MESH-AGENT_E4671E37EC8B": {
			"ipv4": "192.168.16.1",
			"ipv6": "fda8:42e8:8129::1",
			"ipv6": "fe80::e667:1eff:fe37:ec8b",
			"ipv4": "192.168.15.141",
			"port": 22,
			"txt": "daemon=dropbear"
		}
	}
}

this json data is wrong, there is Duplicate key 'ipv6' 'ipv4'

@stintel

@stintel
Copy link
Member

stintel commented Jul 21, 2022

Please don't mention random people. I don't know the umdns code.

@neheb
Copy link
Contributor

neheb commented Jul 21, 2022

I believe @rmilecki works on umdnsd.

@t-8ch
Copy link

t-8ch commented Jul 23, 2022

According to to the documentation examples this looks to be expected.
Duplicate keys in JSON objects are allowed, albeit unusual.
Maybe you need to configure your JSON parser to handle this properly.

@ptpt52
Copy link
Author

ptpt52 commented Jul 30, 2022

According to to the documentation examples this looks to be expected. Duplicate keys in JSON objects are allowed, albeit unusual. Maybe you need to configure your JSON parser to handle this properly.

but most implementations of JSON libraries do not accept duplicate keys
what lib/tools should I use to parse such json?

@t-8ch
Copy link

t-8ch commented Jul 31, 2022

what lib/tools should I use to parse such json?

This depends strongly on your environment.

For Python you can use the object_pairs_hookparameter for json.load.
For json-c you can (probably) use json_object_object_foreach().

In general APIs that iterate over object contents are more likely to expose this feature than APIs that treat objects as dictionaries.

@ynezz ynezz transferred this issue from openwrt/openwrt Jun 4, 2023
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

No branches or pull requests

4 participants