Browse Source

Merge pull request #96 from stakwork/home-config

Home config
dependabot/npm_and_yarn/ini-1.3.7 v1.0.12
Evan Feenstra 4 years ago
committed by GitHub
parent
commit
cbd75e016f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app.ts
  2. 6
      config/app.json
  3. 2
      dist/app.js
  4. 2
      dist/app.js.map
  5. 1
      dist/src/utils/lightning.js
  6. 2
      dist/src/utils/lightning.js.map
  7. 24
      dist/src/utils/setup.js
  8. 2
      dist/src/utils/setup.js.map
  9. 1
      src/utils/lightning.ts
  10. 127
      src/utils/setup.ts

2
app.ts

@ -16,7 +16,7 @@ import * as network from './src/network'
let server: any = null
const env = process.env.NODE_ENV || 'development';
const config = require(path.join(__dirname, 'config/app.json'))[env];
const port = process.env.PORT || 3001 // config.node_http_port || 3001
const port = process.env.PORT || config.node_http_port || 3001
process.env.GRPC_SSL_CIPHER_SUITES = 'HIGH+ECDSA'

6
config/app.json

@ -12,7 +12,8 @@
"hub_invite_url": "http://lvh.me/invites",
"hub_check_invite_url": "http://lvh.me/check_invite",
"media_host": "localhost:5000",
"tribes_host": "tribes.sphinx.chat"
"tribes_host": "tribes.sphinx.chat",
"public_url": ""
},
"production": {
"senza_url": "https://staging.senza.us/api/v2/",
@ -28,6 +29,7 @@
"hub_invite_url": "https://hub.sphinx.chat/invites",
"hub_check_invite_url": "https://hub.sphinx.chat/check_invite",
"media_host": "memes.sphinx.chat",
"tribes_host": "tribes.sphinx.chat"
"tribes_host": "tribes.sphinx.chat",
"public_url": ""
}
}

2
dist/app.js

@ -26,7 +26,7 @@ const network = require("./src/network");
let server = null;
const env = process.env.NODE_ENV || 'development';
const config = require(path.join(__dirname, 'config/app.json'))[env];
const port = process.env.PORT || 3001; // config.node_http_port || 3001
const port = process.env.PORT || config.node_http_port || 3001;
process.env.GRPC_SSL_CIPHER_SUITES = 'HIGH+ECDSA';
var i = 0;
// START SETUP!

2
dist/app.js.map

@ -1 +1 @@
{"version":3,"file":"app.js","s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AAY,EAAC,CAAC,CAAC;YAC5E,GAAG,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;SAClC;aAAM;YACN,MAAM,IAAI,GAAG,MAAM,eAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAC,CAAC,CAAA;YACtE,MAAM,WAAW,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC/E,IAAI,IAAI,CAAC,SAAS,IAAI,IAAI,IAAI,IAAI,CAAC,SAAS,IAAI,WAAW,EAAE;gBAC5D,GAAG,CAAC,SAAS,CAAC,GAAG,EAAE,yBAAyB,EAAE,EAAC,cAAc,EAAG,YAAY,EAAC,CAAC,CAAC;gBAC/E,GAAG,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;aAC/B;iBAAM;gBACN,IAAI,EAAE,CAAC;aACP;SACD;IACF,CAAC;CAAA;AAED,kBAAe,MAAM,CAAA"}

1
dist/src/utils/lightning.js

