Task: Add extra info for headers and updated the client can override the subdomain with apikey first priority
This commit is contained in:
parent
cf56b920b3
commit
f155410eea
13
client.js
13
client.js
@ -35,7 +35,7 @@ function initClient(options) {
|
|||||||
// Current style using sub-domain: https://{{clientId}}-tunnel.myhostingdomain.com
|
// Current style using sub-domain: https://{{clientId}}-tunnel.myhostingdomain.com
|
||||||
// (Original server: https://tunnel.myhostingdomain.com)
|
// (Original server: https://tunnel.myhostingdomain.com)
|
||||||
const profile = options.profile || PROFILE_DEFAULT;
|
const profile = options.profile || PROFILE_DEFAULT;
|
||||||
const clientId = `${options.clientId || options.apiKey || generateUUID()}`;
|
const clientId = `${options.apiKey || options.clientId || generateUUID()}`;
|
||||||
const clientIdSub =
|
const clientIdSub =
|
||||||
profile === PROFILE_DEFAULT ? `${clientId}-` : `${clientId}-${profile}-`;
|
profile === PROFILE_DEFAULT ? `${clientId}-` : `${clientId}-${profile}-`;
|
||||||
const clientEndpoint = (
|
const clientEndpoint = (
|
||||||
@ -45,6 +45,7 @@ function initClient(options) {
|
|||||||
.trim();
|
.trim();
|
||||||
const serverUrl = addPrefixOnHttpSchema(options.server, clientEndpoint);
|
const serverUrl = addPrefixOnHttpSchema(options.server, clientEndpoint);
|
||||||
|
|
||||||
|
// extra options for socket to identify the client (authentication and options of tunnel)
|
||||||
const defaultParams = {
|
const defaultParams = {
|
||||||
apiKey: options.apiKey,
|
apiKey: options.apiKey,
|
||||||
clientId: options.clientId,
|
clientId: options.clientId,
|
||||||
@ -56,6 +57,15 @@ function initClient(options) {
|
|||||||
keep_connection: options.keep_connection || true,
|
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 = {
|
const initParams = {
|
||||||
path: "/$cubetiq_http_tunnel",
|
path: "/$cubetiq_http_tunnel",
|
||||||
transports: ["websocket"],
|
transports: ["websocket"],
|
||||||
@ -65,6 +75,7 @@ function initClient(options) {
|
|||||||
},
|
},
|
||||||
headers: {
|
headers: {
|
||||||
...defaultParams,
|
...defaultParams,
|
||||||
|
os: osInfo,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@cubetiq/hlt",
|
"name": "@cubetiq/hlt",
|
||||||
"version": "0.0.7",
|
"version": "0.0.8",
|
||||||
"description": "A lightweight http tunnel client using nodejs and socket.io client",
|
"description": "A lightweight http tunnel client using nodejs and socket.io client",
|
||||||
"main": "client.js",
|
"main": "client.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
Loading…
Reference in New Issue
Block a user