Chat Federation (and a lot more) WIP:
Note: websocket s2s is not working yet, still WIP. New Features * Chat Federation: * You can now connect to a remote chat with your local account. * This remote connection is done using a custom implementation of [XEP-0468: WebSocket S2S](https://xmpp.org/extensions/xep-0468.html), using some specific discovering method (so that it will work without any DNS configuration). Minor changes and fixes * Possibility to debug Prosody in development environments. * Using process.spawn instead of process.exec to launch Prosody (safer, and more optimal). * Prosody AppImage: fix path mapping: we only map necessary /etc/ subdir, so that the AppImage can access to /etc/resolv.conf, /etc/hosts, ... * Prosody AppImage: hidden debug mode to disable lua-unbound, that seems broken in some docker dev environments.
This commit is contained in:
@ -37,8 +37,34 @@ function sanitizePeertubeLiveChatInfos (chatInfos: any): LiveChatJSONLDAttribute
|
||||
})
|
||||
}
|
||||
if (link.type === 'xmpp-s2s') {
|
||||
if (!/^\d+$/.test(link.port)) {
|
||||
continue
|
||||
}
|
||||
const host = _validateHost(link.host)
|
||||
if (!host) {
|
||||
continue
|
||||
}
|
||||
r.links.push({
|
||||
type: link.type
|
||||
type: link.type,
|
||||
host,
|
||||
port: link.port
|
||||
})
|
||||
}
|
||||
if (link.type === 'xmpp-peertube-livechat-ws-s2s') {
|
||||
if ((typeof link.url) !== 'string') { continue }
|
||||
|
||||
if (
|
||||
!_validUrl(link.url, {
|
||||
noSearchParams: true,
|
||||
protocol: 'ws.'
|
||||
})
|
||||
) {
|
||||
continue
|
||||
}
|
||||
|
||||
r.links.push({
|
||||
type: link.type,
|
||||
url: link.url
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -81,6 +107,16 @@ function _validUrl (s: string, constraints: URLConstraints): boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
function _validateHost (s: string): false | string {
|
||||
try {
|
||||
if (s.includes('/')) { return false }
|
||||
const url = new URL('http://' + s)
|
||||
return url.hostname
|
||||
} catch (_err) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
export {
|
||||
sanitizePeertubeLiveChatInfos
|
||||
}
|
||||
|
Reference in New Issue
Block a user