mirror of
https://github.com/balzack/databag.git
synced 2025-02-11 19:19:16 +00:00
detecting ip based url and use http
This commit is contained in:
parent
0bcb289833
commit
aab471eed7
@ -192,7 +192,9 @@ export function useAppContext() {
|
||||
}
|
||||
|
||||
const setWebsocket = (session) => {
|
||||
ws.current = createWebsocket(`wss://${session.server}/status?mode=ring`);
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(session.server);
|
||||
const protocol = insecure ? 'ws' : 'wss';
|
||||
ws.current = createWebsocket(`${protocol}://${session.server}/status?mode=ring`);
|
||||
ws.current.onmessage = (ev) => {
|
||||
if (ev.data == '') {
|
||||
actions.logout();
|
||||
|
@ -239,7 +239,9 @@ export function useRingContext() {
|
||||
videoTrack.current = false;
|
||||
audioTrack.current = false;
|
||||
|
||||
ws.current = createWebsocket(`wss://${node}/signal`);
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(node);
|
||||
const protocol = insecure ? 'ws' : 'wss';
|
||||
ws.current = createWebsocket(`${protocol}://${node}/signal`);
|
||||
ws.current.onmessage = async (ev) => {
|
||||
// handle messages [impolite]
|
||||
try {
|
||||
|
@ -66,11 +66,13 @@ export function useUploadContext() {
|
||||
|
||||
const actions = {
|
||||
addTopic: (node, token, channelId, topicId, files, success, failure, cardId) => {
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(node);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
const key = cardId ? `${cardId}:${channelId}` : `:${channelId}`;
|
||||
const controller = new AbortController();
|
||||
const entry = {
|
||||
index: index.current,
|
||||
baseUrl: cardId ? `https://${node}/content/channels/${channelId}/topics/${topicId}/` : `https://${node}/content/channels/${channelId}/topics/${topicId}/`,
|
||||
baseUrl: cardId ? `${protocol}://${node}/content/channels/${channelId}/topics/${topicId}/` : `${protocol}://${node}/content/channels/${channelId}/topics/${topicId}/`,
|
||||
urlParams: cardId ? `?contact=${token}` : `?agent=${token}`,
|
||||
files,
|
||||
assets: [],
|
||||
|
Loading…
Reference in New Issue
Block a user