mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
removed pw from self info, checking if third party peers file exists, minor logging fix
This commit is contained in:
parent
5106614088
commit
5ce0c2d71c
2 changed files with 11 additions and 6 deletions
|
@ -96,8 +96,10 @@ interface SyncDataRes {
|
||||||
function updateThirdPartyPeers(
|
function updateThirdPartyPeers(
|
||||||
newVal: Omit<PeerInfo, 'publicKey' | 'name' | 'contact'>[]
|
newVal: Omit<PeerInfo, 'publicKey' | 'name' | 'contact'>[]
|
||||||
) {
|
) {
|
||||||
// TODO: check if thirdPartyPeersFile exists!
|
const prevVal = utils.FileExists(paths.thirdPartyPeersFile)
|
||||||
const prevVal = utils.ReadJSON<PeerInfo[]>(paths.thirdPartyPeersFile)
|
? utils.ReadJSON<PeerInfo[]>(paths.thirdPartyPeersFile)
|
||||||
|
: []
|
||||||
|
|
||||||
const dataToWrite = newVal.reduce((acc, peer) => {
|
const dataToWrite = newVal.reduce((acc, peer) => {
|
||||||
const isIncluded = acc.find((x) => {
|
const isIncluded = acc.find((x) => {
|
||||||
return peerToString(x) === peerToString(peer)
|
return peerToString(x) === peerToString(peer)
|
||||||
|
@ -466,7 +468,11 @@ function setup(data: SubmoduleData): Submodule {
|
||||||
function getSelfInfo(includeVerboseInfo?: boolean) {
|
function getSelfInfo(includeVerboseInfo?: boolean) {
|
||||||
const result: RemotePeerInfo = {
|
const result: RemotePeerInfo = {
|
||||||
selfInfo: { ...selfInfo, publicKey: publicKey },
|
selfInfo: { ...selfInfo, publicKey: publicKey },
|
||||||
myPeers: peers,
|
myPeers: peers.map((peer) => {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
|
const { pw, ...restOfPeer } = peer
|
||||||
|
return restOfPeer
|
||||||
|
}),
|
||||||
}
|
}
|
||||||
|
|
||||||
if (includeVerboseInfo) {
|
if (includeVerboseInfo) {
|
||||||
|
@ -964,8 +970,7 @@ function setup(data: SubmoduleData): Submodule {
|
||||||
remoteInfo: getSelfInfo(),
|
remoteInfo: getSelfInfo(),
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: hostname is invalid, should be remote host?
|
let hostToLog = remoteHost || 'Unknown host'
|
||||||
let hostToLog = req.hostname
|
|
||||||
if (remoteHost) {
|
if (remoteHost) {
|
||||||
const remotePeerInfo = peers.find((peer) => {
|
const remotePeerInfo = peers.find((peer) => {
|
||||||
return peerToString(peer) === remoteHost
|
return peerToString(peer) === remoteHost
|
||||||
|
@ -1000,7 +1005,6 @@ function setup(data: SubmoduleData): Submodule {
|
||||||
)
|
)
|
||||||
if (remoteHost.includes(':')) {
|
if (remoteHost.includes(':')) {
|
||||||
const [host, port] = remoteHost.split(':')
|
const [host, port] = remoteHost.split(':')
|
||||||
// TODO: add public key
|
|
||||||
updateThirdPartyPeers([
|
updateThirdPartyPeers([
|
||||||
{
|
{
|
||||||
host: host,
|
host: host,
|
||||||
|
|
|
@ -286,6 +286,7 @@ export const files = {
|
||||||
},
|
},
|
||||||
thirdPartyPeersFile: {
|
thirdPartyPeersFile: {
|
||||||
path: 'data/p2p/thirdPartyPeers.json',
|
path: 'data/p2p/thirdPartyPeers.json',
|
||||||
|
defaultValue: JSON.stringify([]),
|
||||||
description: 'json of third party peers reported by other peers',
|
description: 'json of third party peers reported by other peers',
|
||||||
},
|
},
|
||||||
keyFile: {
|
keyFile: {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue