mirror of
https://github.com/AuxXxilium/docker-ddns-server.git
synced 2024-11-23 23:00:59 +07:00
Save updated ip to host entry
This commit is contained in:
parent
f7f84557f6
commit
71411eedf5
2
.github/workflows/containers.yml
vendored
2
.github/workflows/containers.yml
vendored
@ -11,7 +11,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
- name: Prepare
|
- name: Prepare
|
||||||
id: prep
|
id: prep
|
||||||
run: |
|
run: |
|
||||||
|
@ -237,7 +237,7 @@ func (h *Handler) UpdateIP(c echo.Context) (err error) {
|
|||||||
log.SentIP = c.QueryParam(("myip"))
|
log.SentIP = c.QueryParam(("myip"))
|
||||||
|
|
||||||
// Get caller IP
|
// Get caller IP
|
||||||
log.CallerIP, err = nswrapper.GetCallerIP(c.Request())
|
log.CallerIP, _ = nswrapper.GetCallerIP(c.Request())
|
||||||
if log.CallerIP == "" {
|
if log.CallerIP == "" {
|
||||||
log.CallerIP, _, err = net.SplitHostPort(c.Request().RemoteAddr)
|
log.CallerIP, _, err = net.SplitHostPort(c.Request().RemoteAddr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -276,7 +276,7 @@ func (h *Handler) UpdateIP(c echo.Context) (err error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// add/update DNS record
|
// Add/update DNS record
|
||||||
if err = nswrapper.UpdateRecord(log.Host.Hostname, log.SentIP, ipType, log.Host.Domain, log.Host.Ttl, h.AllowWildcard); err != nil {
|
if err = nswrapper.UpdateRecord(log.Host.Hostname, log.SentIP, ipType, log.Host.Domain, log.Host.Ttl, h.AllowWildcard); err != nil {
|
||||||
log.Message = fmt.Sprintf("DNS error: %v", err)
|
log.Message = fmt.Sprintf("DNS error: %v", err)
|
||||||
l.Error(log.Message)
|
l.Error(log.Message)
|
||||||
@ -286,8 +286,14 @@ func (h *Handler) UpdateIP(c echo.Context) (err error) {
|
|||||||
return c.String(http.StatusBadRequest, "dnserr\n")
|
return c.String(http.StatusBadRequest, "dnserr\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update DB host entry
|
||||||
log.Host.Ip = log.SentIP
|
log.Host.Ip = log.SentIP
|
||||||
log.Host.LastUpdate = log.TimeStamp
|
log.Host.LastUpdate = log.TimeStamp
|
||||||
|
|
||||||
|
if err = h.DB.Save(log.Host).Error; err != nil {
|
||||||
|
return c.JSON(http.StatusBadRequest, "badrequest\n")
|
||||||
|
}
|
||||||
|
|
||||||
log.Status = true
|
log.Status = true
|
||||||
log.Message = "No errors occurred"
|
log.Message = "No errors occurred"
|
||||||
if err = h.CreateLogEntry(log); err != nil {
|
if err = h.CreateLogEntry(log); err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user