Skip to content

Commit

Permalink
Added authKey and ControlUrl to reference
Browse files Browse the repository at this point in the history
  • Loading branch information
AtibQur committed Dec 14, 2024
1 parent aebb807 commit da2d2e7
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sites/cheerpx/src/content/docs/11-guides/Networking.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ const cx = await CheerpX.Linux.create({
What is happening here?

- `controlUrl` is a string URL of the Tailscale control plane which verifies the user's identity. You only need to pass this option if you are [self-hosting Tailscale](/docs/guides/Networking#self-hosting-headscale).
- `authKey` is string with an auth key to register new users/devices that are pre-authenticated. You can create an auth key [here](https://login.tailscale.com/admin/settings/keys).
- [`controlUrl`](/docs/reference/CheerpX-Linux-create#controlurl) is a string URL of the Tailscale control plane which verifies the user's identity. You only need to pass this option if you are [self-hosting Tailscale](/docs/guides/Networking#self-hosting-headscale).
- [`authKey`](/docs/reference/CheerpX-Linux-create#authkey) is string with an auth key to register new users/devices that are pre-authenticated. You can create an auth key [here](https://login.tailscale.com/admin/settings/keys).
- [`stateUpdateCb`](/docs/reference/CheerpX-Linux-create#stateupdatecb) is a callback function that receives the current state of the network. It is required for monitoring changes in the network status.
- [`netmapUpdateCb`](/docs/reference/CheerpX-Linux-create#netmapupdatecb) is a callback function that receives updates about the network map. This callback is also necessary for receiving network mapping information.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,59 @@ This option configures network settings, which allows CheerpX to communicate ove

[Promise]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise

### `authKey`

```ts
authKey?: string;
```

The `authKey` is an optional string used for authentication. It is usually taken from the URL, allowing the CheerpX Linux environment to be set up automatically without the user needing to enter it manually.

**Example of usage:**

```js
let authKey = undefined;
if (browser) {
let params = new URLSearchParams("?" + window.location.hash.substr(1));
authKey = params.get("authKey") || undefined;
}
const networkInterface = { authKey };
```

**Explanation**

1. The `authKey` is taken from the URL, allowing the application to automatically use the authentication key provided by the browser.

2. The `authKey` is added to the `networkInterface` object, ensuring the application can access the authentication data whenever needed in the CheerpX environment.

### `controlUrl`

```ts
controlUrl?: string;
```

The `controlUrl` is an optional string parameter representing a URL used to manage or monitor the connection. It is typically fetched from the URL parameters and can be utilized for dashboard or configuration purposes.

**Example of usage:**

```js
let controlUrl = undefined;
if (browser) {
let params = new URLSearchParams("?" + window.location.hash.substr(1));
controlUrl = params.get("controlUrl") || undefined;
}
const dashboardUrl = controlUrl
? null
: "https://login.tailscale.com/admin/machines";
const networkInterface = { controlUrl };
```

**Explanation**

1. The `controlUrl` is taken from the URL and added to the `networkInterface` object, making it easy to connect to the appropriate control dashboard.

2. If `controlUrl` isn’t provided, the app automatically uses a default URL (`dashboardUrl`) for monitoring or setup.

### `loginUrlCb`

```ts
Expand Down

0 comments on commit da2d2e7

Please sign in to comment.