Change project name from libredns to happydns.org
This commit is contained in:
parent
02f437509a
commit
fcc62a0990
|
@ -1,2 +1,2 @@
|
|||
libredns
|
||||
happydns
|
||||
bindata.go
|
|
@ -12,7 +12,7 @@ import (
|
|||
|
||||
"github.com/julienschmidt/httprouter"
|
||||
|
||||
"git.nemunai.re/libredns/struct"
|
||||
"git.happydns.org/happydns/struct"
|
||||
)
|
||||
|
||||
type Response interface {
|
||||
|
@ -76,7 +76,7 @@ func apiHandler(f func(httprouter.Params, io.Reader) (Response)) func(http.Respo
|
|||
}
|
||||
}
|
||||
|
||||
func apiAuthHandler(f func(libredns.User, httprouter.Params, io.Reader) (Response)) func(http.ResponseWriter, *http.Request, httprouter.Params) {
|
||||
func apiAuthHandler(f func(happydns.User, httprouter.Params, io.Reader) (Response)) func(http.ResponseWriter, *http.Request, httprouter.Params) {
|
||||
return func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
||||
if addr := r.Header.Get("X-Forwarded-For"); addr != "" {
|
||||
r.RemoteAddr = addr
|
||||
|
@ -99,12 +99,12 @@ func apiAuthHandler(f func(libredns.User, httprouter.Params, io.Reader) (Respons
|
|||
err: err,
|
||||
status: http.StatusUnauthorized,
|
||||
}.WriteResponse(w)
|
||||
} else if session, err := libredns.GetSession(sessionid); err != nil {
|
||||
} else if session, err := happydns.GetSession(sessionid); err != nil {
|
||||
APIErrorResponse{
|
||||
err: err,
|
||||
status: http.StatusUnauthorized,
|
||||
}.WriteResponse(w)
|
||||
} else if std, err := libredns.GetUser(int(session.IdUser)); err != nil {
|
||||
} else if std, err := happydns.GetUser(int(session.IdUser)); err != nil {
|
||||
APIErrorResponse{
|
||||
err: err,
|
||||
status: http.StatusUnauthorized,
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
|
||||
"github.com/julienschmidt/httprouter"
|
||||
|
||||
"git.nemunai.re/libredns/struct"
|
||||
"git.happydns.org/happydns/struct"
|
||||
)
|
||||
|
||||
var AuthFunc = checkAuth
|
||||
|
@ -20,7 +20,7 @@ func init() {
|
|||
}))
|
||||
}
|
||||
|
||||
func validateAuthToken(u libredns.User, _ httprouter.Params, _ io.Reader) (Response) {
|
||||
func validateAuthToken(u happydns.User, _ httprouter.Params, _ io.Reader) (Response) {
|
||||
return APIResponse{
|
||||
response: u,
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ func dummyAuth(_ httprouter.Params, body io.Reader) Response {
|
|||
}
|
||||
}
|
||||
|
||||
if user, err := libredns.GetUserByEmail(lf.Email); err != nil {
|
||||
if user, err := happydns.GetUserByEmail(lf.Email); err != nil {
|
||||
return APIErrorResponse{
|
||||
err: err,
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ func checkAuth(_ httprouter.Params, body io.Reader) Response {
|
|||
}
|
||||
}
|
||||
|
||||
if user, err := libredns.GetUserByEmail(lf.Email); err != nil {
|
||||
if user, err := happydns.GetUserByEmail(lf.Email); err != nil {
|
||||
return APIErrorResponse{
|
||||
err: err,
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
|
||||
"github.com/julienschmidt/httprouter"
|
||||
|
||||
"git.nemunai.re/libredns/struct"
|
||||
"git.happydns.org/happydns/struct"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -16,7 +16,7 @@ func init() {
|
|||
}
|
||||
|
||||
func listUsers(_ httprouter.Params, _ io.Reader) Response {
|
||||
if users, err := libredns.GetUsers(); err != nil {
|
||||
if users, err := happydns.GetUsers(); err != nil {
|
||||
return APIErrorResponse{
|
||||
err: err,
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ func registerUser(p httprouter.Params, body io.Reader) Response {
|
|||
}
|
||||
}
|
||||
|
||||
if user, err := libredns.NewUser(uu.Email, uu.Password); err != nil {
|
||||
if user, err := happydns.NewUser(uu.Email, uu.Password); err != nil {
|
||||
return APIErrorResponse{
|
||||
err: err,
|
||||
}
|
||||
|
|
22
api/zones.go
22
api/zones.go
|
@ -11,7 +11,7 @@ import (
|
|||
"github.com/julienschmidt/httprouter"
|
||||
"github.com/miekg/dns"
|
||||
|
||||
"git.nemunai.re/libredns/struct"
|
||||
"git.happydns.org/happydns/struct"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -25,7 +25,7 @@ func init() {
|
|||
}
|
||||
|
||||
func getZones(p httprouter.Params, body io.Reader) Response {
|
||||
if zones, err := libredns.GetZones(); err != nil {
|
||||
if zones, err := happydns.GetZones(); err != nil {
|
||||
return APIErrorResponse{
|
||||
err: err,
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ func getZones(p httprouter.Params, body io.Reader) Response {
|
|||
}
|
||||
|
||||
func addZone(p httprouter.Params, body io.Reader) Response {
|
||||
var uz libredns.Zone
|
||||
var uz happydns.Zone
|
||||
err := json.NewDecoder(body).Decode(&uz)
|
||||
if err != nil {
|
||||
return APIErrorResponse{
|
||||
|
@ -59,7 +59,7 @@ func addZone(p httprouter.Params, body io.Reader) Response {
|
|||
uz.KeyName = uz.KeyName + "."
|
||||
}
|
||||
|
||||
if libredns.ZoneExists(uz.DomainName) {
|
||||
if happydns.ZoneExists(uz.DomainName) {
|
||||
return APIErrorResponse{
|
||||
err: errors.New("This zone already exists."),
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ func addZone(p httprouter.Params, body io.Reader) Response {
|
|||
}
|
||||
}
|
||||
|
||||
func delZone(zone libredns.Zone, body io.Reader) Response {
|
||||
func delZone(zone happydns.Zone, body io.Reader) Response {
|
||||
if _, err := zone.Delete(); err != nil {
|
||||
return APIErrorResponse{
|
||||
err: err,
|
||||
|
@ -86,9 +86,9 @@ func delZone(zone libredns.Zone, body io.Reader) Response {
|
|||
}
|
||||
}
|
||||
|
||||
func zoneHandler(f func(libredns.Zone, io.Reader) Response) func(httprouter.Params, io.Reader) Response {
|
||||
func zoneHandler(f func(happydns.Zone, io.Reader) Response) func(httprouter.Params, io.Reader) Response {
|
||||
return func(ps httprouter.Params, body io.Reader) Response {
|
||||
if zone, err := libredns.GetZoneByDN(ps.ByName("zone")); err != nil {
|
||||
if zone, err := happydns.GetZoneByDN(ps.ByName("zone")); err != nil {
|
||||
return APIErrorResponse{
|
||||
status: http.StatusNotFound,
|
||||
err: errors.New("Domain not found"),
|
||||
|
@ -99,13 +99,13 @@ func zoneHandler(f func(libredns.Zone, io.Reader) Response) func(httprouter.Para
|
|||
}
|
||||
}
|
||||
|
||||
func getZone(zone libredns.Zone, body io.Reader) Response {
|
||||
func getZone(zone happydns.Zone, body io.Reader) Response {
|
||||
return APIResponse{
|
||||
response: zone,
|
||||
}
|
||||
}
|
||||
|
||||
func axfrZone(zone libredns.Zone, body io.Reader) Response {
|
||||
func axfrZone(zone happydns.Zone, body io.Reader) Response {
|
||||
t := new(dns.Transfer)
|
||||
|
||||
m := new(dns.Msg)
|
||||
|
@ -145,7 +145,7 @@ type uploadedRR struct {
|
|||
RR string `json:"string"`
|
||||
}
|
||||
|
||||
func addRR(zone libredns.Zone, body io.Reader) Response {
|
||||
func addRR(zone happydns.Zone, body io.Reader) Response {
|
||||
var urr uploadedRR
|
||||
err := json.NewDecoder(body).Decode(&urr)
|
||||
if err != nil {
|
||||
|
@ -190,7 +190,7 @@ func addRR(zone libredns.Zone, body io.Reader) Response {
|
|||
}
|
||||
}
|
||||
|
||||
func delRR(zone libredns.Zone, body io.Reader) Response {
|
||||
func delRR(zone happydns.Zone, body io.Reader) Response {
|
||||
var urr uploadedRR
|
||||
err := json.NewDecoder(body).Decode(&urr)
|
||||
if err != nil {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<div id="app">
|
||||
<b-navbar size="lg" type="dark" variant="dark" sticky class="text-light">
|
||||
<b-navbar-brand class="navbar-brand" to="/">
|
||||
<img alt="LibreDNS" src="<%= BASE_URL %>img/logo.png" style="height: 30px">
|
||||
<img alt="HappyDNS" src="<%= BASE_URL %>img/logo.png" style="height: 30px">
|
||||
</b-navbar-brand>
|
||||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#adminMenu" aria-controls="adminMenu" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
placeholder="example.com"
|
||||
ref="domainname"
|
||||
></b-form-input>
|
||||
<small id="dnHelp" class="form-text text-muted">Fill here the domain name you would like to manage with LibreDNS.</small>
|
||||
<small id="dnHelp" class="form-text text-muted">Fill here the domain name you would like to manage with HappyDNS.</small>
|
||||
</b-form-group>
|
||||
<b-form-group
|
||||
:state="newForm.domainServerState"
|
||||
|
@ -61,7 +61,7 @@
|
|||
id="srv-input"
|
||||
v-model="newForm.server"
|
||||
:state="newForm.domainServerState"
|
||||
placeholder="ns0.libredns.com"
|
||||
placeholder="ns0.happydns.org"
|
||||
ref="domainserver"
|
||||
></b-form-input>
|
||||
</b-form-group>
|
||||
|
|
12
main.go
12
main.go
|
@ -8,8 +8,8 @@ import (
|
|||
"path"
|
||||
"strings"
|
||||
|
||||
"git.nemunai.re/libredns/api"
|
||||
"git.nemunai.re/libredns/struct"
|
||||
"git.happydns.org/happydns/api"
|
||||
"git.happydns.org/happydns/struct"
|
||||
)
|
||||
|
||||
type ResponseWriterPrefix struct {
|
||||
|
@ -56,7 +56,7 @@ func main() {
|
|||
// Read parameters from command line
|
||||
flag.StringVar(&DevProxy, "dev", DevProxy, "Proxify traffic to this host for static assets")
|
||||
var bind = flag.String("bind", ":8081", "Bind port/socket")
|
||||
var dsn = flag.String("dsn", libredns.DSNGenerator(), "DSN to connect to the MySQL server")
|
||||
var dsn = flag.String("dsn", happydns.DSNGenerator(), "DSN to connect to the MySQL server")
|
||||
var baseURL = flag.String("baseurl", "/", "URL prepended to each URL")
|
||||
flag.StringVar(&api.DefaultNameServer, "defaultns", api.DefaultNameServer, "Adress to the default name server")
|
||||
flag.Parse()
|
||||
|
@ -72,13 +72,13 @@ func main() {
|
|||
|
||||
// Initialize contents
|
||||
log.Println("Opening database...")
|
||||
if err := libredns.DBInit(*dsn); err != nil {
|
||||
if err := happydns.DBInit(*dsn); err != nil {
|
||||
log.Fatal("Cannot open the database: ", err)
|
||||
}
|
||||
defer libredns.DBClose()
|
||||
defer happydns.DBClose()
|
||||
|
||||
log.Println("Creating database...")
|
||||
if err := libredns.DBCreate(); err != nil {
|
||||
if err := happydns.DBCreate(); err != nil {
|
||||
log.Fatal("Cannot create database: ", err)
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
"net/url"
|
||||
"path"
|
||||
|
||||
"git.nemunai.re/libredns/api"
|
||||
"git.happydns.org/happydns/api"
|
||||
|
||||
"github.com/julienschmidt/httprouter"
|
||||
)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package libredns
|
||||
package happydns
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
|
@ -13,10 +13,10 @@ var db *sql.DB
|
|||
|
||||
// DSNGenerator returns DSN filed with values from environment
|
||||
func DSNGenerator() string {
|
||||
db_user := "libredns"
|
||||
db_password := "libredns"
|
||||
db_user := "happydns"
|
||||
db_password := "happydns"
|
||||
db_host := ""
|
||||
db_db := "libredns"
|
||||
db_db := "happydns"
|
||||
|
||||
if v, exists := os.LookupEnv("MYSQL_HOST"); exists {
|
||||
db_host = v
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package libredns
|
||||
package happydns
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package libredns
|
||||
package happydns
|
||||
|
||||
import (
|
||||
"crypto/hmac"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package libredns
|
||||
package happydns
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
|
|
Loading…
Reference in New Issue