mirror of
https://github.com/benjamin-wilson/public-pool.git
synced 2026-09-29 09:05:06 -07:00
https
This commit is contained in:
+3
-1
@@ -18,4 +18,6 @@ PORT=3333
|
|||||||
#optional
|
#optional
|
||||||
DEV_FEE_ADDRESS=
|
DEV_FEE_ADDRESS=
|
||||||
# mainnet | testnet
|
# mainnet | testnet
|
||||||
NETWORK=mainnet
|
NETWORK=mainnet
|
||||||
|
|
||||||
|
API_SECURE=false
|
||||||
+14
-11
@@ -3,6 +3,7 @@ import { NestFactory } from '@nestjs/core';
|
|||||||
import { FastifyAdapter, NestFastifyApplication } from '@nestjs/platform-fastify';
|
import { FastifyAdapter, NestFastifyApplication } from '@nestjs/platform-fastify';
|
||||||
import * as bitcoinjs from 'bitcoinjs-lib';
|
import * as bitcoinjs from 'bitcoinjs-lib';
|
||||||
import { useContainer } from 'class-validator';
|
import { useContainer } from 'class-validator';
|
||||||
|
import { readFileSync } from 'fs';
|
||||||
import * as ecc from 'tiny-secp256k1';
|
import * as ecc from 'tiny-secp256k1';
|
||||||
|
|
||||||
import { AppModule } from './app.module';
|
import { AppModule } from './app.module';
|
||||||
@@ -14,20 +15,22 @@ async function bootstrap() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// const httpsOptions = {
|
let options = {};
|
||||||
// key: readFileSync('./secrets/key.pem'),
|
const secure = process.env.API_SECURE?.toLowerCase() == 'true';
|
||||||
// cert: readFileSync('./secrets/cert.pem'),
|
if (secure) {
|
||||||
// };
|
|
||||||
|
|
||||||
//const app = await NestFactory.create<NestFastifyApplication>(AppModule, new FastifyAdapter({ https: httpsOptions }));
|
const httpsOptions = {
|
||||||
|
key: readFileSync('./secrets/key.pem'),
|
||||||
|
cert: readFileSync('./secrets/cert.pem'),
|
||||||
|
};
|
||||||
|
|
||||||
// stagger startup
|
options = { https: httpsOptions };
|
||||||
// if (process.env.NODE_APP_INSTANCE != null) {
|
|
||||||
// await setTimeout(parseInt(process.env.NODE_APP_INSTANCE) * 5000);
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
const app = await NestFactory.create<NestFastifyApplication>(AppModule, new FastifyAdapter());
|
}
|
||||||
|
|
||||||
|
const app = await NestFactory.create<NestFastifyApplication>(AppModule, new FastifyAdapter(options));
|
||||||
app.setGlobalPrefix('api')
|
app.setGlobalPrefix('api')
|
||||||
app.useGlobalPipes(
|
app.useGlobalPipes(
|
||||||
new ValidationPipe({
|
new ValidationPipe({
|
||||||
@@ -45,7 +48,7 @@ async function bootstrap() {
|
|||||||
bitcoinjs.initEccLib(ecc);
|
bitcoinjs.initEccLib(ecc);
|
||||||
|
|
||||||
await app.listen(process.env.PORT, '0.0.0.0', () => {
|
await app.listen(process.env.PORT, '0.0.0.0', () => {
|
||||||
console.log(`https listening on port ${process.env.PORT}`);
|
console.log(`${secure ? 'https' : 'http'} listening on port ${process.env.PORT}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -318,6 +318,11 @@ export class StratumV1Client {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
default: {
|
||||||
|
console.log("Invalid message");
|
||||||
|
await this.socket.end();
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,10 @@ export class StratumV1Service implements OnModuleInit {
|
|||||||
private startSocketServer() {
|
private startSocketServer() {
|
||||||
const server = new Server(async (socket: Socket) => {
|
const server = new Server(async (socket: Socket) => {
|
||||||
|
|
||||||
|
socket.setTimeout(5000, () => {
|
||||||
|
console.log(`Client ${client.extraNonceAndSessionId} timeout`);
|
||||||
|
socket.destroy();
|
||||||
|
});
|
||||||
|
|
||||||
const client = new StratumV1Client(
|
const client = new StratumV1Client(
|
||||||
socket,
|
socket,
|
||||||
|
|||||||
Reference in New Issue
Block a user