Mise à jour de GitLab prévue ce samedi 23 octobre 2021 à partir de 9h00 CET

Commit 8c33efe2 authored by Éloïs's avatar Éloïs
Browse files

[enh] prepare api type in head mesage

parent 5e4997b5
......@@ -291,7 +291,7 @@ export class WS2PCluster {
async connectToRemoteWS(host: string, port: number, path:string, messageHandler:WS2PMessageHandler, expectedPub:string, ws2pEndpointUUID:string = ""): Promise<WS2PConnection> {
const uuid = nuuid.v4()
let pub = "--------"
let pub = expectedPub.slice(0, 8)
const api:string = (host.match(WS2PConstants.HOST_ONION_REGEX) !== null) ? 'WS2PTOR':'WS2P'
try {
const fullEndpointAddress = WS2PCluster.getFullAddress(host, port, path)
......@@ -463,13 +463,14 @@ export class WS2PCluster {
}
private sayHeadChangedTo(number:number, hash:string) {
const api = (this.server.conf.ws2p && this.server.conf.ws2p.remotehost && this.server.conf.ws2p.remotehost.match(WS2PConstants.HOST_ONION_REGEX)) ? 'WS2P':'WS2P'
const key = new Key(this.server.conf.pair.pub, this.server.conf.pair.sec)
const pub = key.publicKey
const software = 'duniter'
const softVersion = Package.getInstance().version
const ws2pId = (this.server.conf.ws2p && this.server.conf.ws2p.uuid) || '00000000'
const prefix = this.server.conf.prefix || Constants.DEFAULT_PEER_ID
const message = `WS2P:HEAD:1:${pub}:${number}-${hash}:${ws2pId}:${software}:${softVersion}:${prefix}`
const message = `${api}:HEAD:1:${pub}:${number}-${hash}:${ws2pId}:${software}:${softVersion}:${prefix}`
const sig = key.signSync(message)
return { sig, message, pub }
}
......
......@@ -30,7 +30,7 @@ export const WS2PConstants = {
+ CommonConstants.FORMATS.BLOCKSTAMP
+ '$'),
HEAD_V1_REGEXP: new RegExp('^WS2P:HEAD:1:'
HEAD_V1_REGEXP: new RegExp('^WS2P(?:TOR)?:HEAD:1:'
+ '(' + CommonConstants.FORMATS.PUBKEY + '):'
+ '(' + CommonConstants.FORMATS.BLOCKSTAMP + '):'
+ '(' + CommonConstants.FORMATS.WS2PID + '):'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment