You've already forked directdnsonly-go
Initial Project
This commit is contained in:
34
internal/handlers/DNSAdmin.go
Normal file
34
internal/handlers/DNSAdmin.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
||||
"github.com/guisea/directdnsonly/internal/util"
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
||||
func DNSAdmin(c echo.Context) error {
|
||||
// Implementation still to come
|
||||
if c.Request().Method == "POST" {
|
||||
action := c.QueryParam("action")
|
||||
c.Logger().Debug("Action received via querystring: " + action)
|
||||
body := c.Request().Body
|
||||
respBytes, err := io.ReadAll(body)
|
||||
if err != nil {
|
||||
c.Logger().Error(err)
|
||||
}
|
||||
c.Logger().Debugf("Body of request: %s", respBytes)
|
||||
if action == "" {
|
||||
c.Logger().Debug("Action was not found, check body")
|
||||
decoded_params := util.DecodeParams(string(respBytes))
|
||||
|
||||
c.Logger().Debugf("Parameters decoded: %s", decoded_params)
|
||||
action = decoded_params["action"]
|
||||
}
|
||||
// zone_file := body
|
||||
}
|
||||
if c.Request().Method == "GET" {
|
||||
// Implement some stuff
|
||||
}
|
||||
return nil
|
||||
}
|
||||
20
internal/handlers/LoginTest.go
Normal file
20
internal/handlers/LoginTest.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/guisea/directdnsonly/internal/responses"
|
||||
"github.com/guisea/directdnsonly/internal/util"
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
||||
// Login - LoginTest endpoint allows DirectAdmin to check login details
|
||||
// As we have set Basic Auth middleware just returns message
|
||||
func LoginTest(c echo.Context) error {
|
||||
// Construct a response
|
||||
resp := responses.DAResponse{}
|
||||
resp.Error = 0
|
||||
resp.Message = "Login OK"
|
||||
// Returns the response to the client
|
||||
return c.String(http.StatusOK, util.EncodeQueryString(resp))
|
||||
}
|
||||
Reference in New Issue
Block a user