Skip to content

Commit

Permalink
Use iris v6 and Go 1.8+ (#10)
Browse files Browse the repository at this point in the history
* Quick fixes to bring framework up to date

* Script for test running, api tests need complete rewrite

* Removed govendor from tests

* Fix for AutoTLS
  • Loading branch information
joohoi committed Aug 2, 2017
1 parent 2bfeedd commit 41b2ff5
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 840 deletions.
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
language: go
go:
- 1.7
- 1.8
env:
- "PATH=/home/travis/gopath/bin:$PATH"
before_install:
- go get -u github.com/kardianos/govendor
- go get github.com/golang/lint/golint
- go get github.com/mattn/goveralls
- govendor sync
script:
- go vet
- golint -set_exit_status
Expand Down
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,17 @@ Check out how in the INSTALL section.

## Installation

1) Install [Go](https://golang.org/doc/install)
1) Install [Go 1.8 or newer](https://golang.org/doc/install)

2) Clone this repo: `git clone https://github.com/joohoi/acme-dns $GOPATH/src/acme-dns`

3) Install govendor. ‘go get -u github.com/kardianos/govendor’ . This is used for dependency handling.
3) Get dependencies: `go get -u`

4) Get dependencies: `cd $GOPATH/src/acme-dns` and `govendor sync`
4) Build ACME-DNS: `go build`

5) Build ACME-DNS: `go build`
5) Edit config.cfg to suit your needs (see [configuration](#configuration))

6) Edit config.cfg to suit your needs (see [configuration](#configuration))

7) Run acme-dns. Please note that acme-dns needs to open a privileged port (53, domain), so it needs to be run with elevated privileges.
6) Run acme-dns. Please note that acme-dns needs to open a privileged port (53, domain), so it needs to be run with elevated privileges.


## Configuration
Expand Down
6 changes: 3 additions & 3 deletions api.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"errors"
"fmt"

log "github.com/Sirupsen/logrus"
"gopkg.in/kataras/iris.v5"
log "github.com/sirupsen/logrus"
"gopkg.in/kataras/iris.v6"
)

// Serve is an authentication middlware function used to authenticate update requests
Expand All @@ -31,7 +31,7 @@ func (a authMiddleware) Serve(ctx *iris.Context) {
ips := getIPListFromHeader(ctx.RequestHeader(DNSConf.API.HeaderName))
allowUpdate = au.allowedFromList(ips)
} else {
allowUpdate = au.allowedFrom(ctx.RequestIP())
allowUpdate = au.allowedFrom(ctx.RemoteAddr())
}

if allowUpdate {
Expand Down
263 changes: 0 additions & 263 deletions api_test.go

This file was deleted.

2 changes: 1 addition & 1 deletion db.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"regexp"
"time"

log "github.com/Sirupsen/logrus"
log "github.com/sirupsen/logrus"
_ "github.com/lib/pq"
_ "github.com/mattn/go-sqlite3"
"github.com/satori/go.uuid"
Expand Down
2 changes: 1 addition & 1 deletion dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

import (
"fmt"
log "github.com/Sirupsen/logrus"
log "github.com/sirupsen/logrus"
"github.com/miekg/dns"
"strings"
"time"
Expand Down
18 changes: 9 additions & 9 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ package main
import (
"os"

log "github.com/Sirupsen/logrus"
"gopkg.in/iris-contrib/middleware.v5/cors"
"gopkg.in/kataras/iris.v5"
log "github.com/sirupsen/logrus"
"gopkg.in/kataras/iris.v6"
"gopkg.in/kataras/iris.v6/adaptors/cors"
"gopkg.in/kataras/iris.v6/adaptors/httprouter"
)

func main() {
Expand Down Expand Up @@ -40,21 +41,20 @@ func main() {
}

func startHTTPAPI() {
api := iris.New()
api.Config.DisableBanner = true
crs := cors.New(cors.Options{
api := iris.New(iris.Configuration{DisableBodyConsumptionOnUnmarshal: true})
api.Adapt(httprouter.New())
api.Adapt(cors.New(cors.Options{
AllowedOrigins: DNSConf.API.CorsOrigins,
AllowedMethods: []string{"GET", "POST"},
OptionsPassthrough: false,
Debug: DNSConf.General.Debug,
})
api.Use(crs)
}))
var ForceAuth = authMiddleware{}
api.Post("/register", webRegisterPost)
api.Post("/update", ForceAuth.Serve, webUpdatePost)
switch DNSConf.API.TLS {
case "letsencrypt":
listener, err := iris.LETSENCRYPTPROD(DNSConf.API.Domain)
listener, err := iris.LETSENCRYPT("0.0.0.0", DNSConf.API.Domain)
err = api.Serve(listener)
if err != nil {
log.Errorf("Error in HTTP server [%v]", err)
Expand Down
4 changes: 2 additions & 2 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package main
import (
"flag"
"fmt"
log "github.com/Sirupsen/logrus"
logrustest "github.com/Sirupsen/logrus/hooks/test"
log "github.com/sirupsen/logrus"
logrustest "github.com/sirupsen/logrus/hooks/test"
"io/ioutil"
"os"
"testing"
Expand Down
Loading

0 comments on commit 41b2ff5

Please sign in to comment.