mirror of
https://github.com/MarekWojt/gertdns.git
synced 2025-12-15 12:59:53 +01:00
Merge pull request #6 from MarekWojt/features/fixes
Fixed: - missing response text on authentication failure - missing response text on internal server error - updating ipv6 via request for updating both ipv4 and ipv6 didn't work, could reset previously set ipv4 - domain list in auth.toml needed "." suffixes
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package auth
|
package auth
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/MarekWojt/gertdns/util"
|
||||||
"github.com/raja/argon2pw"
|
"github.com/raja/argon2pw"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -40,7 +41,8 @@ func (selfUser *userRaw) Tidy() (user, error) {
|
|||||||
// Create a map => faster access times
|
// Create a map => faster access times
|
||||||
parsedDomains := make(map[string]string)
|
parsedDomains := make(map[string]string)
|
||||||
for _, domain := range selfUser.Domains {
|
for _, domain := range selfUser.Domains {
|
||||||
parsedDomains[domain] = domain
|
parsedDomain := util.ParseDomain(domain)
|
||||||
|
parsedDomains[parsedDomain] = parsedDomain
|
||||||
}
|
}
|
||||||
|
|
||||||
parsedUser := user{
|
parsedUser := user{
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ func update(ctx *fasthttp.RequestCtx) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ipv6 != "" {
|
if ipv6 != "" {
|
||||||
err := dns.UpdateIpv4(domain, ipv4)
|
err := dns.UpdateIpv6(domain, ipv6)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.WriteString(err.Error())
|
ctx.WriteString(err.Error())
|
||||||
ctx.SetStatusCode(fasthttp.StatusNotFound)
|
ctx.SetStatusCode(fasthttp.StatusNotFound)
|
||||||
@@ -190,11 +190,13 @@ func authenticatedRequest(request func(ctx *fasthttp.RequestCtx)) func(ctx *fast
|
|||||||
|
|
||||||
authenticated, err := auth.IsPasswordAuthenticated(authRequest)
|
authenticated, err := auth.IsPasswordAuthenticated(authRequest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
ctx.WriteString("Internal server error")
|
||||||
ctx.SetStatusCode(fasthttp.StatusInternalServerError)
|
ctx.SetStatusCode(fasthttp.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if !authenticated {
|
if !authenticated {
|
||||||
|
ctx.WriteString("Authentication failed")
|
||||||
ctx.SetStatusCode(fasthttp.StatusForbidden)
|
ctx.SetStatusCode(fasthttp.StatusForbidden)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user