cfsghost / jsdx-connman

JSDX Connection Manager API
MIT License
11 stars 15 forks source link

Connecting to secured accesspoint / using Agent API #4

Open peteruithoven opened 9 years ago

peteruithoven commented 9 years ago

I've been hard at work at improving our fork of jsdx-connman and I'm working on a library that should make controlling wifi much easier. I'll release it soon as a "extension" to jsdx-connman.

But something I'm having trouble with is using the Agent API, so that we for example can connect to secure networks. Your tests/ConnectAP contains some Agent API event handlers, but they never get called. Looking through your code I can't find anything strange (in that particular part at least). But then again I don't have experience with using dbus. And sadly I'm having problems finding resources or examples, I'm afraid the people that are using Node.js, dbus and Connman are scarce.
Any help would be very much appreciated.

peteruithoven commented 9 years ago

I'll keep researching btw. I found a python example: https://git.kernel.org/cgit/network/connman/connman.git/tree/test/simple-agent

I found someone else with the problem, but doesn't find the solution: http://permalink.gmane.org/gmane.linux.network.connman/15272

Some resort to creating config files (which is how we got it sort of working as well): http://expertland.net/question/25b87236243192y7c3q52o19b5b2a24o5t8c3/detail.html

I'll figure out how to enable connman debugging, that might report something useful.

cfsghost commented 9 years ago

What's your connman version?

Agent works well on my computer.

2015-01-10 8:33 GMT+08:00 Peter Uithoven notifications@github.com:

I'll keep researching btw. I found a python example: https://git.kernel.org/cgit/network/connman/connman.git/tree/test/simple-agent

I found someone else with the problem: http://permalink.gmane.org/gmane.linux.network.connman/15272

Some resort to creating config files (which is how we got it sort of working as well):

http://expertland.net/question/25b87236243192y7c3q52o19b5b2a24o5t8c3/detail.html

I'll figure out how to enable connman debugging, that might report something useful.

— Reply to this email directly or view it on GitHub https://github.com/cfsghost/jsdx-connman/issues/4#issuecomment-69426140.

peteruithoven commented 9 years ago

Connman version 1.21, I think:

$ connmand -v
1.21

DBus version 1.8.12:

~$ dbus-daemon --version
D-Bus Message Bus Daemon 1.8.12

Would other packages be able to influence this?

peteruithoven commented 9 years ago

Using the agent through connmanctl works fine btw. connmanctl asks for the passphrase and connects properly.

peteruithoven commented 9 years ago

So I got some help figuring out how to get more debug info (running connman manually with -d and -n).

I looks like the agent get registered:

connmand[1343]: src/manager.c:register_agent() conn 0xb53f8
connmand[1343]: src/agent.c:connman_agent_register() sender :1.29 path /jsdx/connman/agent
connmand[1343]: src/agent.c:agent_ref_debug() 0xc26a0 ref 1 by src/agent.c:308:agent_create()
connmand[1343]: src/agent.c:connman_agent_register() agent :1.29
connmand[1343]: src/agent.c:set_default_agent() default agent set to :1.29 /jsdx/connman/agent

And then on connect:

connmand[1343]: src/agent-connman.c:__connman_agent_request_passphrase_input() agent 0xc26a0 service 0xbd7e0 path /jsdx/connman/agent
connmand[1343]: src/network.c:connman_network_get_string() network 0xc10c8 key WiFi.PinWPS
connmand[1343]: src/network.c:connman_network_get_bool() network 0xc10c8 key WiFi.UseWPS
connmand[1343]: src/agent.c:connman_agent_queue_message() driver 0x958f4
connmand[1343]: src/service.c:connman_service_ref_debug() 0xbd7e0 ref 2 by src/service.c:6919:agent_context_ref()
connmand[1343]: src/agent.c:agent_receive_message() agent 0xc26a0 req 0xd9700
connmand[1343]: src/service.c:request_input_cb() RequestInput return, 0xbd7e0
connmand[1343]: src/service.c:request_input_cb() error: org.freedesktop.DBus.Error.UnknownMethod
connmand[1343]: src/service.c:__connman_service_return_error() service 0xbd7e0 error 22 user_data (nil)
connmand[1343]: src/service.c:__connman_service_set_hidden_data() service 0xbd7e0 pending (nil)
connmand[1343]: src/service.c:service_save() service 0xbd7e0 new 0
connmand[1343]: src/storage.c:storage_load() Loading /var/lib/connman/wifi_001970fb2450_5665636874636c756220584c2046312e3139_managed_psk/settings
peteruithoven commented 9 years ago

