Fixed icon and avatar loading
This commit is contained in:
parent
cbbe2094f2
commit
33c8b75957
5 changed files with 50 additions and 13 deletions
|
@ -1,4 +1,7 @@
|
||||||
# Changelog:
|
# Changelog:
|
||||||
|
* **25.07.20**
|
||||||
|
- Fixed bug where icons could not be loaded due to cros policy
|
||||||
|
|
||||||
* **24.07.20**
|
* **24.07.20**
|
||||||
- Cleaned up the web client socket connection establishment code
|
- Cleaned up the web client socket connection establishment code
|
||||||
- Improved connect refused error detection (Not showing the certificate accept dialog if the server is down)
|
- Improved connect refused error detection (Not showing the certificate accept dialog if the server is down)
|
||||||
|
|
|
@ -46,6 +46,8 @@ export abstract class AbstractServerConnection {
|
||||||
abstract set onconnectionstatechanged(listener: ConnectionStateListener);
|
abstract set onconnectionstatechanged(listener: ConnectionStateListener);
|
||||||
|
|
||||||
abstract remote_address() : ServerAddress; /* only valid when connected */
|
abstract remote_address() : ServerAddress; /* only valid when connected */
|
||||||
|
connectionProxyAddress() : ServerAddress | undefined { return undefined; };
|
||||||
|
|
||||||
abstract handshake_handler() : HandshakeHandler; /* only valid when connected */
|
abstract handshake_handler() : HandshakeHandler; /* only valid when connected */
|
||||||
|
|
||||||
//FIXME: Remove this this is currently only some kind of hack
|
//FIXME: Remove this this is currently only some kind of hack
|
||||||
|
|
|
@ -195,9 +195,12 @@ class FileCommandHandler extends AbstractCommandHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fixIPAddresses(properties: InitializedTransferProperties) {
|
private fixIPAddresses(properties: InitializedTransferProperties) {
|
||||||
for(const address of properties.addresses)
|
for(const address of properties.addresses) {
|
||||||
if(address.serverAddress === '0.0.0.0')
|
if(address.serverAddress === '0.0.0.0') {
|
||||||
address.serverAddress = this.manager.connectionHandler.serverConnection.remote_address().host;
|
const sconnection = this.manager.connectionHandler.serverConnection;
|
||||||
|
address.serverAddress = (sconnection.connectionProxyAddress() || sconnection.remote_address()).host;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -133,9 +133,17 @@ export class ServerConnection extends AbstractServerConnection {
|
||||||
break proxySocket;
|
break proxySocket;
|
||||||
}
|
}
|
||||||
|
|
||||||
availableSockets.push(new WrappedWebSocket("wss://" + host + ":" + address.port))
|
availableSockets.push(new WrappedWebSocket({
|
||||||
|
host: host,
|
||||||
|
port: address.port,
|
||||||
|
secure: true
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
availableSockets.push(new WrappedWebSocket("wss://" + address.host + ":" + address.port));
|
availableSockets.push(new WrappedWebSocket({
|
||||||
|
host: address.host,
|
||||||
|
port: address.port,
|
||||||
|
secure: true
|
||||||
|
}));
|
||||||
|
|
||||||
let timeoutRaised = false;
|
let timeoutRaised = false;
|
||||||
let timeoutPromise = new Promise(resolve => setTimeout(() => {
|
let timeoutPromise = new Promise(resolve => setTimeout(() => {
|
||||||
|
@ -176,12 +184,12 @@ export class ServerConnection extends AbstractServerConnection {
|
||||||
|
|
||||||
switch (finished.state) {
|
switch (finished.state) {
|
||||||
case "unconnected":
|
case "unconnected":
|
||||||
log.debug(LogCategory.NETWORKING, tr("Connection attempt to %s:%d via %s got aborted."), this.remoteServerAddress.host, this.remoteServerAddress.port, finished.url);
|
log.debug(LogCategory.NETWORKING, tr("Connection attempt to %s:%d via %s got aborted."), this.remoteServerAddress.host, this.remoteServerAddress.port, finished.socketUrl());
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case "errored":
|
case "errored":
|
||||||
const error = finished.popError();
|
const error = finished.popError();
|
||||||
log.info(LogCategory.NETWORKING, tr("Connection attempt to %s:%d via %s failed:\n%o"), this.remoteServerAddress.host, this.remoteServerAddress.port, finished.url, error);
|
log.info(LogCategory.NETWORKING, tr("Connection attempt to %s:%d via %s failed:\n%o"), this.remoteServerAddress.host, this.remoteServerAddress.port, finished.socketUrl(), error);
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case "connected":
|
case "connected":
|
||||||
|
@ -238,7 +246,7 @@ export class ServerConnection extends AbstractServerConnection {
|
||||||
log.info(LogCategory.NETWORKING, tr("Successfully initialized a connection to %s:%d via %s within %d milliseconds."),
|
log.info(LogCategory.NETWORKING, tr("Successfully initialized a connection to %s:%d via %s within %d milliseconds."),
|
||||||
this.remoteServerAddress.host,
|
this.remoteServerAddress.host,
|
||||||
this.remoteServerAddress.port,
|
this.remoteServerAddress.port,
|
||||||
this.socket.url,
|
this.socket.socketUrl(),
|
||||||
connectEndTimestamp - connectBeginTimestamp);
|
connectEndTimestamp - connectBeginTimestamp);
|
||||||
|
|
||||||
|
|
||||||
|
@ -447,6 +455,10 @@ export class ServerConnection extends AbstractServerConnection {
|
||||||
return this.remoteServerAddress;
|
return this.remoteServerAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
connectionProxyAddress(): ServerAddress | undefined {
|
||||||
|
return this.socket?.address;
|
||||||
|
}
|
||||||
|
|
||||||
private doNextPing() {
|
private doNextPing() {
|
||||||
if(this.pingStatistics.lastRequestTimestamp + this.pingStatistics.timeout < Date.now()) {
|
if(this.pingStatistics.lastRequestTimestamp + this.pingStatistics.timeout < Date.now()) {
|
||||||
this.pingStatistics.currentJsValue = this.pingStatistics.timeout;
|
this.pingStatistics.currentJsValue = this.pingStatistics.timeout;
|
||||||
|
|
|
@ -3,8 +3,16 @@ import {LogCategory} from "tc-shared/log";
|
||||||
|
|
||||||
const kPreventOpeningWebSocketClosing = false;
|
const kPreventOpeningWebSocketClosing = false;
|
||||||
|
|
||||||
|
export type WebSocketUrl = {
|
||||||
|
secure: boolean;
|
||||||
|
|
||||||
|
host: string,
|
||||||
|
port: number,
|
||||||
|
|
||||||
|
path?: string
|
||||||
|
};
|
||||||
export class WrappedWebSocket {
|
export class WrappedWebSocket {
|
||||||
public readonly url: string;
|
public readonly address: WebSocketUrl;
|
||||||
public socket: WebSocket;
|
public socket: WebSocket;
|
||||||
public state: "unconnected" | "connecting" | "connected" | "errored";
|
public state: "unconnected" | "connecting" | "connected" | "errored";
|
||||||
|
|
||||||
|
@ -16,17 +24,26 @@ export class WrappedWebSocket {
|
||||||
private errorQueue = [];
|
private errorQueue = [];
|
||||||
private connectResultListener = [];
|
private connectResultListener = [];
|
||||||
|
|
||||||
constructor(url: string) {
|
constructor(addr: WebSocketUrl) {
|
||||||
this.url = url;
|
this.address = addr;
|
||||||
this.state = "unconnected";
|
this.state = "unconnected";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
socketUrl() : string {
|
||||||
|
let result = "";
|
||||||
|
result += this.address.secure ? "wss://" : "ws://";
|
||||||
|
result += this.address.host + ":" + this.address.port;
|
||||||
|
if(this.address.path)
|
||||||
|
result += (this.address.path.startsWith("/") ? "" : "/") + this.address.path;
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
doConnect() {
|
doConnect() {
|
||||||
this.closeConnection();
|
this.closeConnection();
|
||||||
|
|
||||||
this.state = "connecting";
|
this.state = "connecting";
|
||||||
try {
|
try {
|
||||||
this.socket = new WebSocket(this.url);
|
this.socket = new WebSocket(this.socketUrl());
|
||||||
|
|
||||||
this.socket.onopen = () => {
|
this.socket.onopen = () => {
|
||||||
this.state = "connected";
|
this.state = "connected";
|
||||||
|
@ -111,7 +128,7 @@ export class WrappedWebSocket {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log.warn(LogCategory.NETWORKING, tr("Failed to close the web socket to %s: %o"), this.url, error);
|
log.warn(LogCategory.NETWORKING, tr("Failed to close the web socket to %s: %o"), this.socketUrl(), error);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.socket = undefined;
|
this.socket = undefined;
|
||||||
|
|
Loading…
Add table
Reference in a new issue