Fixed icon and avatar loading
parent
cbbe2094f2
commit
cadabd69c7
|
@ -1,4 +1,7 @@
|
|||
# Changelog:
|
||||
* **25.07.20**
|
||||
- Fixed bug where icons could not be loaded due to cros policy
|
||||
|
||||
* **24.07.20**
|
||||
- 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)
|
||||
|
|
|
@ -46,6 +46,8 @@ export abstract class AbstractServerConnection {
|
|||
abstract set onconnectionstatechanged(listener: ConnectionStateListener);
|
||||
|
||||
abstract remote_address() : ServerAddress; /* only valid when connected */
|
||||
connectionProxyAddress() : ServerAddress | undefined { return undefined; };
|
||||
|
||||
abstract handshake_handler() : HandshakeHandler; /* only valid when connected */
|
||||
|
||||
//FIXME: Remove this this is currently only some kind of hack
|
||||
|
|
|
@ -195,9 +195,12 @@ class FileCommandHandler extends AbstractCommandHandler {
|
|||
}
|
||||
|
||||
private fixIPAddresses(properties: InitializedTransferProperties) {
|
||||
for(const address of properties.addresses)
|
||||
if(address.serverAddress === '0.0.0.0')
|
||||
address.serverAddress = this.manager.connectionHandler.serverConnection.remote_address().host;
|
||||
for(const address of properties.addresses) {
|
||||
if(address.serverAddress === '0.0.0.0') {
|
||||
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;
|
||||
}
|
||||
|
||||
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 timeoutPromise = new Promise(resolve => setTimeout(() => {
|
||||
|
@ -176,12 +184,12 @@ export class ServerConnection extends AbstractServerConnection {
|
|||
|
||||
switch (finished.state) {
|
||||
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;
|
||||
|
||||
case "errored":
|
||||
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;
|
||||
|
||||
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."),
|
||||
this.remoteServerAddress.host,
|
||||
this.remoteServerAddress.port,
|
||||
this.socket.url,
|
||||
this.socket.socketUrl(),
|
||||
connectEndTimestamp - connectBeginTimestamp);
|
||||
|
||||
|
||||
|
@ -447,6 +455,10 @@ export class ServerConnection extends AbstractServerConnection {
|
|||
return this.remoteServerAddress;
|
||||
}
|
||||
|
||||
connectionProxyAddress(): ServerAddress | undefined {
|
||||
return this.socket?.address;
|
||||
}
|
||||
|
||||
private doNextPing() {
|
||||
if(this.pingStatistics.lastRequestTimestamp + this.pingStatistics.timeout < Date.now()) {
|
||||
this.pingStatistics.currentJsValue = this.pingStatistics.timeout;
|
||||
|
|
|
@ -3,8 +3,16 @@ import {LogCategory} from "tc-shared/log";
|
|||
|
||||
const kPreventOpeningWebSocketClosing = false;
|
||||
|
||||
export type WebSocketUrl = {
|
||||
secure: boolean;
|
||||
|
||||
host: string,
|
||||
port: number,
|
||||
|
||||
path?: string
|
||||
};
|
||||
export class WrappedWebSocket {
|
||||
public readonly url: string;
|
||||
public readonly address: WebSocketUrl;
|
||||
public socket: WebSocket;
|
||||
public state: "unconnected" | "connecting" | "connected" | "errored";
|
||||
|
||||
|
@ -16,17 +24,26 @@ export class WrappedWebSocket {
|
|||
private errorQueue = [];
|
||||
private connectResultListener = [];
|
||||
|
||||
constructor(url: string) {
|
||||
this.url = url;
|
||||
constructor(addr: WebSocketUrl) {
|
||||
this.address = addr;
|
||||
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() {
|
||||
this.closeConnection();
|
||||
|
||||
this.state = "connecting";
|
||||
try {
|
||||
this.socket = new WebSocket(this.url);
|
||||
this.socket = new WebSocket(this.socketUrl());
|
||||
|
||||
this.socket.onopen = () => {
|
||||
this.state = "connected";
|
||||
|
@ -111,7 +128,7 @@ export class WrappedWebSocket {
|
|||
}
|
||||
}
|
||||
} 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;
|
||||
|
|
Loading…
Reference in New Issue