mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
remove sign along changes
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
1a5ebc94f4
commit
fb109e8cff
@ -124,28 +124,30 @@ export class Tracker extends Util.Singleton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected resolveOS() {
|
protected resolveOS() {
|
||||||
|
let os = "";
|
||||||
if (App.isMac) {
|
if (App.isMac) {
|
||||||
return "MacOS";
|
os = "MacOS";
|
||||||
|
} else if(App.isWindows) {
|
||||||
|
os = "Windows";
|
||||||
|
} else if (App.isLinux) {
|
||||||
|
os = "Linux";
|
||||||
|
if (App.isSnap) {
|
||||||
|
os += "; Snap";
|
||||||
|
} else {
|
||||||
|
os += "; AppImage";
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
if (App.isWindows) {
|
os = "Unknown";
|
||||||
return "Windows";
|
|
||||||
}
|
}
|
||||||
|
return os;
|
||||||
if (App.isLinux) {
|
|
||||||
return `Linux; ${App.isSnap ? "Snap" : "AppImage"}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
return "Unknown";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async event(eventCategory: string, eventAction: string, otherParams = {}) {
|
protected async event(eventCategory: string, eventAction: string, otherParams = {}) {
|
||||||
|
try {
|
||||||
const allowed = await this.isTelemetryAllowed();
|
const allowed = await this.isTelemetryAllowed();
|
||||||
if (!allowed) {
|
if (!allowed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
this.visitor.event({
|
this.visitor.event({
|
||||||
ec: eventCategory,
|
ec: eventCategory,
|
||||||
ea: eventAction,
|
ea: eventAction,
|
||||||
|
|||||||
@ -10,7 +10,6 @@ import { Router } from "./router";
|
|||||||
import { ClusterManager } from "./cluster-manager";
|
import { ClusterManager } from "./cluster-manager";
|
||||||
import { ContextHandler } from "./context-handler";
|
import { ContextHandler } from "./context-handler";
|
||||||
import logger from "./logger";
|
import logger from "./logger";
|
||||||
import _ from "lodash";
|
|
||||||
|
|
||||||
export class LensProxy {
|
export class LensProxy {
|
||||||
protected origin: string;
|
protected origin: string;
|
||||||
@ -65,10 +64,7 @@ export class LensProxy {
|
|||||||
|
|
||||||
protected async handleProxyUpgrade(proxy: httpProxy, req: http.IncomingMessage, socket: net.Socket, head: Buffer) {
|
protected async handleProxyUpgrade(proxy: httpProxy, req: http.IncomingMessage, socket: net.Socket, head: Buffer) {
|
||||||
const cluster = this.clusterManager.getClusterForRequest(req);
|
const cluster = this.clusterManager.getClusterForRequest(req);
|
||||||
if (!cluster) {
|
if (cluster) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const proxyUrl = await cluster.contextHandler.resolveAuthProxyUrl() + req.url.replace(apiKubePrefix, "");
|
const proxyUrl = await cluster.contextHandler.resolveAuthProxyUrl() + req.url.replace(apiKubePrefix, "");
|
||||||
const apiUrl = url.parse(cluster.apiUrl);
|
const apiUrl = url.parse(cluster.apiUrl);
|
||||||
const pUrl = url.parse(proxyUrl);
|
const pUrl = url.parse(proxyUrl);
|
||||||
@ -77,15 +73,12 @@ export class LensProxy {
|
|||||||
proxySocket.connect(connectOpts, () => {
|
proxySocket.connect(connectOpts, () => {
|
||||||
proxySocket.write(`${req.method} ${pUrl.path} HTTP/1.1\r\n`);
|
proxySocket.write(`${req.method} ${pUrl.path} HTTP/1.1\r\n`);
|
||||||
proxySocket.write(`Host: ${apiUrl.host}\r\n`);
|
proxySocket.write(`Host: ${apiUrl.host}\r\n`);
|
||||||
|
for (let i = 0; i < req.rawHeaders.length; i += 2) {
|
||||||
for (const [key, value] of _.chunk(req.rawHeaders, 2)) {
|
const key = req.rawHeaders[i];
|
||||||
if (["Host", "Authorization"].includes(key)) {
|
if (key !== "Host" && key !== "Authorization") {
|
||||||
continue;
|
proxySocket.write(`${req.rawHeaders[i]}: ${req.rawHeaders[i+1]}\r\n`);
|
||||||
}
|
}
|
||||||
|
|
||||||
proxySocket.write(`${key}: ${value}\r\n`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
proxySocket.write("\r\n");
|
proxySocket.write("\r\n");
|
||||||
proxySocket.write(head);
|
proxySocket.write(head);
|
||||||
});
|
});
|
||||||
@ -102,7 +95,7 @@ export class LensProxy {
|
|||||||
socket.end();
|
socket.end();
|
||||||
});
|
});
|
||||||
proxySocket.on('error', function (err) {
|
proxySocket.on('error', function (err) {
|
||||||
socket.write(`HTTP/${req.httpVersion} 500 Connection error\r\n\r\n`);
|
socket.write("HTTP/" + req.httpVersion + " 500 Connection error\r\n\r\n");
|
||||||
socket.end();
|
socket.end();
|
||||||
});
|
});
|
||||||
socket.on('data', function (chunk) {
|
socket.on('data', function (chunk) {
|
||||||
@ -115,6 +108,7 @@ export class LensProxy {
|
|||||||
proxySocket.end();
|
proxySocket.end();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected createProxy(): httpProxy {
|
protected createProxy(): httpProxy {
|
||||||
const proxy = httpProxy.createProxyServer();
|
const proxy = httpProxy.createProxyServer();
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import { stringify } from "querystring";
|
import { stringify } from "querystring";
|
||||||
import { EventEmitter } from "../../common/event-emitter";
|
import { EventEmitter } from "../../common/event-emitter";
|
||||||
import { cancelableFetch, CancelablePromise } from "../utils/cancelableFetch";
|
import { cancelableFetch } from "../utils/cancelableFetch";
|
||||||
|
|
||||||
export interface JsonApiData {
|
export interface JsonApiData {
|
||||||
}
|
}
|
||||||
@ -71,7 +71,7 @@ export class JsonApi<D = JsonApiData, P extends JsonApiParams = JsonApiParams> {
|
|||||||
return this.request<T>(path, params, { ...reqInit, method: "delete" });
|
return this.request<T>(path, params, { ...reqInit, method: "delete" });
|
||||||
}
|
}
|
||||||
|
|
||||||
protected request<D>(path: string, params?: P, init: RequestInit = {}): CancelablePromise<D> {
|
protected request<D>(path: string, params?: P, init: RequestInit = {}) {
|
||||||
let reqUrl = this.config.apiBase + path;
|
let reqUrl = this.config.apiBase + path;
|
||||||
const reqInit: RequestInit = { ...this.reqInit, ...init };
|
const reqInit: RequestInit = { ...this.reqInit, ...init };
|
||||||
const { data, query } = params || {} as P;
|
const { data, query } = params || {} as P;
|
||||||
@ -92,9 +92,9 @@ export class JsonApi<D = JsonApiData, P extends JsonApiParams = JsonApiParams> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async parseResponse<D>(res: Response, log: JsonApiLog): Promise<D> {
|
protected parseResponse<D>(res: Response, log: JsonApiLog): Promise<D> {
|
||||||
const { status } = res;
|
const { status } = res;
|
||||||
const text = await res.text();
|
return res.text().then(text => {
|
||||||
let data;
|
let data;
|
||||||
try {
|
try {
|
||||||
data = text ? JSON.parse(text) : ""; // DELETE-requests might not have response-body
|
data = text ? JSON.parse(text) : ""; // DELETE-requests might not have response-body
|
||||||
@ -113,6 +113,7 @@ export class JsonApi<D = JsonApiData, P extends JsonApiParams = JsonApiParams> {
|
|||||||
this.writeLog({ ...log, error });
|
this.writeLog({ ...log, error });
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected parseError(error: JsonApiError | string, res: Response): string[] {
|
protected parseError(error: JsonApiError | string, res: Response): string[] {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user