Skip to content
This repository has been archived by the owner on Oct 28, 2023. It is now read-only.

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Kcrong committed Oct 3, 2023
1 parent eba4c67 commit adf73ae
Show file tree
Hide file tree
Showing 17 changed files with 717 additions and 24 deletions.
11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
.PHONY: format
format:
@go install golang.org/x/tools/cmd/goimports@latest
goimports -local "github.com/hodlgap" -w .
@#go install golang.org/x/tools/cmd/goimports@latest
@#goimports -local "github.com/hodlgap/captive-portal" -w .
@go install -v github.com/incu6us/goimports-reviser/v3@latest
goimports-reviser -rm-unused \
-company-prefixes 'github.com/hodlgap' \
-excludes 'pkg/models,vendor,db' \
-project-name 'github.com/hodlgap/captive-portal' \
-format \
./...
gofmt -s -w .
go mod tidy
go mod vendor
Expand Down
17 changes: 9 additions & 8 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@ import (
"os/signal"
"time"

"github.com/hodlgap/captive-portal/pkg"
"github.com/hodlgap/captive-portal/pkg/handler"

"github.com/labstack/gommon/log"
"github.com/newrelic/go-agent/v3/integrations/nrredis-v9"
"github.com/pkg/errors"
"github.com/redis/go-redis/v9"

"github.com/hodlgap/captive-portal/pkg"
"github.com/hodlgap/captive-portal/pkg/config"

"github.com/labstack/gommon/log"
"github.com/redis/go-redis/v9"
"github.com/hodlgap/captive-portal/pkg/handler"
)

const (
Expand All @@ -39,11 +38,13 @@ func main() {
log.Fatalf("%+v", errors.WithStack(err))
}

redisCli := redis.NewClient(&redis.Options{
redisOpt := &redis.Options{
Addr: fmt.Sprintf("%s:%d", c.Redis.Host, c.Redis.Port),
Password: c.Redis.Password, // no password set
DB: c.Redis.DB, // use default DB
})
}
redisCli := redis.NewClient(redisOpt)
redisCli.AddHook(nrredis.NewHook(redisOpt))

app = handler.SetRoute(c, app, redisCli)

Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ require (
github.com/labstack/echo/v4 v4.11.1
github.com/labstack/gommon v0.4.0
github.com/newrelic/go-agent/v3 v3.26.0
github.com/newrelic/go-agent/v3/integrations/nrecho-v4 v1.0.4
github.com/newrelic/go-agent/v3/integrations/nrredis-v9 v1.0.0
github.com/pkg/errors v0.9.1
github.com/redis/go-redis/v9 v9.1.0
github.com/sirupsen/logrus v1.9.3
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,10 @@ github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRW
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/newrelic/go-agent/v3 v3.26.0 h1:xJkqiQgLtC3ys5zoBxD91ITm7sVHZNEF+7/mqmFjnl0=
github.com/newrelic/go-agent/v3 v3.26.0/go.mod h1:sE2WdlLF3B/xI5HUuIHTa7Aht1gpcIY65pzaUoN1pJs=
github.com/newrelic/go-agent/v3/integrations/nrecho-v4 v1.0.4 h1:c9kq15TraxDAZr0bHDmBq5VSRZYPGwH6IyksshILxnY=
github.com/newrelic/go-agent/v3/integrations/nrecho-v4 v1.0.4/go.mod h1:UdtAjlKMd7hzPxylHMXzCvv3Ryx6+Du1DWZez01iK+M=
github.com/newrelic/go-agent/v3/integrations/nrredis-v9 v1.0.0 h1:jPjdL6i69gAXeOHJH/GCmLXxrzMl0J19wE5H1U3FdGE=
github.com/newrelic/go-agent/v3/integrations/nrredis-v9 v1.0.0/go.mod h1:oRTLRKiOcFsOJZgioSMRUQ54vUMomoQkoQW8wql4B4s=
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
Expand Down
7 changes: 4 additions & 3 deletions pkg/app.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package pkg

import (
"github.com/labstack/echo/v4"
echo "github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
nrecho "github.com/newrelic/go-agent/v3/integrations/nrecho-v4"
"github.com/newrelic/go-agent/v3/newrelic"

"github.com/hodlgap/captive-portal/pkg/config"
Expand All @@ -12,9 +13,9 @@ func NewApp(c config.Config, nr *newrelic.Application) (*echo.Echo, error) {
app := echo.New()
app.Logger.SetLevel(c.App.LogLevel.ToLevel())

//app.Use(middleware.Logger())
app.Use(middleware.Logger())
app.Use(middleware.Recover())
//app.Use(nrecho.Middleware(nr))
app.Use(nrecho.Middleware(nr))

return app, nil
}
2 changes: 1 addition & 1 deletion pkg/config/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
"gopkg.in/yaml.v3"
yaml "gopkg.in/yaml.v3"
)

type Openwrt struct {
Expand Down
5 changes: 2 additions & 3 deletions pkg/handler/captiveportal/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ import (
"net/url"
"strings"

"github.com/redis/go-redis/v9"

"github.com/labstack/echo/v4"
echo "github.com/labstack/echo/v4"
"github.com/pkg/errors"
redis "github.com/redis/go-redis/v9"
)

type RawAuthRequest struct {
Expand Down
5 changes: 2 additions & 3 deletions pkg/handler/captiveportal/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ import (
"strings"
"testing"

"github.com/labstack/echo/v4"
redismock "github.com/go-redis/redismock/v9"
echo "github.com/labstack/echo/v4"
"github.com/pkg/errors"
"github.com/stretchr/testify/assert"

"github.com/go-redis/redismock/v9"
)

// nolint:unused
Expand Down
4 changes: 2 additions & 2 deletions pkg/handler/captiveportal/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"net/http"
"strings"

"github.com/labstack/echo/v4"
echo "github.com/labstack/echo/v4"
"github.com/pkg/errors"
"github.com/redis/go-redis/v9"
redis "github.com/redis/go-redis/v9"
)

/* Send and/or clear the Auth List when requested by openNDS
Expand Down
4 changes: 2 additions & 2 deletions pkg/handler/route.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package handler

import (
"github.com/labstack/echo/v4"
"github.com/redis/go-redis/v9"
echo "github.com/labstack/echo/v4"
redis "github.com/redis/go-redis/v9"

"github.com/hodlgap/captive-portal/pkg/config"
"github.com/hodlgap/captive-portal/pkg/handler/captiveportal"
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit adf73ae

Please sign in to comment.