Skip to content

Commit 152ad62

Browse files
committed
Added the ability to provide a password for the Cluster (Leave blank for old-behaviour)
1 parent 91ee06b commit 152ad62

3 files changed

Lines changed: 16 additions & 5 deletions

File tree

docker-compose.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ services:
77
environment:
88
MAXCACHE: 100 # Max Spots to cache
99
WEBPORT: 8192 # Port the App should listen on for Requests (see ports here)
10-
WAVELOG_URL: https://[my_wavelog_instance]/index.php/api/lookup # Wavelog-API-Endpoint for looking up DXCC
10+
WAVELOG_URL: http[s]://[my_wavelog_instance]/index.php/api/lookup # Wavelog-API-Endpoint for looking up DXCC
1111
WEBURL: /t # sub-url. e.g. if "/t" the application can be reached via "http://[ip]/t/stats" etc.
1212
WAVELOG_KEY: clxyz1234567 # Key from wavelog-api
1313
DXHOST: dxfun.com # DNS of DXCluster upstream
1414
DXPORT: 8000 # Port of DXCluster upstream
1515
DXCALL: [my_call] # Login-Call for Cluster
16+
DXPASSWORD: [my_password] # Login-Passwort for Cluster (in most of all cases leave this blank!!
1617
ports:
1718
- 8192:8192 # Exposed port - see WEBPORT above
1819
restart: unless-stopped

dxcluster/index.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ module.exports = class DXCluster extends events.EventEmitter {
1010
this.status = {
1111
connected: false,
1212
awaiting_login: false,
13+
awaiting_password: false,
1314
}
1415
this.regex = {
1516
deline: /^(DX de) +([A-Z0-9/\-#]{3,}):? *(\d*.\d{1,2}) *([A-Z0-9/\-#]{3,}) +(.*\S)? +(\d{4}){1}Z *(\w{2}\d{2})?/g,
@@ -33,14 +34,16 @@ module.exports = class DXCluster extends events.EventEmitter {
3334
this.port = opts.port || 23
3435

3536
this.socket = net.createConnection({
36-
host: this.host || 'w6cua.no-ip.org',
37+
host: this.host,
3738
port: this.port || 7300
3839
}, () => {
39-
this.status.connected = this.status.awaiting_login = true
40+
this.status.connected = this.status.awaiting_login = true;
41+
if ((opts.password || '') !== '') { this.status.awaiting_password = true; }
4042
resolve(this.socket);
4143
})
4244

43-
let loginPrompt = opts.loginPrompt || 'Please enter your call:'
45+
let loginPrompt = opts.loginPrompt || 'Please enter your call:';
46+
let passPrompt = opts.passPrompt || 'password:';
4447

4548
this.socket.on('data', (data) => {
4649
if(this.status.awaiting_login) {
@@ -50,6 +53,13 @@ module.exports = class DXCluster extends events.EventEmitter {
5053
}
5154
}
5255
}
56+
if(this.status.awaiting_password) {
57+
if(data.toString('utf8').indexOf(passPrompt) != -1) {
58+
if(this.write(opts.password)) {
59+
this.status.awaiting_password = false
60+
}
61+
}
62+
}
5363
this._parseDX(data.toString('utf8'))
5464
})
5565

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ if (process.env.WEBPORT === undefined) {
1414
config = require("./config.js");
1515
} else {
1616
config={maxcache: process.env.MAXCACHE, webport: process.env.WEBPORT, baseUrl: process.env.WEBURL, dxcc_lookup_wavelog_url: process.env.WAVELOG_URL, dxcc_lookup_wavelog_key: process.env.WAVELOG_KEY };
17-
config.dxc={ host: process.env.DXHOST, port: process.env.DXPORT, loginPrompt: 'login:', call: process.env.DXCALL };
17+
config.dxc={ host: process.env.DXHOST, port: process.env.DXPORT, loginPrompt: 'login:', call: process.env.DXCALL, password: process.env.DXPASSWORD };
1818
}
1919

2020
morgan.token('remote-addr', function (req, res) {

0 commit comments

Comments
 (0)