fix segfault
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Elizabeth Hunt 2024-05-12 14:32:50 -07:00
parent cd324e1d48
commit fca8f5d8ad
Signed by untrusted user who does not match committer: simponic
GPG Key ID: 2909B9A7FF6213EE
4 changed files with 7 additions and 2 deletions

View File

@ -170,7 +170,6 @@ func VerifySessionContinuation(context *types.RequestContext, req *http.Request,
func GoLoginContinuation(context *types.RequestContext, req *http.Request, resp http.ResponseWriter) types.ContinuationChain { func GoLoginContinuation(context *types.RequestContext, req *http.Request, resp http.ResponseWriter) types.ContinuationChain {
return func(success types.Continuation, failure types.Continuation) types.ContinuationChain { return func(success types.Continuation, failure types.Continuation) types.ContinuationChain {
log.Println("GoLoginContinuation")
http.SetCookie(resp, &http.Cookie{ http.SetCookie(resp, &http.Cookie{
Name: "redirect", Name: "redirect",
Value: req.URL.Path, Value: req.URL.Path,

View File

@ -20,6 +20,10 @@ var UserOwnedInternalFmtDomains = []string{"%s", "%s.endpoints"}
func ListDNSRecordsContinuation(context *types.RequestContext, req *http.Request, resp http.ResponseWriter) types.ContinuationChain { func ListDNSRecordsContinuation(context *types.RequestContext, req *http.Request, resp http.ResponseWriter) types.ContinuationChain {
return func(success types.Continuation, failure types.Continuation) types.ContinuationChain { return func(success types.Continuation, failure types.Continuation) types.ContinuationChain {
if context.User == nil {
return failure(context, req, resp)
}
dnsRecords, err := database.GetUserDNSRecords(context.DBConn, context.User.ID) dnsRecords, err := database.GetUserDNSRecords(context.DBConn, context.User.ID)
if err != nil { if err != nil {
log.Println(err) log.Println(err)

View File

@ -138,7 +138,8 @@ func MakeServer(argv *args.Arguments, dbConn *sql.DB) *http.Server {
mux.HandleFunc("POST /dns", func(w http.ResponseWriter, r *http.Request) { mux.HandleFunc("POST /dns", func(w http.ResponseWriter, r *http.Request) {
requestContext := makeRequestContext() requestContext := makeRequestContext()
LogRequestContinuation(requestContext, r, w)(auth.VerifySessionContinuation, FailurePassingContinuation)(dns.ListDNSRecordsContinuation, auth.GoLoginContinuation)(dns.CreateDNSRecordContinuation(cloudflareAdapter, dns.MaxUserRecords, dns.UserOwnedInternalFmtDomains), FailurePassingContinuation)(dns.ListDNSRecordsContinuation, dns.ListDNSRecordsContinuation)(template.TemplateContinuation("dns.html", true), template.TemplateContinuation("dns.html", true))(LogExecutionTimeContinuation, LogExecutionTimeContinuation)(IdContinuation, IdContinuation) createRecordContinuation := dns.CreateDNSRecordContinuation(cloudflareAdapter, dns.MaxUserRecords, dns.UserOwnedInternalFmtDomains)
LogRequestContinuation(requestContext, r, w)(auth.VerifySessionContinuation, FailurePassingContinuation)(dns.ListDNSRecordsContinuation, auth.GoLoginContinuation)(createRecordContinuation, FailurePassingContinuation)(dns.ListDNSRecordsContinuation, dns.ListDNSRecordsContinuation)(template.TemplateContinuation("dns.html", true), template.TemplateContinuation("dns.html", true))(LogExecutionTimeContinuation, LogExecutionTimeContinuation)(IdContinuation, IdContinuation)
}) })
mux.HandleFunc("POST /dns/delete", func(w http.ResponseWriter, r *http.Request) { mux.HandleFunc("POST /dns/delete", func(w http.ResponseWriter, r *http.Request) {

View File

@ -56,6 +56,7 @@ func main() {
log.Println("🚀🚀 DNS resolver listening on port", argv.DnsPort) log.Println("🚀🚀 DNS resolver listening on port", argv.DnsPort)
go func() { go func() {
err = server.ListenAndServe() err = server.ListenAndServe()
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }