Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions dashsight-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,12 @@ DashSightServer.create = function ({ rpc, wss, authenticate }) {
res.json(response);
};

dss._socketId = 0;
dss.sockets = {};
dss.sockets.onconnection = async function (ws, request) {
console.error("[DEBUG] dss.sockets.onconnection");
dss._socketId += 1;
let sid = dss._socketId;
console.error(`[DEBUG] [${sid}] dss.sockets.onconnection`);
ws.on("error", console.error);

// TODO session should establish which hostname and port
Expand All @@ -97,7 +100,7 @@ DashSightServer.create = function ({ rpc, wss, authenticate }) {
return;
}

console.log(`[DEBUG] ws query:`);
console.log(`[DEBUG] [${sid}] ws query:`);
console.log(query);
let stream = WebSocket.createWebSocketStream(ws, { encoding: null });
let conn = Net.createConnection({
Expand All @@ -110,28 +113,28 @@ DashSightServer.create = function ({ rpc, wss, authenticate }) {
stream.pipe(conn);
conn.pipe(stream);
ws.on("open", function (chunk) {
console.log("[DEBUG] ws.on open");
console.log(`[DEBUG] [${sid}] ws.on open`);
});
ws.on("message", function (chunk) {
let hex = chunk.toString("hex");
console.log("[DEBUG] ws.on data hex", hex);
console.log(`[DEBUG] [${sid}] ws.on data hex`, hex);
});
conn.on("data", function (chunk) {
let hex = chunk.toString("hex");
console.log("[DEBUG] conn.on data hex", hex);
console.log(`[DEBUG] [${sid}] conn.on data hex`, hex);
// ws.send(chunk);
});

stream.once("error", disconnect);
stream.once("end", disconnect);
stream.once("close", disconnect);
function disconnect() {
console.log("[DEBUG] ws stream pipe disconnected");
console.log(`[DEBUG] [${sid}] ws stream pipe disconnected`);
conn.end();
conn.destroy();
}

console.log("[DEBUG] piped each end and added handlers");
console.log(`[DEBUG] [${sid}] piped each end and added handlers`);
};

dss.router = new AsyncRouter.Router();
Expand Down
7 changes: 0 additions & 7 deletions example.env
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,3 @@ DASHD_RPC_HOST='127.0.0.1'
# mainnet=9998, testnet=19998, regtest=<see ~/.dashmate/local_seed/core/dash.conf>
DASHD_RPC_PORT='20302'
DASHD_RPC_TIMEOUT='10.0'

# Generate this from
# npx -p dashphrase-cli -- dashphrase gen --bits 128 -o ./words.txt
# npx -p dashphrase-cli -- dashphrase seed ./words.txt "" -o ./seed.hex
DASH_WALLET_PHRASE='zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo wrong'
#DASH_WALLET_SALT='TREZOR'
DASH_WALLET_SEED='ac27495480225222079d7be181583751e86f571027b0497b5b5d11218e0a8a13332572917f0f8e5a589620c6f15b11c61dee327651a14c34e18231052e48c069'