When using it through connmanctl, on connect:

connmand[1343]: src/service.c:connect_service() service 0xca310
connmand[1343]: src/service.c:__connman_service_connect() service 0xca310 state idle
connmand[1343]: src/network.c:__connman_network_disconnect() network 0xcdcc8
connmand[1343]: src/agent-connman.c:__connman_agent_request_passphrase_input() agent 0xd5be0 service 0xca310 path /net/connman/connmanctl1954
connmand[1343]: src/network.c:connman_network_get_string() network 0xcdcc8 key WiFi.PinWPS
connmand[1343]: src/network.c:connman_network_get_bool() network 0xcdcc8 key WiFi.UseWPS
connmand[1343]: src/agent.c:connman_agent_queue_message() driver 0x958f4
connmand[1343]: src/service.c:connman_service_ref_debug() 0xca310 ref 2 by src/service.c:6919:agent_context_ref()
connmand[1343]: src/rtnl.c:rtnl_message() buf 0xbefbfae4 len 76
connmand[1343]: src/rtnl.c:rtnl_message() NEWNDUSEROPT len 76 type 68 flags 0x0000 seq 0 pid 0
connmand[1343]: src/rtnl.c:rtnl_newnduseropt() family 10 index 2 len 24 type 134 code 0
connmand[1343]: src/rtnl.c:rtnl_newnduseropt() remaining 24 nd opt type 31 len 3
connmand[1343]: src/resolver.c:connman_resolver_append_lifetime() index 2 domain lan server (null) lifetime 1200
connmand[1343]: src/resolver.c:connman_resolver_append_lifetime() RDNSS start index 2 domain lan server (null) lifetime threshold 960

On submitting a passphrase:

connmand[1343]: src/agent.c:agent_receive_message() agent 0xd5be0 req 0xc1298
connmand[1343]: src/service.c:request_input_cb() RequestInput return, 0xca310
connmand[1343]: src/network.c:connman_network_set_string() network 0xcdcc8 key WiFi.Passphrase value <thepassphrase>
connmand[1343]: src/service.c:service_save() service 0xca310 new 0
connmand[1343]: src/storage.c:storage_load() Loading /var/lib/connman/wifi_001970fb2450_5665636874636c756[ 5881.037464] IPv6: ADDRCONF(NETDEV_UP): wlan3: link is not ready
220584c2046312e3139_managed_psk/settings
connmand[1343]: src/network.c:connman_network_get_blob() network 0xcdcc8 key WiFi.SSID
connmand[1343]: src/ipconfig.c:__connman_ipconfig_save() ipconfig 0xc0698 identifier wifi_001970fb2450_5665636874636c756220584c2046312e3139_managed_psk method dhcp
connmand[1343]: src/ipconfig.c:__connman_ipconfig_save() ipconfig 0xc3b38 identifier wifi_001970fb2450_5665636874636c756220584c2046312e3139_managed_psk method auto
connmand[1343]: src/service.c:__connman_service_connect() service 0xca310 state failure
connmand[1343]: src/network.c:connman_network_get_blob() network 0xcdcc8 key WiFi.SSID
connmand[1343]: src/network.c:connman_network_set_string() network 0xcdcc8 key WiFi.Passphrase value <thepassphrase>
peteruithoven commented 9 years ago

One big downside (besides having to edit files) is that it takes very long to get feedback when connecting to a network fails. For example when the passphrase is incorrect. This takes much longer compared to connmanctl for example.

peteruithoven commented 9 years ago

Connman might not accept overriding the path when there is already a path with that name registered. So one thing we could try is changing the path. The path is defined here: https://github.com/Doodle3D/connman-api/blob/master/lib/agent.js#L17

Other things we could try:

@cfsghost, what's your version of Connman? What DBUS_SESSION_BUS_ADDRESS environment variable do you use? (We currently use 'unix:path=/run/dbus/system_bus_socket')