Skip to content

Commit

Permalink
add domainname & dns to API, #11.
Browse files Browse the repository at this point in the history
  • Loading branch information
m1k1o committed Oct 1, 2023
1 parent 0c2e56c commit bfc4a47
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 3 deletions.
8 changes: 8 additions & 0 deletions OpenApi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,14 @@ components:
$ref: '#/components/schemas/RoomMount'
resources:
$ref: '#/components/schemas/RoomResources'
hostname:
type: string
example: server.lan
dns:
type: array
items:
type: string
example: 1.1.1.1
browser_policy:
$ref: '#/components/schemas/BrowserPolicy'

Expand Down
12 changes: 12 additions & 0 deletions client/src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,18 @@ export interface RoomSettings {
* @memberof RoomSettings
*/
'resources'?: RoomResources;
/**
*
* @type {string}
* @memberof RoomSettings
*/
'hostname'?: string;
/**
*
* @type {Array<string>}
* @memberof RoomSettings
*/
'dns'?: Array<string>;
/**
*
* @type {BrowserPolicy}
Expand Down
10 changes: 10 additions & 0 deletions client/src/components/RoomInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,16 @@
</template>
</v-simple-table>

<div class="my-3 headline">Network</div>
<v-simple-table>
<template v-slot:default>
<tbody>
<tr><th style="width:50%;"> Hostname </th><td>{{ settings.hostname }}</td></tr>
<tr><th> DNS </th><td><span v-if="settings.dns">{{ settings.dns.join(", ") }}</span><i v-else>--system-default--</i></td></tr>
</tbody>
</template>
</v-simple-table>

<div class="my-3 headline">Browser policy</div>
<v-simple-table v-if="settings.browser_policy">
<template v-slot:default>
Expand Down
49 changes: 47 additions & 2 deletions client/src/components/RoomsCreate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -401,10 +401,55 @@
</v-combobox>
</v-col>
</v-row>
<v-row align="center" no-gutters class="mt-3">
<h2> Network </h2>
</v-row>
<v-row align="center" class="mt-0">
<v-col class="py-0">
<v-text-field
label="Hostname"
v-model="data.hostname"
autocomplete="off"
></v-text-field>
</v-col>
<v-col class="pt-0">
<v-combobox class="pt-0"
label="DNS"
v-model="data.dns"
multiple
hide-details
>
<template v-slot:selection="{ attrs, item, parent, selected }">
<v-chip
v-bind="attrs"
:input-value="selected"
label
small
>
<span class="pr-2">
{{ item }}
</span>
<v-icon
small
@click="parent.selectItem(item)"
>
$delete
</v-icon>
</v-chip>
</template>
</v-combobox>
</v-col>
</v-row>
<v-row align="center" no-gutters class="mb-3">
<v-col>
<p> <i> Leave empty to use container name. </i> </p>
</v-col>
<v-col class="pl-6">
<p> <i> Leave empty to use system defaults.</i> </p>
</v-col>
</v-row>
</template>

<hr />

<v-row align="center" no-gutters class="mt-3">
<h2 class="my-3">
Browser policy
Expand Down
5 changes: 5 additions & 0 deletions client/src/store/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ export const state = {
shm_size: 2000000000,
devices: [],
},

// eslint-disable-next-line
hostname: '',
// eslint-disable-next-line
dns: [],
} as RoomSettings,
videoCodecs: [
"VP8",
Expand Down
11 changes: 10 additions & 1 deletion internal/room/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -561,9 +561,14 @@ func (manager *RoomManagerCtx) Create(settings types.RoomSettings) (string, erro
// Set container configs
//

hostname := containerName
if settings.Hostname != "" {
hostname = settings.Hostname
}

config := &container.Config{
// Hostname
Hostname: containerName,
Hostname: hostname,
// Domainname is preventing from running container on LXC (Proxmox)
// https://www.gitmemory.com/issue/docker/for-linux/743/524569376
// Domainname: containerName,
Expand Down Expand Up @@ -605,6 +610,8 @@ func (manager *RoomManagerCtx) Create(settings types.RoomSettings) (string, erro
DeviceRequests: deviceRequests,
Devices: devices,
},
// DNS
DNS: settings.DNS,
// Privileged
Privileged: isPrivilegedImage,
}
Expand Down Expand Up @@ -803,6 +810,8 @@ func (manager *RoomManagerCtx) GetSettings(id string) (*types.RoomSettings, erro
Labels: labels.UserDefined,
Mounts: mounts,
Resources: roomResources,
Hostname: container.Config.Hostname,
DNS: container.HostConfig.DNS,
BrowserPolicy: browserPolicy,
}

Expand Down
3 changes: 3 additions & 0 deletions internal/types/room.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ type RoomSettings struct {
Mounts []RoomMount `json:"mounts"`
Resources RoomResources `json:"resources"`

Hostname string `json:"hostname,omitempty"`
DNS []string `json:"dns,omitempty"`

BrowserPolicy *BrowserPolicy `json:"browser_policy,omitempty"`
}

Expand Down

0 comments on commit bfc4a47

Please sign in to comment.