Skip to content

Commit

Permalink
feat: mumble integration initial
Browse files Browse the repository at this point in the history
  • Loading branch information
garrappachc committed Dec 14, 2024
1 parent 6b283a3 commit 5d3132f
Show file tree
Hide file tree
Showing 34 changed files with 578 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ jobs:
image: mongo:latest
ports:
- 27017:27017
mumble:
image: mumblevoip/mumble-server:latest
ports:
- 64738:64738
- 64738:64738/udp

steps:
- uses: actions/checkout@v4
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"@kitajs/html": "4.2.5",
"@kitajs/ts-html-plugin": "4.1.1",
"@tailwindcss/typography": "0.5.15",
"@tf2pickup-org/mumble-client": "0.8.0",
"async-mutex": "0.5.0",
"autoprefixer": "10.4.20",
"croner": "9.0.0",
Expand All @@ -46,6 +47,7 @@
"mongodb": "6.12.0",
"nanoid": "5.0.9",
"openid": "2.0.12",
"pem": "1.14.8",
"pino": "9.5.0",
"postcss": "8.4.49",
"postcss-import": "16.1.0",
Expand All @@ -68,6 +70,7 @@
"@types/lodash-es": "4.17.12",
"@types/node": "22.10.2",
"@types/openid": "2.0.5",
"@types/pem": "1.14.4",
"@types/postcss-import": "14.0.3",
"@types/steamid": "2.0.3",
"@types/ws": "8.5.13",
Expand Down
91 changes: 91 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 12 additions & 2 deletions src/admin/voice-server/views/html/voice-server.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,12 @@ export async function VoiceServerPage(props: { user: User }) {
</label>
</dt>
<dd>
<input type="text" name="mumblePassword" value={mumblePassword ?? ''} />
<input
type="text"
id="mumble-password"
name="mumblePassword"
value={mumblePassword ?? ''}
/>
</dd>
</dl>

Expand All @@ -129,7 +134,12 @@ export async function VoiceServerPage(props: { user: User }) {
</label>
</dt>
<dd>
<input type="text" name="mumbleChannelName" value={mumbleChannelName ?? ''} />
<input
type="text"
id="mumble-channel-name"
name="mumbleChannelName"
value={mumbleChannelName ?? ''}
/>
</dd>
</dl>
</fieldset>
Expand Down
32 changes: 32 additions & 0 deletions src/certificates/get.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { yearsToDays } from 'date-fns'
import { collections } from '../database/collections'
import { logger } from '../logger'
import pem from 'pem'
import type { CertificateModel } from '../database/models/certificate.model'

const createCertificate = (options: pem.CertificateCreationOptions) =>
new Promise<pem.CertificateCreationResult>((resolve, reject) => {
pem.createCertificate(options, (error, result) => {
if (error) {
reject(error)
} else {
resolve(result)
}
})
})

export async function get(purpose: string): Promise<CertificateModel> {
logger.trace(`certificates.get(purpose=${purpose})`)
const c = await collections.certificates.findOne({ purpose })
if (c !== null) {
return c
}

const { clientKey, certificate } = await createCertificate({
days: yearsToDays(10),
selfSigned: true,
})
await collections.certificates.insertOne({ purpose, clientKey, certificate })
logger.info({ purpose }, `certificate created`)
return { purpose, clientKey, certificate }
}
5 changes: 5 additions & 0 deletions src/certificates/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { get } from './get'

export const certificates = {
get,
} as const
2 changes: 2 additions & 0 deletions src/configuration/reset.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { collections } from '../database/collections'
import type { Configuration } from '../database/models/configuration-entry.model'
import { events } from '../events'
import { get } from './get'

export async function reset<T extends keyof Configuration>(key: T): Promise<Configuration[T]> {
await collections.configuration.deleteOne({ key })
events.emit('configuration:updated', { key })
return await get(key)
}
2 changes: 2 additions & 0 deletions src/configuration/set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import {
configurationSchema,
type Configuration,
} from '../database/models/configuration-entry.model'
import { events } from '../events'

export async function set<T extends keyof Configuration>(
key: T,
value: Configuration[T],
): Promise<void> {
configurationSchema.parse({ key, value })
await collections.configuration.updateOne({ key }, { $set: { value } }, { upsert: true })
events.emit('configuration:updated', { key })
}
Loading

0 comments on commit 5d3132f

Please sign in to comment.