chore: bunch of improvements
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -15,6 +15,7 @@ import type {
|
||||
*/
|
||||
export abstract class Location {
|
||||
abstract toJson(): ServiceLocation;
|
||||
abstract clone(): Location;
|
||||
|
||||
static fromJson(data: ServiceLocation): Location {
|
||||
switch (data.type) {
|
||||
@@ -89,6 +90,17 @@ export class LocationUri extends Location {
|
||||
const path = this.path || '';
|
||||
return `${this.scheme}://${this.host}:${this.port}${path}`;
|
||||
}
|
||||
|
||||
clone(): LocationUri {
|
||||
return new LocationUri(
|
||||
this.scheme,
|
||||
this.host,
|
||||
this.port,
|
||||
this.path,
|
||||
this.verifyPeer,
|
||||
this.verifyHost
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -138,6 +150,16 @@ export class LocationSocketSole extends Location {
|
||||
...(this.verifyHost !== undefined && { verifyHost: this.verifyHost })
|
||||
};
|
||||
}
|
||||
|
||||
clone(): LocationSocketSole {
|
||||
return new LocationSocketSole(
|
||||
this.host,
|
||||
this.port,
|
||||
this.encryption,
|
||||
this.verifyPeer,
|
||||
this.verifyHost
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -212,6 +234,21 @@ export class LocationSocketSplit extends Location {
|
||||
...(this.outboundVerifyHost !== undefined && { outboundVerifyHost: this.outboundVerifyHost })
|
||||
};
|
||||
}
|
||||
|
||||
clone(): LocationSocketSplit {
|
||||
return new LocationSocketSplit(
|
||||
this.inboundHost,
|
||||
this.inboundPort,
|
||||
this.inboundEncryption,
|
||||
this.outboundHost,
|
||||
this.outboundPort,
|
||||
this.outboundEncryption,
|
||||
this.inboundVerifyPeer,
|
||||
this.inboundVerifyHost,
|
||||
this.outboundVerifyPeer,
|
||||
this.outboundVerifyHost
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -237,4 +274,8 @@ export class LocationFile extends Location {
|
||||
path: this.path
|
||||
};
|
||||
}
|
||||
|
||||
clone(): LocationFile {
|
||||
return new LocationFile(this.path);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user