updates
This commit is contained in:
@@ -47,6 +47,7 @@ applyBareOsConstantsEddsaPatch(path.join(dest, 'lib', 'protocol', 'constants.js'
|
||||
applyBareOsKexCurve25519CopyPatch(path.join(dest, 'lib', 'protocol', 'kex.js'))
|
||||
applyBareOsKexBareBufferCopyPatch(path.join(dest, 'lib', 'protocol', 'kex.js'))
|
||||
applyBareOsKeygenPatch(path.join(dest, 'lib', 'keygen.js'))
|
||||
applyBareOsChannelStreamFlagsPatch(path.join(dest, 'lib', 'Channel.js'))
|
||||
console.log('vendor-bare-ssh2: synced →', dest)
|
||||
|
||||
/** Re-apply Bare/Pear fix after rsync (upstream uses createInflate()._handle.constructor at load time). */
|
||||
@@ -405,3 +406,48 @@ function applyBareOsKeygenPatch(keygenPath) {
|
||||
fs.writeFileSync(keygenPath, s)
|
||||
console.log('vendor-bare-ssh2: applied lib/keygen.js Bare patch')
|
||||
}
|
||||
|
||||
/**
|
||||
* streamx (bare-node-stream) exposes `readable` / `writable` as getter-only; ssh2 sets them on end/finish.
|
||||
*/
|
||||
function applyBareOsChannelStreamFlagsPatch(channelPath) {
|
||||
if (!fs.existsSync(channelPath)) return
|
||||
let s = fs.readFileSync(channelPath, 'utf8')
|
||||
if (s.includes('bare-node-stream / streamx: readable')) return
|
||||
const old =
|
||||
'function onFinish() {\n' +
|
||||
' this.eof()\n' +
|
||||
' if (this.server || !this.allowHalfOpen) this.close()\n' +
|
||||
' this.writable = false\n' +
|
||||
'}\n' +
|
||||
'\n' +
|
||||
'function onEnd() {\n' +
|
||||
' this.readable = false\n' +
|
||||
'}'
|
||||
if (!s.includes(old)) {
|
||||
console.warn(
|
||||
'vendor-bare-ssh2: lib/Channel.js onFinish/onEnd changed; re-apply stream-flags patch manually'
|
||||
)
|
||||
return
|
||||
}
|
||||
const neu =
|
||||
'function onFinish() {\n' +
|
||||
' this.eof()\n' +
|
||||
' if (this.server || !this.allowHalfOpen) this.close()\n' +
|
||||
' try {\n' +
|
||||
' this.writable = false\n' +
|
||||
' } catch (_) {\n' +
|
||||
' /* bare-node-stream / streamx: writable may be getter-only */\n' +
|
||||
' }\n' +
|
||||
'}\n' +
|
||||
'\n' +
|
||||
'function onEnd() {\n' +
|
||||
' try {\n' +
|
||||
' this.readable = false\n' +
|
||||
' } catch (_) {\n' +
|
||||
' /* bare-node-stream / streamx: readable is getter-only */\n' +
|
||||
' }\n' +
|
||||
'}'
|
||||
fs.writeFileSync(channelPath, s.replace(old, neu))
|
||||
console.log('vendor-bare-ssh2: applied lib/Channel.js streamx readable/writable patch')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user