mirror of
https://github.com/balzack/databag.git
synced 2025-02-12 03:29: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) => {
|
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) => {
|
ws.current.onmessage = (ev) => {
|
||||||
if (ev.data == '') {
|
if (ev.data == '') {
|
||||||
actions.logout();
|
actions.logout();
|
||||||
|
@ -239,7 +239,9 @@ export function useRingContext() {
|
|||||||
videoTrack.current = false;
|
videoTrack.current = false;
|
||||||
audioTrack.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) => {
|
ws.current.onmessage = async (ev) => {
|
||||||
// handle messages [impolite]
|
// handle messages [impolite]
|
||||||
try {
|
try {
|
||||||
|
@ -66,11 +66,13 @@ export function useUploadContext() {
|
|||||||
|
|
||||||
const actions = {
|
const actions = {
|
||||||
addTopic: (node, token, channelId, topicId, files, success, failure, cardId) => {
|
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 key = cardId ? `${cardId}:${channelId}` : `:${channelId}`;
|
||||||
const controller = new AbortController();
|
const controller = new AbortController();
|
||||||
const entry = {
|
const entry = {
|
||||||
index: index.current,
|
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}`,
|
urlParams: cardId ? `?contact=${token}` : `?agent=${token}`,
|
||||||
files,
|
files,
|
||||||
assets: [],
|
assets: [],
|
||||||
|
Loading…
Reference in New Issue
Block a user