added error messages to logs and implemented visibility via tooltips
This commit is contained in:
parent
3bf506cbba
commit
3ad186bcb4
@ -205,6 +205,7 @@ func (h *Handler) UpdateIP(c echo.Context) (err error) {
|
||||
if log.CallerIP == "" {
|
||||
log.CallerIP, _, err = net.SplitHostPort(c.Request().RemoteAddr)
|
||||
if err != nil {
|
||||
log.Message = "Bad Request: Unable to get caller IP"
|
||||
if err = h.CreateLogEntry(log); err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
@ -216,6 +217,7 @@ func (h *Handler) UpdateIP(c echo.Context) (err error) {
|
||||
// Validate hostname
|
||||
hostname := c.QueryParam("hostname")
|
||||
if hostname == "" || hostname != h.AuthHost.Hostname+"."+h.AuthHost.Domain {
|
||||
log.Message = "Hostname or combination of authenticated user and hostname is invalid"
|
||||
if err = h.CreateLogEntry(log); err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
@ -229,6 +231,7 @@ func (h *Handler) UpdateIP(c echo.Context) (err error) {
|
||||
log.SentIP = log.CallerIP
|
||||
ipType = getIPType(log.SentIP)
|
||||
if ipType == "" {
|
||||
log.Message = "Bad Request: Sent IP is invalid"
|
||||
if err = h.CreateLogEntry(log); err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
@ -239,6 +242,7 @@ func (h *Handler) UpdateIP(c echo.Context) (err error) {
|
||||
|
||||
// add/update DNS record
|
||||
if err = h.updateRecord(log.Host.Hostname, log.SentIP, ipType, log.Host.Domain, log.Host.Ttl); err != nil {
|
||||
log.Message = fmt.Sprintf("DNS error: %v", err)
|
||||
if err = h.CreateLogEntry(log); err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
@ -249,6 +253,7 @@ func (h *Handler) UpdateIP(c echo.Context) (err error) {
|
||||
log.Host.Ip = log.SentIP
|
||||
log.Host.LastUpdate = log.TimeStamp
|
||||
log.Status = true
|
||||
log.Message = "No errors occurred"
|
||||
if err = h.CreateLogEntry(log); err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
@ -27,7 +27,6 @@ func (h *Handler) ShowLogs(c echo.Context) (err error) {
|
||||
|
||||
return c.Render(http.StatusOK, "listlogs", echo.Map{
|
||||
"logs": logs,
|
||||
"config": h.Config,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@ -9,6 +9,7 @@ import (
|
||||
type Log struct {
|
||||
gorm.Model
|
||||
Status bool
|
||||
Message string
|
||||
Host Host
|
||||
HostID uint
|
||||
SentIP string
|
||||
|
||||
@ -114,3 +114,12 @@ $("button.generateHash").click(function () {
|
||||
let input = document.getElementById(id);
|
||||
input.value = randomHash();
|
||||
});
|
||||
|
||||
$(document).ready(function(){
|
||||
$(".errorTooltip").tooltip({
|
||||
track: true,
|
||||
content: function () {
|
||||
return $(this).prop('title');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
{{range .logs}}
|
||||
<tr>
|
||||
<tr class="errorTooltip" title="<b>{{if .Status}}Successful{{else}}Failed{{end}}</b><br>{{.Message}}">
|
||||
<td class="align-middle mx-auto"><div class="{{if .Status}}bg-success{{else}}bg-danger{{end}}" style="width: 16px; height: 16px; margin: auto"></div></td>
|
||||
<td>{{.Host.Hostname}}.{{.Host.Domain}}</td>
|
||||
<td>{{.SentIP}}</td>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user