@ -144,6 +144,7 @@ const keysend = (opts) => {
},
payment_hash: sha.sha256.arrayBuffer(preimage.toBuffer()),
dest_features: [9],
fee_limit: { fixed: 10 }
};
const call = lightning.sendPayment();
call.on('data', function (payment) {

2
dist/src/utils/lightning.js.map

File diff suppressed because one or more lines are too long

24
dist/src/utils/setup.js

@ -15,7 +15,10 @@ const child_process_1 = require("child_process");
const QRCode = require("qrcode");
const publicIp = require("public-ip");
const password_1 = require("../utils/password");
const path = require("path");
const gitinfo_1 = require("../utils/gitinfo");
const env = process.env.NODE_ENV || 'development';
const config = require(path.join(__dirname, '../../config/app.json'))[env];
const USER_VERSION = 7;
const setupDatabase = () => __awaiter(void 0, void 0, void 0, function* () {
console.log('=> [db] starting setup...');
@ -196,16 +199,21 @@ function printGitInfo() {
}
function printQR() {
return __awaiter(this, void 0, void 0, function* () {
const ip = process.env.NODE_IP;
let public_ip;
if (!ip) {
try {
public_ip = yield publicIp.v4();
const public_url = config.public_url;
if (public_url)
public_ip = public_url;
if (!public_ip) {
const ip = process.env.NODE_IP;
if (!ip) {
try {
public_ip = yield publicIp.v4();
}
catch (e) { }
}
else {
public_ip = ip;
}
catch (e) { }
}
else {
public_ip = ip;
}
if (!public_ip) {
console.log('=> no public IP provided');

2
dist/src/utils/setup.js.map

File diff suppressed because one or more lines are too long

1
src/utils/lightning.ts

@ -134,6 +134,7 @@ const keysend = (opts) => {
},
payment_hash: sha.sha256.arrayBuffer(preimage.toBuffer()),
dest_features:[9],
fee_limit: {fixed:10}
}
const call = lightning.sendPayment()
call.on('data', function(payment) {

127
src/utils/setup.ts

@ -1,10 +1,14 @@
import { loadLightning } from './lightning'
import {sequelize, models} from '../models'
import { exec } from 'child_process'
import { sequelize, models } from '../models'
import { exec } from 'child_process'
import * as QRCode from 'qrcode'
import * as publicIp from 'public-ip'
import password from '../utils/password'
import {checkTag, checkCommitHash} from '../utils/gitinfo'
import * as path from 'path'
import { checkTag, checkCommitHash } from '../utils/gitinfo'
const env = process.env.NODE_ENV || 'development';
const config = require(path.join(__dirname, '../../config/app.json'))[env]
const USER_VERSION = 7
@ -14,27 +18,27 @@ const setupDatabase = async () => {
try {
await sequelize.sync()
console.log("=> [db] done syncing")
} catch(e) {
console.log("db sync failed",e)
} catch (e) {
console.log("db sync failed", e)
}
await migrate()
setupOwnerContact()
console.log('=> [db] setup done')
}
async function setVersion(){
async function setVersion() {
try {
await sequelize.query(`PRAGMA user_version = ${USER_VERSION}`)
} catch(e) {
console.log('=> setVersion failed',e)
} catch (e) {
console.log('=> setVersion failed', e)
}
}
async function migrate(){
async function migrate() {
addTableColumn('sphinx_contacts', 'last_active', 'DATETIME')
try{
try {
await sequelize.query(`
CREATE TABLE sphinx_chat_bots (
id BIGINT NOT NULL PRIMARY KEY,
@ -49,17 +53,17 @@ async function migrate(){
created_at DATETIME,
updated_at DATETIME
)`)
} catch(e){}
} catch (e) { }
try{
try {
await sequelize.query(`CREATE UNIQUE INDEX chat_bot_index ON sphinx_chat_bots(chat_id, bot_uuid);`)
}catch(e){}
} catch (e) { }
addTableColumn('sphinx_bots', 'webhook')
addTableColumn('sphinx_bots', 'uuid')
addTableColumn('sphinx_bots', 'price_per_use', 'INT')
try{
try {
await sequelize.query(`
CREATE TABLE sphinx_bot_members (
id BIGINT NOT NULL PRIMARY KEY,
@ -69,13 +73,13 @@ async function migrate(){
created_at DATETIME,
updated_at DATETIME
)`)
} catch(e){}
} catch (e) { }
addTableColumn('sphinx_bot_members', 'bot_id')
//////////
try{
try {
await sequelize.query(`
CREATE TABLE sphinx_bots (
id TEXT NOT NULL PRIMARY KEY,
@ -84,24 +88,24 @@ async function migrate(){
created_at DATETIME,
updated_at DATETIME
)`)
} catch(e){}
} catch (e) { }
addTableColumn('sphinx_chats', 'app_url')
addTableColumn('sphinx_chats', 'feed_url')
try{
try {
await sequelize.query(`CREATE UNIQUE INDEX chat_member_index ON sphinx_chat_members(chat_id, contact_id);`)
}catch(e){}
} catch (e) { }
addTableColumn('sphinx_chats', 'private', 'BOOLEAN')
addTableColumn('sphinx_chats', 'unlisted', 'BOOLEAN')
addTableColumn('sphinx_chat_members', 'status', 'BIGINT')
addTableColumn('sphinx_chats', 'seen', 'BOOLEAN')
try{
try {
await sequelize.query(`CREATE INDEX idx_messages_sender ON sphinx_messages (sender);`)
}catch(e){}
} catch (e) { }
addTableColumn('sphinx_contacts', 'notification_sound')
@ -109,31 +113,31 @@ async function migrate(){
addTableColumn('sphinx_chats', 'escrow_amount', 'BIGINT')
addTableColumn('sphinx_chats', 'escrow_millis', 'BIGINT')
// try{
// await sequelize.query(`
// CREATE TABLE sphinx_timers (
// id BIGINT,
// chat_id BIGINT,
// receiver BIGINT,
// millis BIGINT,
// msg_id BIGINT,
// amount DECIMAL
// )`)
// } catch(e){}
// try{
// await sequelize.query(`
// CREATE TABLE sphinx_timers (
// id BIGINT,
// chat_id BIGINT,
// receiver BIGINT,
// millis BIGINT,
// msg_id BIGINT,
// amount DECIMAL
// )`)
// } catch(e){}
}
async function addTableColumn(table:string, column:string, type='TEXT') {
async function addTableColumn(table: string, column: string, type = 'TEXT') {
try {
await sequelize.query(`alter table ${table} add ${column} ${type}`)
} catch(e) {
} catch (e) {
//console.log('=> migrate failed',e)
}
}
const setupOwnerContact = async () => {
const owner = await models.Contact.findOne({ where: { isOwner: true }})
const owner = await models.Contact.findOne({ where: { isOwner: true } })
if (!owner) {
const lightning = await loadLightning()
lightning.getInfo({}, async (err, info) => {
@ -141,8 +145,8 @@ const setupOwnerContact = async () => {
console.log('[db] error creating node owner due to lnd failure', err)
} else {
try {
const one = await models.Contact.findOne({ where: { id: 1 }})
if(!one){
const one = await models.Contact.findOne({ where: { id: 1 } })
if (!one) {
const contact = await models.Contact.create({
id: 1,
publicKey: info.identity_pubkey,
@ -150,8 +154,8 @@ const setupOwnerContact = async () => {
authToken: null
})
console.log('[db] created node owner contact, id:', contact.id)
}
} catch(error) {
}
} catch (error) {
console.log('[db] error creating owner contact', error)
}
}
@ -162,7 +166,7 @@ const setupOwnerContact = async () => {
const runMigrations = async () => {
await new Promise((resolve, reject) => {
const migrate: any = exec('node_modules/.bin/sequelize db:migrate',
{env: process.env},
{ env: process.env },
(err, stdout, stderr) => {
if (err) {
reject(err);
@ -180,38 +184,45 @@ const runMigrations = async () => {
export { setupDatabase, setupOwnerContact, runMigrations, setupDone }
async function setupDone(){
async function setupDone() {
await printGitInfo()
printQR()
}
async function printGitInfo(){
async function printGitInfo() {
const commitHash = await checkCommitHash()
const tag = await checkTag()
console.log(`=> Relay version: ${tag}, commit: ${commitHash}`)
}
async function printQR(){
const ip = process.env.NODE_IP
async function printQR() {
let public_ip
if(!ip) {
try {
public_ip = await publicIp.v4()
} catch(e){}
} else {
public_ip = ip
const public_url = config.public_url
if (public_url) public_ip = public_url
if (!public_ip) {
const ip = process.env.NODE_IP
if (!ip) {
try {
public_ip = await publicIp.v4()
} catch (e) { }
} else {
public_ip = ip
}
}
if(!public_ip) {
if (!public_ip) {
console.log('=> no public IP provided')
return
}
let theIP = public_ip
// if(!theIP.includes(":")) theIP = public_ip+':3001'
const b64 = Buffer.from(`ip::${theIP}::${password||''}`).toString('base64')
const b64 = Buffer.from(`ip::${theIP}::${password || ''}`).toString('base64')
console.log('Scan this QR in Sphinx app:')
console.log(b64)
QRCode.toString(b64,{type:'terminal'}, function (err, url) {
QRCode.toString(b64, { type: 'terminal' }, function (err, url) {
console.log(url)
})
}
Loading…
Cancel
Save