Task: Add extra info for headers and updated the client can override the subdomain with apikey first priority

This commit is contained in:
Sambo Chea 2022-06-27 23:32:22 +07:00
parent cf56b920b3
commit f155410eea
2 changed files with 13 additions and 2 deletions

View File

@ -35,7 +35,7 @@ function initClient(options) {
// Current style using sub-domain: https://{{clientId}}-tunnel.myhostingdomain.com
// (Original server: https://tunnel.myhostingdomain.com)
const profile = options.profile || PROFILE_DEFAULT;
const clientId = `${options.clientId || options.apiKey || generateUUID()}`;
const clientId = `${options.apiKey || options.clientId || generateUUID()}`;
const clientIdSub =
profile === PROFILE_DEFAULT ? `${clientId}-` : `${clientId}-${profile}-`;
const clientEndpoint = (
@ -45,6 +45,7 @@ function initClient(options) {
.trim();
const serverUrl = addPrefixOnHttpSchema(options.server, clientEndpoint);
// extra options for socket to identify the client (authentication and options of tunnel)
const defaultParams = {
apiKey: options.apiKey,
clientId: options.clientId,
@ -56,6 +57,15 @@ function initClient(options) {
keep_connection: options.keep_connection || true,
};
// extra info for notify about the running of the tunnel (it's private info, other platfom cannot access this)
// this using for internal only (don't worry about this)
const osInfo = {
hostname: os.hostname(),
platform: os.platform(),
arch: os.arch(),
release: os.release(),
};
const initParams = {
path: "/$cubetiq_http_tunnel",
transports: ["websocket"],
@ -65,6 +75,7 @@ function initClient(options) {
},
headers: {
...defaultParams,
os: osInfo,
},
};

View File

@ -1,6 +1,6 @@
{
"name": "@cubetiq/hlt",
"version": "0.0.7",
"version": "0.0.8",
"description": "A lightweight http tunnel client using nodejs and socket.io client",
"main": "client.js",
"bin": {