Skip to content

Commit

Permalink
Revert "Replace dnsmasq with bind"
Browse files Browse the repository at this point in the history
This reverts commit 0158e0e.
  • Loading branch information
USA-RedDragon committed Aug 17, 2023
1 parent 72337ce commit 135108f
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 371 deletions.
9 changes: 1 addition & 8 deletions cmd/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package cmd
import (
"fmt"

"github.com/USA-RedDragon/aredn-manager/internal/bind"
"github.com/USA-RedDragon/aredn-manager/internal/config"
"github.com/USA-RedDragon/aredn-manager/internal/db"
"github.com/USA-RedDragon/aredn-manager/internal/olsrd"
Expand Down Expand Up @@ -38,11 +37,5 @@ func runGenerate(cmd *cobra.Command, _ []string) error {
}

fmt.Println("Generating vtund config")
err = vtun.GenerateAndSave(config, db)
if err != nil {
return err
}

fmt.Println("Generating BIND config")
return bind.GenerateAndSave(config, db)
return vtun.GenerateAndSave(config, db)
}
10 changes: 5 additions & 5 deletions frontend/src/views/MainPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
<h3 style="font-weight: bold;">OLSR Daemon</h3>
<p>{{ olsrdRunning ? 'Running':'Stopped' }}</p>
<br />
<h3 style="font-weight: bold;">BIND DNS</h3>
<p>{{ bindRunning ? 'Running':'Stopped' }}</p>
<h3 style="font-weight: bold;">DNSMasq</h3>
<p>{{ dnsRunning ? 'Running':'Stopped' }}</p>
</template>
</Card>
<Card style="width: 48%;">
Expand Down Expand Up @@ -51,7 +51,7 @@ export default {
return {
vtundRunning: true,
olsrdRunning: true,
bindRunning: true,
dnsRunning: true,
tunnelsConnected: 0,
totalTunnels: 0,
stats: {},
Expand All @@ -65,8 +65,8 @@ export default {
API.get('/vtun/running').then((res) => {
this.vtundRunning = res.data.running;
});
API.get('/bind/running').then((res) => {
this.bindRunning = res.data.running;
API.get('/dns/running').then((res) => {
this.dnsRunning = res.data.running;
});
API.get('/tunnels').then((res) => {
this.tunnelsConnected = 0;
Expand Down
255 changes: 0 additions & 255 deletions internal/bind/generator.go

This file was deleted.

23 changes: 3 additions & 20 deletions internal/bind/reload.go → internal/dnsmasq/reload.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package bind
package dnsmasq

import (
"os"
"strconv"
"syscall"
)

// This file will run bind
// This file will run dnsmasq
const (
pidFile = "/var/run/named/named.pid"
pidFile = "/var/run/dnsmasq.pid"
)

func Reload() error {
Expand All @@ -27,23 +27,6 @@ func Reload() error {
return syscall.Kill(int(pid), syscall.SIGHUP)
}

func Restart() error {
// Read the PID file
pidBytes, err := os.ReadFile(pidFile)
if err != nil {
return err
}
pidStr := string(pidBytes)
// Trim newline
pidStr = pidStr[:len(pidStr)-1]
pid, err := strconv.ParseInt(pidStr, 10, 64)
if err != nil {
return err
}
return syscall.Kill(int(pid), syscall.SIGTERM)
// SNEAKY: s6 will restart the process, so we don't need to do anything else
}

func IsRunning() bool {
pidBytes, err := os.ReadFile(pidFile)
if err != nil {
Expand Down
12 changes: 0 additions & 12 deletions internal/server/api/controllers/v1/bind.go

This file was deleted.

12 changes: 12 additions & 0 deletions internal/server/api/controllers/v1/dns.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package v1

import (
"net/http"

"github.com/USA-RedDragon/aredn-manager/internal/dnsmasq"
"github.com/gin-gonic/gin"
)

func GETDNSRunning(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"running": dnsmasq.IsRunning()})
}
Loading

0 comments on commit 135108f

Please sign in to comment.