allow custom port for API server (#204)
* allow custom port for API server * add .editorconfig
This commit is contained in:
parent
5db8873807
commit
134eb654d2
6 changed files with 23 additions and 17 deletions
|
@ -25,8 +25,10 @@ const Rinit = 0x08;
|
|||
class ImageConnection {
|
||||
constructor(host, auth, tls = false) {
|
||||
this.requests = new Map();
|
||||
if(!host.includes(":")){
|
||||
host += ":3762";
|
||||
}
|
||||
this.host = host;
|
||||
this.port = 3762;
|
||||
this.auth = auth;
|
||||
this.tag = null;
|
||||
this.disconnected = false;
|
||||
|
@ -39,19 +41,19 @@ class ImageConnection {
|
|||
} else {
|
||||
this.wsproto = "ws";
|
||||
}
|
||||
this.sockurl = `${this.wsproto}://${host}:${this.port}/sock`;
|
||||
this.conn = new WebSocket(this.sockurl, {
|
||||
headers: {
|
||||
"Authentication": auth && auth !== "" ? auth : undefined
|
||||
}
|
||||
});
|
||||
this.sockurl = `${this.wsproto}://${host}/sock`;
|
||||
let headers = {};
|
||||
if(auth){
|
||||
headers.Authentication = auth;
|
||||
}
|
||||
this.conn = new WebSocket(this.sockurl, {headers});
|
||||
let httpproto;
|
||||
if (tls) {
|
||||
httpproto = "https";
|
||||
} else {
|
||||
httpproto = "http";
|
||||
}
|
||||
this.httpurl = `${httpproto}://${host}:${this.port}/image`;
|
||||
this.httpurl = `${httpproto}://${host}/image`;
|
||||
this.conn.on("message", (msg) => this.onMessage(msg));
|
||||
this.conn.once("error", (err) => this.onError(err));
|
||||
this.conn.once("close", () => this.onClose());
|
||||
|
@ -87,7 +89,7 @@ class ImageConnection {
|
|||
}
|
||||
this.requests.clear();
|
||||
if (!this.disconnected) {
|
||||
logger.warn(`Lost connection to ${this.host}:${this.port}, attempting to reconnect in 5 seconds...`);
|
||||
logger.warn(`Lost connection to ${this.host}, attempting to reconnect in 5 seconds...`);
|
||||
await setTimeout(5000);
|
||||
this.conn = new WebSocket(this.sockurl, {
|
||||
headers: {
|
||||
|
@ -164,4 +166,4 @@ class ImageConnection {
|
|||
}
|
||||
}
|
||||
|
||||
export default ImageConnection;
|
||||
export default ImageConnection;
|
||||
|
|
|
@ -27,8 +27,8 @@ export async function clean(text) {
|
|||
const imageServers = JSON.parse(fs.readFileSync("./servers.json", { encoding: "utf8" })).image;
|
||||
|
||||
for (const { server, auth } of imageServers) {
|
||||
text = text.replaceAll(server, "<redacted>");
|
||||
text = text.replaceAll(auth, "<redacted>");
|
||||
text = optionalReplace(server);
|
||||
text = optionalReplace(auth);
|
||||
}
|
||||
|
||||
for (const env of Object.keys(parsed)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue