Skip to content
This repository was archived by the owner on May 24, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions gddns/domain_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ type DomainConfig struct {
DomainKey string
}


func ListDomains(c appengine.Context, u *user.User) ([]*DomainConfig, error) {
userKey := domainUserKey(c, u)
q := datastore.NewQuery("DomainConfig").Ancestor(userKey).Order("-Hostname").Limit(100)
Expand All @@ -25,7 +24,7 @@ func ListDomains(c appengine.Context, u *user.User) ([]*DomainConfig, error) {
if _, err := q.GetAll(c, &domains); err != nil {
return nil, err
}

return domains, nil
}

Expand All @@ -41,15 +40,15 @@ func AddDomain(c appengine.Context, u *user.User, hostname string, username stri
Password: password,
DomainKey: dk,
}

c.Infof("DomainConfig: %v", dc)

userKey := domainUserKey(c, u)
c.Infof("userKey: %v", userKey)

dcKey := datastore.NewIncompleteKey(c, "DomainConfig", userKey)
c.Infof("dcKey: %v", dcKey)

if _, err := datastore.Put(c, dcKey, &dc); err != nil {
c.Infof("err: %v", err)
return nil, err
Expand Down
16 changes: 8 additions & 8 deletions gddns/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ var (
)

func init() {
http.HandleFunc("/admin/domains/list", list_domains)
http.HandleFunc("/admin/domains/add", add_domain)
http.HandleFunc("/update_ip", update_ip)
http.HandleFunc("/admin/domains/list", listDomains)
http.HandleFunc("/admin/domains/add", addDomains)
http.HandleFunc("/update_ip", updateIp)
}

func list_domains(w http.ResponseWriter, r *http.Request) {
func listDomains(w http.ResponseWriter, r *http.Request) {
u := getAdminUser(w, r)
if u == nil {
return
Expand All @@ -43,10 +43,10 @@ func list_domains(w http.ResponseWriter, r *http.Request) {
if err := templates.ExecuteTemplate(b, "domain_list.html", domains); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
b.WriteTo(w)
b.WriteTo(w)
}

func add_domain(w http.ResponseWriter, r *http.Request) {
func addDomains(w http.ResponseWriter, r *http.Request) {
u := getAdminUser(w, r)
if u == nil {
return
Expand All @@ -61,7 +61,7 @@ func add_domain(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "/admin/domains/list", http.StatusFound)
}

func update_ip(w http.ResponseWriter, r *http.Request) {
func updateIp(w http.ResponseWriter, r *http.Request) {
domainKey := r.FormValue("domain_key")
if domainKey == "" {
http.Error(w, "domain_key parameter must be specified", http.StatusInternalServerError)
Expand Down Expand Up @@ -141,7 +141,7 @@ func getAdminUser(w http.ResponseWriter, r *http.Request) *user.User {
func getCurrentUser(w http.ResponseWriter, r *http.Request) *user.User {
c := appengine.NewContext(r)
u := user.Current(c)

if u == nil {
url, err := user.LoginURL(c, r.URL.String())
if err != nil {
Expand Down