Skip to content

Commit

Permalink
Save updated ip to host entry
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminbear committed May 20, 2024
1 parent f7f8455 commit 71411ee
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/containers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Prepare
id: prep
run: |
Expand Down
10 changes: 8 additions & 2 deletions dyndns/handler/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ func (h *Handler) UpdateIP(c echo.Context) (err error) {
log.SentIP = c.QueryParam(("myip"))

// Get caller IP
log.CallerIP, err = nswrapper.GetCallerIP(c.Request())
log.CallerIP, _ = nswrapper.GetCallerIP(c.Request())
if log.CallerIP == "" {
log.CallerIP, _, err = net.SplitHostPort(c.Request().RemoteAddr)
if err != nil {
Expand Down Expand Up @@ -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 {
log.Message = fmt.Sprintf("DNS error: %v", err)
l.Error(log.Message)
Expand All @@ -286,8 +286,14 @@ func (h *Handler) UpdateIP(c echo.Context) (err error) {
return c.String(http.StatusBadRequest, "dnserr\n")
}

// Update DB host entry
log.Host.Ip = log.SentIP
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.Message = "No errors occurred"
if err = h.CreateLogEntry(log); err != nil {
Expand Down

0 comments on commit 71411ee

Please sign in to comment.