Skip to content

Commit

Permalink
TLS and Auth Support (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
hobbyquaker committed Oct 4, 2019
1 parent 7cbe77b commit 3025810
Show file tree
Hide file tree
Showing 5 changed files with 223 additions and 24 deletions.
28 changes: 25 additions & 3 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ function findInterfaces() {
config.daemons[iface] = {
type: iface,
ip: config.ccuAddress,
isSecure: config.useTLS,
useAuth: config.useAuth,
user: config.user,
pass: config.pass,
port: ports[iface],
protocol: iface === 'CUxD' ? 'binrpc' : 'xmlrpc',
reinitTimeout: iface === 'HmIP' ? 600000 : 60000,
Expand All @@ -194,7 +198,11 @@ function findInterfaces() {
initRpcClients();
if (regaPresent) {
rega = new Rega({
host: config.ccuAddress
host: config.ccuAddress,
tls: config.useTls,
auth: config.useAuth,
user: config.user,
pass: config.pass
});
getRegaNames();
}
Expand Down Expand Up @@ -311,11 +319,25 @@ function initRpcClients() {
config.daemons[daemon].ident = daemon === 'CUxD' ? 'CUxD' : 'hmm_' + daemon;
daemonIndex[config.daemons[daemon].ident] = daemon;

rpcClients[daemon] = (config.daemons[daemon].protocol === 'binrpc' ? binrpc : xmlrpc).createClient({
const clientOptions = {
host: config.daemons[daemon].ip,
port: config.daemons[daemon].port,
path: config.daemons[daemon].path,
});
isSecure: config.daemons[daemon].isSecure,
};

if (config.daemons[daemon].isSecure && config.daemons[daemon].ident !== 'CUxD') {
config.daemons[daemon].port = 40000 + config.daemons[daemon].port;
}

if (config.daemons[daemon].useAuth) {
clientOptions.basic_auth = {
user: config.daemons[daemon].user,
pass: config.daemons[daemon].pass
}
}

rpcClients[daemon] = (config.daemons[daemon].protocol === 'binrpc' ? binrpc : xmlrpc).createClient(clientOptions);

initRpcServer(config.daemons[daemon].protocol);
init(daemon);
Expand Down
175 changes: 157 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "homematic-manager",
"version": "2.5.1",
"version": "2.6.0",
"private": true,
"dependencies": {
"async": "2.6.2",
Expand All @@ -11,7 +11,7 @@
"electron-window-state": "5.0.3",
"free-jqgrid": "4.15.5",
"hm-discover": "1.1.0",
"homematic-rega": "1.3.5",
"homematic-rega": "^1.4.0",
"homematic-xmlrpc": "1.0.2",
"instascan": "1.0.0",
"jquery": "3.3.1",
Expand Down
Loading

0 comments on commit 3025810

Please sign in to comment.