Skip to content

Commit

Permalink
show /etc/resolv.conf
Browse files Browse the repository at this point in the history
  • Loading branch information
Eslam-Nawara committed Dec 26, 2024
1 parent 2a0c629 commit 9d82197
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 8 additions & 1 deletion pkg/zos_api/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"context"
"encoding/json"
"fmt"
"os"
"path/filepath"

"github.com/threefoldtech/zos/pkg/zinit"
)
Expand Down Expand Up @@ -42,7 +44,7 @@ func (g *ZosAPI) adminRestartAllHandler(ctx context.Context, payload []byte) (in
return nil, nil
}

func (g *ZosAPI) adminShowLogs(ctx context.Context, payload []byte) (interface{}, error) {
func (g *ZosAPI) adminShowLogsHandler(ctx context.Context, payload []byte) (interface{}, error) {
var n int
if err := json.Unmarshal(payload, &n); err != nil {
return nil, fmt.Errorf("failed to decode input, expecting string: %w", err)
Expand All @@ -53,6 +55,11 @@ func (g *ZosAPI) adminShowLogs(ctx context.Context, payload []byte) (interface{}
return zinit.Log(n)
}

func (g *ZosAPI) adminShowResolveHandler(ctx context.Context, payload []byte) (interface{}, error) {
path := filepath.Join("/etc", "resolv.conf")
return os.ReadFile(path)
}

func (g *ZosAPI) adminInterfacesHandler(ctx context.Context, payload []byte) (interface{}, error) {
// list all interfaces on node
type Interface struct {
Expand Down
3 changes: 2 additions & 1 deletion pkg/zos_api/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ func (g *ZosAPI) SetupRoutes(router *peer.Router) {
admin.WithHandler("restart", g.adminRestartServiceHandler)
admin.WithHandler("restart_all", g.adminRestartAllHandler)

admin.WithHandler("show_logs", g.adminShowLogs)
admin.WithHandler("show_logs", g.adminShowLogsHandler)
admin.WithHandler("show_resolve", g.adminShowResolveHandler)

admin.WithHandler("interfaces", g.adminInterfacesHandler)
admin.WithHandler("set_public_nic", g.adminSetPublicNICHandler)
Expand Down

0 comments on commit 9d82197

Please sign in to comment.