{"action":"created","issue":{"url":"https://api.github.com/repos/mit-dci/lit/issues/312","repository_url":"https://api.github.com/repos/mit-dci/lit","labels_url":"https://api.github.com/repos/mit-dci/lit/issues/312/labels{/name}","comments_url":"https://api.github.com/repos/mit-dci/lit/issues/312/comments","events_url":"https://api.github.com/repos/mit-dci/lit/issues/312/events","html_url":"https://github.com/mit-dci/lit/pull/312","id":348638152,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA2OTM5Mzk0","number":312,"title":"[WIP] Remote control","user":{"login":"gertjaap","id":4141625,"node_id":"MDQ6VXNlcjQxNDE2MjU=","avatar_url":"https://avatars0.githubusercontent.com/u/4141625?v=4","gravatar_id":"","url":"https://api.github.com/users/gertjaap","html_url":"https://github.com/gertjaap","followers_url":"https://api.github.com/users/gertjaap/followers","following_url":"https://api.github.com/users/gertjaap/following{/other_user}","gists_url":"https://api.github.com/users/gertjaap/gists{/gist_id}","starred_url":"https://api.github.com/users/gertjaap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gertjaap/subscriptions","organizations_url":"https://api.github.com/users/gertjaap/orgs","repos_url":"https://api.github.com/users/gertjaap/repos","events_url":"https://api.github.com/users/gertjaap/events{/privacy}","received_events_url":"https://api.github.com/users/gertjaap/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-08-08T09:06:12Z","updated_at":"2018-08-27T14:19:44Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/mit-dci/lit/pulls/312","html_url":"https://github.com/mit-dci/lit/pull/312","diff_url":"https://github.com/mit-dci/lit/pull/312.diff","patch_url":"https://github.com/mit-dci/lit/pull/312.patch"},"body":""},"comment":{"url":"https://api.github.com/repos/mit-dci/lit/issues/comments/416242565","html_url":"https://github.com/mit-dci/lit/pull/312#issuecomment-416242565","issue_url":"https://api.github.com/repos/mit-dci/lit/issues/312","id":416242565,"node_id":"MDEyOklzc3VlQ29tbWVudDQxNjI0MjU2NQ==","user":{"login":"gertjaap","id":4141625,"node_id":"MDQ6VXNlcjQxNDE2MjU=","avatar_url":"https://avatars0.githubusercontent.com/u/4141625?v=4","gravatar_id":"","url":"https://api.github.com/users/gertjaap","html_url":"https://github.com/gertjaap","followers_url":"https://api.github.com/users/gertjaap/followers","following_url":"https://api.github.com/users/gertjaap/following{/other_user}","gists_url":"https://api.github.com/users/gertjaap/gists{/gist_id}","starred_url":"https://api.github.com/users/gertjaap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gertjaap/subscriptions","organizations_url":"https://api.github.com/users/gertjaap/orgs","repos_url":"https://api.github.com/users/gertjaap/repos","events_url":"https://api.github.com/users/gertjaap/events{/privacy}","received_events_url":"https://api.github.com/users/gertjaap/received_events","type":"User","site_admin":false},"created_at":"2018-08-27T14:19:44Z","updated_at":"2018-08-27T14:19:44Z","author_association":"CONTRIBUTOR","body":"Okay, so this pull requests allows RPC-via-LNDC.\r\n\r\n# Local control (i.e. lit-af on host)\r\n\r\nlit-af connects to localhost over LNDC and uses a key derived from privkey.hex. Since this key is also available to lit, it can determine the public key and autorize commands from that key by default. \r\n\r\nWhen lit receives an RPC call over LNDC, it will [check if the node is authorized](https://github.com/gertjaap/lit/blob/remotecontrol/qln/remotecontrol.go#L35) using the pubkey of the peer or the pubkey included in the message (the one in the message has preference). If unauthorized, lit will reject the call. \r\n\r\nIf authorized, it will execute the RPC request using reflection (similar to how jsonrpc does this internally), and send back the result wrapped in a response message to the peer that sent the request.\r\n\r\n# Remote control\r\n\r\nWhen privkey.hex is not present, lit-af will use a newly generated / password protected key stored in the homefolder, similar to privkey.hex (just named `lit-af-key.hex`). This key is used as node ID in the LNDC communication. \r\n\r\nThere is an extra parameter to lit-af (`addr`) that specifies the ln address of the host we're going to control. So starting lit-af for a remote host would look something like this:\r\n\r\n`lit-af -node 1.2.3.4 -p 2448 -addr ln1hzcjphula5cxh5hpj3zqancy0jv7t2zvyz0wnt`\r\n\r\nWhen sending commands using lit-af in this fashion, it will identify with the node ID, and therefore it's important to authorize this on the lit node. You can issue the `rcreq` command in lit-af, which will execute the `LitRPC.RequestRemoteControlAuthorization` RPC call, which is not protected by authorization. This will mark the key you're connecting with as one that is requesting access. Using lit-af on the host (which is authorized by default) you can then use `ls rcauth` to view pending requests and use `rcauth {key} true` to authorize or `rcauth {key} false` to decline.\r\n\r\nOnce authorized, the remote lit-af can do the same things the local lit-af can, and is controlling the node over LNDC.\r\n\r\nI also created a [websocket RPC proxy](https://github.com/gertjaap/lit/blob/remotecontrol/litrpc/lndcproxy.go) - which behaves the same as the original websocket RPC, just tunnels the commands over LNDC. When you run this proxy from the lit host, it will use the same key as lit-af, which means it will be authorized by default. When using it from a remote host (or from a mobile phone), you need to provide it with a key to use.\r\n\r\nThis way, we can still support clients that use websocket RPC, just they can run anywhere - not just with lit on localhost.\r\n\r\n"}}
{"actor":{"display_login":"gertjaap"}}