~arx10/procustodibus-app

ca55efea3ceb9038543823cafd28775fb6776744 — Justin Ludwig a month ago 229d03a
extract default wg interface name into constant
M src/components/host/host-bulk-upload-modal.vue => src/components/host/host-bulk-upload-modal.vue +2 -1
@@ 43,6 43,7 @@
<script setup>
import { inject, nextTick, ref, unref, watch } from 'vue'
import { useHostBulkDownload } from '@/mixins/host/use-host-bulk-download'
import { env } from '@/utils/env'
import {
  generateNextAddress,
  joinAddress,


@@ 514,7 515,7 @@ async function createInterface(host, peer) {
  })

  const params = Object.assign({}, defaults, {
    name: 'wg0',
    name: env.defaultInterfaceName,
    peer_id: peer.id,
    address,
  })

M src/components/interface/interface-name-field.vue => src/components/interface/interface-name-field.vue +6 -1
@@ 19,6 19,7 @@

<script setup>
import { computed, inject, onMounted, ref, unref, watch } from 'vue'
import { env } from '@/utils/env'

const props = defineProps({
  /** Interface name (default ''). */


@@ 90,8 91,12 @@ function calculateDefaultName() {
  if (defaultName) return defaultName

  const existing = unref(existingNames)
  const { defaultInterfaceName } = env
  if (!existing.has(defaultInterfaceName)) return defaultInterfaceName

  const base = defaultInterfaceName.replace(/\d+$/, '')
  for (let i = 0; i < 100; i++) {
    const name = `wg${i}`
    const name = `${base}${i}`
    if (!existing.has(name)) return name
  }
  return ''

M src/utils/env.js => src/utils/env.js +9 -2
@@ 64,20 64,27 @@ class Env {
  }

  /**
   * Latest app name, like 'Pro Custodibus'.
   * Application name, like 'Pro Custodibus'.
   */
  get appName() {
    return this.value('APP_NAME') || 'Pro Custodibus'
  }

  /**
   * Latest app name, like 'procustodibus'.
   * Configuration file basename, like 'procustodibus'.
   */
  get confName() {
    return this.value('CONF_NAME') || 'procustodibus'
  }

  /**
   * Default WireGuard interface name, like 'wg0'.
   */
  get defaultInterfaceName() {
    return this.value('DEFAULT_INTERFACE_NAME') || 'wg0'
  }

  /**
   * Base URL of documentation website, like 'https://doc.custodib.us'.
   */
  get docUrl() {