Skip to content

Commit

Permalink
new packages layout in fortio 1.50+ (#51)
Browse files Browse the repository at this point in the history
* new packages layout in fortio 1.50+

* better when it compiles
  • Loading branch information
ldemailly authored Feb 17, 2023
1 parent af080a3 commit 6aaa2f3
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 30 deletions.
2 changes: 2 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ linters-settings:

linters:
disable:
# bad ones:
- musttag
# Deprecated ones:
- scopelint
- golint
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ dev-h2c:

dev:
# Run: curl -H "Host: debug.fortio.org" http://localhost:8001/debug
# and curl -H "Host: debug.fortio.org" http://localhost:8000/foo
# and curl -H "Host: debug.fortio.org" http://localhost:8000/foo (no redirect with that host header)
go run -race . -http-port 8001 -https-port disabled -redirect-port 8000 -hostid "$(shell hostname)-test" \
-debug-host "debug.fortio.org" -routes.json '[{"host":"*", "destination":"http://localhost:8080/"}]'
2 changes: 1 addition & 1 deletion config/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"net/url"
"strings"

"fortio.org/fortio/log"
"fortio.org/log"
)

type JSONURL struct {
Expand Down
2 changes: 1 addition & 1 deletion config/route_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"net/http"
"testing"

"fortio.org/fortio/log"
"fortio.org/log"
)

func TestMatch(t *testing.T) {
Expand Down
15 changes: 9 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@ module fortio.org/proxy
go 1.18

require (
fortio.org/fortio v1.40.1
golang.org/x/crypto v0.5.0
golang.org/x/net v0.5.0
fortio.org/dflag v1.4.1
fortio.org/fortio v1.50.1
fortio.org/log v1.2.2
fortio.org/version v1.0.2
golang.org/x/crypto v0.6.0
golang.org/x/net v0.7.0
)

require (
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/google/uuid v1.3.0 // indirect
golang.org/x/exp v0.0.0-20221111204811-129d8d6c17ab // indirect
golang.org/x/sys v0.4.0 // indirect
golang.org/x/text v0.6.0 // indirect
golang.org/x/exp v0.0.0-20230213192124-5e25df0256eb // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
)
32 changes: 19 additions & 13 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
fortio.org/assert v1.1.2 h1:t6WGDqPD5VFrUvx30U0+3mgXXcoPonrdKqt0vfJHn8E=
fortio.org/fortio v1.40.1 h1:D1H+5aOnauTr4WTnopHl1MhSZt/l0Asi3ZEqkpBwT0c=
fortio.org/fortio v1.40.1/go.mod h1:5dREibidWcceopnW8t1z2PKq6IKCSZaii6lEuYJdKMs=
fortio.org/assert v1.1.3 h1:zXm8xiNiKvq2xG/YQ3sONAg3287XUuklKIDdjyD9pyg=
fortio.org/dflag v1.4.1 h1:WDhlHMh3yrQFrvspyN5YEyr8WATdKM2dUJlTxsjCDtI=
fortio.org/dflag v1.4.1/go.mod h1:pTEF7UEj6sHP9rj9gZG2GyhAGrrPJE4c6zOO7zB2yyI=
fortio.org/fortio v1.50.1 h1:5FSttAHQsyAsi3dzxDmSByfzDYByrWY/yw53bqOg+Kc=
fortio.org/fortio v1.50.1/go.mod h1:TpAo6nixVbTxeIfE8F2c63D3ffouMTa+KDr9eFAYxys=
fortio.org/log v1.2.2 h1:vs42JjNwiqbMbacittZjJE9+oi72Za6aekML9gKmILg=
fortio.org/log v1.2.2/go.mod h1:u/8/2lyczXq52aT5Nw6reD+3cR6m/EbS2jBiIYhgiTU=
fortio.org/version v1.0.2 h1:8NwxdX58aoeKx7T5xAPO0xlUu1Hpk42nRz5s6e6eKZ0=
fortio.org/version v1.0.2/go.mod h1:2JQp9Ax+tm6QKiGuzR5nJY63kFeANcgrZ0osoQFDVm0=
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE=
golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU=
golang.org/x/exp v0.0.0-20221111204811-129d8d6c17ab h1:1S7USr8/C0Sgk4egxq4zZ07zYt2Xh1IiFp8hUMXH/us=
golang.org/x/exp v0.0.0-20221111204811-129d8d6c17ab/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
golang.org/x/net v0.5.0 h1:GyT4nK/YDHSqa1c4753ouYCDajOYKTja9Xb/OHtgvSw=
golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws=
golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc=
golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58=
golang.org/x/exp v0.0.0-20230213192124-5e25df0256eb h1:PaBZQdo+iSDyHT053FjUCgZQ/9uqVwPOcl7KSWhKn6w=
golang.org/x/exp v0.0.0-20230213192124-5e25df0256eb/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g=
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18=
golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.6.0 h1:3XmdazWV+ubf7QgHSTWeykHOci5oeekaGJBLkrkaw4k=
golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
17 changes: 11 additions & 6 deletions proxy_main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ import (
"strings"
"time"

"fortio.org/fortio/dflag"
"fortio.org/fortio/dflag/configmap"
"fortio.org/dflag"
"fortio.org/dflag/configmap"
"fortio.org/dflag/dynloglevel"
"fortio.org/fortio/fhttp"
"fortio.org/fortio/log"
"fortio.org/fortio/version"
"fortio.org/log"
"fortio.org/proxy/rp"
"fortio.org/version"
"golang.org/x/crypto/acme/autocert"
)

Expand All @@ -37,6 +38,7 @@ var (
"Config directory `path` to watch for changes of dynamic flags (empty for no watch)")
httpPort = flag.String("http-port", "disabled", "`port` to listen on for non tls traffic (or 'disabled')")
acert *autocert.Manager
shortV string
)

func hostPolicy(ctx context.Context, host string) error {
Expand All @@ -55,7 +57,7 @@ func debugGetCert(hello *tls.ClientHelloInfo) (*tls.Certificate, error) {

func usage(msg string) {
_, _ = fmt.Fprintf(os.Stderr, "Fortio proxy %s usage:\n\t%s [flags]\nflags (some flags inherited from fortio but not used):\n",
version.Short(),
shortV,
os.Args[0])
flag.PrintDefaults()
if msg != "" {
Expand All @@ -66,8 +68,11 @@ func usage(msg string) {

func main() {
flag.CommandLine.Usage = func() { usage("") }
var longV string
var fullV string
shortV, longV, fullV = version.FromBuildInfo()
dynloglevel.LoggerFlagSetup()
flag.Parse()
_, longV, fullV := version.FromBuildInfo()
if len(flag.Args()) != 0 {
usage("Only flags are expected")
}
Expand Down
4 changes: 2 additions & 2 deletions rp/reverse_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import (
"sort"
"time"

"fortio.org/fortio/dflag"
"fortio.org/dflag"
"fortio.org/fortio/fhttp"
"fortio.org/fortio/log"
"fortio.org/fortio/version"
"fortio.org/log"
"fortio.org/proxy/config"
"golang.org/x/net/http2"
)
Expand Down

0 comments on commit 6aaa2f3

Please sign in to comment.