From eb3660b1b4ccbb973d4a75fecc956b7fcb669dbb Mon Sep 17 00:00:00 2001 From: Tim Liu Date: Tue, 16 Jul 2024 15:33:30 +0000 Subject: [PATCH] refactor N3IWF app --- cmd/main.go | 71 +++++++++++++- go.mod | 51 +++++----- go.sum | 113 +++++++++++---------- internal/logger/logger.go | 20 ++-- internal/ngap/service/service.go | 5 +- internal/nwucp/service/service.go | 7 +- internal/nwuup/service/service.go | 9 +- pkg/app/app.go | 18 ++++ pkg/context/context.go | 8 +- pkg/ike/service/service.go | 16 ++- pkg/service/init.go | 158 ++++++++++++++++-------------- 11 files changed, 284 insertions(+), 192 deletions(-) create mode 100644 pkg/app/app.go diff --git a/cmd/main.go b/cmd/main.go index 3dcf04b5..a312e924 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -1,10 +1,15 @@ package main import ( + "context" "os" + "os/signal" "path/filepath" "runtime/debug" + "syscall" + "github.com/gin-contrib/pprof" + "github.com/gin-gonic/gin" "github.com/urfave/cli" "github.com/free5gc/n3iwf/internal/logger" @@ -37,33 +42,91 @@ func main() { Name: "log, l", Usage: "Output NF log to `FILE`", }, + cli.BoolFlag{ + Name: "nolog, nl", + Usage: "Disable log to stdout/stderr", + }, + cli.StringFlag{ + Name: "loglevel, ll", + Usage: "Override logger level", + }, + cli.BoolFlag{ + Name: "reportcaller, rc", + Usage: "Enable logger report caller", + }, + cli.BoolFlag{ + Name: "debug, deb", + Usage: "Enable pprof debug", + }, } if err := app.Run(os.Args); err != nil { logger.MainLog.Errorf("N3IWF Run Error: %v\n", err) } } +func runPProfServer() { + r := gin.Default() + pprof.Register(r) + // Listen and Server in 0.0.0.0:6061 + err := r.Run(":6061") + if err != nil { + logger.MainLog.Errorf("runPProfServer(): %v", err) + } +} + func action(cliCtx *cli.Context) error { - tlsKeyLogPath, err := initLogFile(cliCtx.StringSlice("log")) + debug := cliCtx.Bool("debug") + if debug { + go runPProfServer() + } + logPathSlice := cliCtx.StringSlice("log") + cfgPath := cliCtx.String("config") + noLog := cliCtx.Bool("nolog") + logLevel := cliCtx.String("loglevel") + reportCaller := cliCtx.Bool("reportcaller") + + tlsKeyLogPath, err := initLogFile(logPathSlice) if err != nil { return err } logger.MainLog.Infoln("N3IWF version: ", version.GetVersion()) - cfg, err := factory.ReadConfig(cliCtx.String("config")) + ctx, cancel := context.WithCancel(context.Background()) + sigCh := make(chan os.Signal, 1) + signal.Notify(sigCh, os.Interrupt, syscall.SIGTERM) + + go func() { + <-sigCh // Wait for interrupt signal to gracefully shutdown + cancel() // Notify each goroutine and wait them stopped + }() + + cfg, err := factory.ReadConfig(cfgPath) if err != nil { + close(sigCh) return err } factory.N3iwfConfig = cfg - n3iwf, err := service.NewApp(cfg) + // Replace logger config with cli parameters + if noLog { + cfg.SetLogEnable(false) + } + if logLevel != "" { + cfg.SetLogLevel(logLevel) + } + if reportCaller { + cfg.SetLogReportCaller(true) + } + + n3iwf, err := service.NewApp(ctx, cfg, tlsKeyLogPath) if err != nil { + close(sigCh) return err } N3IWF = n3iwf - n3iwf.Start(tlsKeyLogPath) + n3iwf.Start() return nil } diff --git a/go.mod b/go.mod index de8c3c45..1aa7a4f8 100644 --- a/go.mod +++ b/go.mod @@ -4,50 +4,53 @@ go 1.21 require ( github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d - github.com/free5gc/aper v1.0.5 - github.com/free5gc/ngap v1.0.8 - github.com/free5gc/sctp v1.0.0 - github.com/free5gc/util v1.0.6 - github.com/sirupsen/logrus v1.8.1 + github.com/free5gc/aper v1.0.6-0.20240503143507-2c4c4780b98f + github.com/free5gc/ngap v1.0.9-0.20240708062829-734d184eed74 + github.com/free5gc/sctp v1.0.1 + github.com/free5gc/util v1.0.7-0.20240713162917-350ee8f4af4c + github.com/gin-contrib/pprof v1.5.0 + github.com/gin-gonic/gin v1.10.0 + github.com/pkg/errors v0.9.1 + github.com/sirupsen/logrus v1.9.3 github.com/urfave/cli v1.22.5 github.com/vishvananda/netlink v1.1.0 github.com/wmnsk/go-gtp v0.8.0 - golang.org/x/net v0.23.0 - golang.org/x/sys v0.18.0 + golang.org/x/net v0.25.0 + golang.org/x/sys v0.20.0 gopkg.in/yaml.v2 v2.4.0 ) require ( - github.com/antonfisher/nested-logrus-formatter v1.3.1 // indirect - github.com/bytedance/sonic v1.9.1 // indirect - github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect + github.com/bytedance/sonic v1.11.6 // indirect + github.com/bytedance/sonic/loader v0.1.1 // indirect + github.com/cloudwego/base64x v0.1.4 // indirect + github.com/cloudwego/iasm v0.2.0 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d // indirect - github.com/free5gc/openapi v1.0.8 // indirect - github.com/gabriel-vasile/mimetype v1.4.2 // indirect + github.com/free5gc/openapi v1.0.9-0.20240503143645-eac9f06c2f6b // indirect + github.com/gabriel-vasile/mimetype v1.4.3 // indirect github.com/gin-contrib/sse v0.1.0 // indirect - github.com/gin-gonic/gin v1.9.1 // indirect github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect - github.com/go-playground/validator/v10 v10.14.0 // indirect + github.com/go-playground/validator/v10 v10.20.0 // indirect github.com/goccy/go-json v0.10.2 // indirect github.com/golang-jwt/jwt v3.2.1+incompatible // indirect + github.com/golang-jwt/jwt/v5 v5.2.1 // indirect github.com/json-iterator/go v1.1.12 // indirect - github.com/klauspost/cpuid/v2 v2.2.4 // indirect - github.com/leodido/go-urn v1.2.4 // indirect - github.com/mattn/go-isatty v0.0.19 // indirect + github.com/klauspost/cpuid/v2 v2.2.7 // indirect + github.com/leodido/go-urn v1.4.0 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect - github.com/pelletier/go-toml/v2 v2.0.8 // indirect - github.com/pkg/errors v0.9.1 // indirect + github.com/pelletier/go-toml/v2 v2.2.2 // indirect github.com/russross/blackfriday/v2 v2.0.1 // indirect github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect github.com/tim-ywliu/nested-logrus-formatter v1.3.2 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect - github.com/ugorji/go/codec v1.2.11 // indirect + github.com/ugorji/go/codec v1.2.12 // indirect github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df // indirect - golang.org/x/arch v0.3.0 // indirect - golang.org/x/crypto v0.21.0 // indirect - golang.org/x/text v0.14.0 // indirect - google.golang.org/protobuf v1.33.0 // indirect + golang.org/x/arch v0.8.0 // indirect + golang.org/x/crypto v0.23.0 // indirect + golang.org/x/text v0.15.0 // indirect + google.golang.org/protobuf v1.34.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 7ef2ccba..e95cafb0 100644 --- a/go.sum +++ b/go.sum @@ -6,22 +6,22 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuy github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= -github.com/antonfisher/nested-logrus-formatter v1.3.1 h1:NFJIr+pzwv5QLHTPyKz9UMEoHck02Q9L0FP13b/xSbQ= -github.com/antonfisher/nested-logrus-formatter v1.3.1/go.mod h1:6WTfyWFkBc9+zyBaKIqRrg/KwMqBbodBjgbHjDz7zjA= github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d h1:Byv0BzEl3/e6D5CLfI0j/7hiIEtvGVFPCZ7Ei2oq8iQ= github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= -github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= -github.com/bytedance/sonic v1.9.1 h1:6iJ6NqdoxCDr6mbY8h18oSO+cShGSMRGCEo7F2h0x8s= -github.com/bytedance/sonic v1.9.1/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U= +github.com/bytedance/sonic v1.11.6 h1:oUp34TzMlL+OY1OUWxHqsdkgC/Zfc85zGqw9siXjrc0= +github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4= +github.com/bytedance/sonic/loader v0.1.1 h1:c+e5Pt1k/cy5wMveRDyk2X4B9hF4g7an8N3zCYjJFNM= +github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY= -github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 h1:qSGYFH7+jGhDF8vLC+iwCD4WpbV1EBDSzWkJODFLams= -github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/0Y= +github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= +github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg= +github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= @@ -32,22 +32,24 @@ github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymF github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/free5gc/aper v1.0.5 h1:sUYFFmOXDLjyL4rU6zFnq81M4YluqP90Pso5e/J4UhA= -github.com/free5gc/aper v1.0.5/go.mod h1:ybHxhYnRqQ9wD4yB9r/3MZdbCYCjtqUyfLpSnJpwWd4= -github.com/free5gc/ngap v1.0.8 h1:ffzSJW26qbZolwbL8yIjrCoEn7PUc/VE91f/zjJIFMs= -github.com/free5gc/ngap v1.0.8/go.mod h1:d5u7tYsBwxmLr3zw7wyBruRjc/gbdsHVhmdGFnVmfBU= -github.com/free5gc/openapi v1.0.8 h1:QjfQdB6VVA1GRnzOJ7nILzrI7gMiY0lH64JHVW7vF34= -github.com/free5gc/openapi v1.0.8/go.mod h1:w6y9P/uySczc1d9OJZAEuB2FImR/z60Wg2BekPAVt3M= -github.com/free5gc/sctp v1.0.0 h1:V868MT9yyF2I8uotLCEjLULmhTzrLKxPBvsqFk82xGI= -github.com/free5gc/sctp v1.0.0/go.mod h1:3wEzH3L0tljQCLaqEqEalLdW2290B8D5Aw4orsKHxUs= -github.com/free5gc/util v1.0.6 h1:dBt9drcXtYKE/cY5XuQcuffgsYclPIpIArhSeS6M+DQ= -github.com/free5gc/util v1.0.6/go.mod h1:eSGN7POUM8LNTvg/E591XR6447a6/w1jFWGKNZPHcXw= -github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU= -github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA= +github.com/free5gc/aper v1.0.6-0.20240503143507-2c4c4780b98f h1:sO8FFwAq7feSw/vKN9ioY+fX1gNTXd6/xQOqaeclzsA= +github.com/free5gc/aper v1.0.6-0.20240503143507-2c4c4780b98f/go.mod h1:oh3dtNsje2W4/q3pfidMWQKXbXIehXK3t6CD9tXmHx0= +github.com/free5gc/ngap v1.0.9-0.20240708062829-734d184eed74 h1:foSd3OVtTfDmn3EZbsBngK+U93Mv8YE+qSja7FvKEVU= +github.com/free5gc/ngap v1.0.9-0.20240708062829-734d184eed74/go.mod h1:UsPP9LWVyNwu5sm7ZE5toAFeBNkkyj0rh+4Q3ylRBi8= +github.com/free5gc/openapi v1.0.9-0.20240503143645-eac9f06c2f6b h1:+VcgZq+3apB6Xr4jEqgGf/uAECRF038SwixEvvxhYrM= +github.com/free5gc/openapi v1.0.9-0.20240503143645-eac9f06c2f6b/go.mod h1:0qRW+H1/Nyzw5tjjvyp+90m+2SOZZefGQC9QV8iPwu8= +github.com/free5gc/sctp v1.0.1 h1:g8WDO97r8B9ubkT5Hyk9b4I1fZUOii9Z39gQ2eRaASo= +github.com/free5gc/sctp v1.0.1/go.mod h1:7QXfRWCmlkBGD0EIu3qL5o71bslfIakydz4h2QDZdjQ= +github.com/free5gc/util v1.0.7-0.20240713162917-350ee8f4af4c h1:baToZn4hxGKoCm3BWwYlRuZoCQ74cMZUJzg9BVLEdE0= +github.com/free5gc/util v1.0.7-0.20240713162917-350ee8f4af4c/go.mod h1:IHKIBd4OM9rwSJ0fG/hv6pXbVC+Eu4Lcaq++BWkfSsY= +github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0= +github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk= +github.com/gin-contrib/pprof v1.5.0 h1:E/Oy7g+kNw94KfdCy3bZxQFtyDnAX2V7axRS7sNYVrU= +github.com/gin-contrib/pprof v1.5.0/go.mod h1:GqFL6LerKoCQ/RSWnkYczkTJ+tOAUVN/8sbnEtaqOKs= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= -github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg= -github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU= +github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU= +github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= @@ -60,14 +62,16 @@ github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/o github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= -github.com/go-playground/validator/v10 v10.14.0 h1:vgvQWe3XCz3gIeFDm/HnTIbj6UGmg/+t63MyGU2n5js= -github.com/go-playground/validator/v10 v10.14.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU= +github.com/go-playground/validator/v10 v10.20.0 h1:K9ISHbSaI0lyB2eWMPJo+kOS/FBExVwjEviJTixqxL8= +github.com/go-playground/validator/v10 v10.20.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/golang-jwt/jwt v3.2.1+incompatible h1:73Z+4BJcrTC+KczS6WvTPvRGOp1WmfEP4Q1lOd9Z/+c= github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= +github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk= +github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -102,8 +106,9 @@ github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHm github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= -github.com/klauspost/cpuid/v2 v2.2.4 h1:acbojRNwl3o09bUq+yDCtZFc1aiwaAAxtcn8YkZXnvk= -github.com/klauspost/cpuid/v2 v2.2.4/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= +github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM= +github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= +github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= @@ -112,10 +117,10 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q= -github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4= -github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= -github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ= +github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= @@ -128,8 +133,8 @@ 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/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= -github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZR9tGQ= -github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4= +github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= +github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -158,12 +163,13 @@ github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeV github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= -github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE= -github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= +github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= +github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= @@ -171,15 +177,15 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY= -github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/tim-ywliu/nested-logrus-formatter v1.3.2 h1:jugNJ2/CNCI79SxOJCOhwUHeN3O7/7/bj+ZRGOFlCSw= github.com/tim-ywliu/nested-logrus-formatter v1.3.2/go.mod h1:oGPmcxZB65j9Wo7mCnQKSrKEJtVDqyjD666SGmyStXI= github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= -github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU= -github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= +github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE= +github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= github.com/urfave/cli v1.22.5 h1:lNq9sAHXK2qfdI8W+GRItjCEkI+2oR4d+MEHy1CKXoU= github.com/urfave/cli v1.22.5/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/vishvananda/netlink v1.1.0 h1:1iyaYNBLmP6L0220aDnYQpo1QEV4t4hJ+xEEhhJH8j0= @@ -189,13 +195,13 @@ github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17 github.com/wmnsk/go-gtp v0.8.0 h1:KbvPh2nRGrB67w3k80YhIv6NkjKsZn20i0B5wCjhdDs= github.com/wmnsk/go-gtp v0.8.0/go.mod h1:Y0reWDB701yW31+HeZcHfO6dLVRfn/f017vH+7syqrg= golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= -golang.org/x/arch v0.3.0 h1:02VY4/ZcO/gBOH6PUaoiptASxtXU10jazRCP865E97k= -golang.org/x/arch v0.3.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= +golang.org/x/arch v0.8.0 h1:3wRIsP3pM4yUptoR96otTUOXI367OS0+c9eeRi9doIc= +golang.org/x/arch v0.8.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= -golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= +golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI= +golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= @@ -210,8 +216,8 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20210501142056-aec3718b3fa0/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= -golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= -golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= +golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac= +golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -227,7 +233,6 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190606203320-7fc4e5ec1444/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -236,16 +241,17 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= -golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= +golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk= +golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= @@ -274,8 +280,8 @@ google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpAD google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= -google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg= +google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= @@ -292,4 +298,5 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50= rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= diff --git a/internal/logger/logger.go b/internal/logger/logger.go index 14f3cbcc..cca85e34 100644 --- a/internal/logger/logger.go +++ b/internal/logger/logger.go @@ -23,14 +23,9 @@ var ( UtilLog *logrus.Entry ) -func init() { - fieldsOrder := []string{ - logger_util.FieldNF, - logger_util.FieldCategory, - } - - Log = logger_util.New(fieldsOrder) - NfLog = Log.WithField(logger_util.FieldNF, "N3IWF") +func UpdateNfLog(s string) { + NfLog = Log.WithField(logger_util.FieldNF, s) + // update logs created from NfLog MainLog = NfLog.WithField(logger_util.FieldCategory, "Main") InitLog = NfLog.WithField(logger_util.FieldCategory, "Init") CfgLog = NfLog.WithField(logger_util.FieldCategory, "CFG") @@ -44,3 +39,12 @@ func init() { RelayLog = NfLog.WithField(logger_util.FieldCategory, "Relay") UtilLog = NfLog.WithField(logger_util.FieldCategory, "Util") } + +func init() { + fieldsOrder := []string{ + logger_util.FieldNF, + logger_util.FieldCategory, + } + Log = logger_util.New(fieldsOrder) + UpdateNfLog("N3IWF") +} diff --git a/internal/ngap/service/service.go b/internal/ngap/service/service.go index 8d33a495..d27cc81f 100644 --- a/internal/ngap/service/service.go +++ b/internal/ngap/service/service.go @@ -23,8 +23,6 @@ var ( // Run start the N3IWF SCTP process. func Run(wg *sync.WaitGroup) error { - ngapLog := logger.NgapLog - // n3iwf context n3iwfSelf := context.N3IWFSelf() // load amf SCTP address slice @@ -38,8 +36,7 @@ func Run(wg *sync.WaitGroup) error { wg.Add(1) go Receiver(localAddr, remoteAddr, errChan, n3iwfSelf.NGAPServer, wg) if err, ok := <-errChan; ok { - ngapLog.Errorln(err) - return errors.New("NGAP service run failed") + return err } } diff --git a/internal/nwucp/service/service.go b/internal/nwucp/service/service.go index 17915922..c8439fa1 100644 --- a/internal/nwucp/service/service.go +++ b/internal/nwucp/service/service.go @@ -3,7 +3,6 @@ package service import ( "encoding/binary" "encoding/hex" - "errors" "fmt" "net" "runtime/debug" @@ -20,21 +19,17 @@ var tcpListener net.Listener // Run setup N3IWF NAS for UE to forward NAS message // to AMF func Run(wg *sync.WaitGroup) error { - nwucpLog := logger.NWuCPLog // N3IWF context n3iwfSelf := context.N3IWFSelf() tcpAddr := fmt.Sprintf("%s:%d", n3iwfSelf.IPSecGatewayAddress, n3iwfSelf.TCPPort) listener, err := net.Listen("tcp", tcpAddr) if err != nil { - nwucpLog.Errorf("Listen TCP address failed: %+v", err) - return errors.New("Listen failed") + return err } tcpListener = listener - nwucpLog.Tracef("Successfully listen %+v", tcpAddr) - wg.Add(1) go listenAndServe(tcpListener, wg) diff --git a/internal/nwuup/service/service.go b/internal/nwuup/service/service.go index eecbe6d3..f2163f74 100644 --- a/internal/nwuup/service/service.go +++ b/internal/nwuup/service/service.go @@ -1,11 +1,11 @@ package service import ( - "errors" "net" "runtime/debug" "sync" + "github.com/pkg/errors" gtpv1 "github.com/wmnsk/go-gtp/gtpv1" gtpMsg "github.com/wmnsk/go-gtp/gtpv1/message" "golang.org/x/net/ipv4" @@ -20,7 +20,6 @@ import ( // with UP_IP_ADDRESS, catching GRE encapsulated packets and forward // to N3 interface. func Run(wg *sync.WaitGroup) error { - nwuupLog := logger.NWuUPLog // Local IPSec address n3iwfSelf := context.N3IWFSelf() listenAddr := n3iwfSelf.IPSecGatewayAddress @@ -29,13 +28,11 @@ func Run(wg *sync.WaitGroup) error { // This socket will only capture GRE encapsulated packet connection, err := net.ListenPacket("ip4:gre", listenAddr) if err != nil { - nwuupLog.Errorf("Error setting listen socket on %s: %+v", listenAddr, err) - return errors.New("ListenPacket failed") + return errors.Wrapf(err, "Error setting listen socket on %s", listenAddr) } ipv4PacketConn := ipv4.NewPacketConn(connection) if ipv4PacketConn == nil { - nwuupLog.Errorf("Error opening IPv4 packet connection socket on %s", listenAddr) - return errors.New("NewPacketConn failed") + return errors.Wrapf(err, "Error opening IPv4 packet connection socket on %s", listenAddr) } n3iwfSelf.NWuIPv4PacketConn = ipv4PacketConn diff --git a/pkg/app/app.go b/pkg/app/app.go new file mode 100644 index 00000000..b6961007 --- /dev/null +++ b/pkg/app/app.go @@ -0,0 +1,18 @@ +package app + +import ( + n3iwf_context "github.com/free5gc/n3iwf/pkg/context" + "github.com/free5gc/n3iwf/pkg/factory" +) + +type App interface { + SetLogEnable(enable bool) + SetLogLevel(level string) + SetReportCaller(reportCaller bool) + + Start() + Terminate() + + Context() *n3iwf_context.N3IWFContext + Config() *factory.Config +} diff --git a/pkg/context/context.go b/pkg/context/context.go index 03bd3c1c..47cfb993 100644 --- a/pkg/context/context.go +++ b/pkg/context/context.go @@ -1,7 +1,6 @@ package context import ( - "context" "crypto/rand" "crypto/rsa" "crypto/sha1" @@ -77,9 +76,6 @@ type N3IWFContext struct { // N3IWF NWu interface IPv4 packet connection NWuIPv4PacketConn *ipv4.PacketConn - Ctx context.Context - Wg sync.WaitGroup - NGAPServer *NGAPServer IKEServer *IkeServer } @@ -377,7 +373,7 @@ func GetInterfaceName(IPAddress string) (interfaceName string, err error) { res, err := net.ResolveIPAddr("ip4", IPAddress) if err != nil { - return "", fmt.Errorf("Error resolving address '%s': %v", IPAddress, err) + return "", fmt.Errorf("Error resolving address [%s]: %v", IPAddress, err) } IPAddress = res.String() @@ -392,7 +388,7 @@ func GetInterfaceName(IPAddress string) (interfaceName string, err error) { } } } - return "", fmt.Errorf("Cannot find interface name") + return "", fmt.Errorf("Cannot find interface name for IP[%s]", IPAddress) } func init() { diff --git a/pkg/ike/service/service.go b/pkg/ike/service/service.go index 0eda9f74..fc2512dc 100644 --- a/pkg/ike/service/service.go +++ b/pkg/ike/service/service.go @@ -1,11 +1,12 @@ package service import ( - "errors" "net" "runtime/debug" "sync" + "github.com/pkg/errors" + "github.com/free5gc/n3iwf/internal/logger" "github.com/free5gc/n3iwf/pkg/context" "github.com/free5gc/n3iwf/pkg/ike" @@ -18,20 +19,17 @@ var ( ) func Run(wg *sync.WaitGroup) error { - ikeLog := logger.IKELog n3iwfSelf := context.N3IWFSelf() // Resolve UDP addresses ip := n3iwfSelf.IKEBindAddress udpAddrPort500, err := net.ResolveUDPAddr("udp", ip+":500") if err != nil { - ikeLog.Errorf("Resolve UDP address failed: %+v", err) - return errors.New("IKE service run failed") + return errors.Wrapf(err, "ResolveUDPAddr (%s:500)", ip) } udpAddrPort4500, err := net.ResolveUDPAddr("udp", ip+":4500") if err != nil { - ikeLog.Errorf("Resolve UDP address failed: %+v", err) - return errors.New("IKE service run failed") + return errors.Wrapf(err, "ResolveUDPAddr (%s:4500)", ip) } n3iwfSelf.IKEServer = NewIKEServer() @@ -44,8 +42,7 @@ func Run(wg *sync.WaitGroup) error { errChan = make(chan error) go Receiver(udpAddrPort500, n3iwfSelf.IKEServer, errChan, wg) if err, ok := <-errChan; ok { - ikeLog.Errorln(err) - return errors.New("IKE service run failed") + return errors.Wrapf(err, "udp 500") } // Port 4500 @@ -53,8 +50,7 @@ func Run(wg *sync.WaitGroup) error { errChan = make(chan error) go Receiver(udpAddrPort4500, n3iwfSelf.IKEServer, errChan, wg) if err, ok := <-errChan; ok { - ikeLog.Errorln(err) - return errors.New("IKE service run failed") + return errors.Wrapf(err, "udp 4500") } wg.Add(1) diff --git a/pkg/service/init.go b/pkg/service/init.go index e0e16cb4..bb769d2f 100644 --- a/pkg/service/init.go +++ b/pkg/service/init.go @@ -6,10 +6,10 @@ import ( "io" "net" "os" - "os/signal" "runtime/debug" - "syscall" + "sync" + "github.com/pkg/errors" "github.com/sirupsen/logrus" "github.com/vishvananda/netlink" @@ -17,28 +17,58 @@ import ( ngap_service "github.com/free5gc/n3iwf/internal/ngap/service" nwucp_service "github.com/free5gc/n3iwf/internal/nwucp/service" nwuup_service "github.com/free5gc/n3iwf/internal/nwuup/service" + "github.com/free5gc/n3iwf/pkg/app" n3iwf_context "github.com/free5gc/n3iwf/pkg/context" "github.com/free5gc/n3iwf/pkg/factory" ike_service "github.com/free5gc/n3iwf/pkg/ike/service" "github.com/free5gc/n3iwf/pkg/ike/xfrm" ) +var N3IWF *N3iwfApp + +var _ app.App = &N3iwfApp{} + type N3iwfApp struct { - cfg *factory.Config n3iwfCtx *n3iwf_context.N3IWFContext + cfg *factory.Config + + ctx context.Context + cancel context.CancelFunc + wg sync.WaitGroup } -func NewApp(cfg *factory.Config) (*N3iwfApp, error) { - n3iwf := &N3iwfApp{cfg: cfg} +func NewApp( + ctx context.Context, + cfg *factory.Config, + tlsKeyLogPath string, +) (*N3iwfApp, error) { + n3iwf := &N3iwfApp{ + cfg: cfg, + wg: sync.WaitGroup{}, + } + n3iwf.ctx, n3iwf.cancel = context.WithCancel(ctx) + n3iwf.SetLogEnable(cfg.GetLogEnable()) n3iwf.SetLogLevel(cfg.GetLogLevel()) n3iwf.SetReportCaller(cfg.GetLogReportCaller()) - // n3iwf_context.Init() n3iwf.n3iwfCtx = n3iwf_context.N3IWFSelf() + N3IWF = n3iwf return n3iwf, nil } +func (a *N3iwfApp) CancelContext() context.Context { + return a.ctx +} + +func (a *N3iwfApp) Context() *n3iwf_context.N3IWFContext { + return a.n3iwfCtx +} + +func (a *N3iwfApp) Config() *factory.Config { + return a.cfg +} + func (a *N3iwfApp) SetLogEnable(enable bool) { logger.MainLog.Infof("Log enable is set to [%v]", enable) if enable && logger.Log.Out == os.Stderr { @@ -81,87 +111,76 @@ func (a *N3iwfApp) SetReportCaller(reportCaller bool) { logger.Log.SetReportCaller(reportCaller) } -func (a *N3iwfApp) Start(tlsKeyLogPath string) { - logger.InitLog.Infoln("Server started") - - var cancel context.CancelFunc - n3iwfContext := n3iwf_context.N3IWFSelf() - n3iwfContext.Ctx, cancel = context.WithCancel(context.Background()) - defer cancel() - +func (a *N3iwfApp) Run() error { if !n3iwf_context.InitN3IWFContext() { - logger.InitLog.Error("Initicating context failed") - return + return errors.Errorf("Initicating context failed") } - if err := a.InitDefaultXfrmInterface(n3iwfContext); err != nil { - logger.InitLog.Errorf("Initicating XFRM interface for control plane failed: %+v", err) - return + if err := a.initDefaultXfrmInterface(a.n3iwfCtx); err != nil { + return err } - n3iwfContext.Wg.Add(1) - // Graceful Shutdown - go a.ListenShutdownEvent(n3iwfContext) + a.wg.Add(1) + go a.listenShutdownEvent() // NGAP - if err := ngap_service.Run(&n3iwfContext.Wg); err != nil { - logger.InitLog.Errorf("Start NGAP service failed: %+v", err) - return + if err := ngap_service.Run(&a.wg); err != nil { + return errors.Wrapf(err, "Start NGAP service failed") } - logger.InitLog.Info("NGAP service running.") + logger.MainLog.Infof("NGAP service running.") // Relay listeners // Control plane - if err := nwucp_service.Run(&n3iwfContext.Wg); err != nil { - logger.InitLog.Errorf("Listen NWu control plane traffic failed: %+v", err) - return + if err := nwucp_service.Run(&a.wg); err != nil { + return errors.Wrapf(err, "Listen NWu control plane traffic failed") } - logger.InitLog.Info("NAS TCP server successfully started.") + logger.MainLog.Infof("NAS TCP server successfully started.") // User plane - if err := nwuup_service.Run(&n3iwfContext.Wg); err != nil { - logger.InitLog.Errorf("Listen NWu user plane traffic failed: %+v", err) - return + if err := nwuup_service.Run(&a.wg); err != nil { + return errors.Wrapf(err, "Listen NWu user plane traffic failed") } - logger.InitLog.Info("Listening NWu user plane traffic") + logger.MainLog.Infof("Listening NWu user plane traffic") // IKE - if err := ike_service.Run(&n3iwfContext.Wg); err != nil { - logger.InitLog.Errorf("Start IKE service failed: %+v", err) - return + if err := ike_service.Run(&a.wg); err != nil { + return errors.Wrapf(err, "Start IKE service failed") } - logger.InitLog.Info("IKE service running.") + logger.MainLog.Infof("IKE service running") - logger.InitLog.Info("N3IWF running...") + logger.MainLog.Infof("N3IWF started") - signalChannel := make(chan os.Signal, 1) - signal.Notify(signalChannel, os.Interrupt, syscall.SIGTERM) - <-signalChannel + a.WaitRoutineStopped() + return nil +} - cancel() - a.WaitRoutineStopped(n3iwfContext) +func (a *N3iwfApp) Start() { + if err := a.Run(); err != nil { + logger.MainLog.Errorf("N3IWF Run err: %v", err) + } } -func (a *N3iwfApp) ListenShutdownEvent(n3iwfContext *n3iwf_context.N3IWFContext) { +func (a *N3iwfApp) listenShutdownEvent() { defer func() { if p := recover(); p != nil { // Print stack for panic to log. Fatalf() will let program exit. - logger.InitLog.Fatalf("panic: %v\n%s", p, string(debug.Stack())) + logger.MainLog.Fatalf("panic: %v\n%s", p, string(debug.Stack())) } - n3iwfContext.Wg.Done() + a.wg.Done() }() - <-n3iwfContext.Ctx.Done() - StopServiceConn(n3iwfContext) + <-a.ctx.Done() + a.terminateProcedure() } -func (a *N3iwfApp) WaitRoutineStopped(n3iwfContext *n3iwf_context.N3IWFContext) { - n3iwfContext.Wg.Wait() +func (a *N3iwfApp) WaitRoutineStopped() { + a.wg.Wait() // Waiting for negotiatioon with netlink for deleting interfaces - a.Terminate(n3iwfContext) + a.removeIPsecInterfaces() + logger.MainLog.Infof("N3IWF App is terminated") } -func (a *N3iwfApp) InitDefaultXfrmInterface(n3iwfContext *n3iwf_context.N3IWFContext) error { +func (a *N3iwfApp) initDefaultXfrmInterface(n3iwfContext *n3iwf_context.N3IWFContext) error { // Setup default IPsec interface for Control Plane var linkIPSec netlink.Link var err error @@ -171,7 +190,7 @@ func (a *N3iwfApp) InitDefaultXfrmInterface(n3iwfContext *n3iwf_context.N3IWFCon if linkIPSec, err = xfrm.SetupIPsecXfrmi(newXfrmiName, n3iwfContext.XfrmParentIfaceName, n3iwfContext.XfrmIfaceId, n3iwfIPAddrAndSubnet); err != nil { - logger.InitLog.Errorf("Setup XFRM interface %s fail: %+v", newXfrmiName, err) + logger.MainLog.Errorf("Setup XFRM interface %s fail: %+v", newXfrmiName, err) return err } @@ -181,10 +200,10 @@ func (a *N3iwfApp) InitDefaultXfrmInterface(n3iwfContext *n3iwf_context.N3IWFCon } if err := netlink.RouteAdd(route); err != nil { - logger.InitLog.Warnf("netlink.RouteAdd: %+v", err) + logger.MainLog.Warnf("netlink.RouteAdd: %+v", err) } - logger.InitLog.Infof("Setup XFRM interface %s ", newXfrmiName) + logger.MainLog.Infof("Setup XFRM interface %s ", newXfrmiName) n3iwfContext.XfrmIfaces.LoadOrStore(n3iwfContext.XfrmIfaceId, linkIPSec) n3iwfContext.XfrmIfaceIdOffsetForUP = 1 @@ -192,34 +211,31 @@ func (a *N3iwfApp) InitDefaultXfrmInterface(n3iwfContext *n3iwf_context.N3IWFCon return nil } -func (a *N3iwfApp) RemoveIPsecInterfaces(n3iwfContext *n3iwf_context.N3IWFContext) { - n3iwfContext.XfrmIfaces.Range( +func (a *N3iwfApp) removeIPsecInterfaces() { + a.n3iwfCtx.XfrmIfaces.Range( func(key, value interface{}) bool { iface := value.(netlink.Link) if err := netlink.LinkDel(iface); err != nil { - logger.InitLog.Errorf("Delete interface %s fail: %+v", iface.Attrs().Name, err) + logger.MainLog.Errorf("Delete interface %s fail: %+v", iface.Attrs().Name, err) } else { - logger.InitLog.Infof("Delete interface: %s", iface.Attrs().Name) + logger.MainLog.Infof("Delete interface: %s", iface.Attrs().Name) } return true }) } -func (a *N3iwfApp) Terminate(n3iwfContext *n3iwf_context.N3IWFContext) { - logger.InitLog.Info("Terminating N3IWF...") - logger.InitLog.Info("Deleting interfaces created by N3IWF") - a.RemoveIPsecInterfaces(n3iwfContext) - logger.InitLog.Info("N3IWF terminated") +func (a *N3iwfApp) Terminate() { + a.cancel() } -func StopServiceConn(n3iwfContext *n3iwf_context.N3IWFContext) { - logger.InitLog.Info("Stopping service created by N3IWF") +func (a *N3iwfApp) terminateProcedure() { + logger.MainLog.Info("Stopping service created by N3IWF") - ngap_service.Stop(n3iwfContext) + ngap_service.Stop(a.n3iwfCtx) - nwucp_service.Stop(n3iwfContext) + nwucp_service.Stop(a.n3iwfCtx) - nwuup_service.Stop(n3iwfContext) + nwuup_service.Stop(a.n3iwfCtx) - ike_service.Stop(n3iwfContext) + ike_service.Stop(a.n3iwfCtx) }