add https and pem files (for anyone to use, fast setup)

This commit is contained in:
Ben Wilson
2023-08-03 17:16:16 -04:00
parent a7ea61f28f
commit a7b73b0610
6 changed files with 64 additions and 7 deletions
+8 -2
View File
@@ -3,6 +3,7 @@ import { NestFactory } from '@nestjs/core';
import { FastifyAdapter, NestFastifyApplication } from '@nestjs/platform-fastify';
import * as bitcoinjs from 'bitcoinjs-lib';
import { useContainer } from 'class-validator';
import { readFileSync } from 'fs';
import * as ecc from 'tiny-secp256k1';
import { AppModule } from './app.module';
@@ -14,8 +15,12 @@ async function bootstrap() {
return;
}
const httpsOptions = {
key: readFileSync('./secrets/key.pem'),
cert: readFileSync('./secrets/cert.pem'),
};
const app = await NestFactory.create<NestFastifyApplication>(AppModule, new FastifyAdapter());
const app = await NestFactory.create<NestFastifyApplication>(AppModule, new FastifyAdapter({ https: httpsOptions }));
app.setGlobalPrefix('api')
app.useGlobalPipes(
new ValidationPipe({
@@ -28,11 +33,12 @@ async function bootstrap() {
app.enableCors();
useContainer(app.select(AppModule), { fallbackOnErrors: true });
//Taproot
bitcoinjs.initEccLib(ecc);
await app.listen(process.env.PORT, '0.0.0.0', () => {
console.log(`http listening on port ${process.env.PORT}`);
console.log(`https listening on port ${process.env.PORT}`);
});
}
+2 -2
View File
@@ -436,8 +436,8 @@ export class StratumV1Client extends EasyUnsubscribe {
submission.id,
eStratumErrorCode.LowDifficultyShare,
'Difficulty too low').response();
console.error(err);
console.log(`Header: ${header.toString('hex')}`);
// console.error(err);
// console.log(`Header: ${header.toString('hex')}`);
try {
await this.promiseSocket.write(err);
} catch (e) {
+2 -2
View File
@@ -66,7 +66,7 @@ export class StratumV1Service implements OnModuleInit {
console.log(`Client disconnected: ${promiseSocket.socket.remoteAddress}, ${client.extraNonceAndSessionId}, ${clientCount} total clients`);
console.log(`Client disconnected, ${client.extraNonceAndSessionId}, ${clientCount} total clients`);
});
@@ -78,7 +78,7 @@ export class StratumV1Service implements OnModuleInit {
await this.clientService.delete(client.extraNonceAndSessionId);
const clientCount = await this.clientService.connectedClientCount();
console.log(`Client disconnected, socket error: ${promiseSocket.socket.remoteAddress}, ${client.extraNonceAndSessionId}, ${clientCount} total clients`);
console.log(`Client disconnected, socket error, ${client.extraNonceAndSessionId}, ${clientCount} total clients`);
console.error(error);