From f91c29b9506d406c1bfa39b15b64d9f184fbc84b Mon Sep 17 00:00:00 2001 From: free5gc-org Date: Thu, 11 Nov 2021 02:31:23 +0000 Subject: [PATCH] refactor packages, update go.mod, and add config validator --- .gitignore | 18 +- .golangci.yml | 17 +- CHANGELOG.md | 9 - LICENSE.txt => LICENSE | 0 cmd/main.go | 85 ++++ factory/config.go | 61 --- go.mod | 25 +- go.sum | 187 +++++---- {context => internal/context}/context.go | 5 +- {logger => internal/logger}/logger.go | 45 +- .../sbi/consumer}/nf_discovery.go | 6 +- .../sbi/consumer}/nf_management.go | 4 +- .../api_create_ee_subscription.go | 8 +- .../api_delete_ee_subscription.go | 6 +- .../api_update_ee_subscription.go | 8 +- .../sbi/eventexposure}/routers.go | 4 +- .../data_change_notification_to_nf.go | 8 +- .../sbi/httpcallback}/router.go | 4 +- .../api_subscription_data_update.go | 8 +- .../api_subscription_data_update_test.go | 0 .../sbi/parameterprovision}/routers.go | 4 +- .../sbi/producer}/callback.go | 12 +- .../sbi/producer}/callback/callback.go | 4 +- .../sbi/producer}/event_exposure.go | 24 +- .../sbi/producer}/generate_auth_data.go | 144 ++++--- .../sbi/producer}/parameter_provision.go | 12 +- .../producer}/subscriber_data_management.go | 138 ++++--- .../sbi/producer}/ue_context_management.go | 70 ++-- ...nd_mobility_subscription_data_retrieval.go | 8 +- .../api_gpsi_to_supi_translation.go | 8 +- ..._acknowledgement_of_steering_of_roaming.go | 0 ...acknowledgement_of_ue_parameters_update.go | 0 .../api_retrieval_of_multiple_data_sets.go | 8 +- .../api_retrieval_of_shared_data.go | 8 +- ..._management_subscription_data_retrieval.go | 8 +- ...e_selection_subscription_data_retrieval.go | 8 +- ...f_selection_subscription_data_retrieval.go | 9 +- ..._management_subscription_data_retrieval.go | 0 .../api_sms_subscription_data_retrieval.go | 0 .../api_subscription_creation.go | 8 +- ...i_subscription_creation_for_shared_data.go | 8 +- .../api_subscription_deletion.go | 8 +- ...i_subscription_deletion_for_shared_data.go | 8 +- .../api_subscription_modification.go | 10 +- .../api_trace_configuration_data_retrieval.go | 8 +- .../api_ue_context_in_smf_data_retrieval.go | 8 +- .../api_ue_context_in_smsf_data_retrieval.go | 0 .../sbi/subscriberdatamanagement}/routers.go | 8 +- .../sbi/ueauthentication}/api_confirm_auth.go | 8 +- .../api_generate_auth_data.go | 9 +- .../sbi/ueauthentication}/routers.go | 6 +- ..._gpp_access_registration_info_retrieval.go | 10 +- ..._gpp_access_registration_info_retrieval.go | 8 +- .../api_amf_registration_for3_gpp_access.go | 9 +- ...pi_amf_registration_for_non3_gpp_access.go | 8 +- ...in_the_amf_registration_for3_gpp_access.go | 9 +- ...he_amf_registration_for_non3_gpp_access.go | 9 +- .../api_smf_deregistration.go | 8 +- .../api_smf_registration.go | 8 +- ..._gpp_access_registration_info_retrieval.go | 0 ...api_smsf_deregistration_for3_gpp_access.go | 0 ...smsf_deregistration_for_non3_gpp_access.go | 0 ..._gpp_access_registration_info_retrieval.go | 0 .../api_smsf_registration_for3_gpp_access.go | 0 ...i_smsf_registration_for_non3_gpp_access.go | 0 .../sbi/uecontextmanagement}/routers.go | 4 +- {util => internal/util}/init_context.go | 13 +- {util => internal/util}/search_nf_service.go | 0 {util => internal/util}/util.go | 7 + pkg/factory/config.go | 174 ++++++++ {factory => pkg/factory}/factory.go | 6 +- {service => pkg/service}/init.go | 183 ++++----- pkg/suci/suci.go | 383 ++++++++++++++++++ pkg/suci/suci_test.go | 46 +++ udm.go | 45 -- 75 files changed, 1303 insertions(+), 689 deletions(-) delete mode 100644 CHANGELOG.md rename LICENSE.txt => LICENSE (100%) create mode 100644 cmd/main.go delete mode 100644 factory/config.go rename {context => internal/context}/context.go (99%) rename {logger => internal/logger}/logger.go (71%) rename {consumer => internal/sbi/consumer}/nf_discovery.go (93%) rename {consumer => internal/sbi/consumer}/nf_management.go (97%) rename {eventexposure => internal/sbi/eventexposure}/api_create_ee_subscription.go (89%) rename {eventexposure => internal/sbi/eventexposure}/api_delete_ee_subscription.go (79%) rename {eventexposure => internal/sbi/eventexposure}/api_update_ee_subscription.go (90%) rename {eventexposure => internal/sbi/eventexposure}/routers.go (95%) rename {httpcallback => internal/sbi/httpcallback}/data_change_notification_to_nf.go (89%) rename {httpcallback => internal/sbi/httpcallback}/router.go (94%) rename {parameterprovision => internal/sbi/parameterprovision}/api_subscription_data_update.go (90%) rename {parameterprovision => internal/sbi/parameterprovision}/api_subscription_data_update_test.go (100%) rename {parameterprovision => internal/sbi/parameterprovision}/routers.go (94%) rename {producer => internal/sbi/producer}/callback.go (58%) rename {producer => internal/sbi/producer}/callback/callback.go (96%) rename {producer => internal/sbi/producer}/event_exposure.go (89%) rename {producer => internal/sbi/producer}/generate_auth_data.go (77%) rename {producer => internal/sbi/producer}/parameter_provision.go (77%) rename {producer => internal/sbi/producer}/subscriber_data_management.go (89%) rename {producer => internal/sbi/producer}/ue_context_management.go (89%) rename {subscriberdatamanagement => internal/sbi/subscriberdatamanagement}/api_access_and_mobility_subscription_data_retrieval.go (85%) rename {subscriberdatamanagement => internal/sbi/subscriberdatamanagement}/api_gpsi_to_supi_translation.go (84%) rename {subscriberdatamanagement => internal/sbi/subscriberdatamanagement}/api_providing_acknowledgement_of_steering_of_roaming.go (100%) rename {subscriberdatamanagement => internal/sbi/subscriberdatamanagement}/api_providing_acknowledgement_of_ue_parameters_update.go (100%) rename {subscriberdatamanagement => internal/sbi/subscriberdatamanagement}/api_retrieval_of_multiple_data_sets.go (85%) rename {subscriberdatamanagement => internal/sbi/subscriberdatamanagement}/api_retrieval_of_shared_data.go (84%) rename {subscriberdatamanagement => internal/sbi/subscriberdatamanagement}/api_session_management_subscription_data_retrieval.go (86%) rename {subscriberdatamanagement => internal/sbi/subscriberdatamanagement}/api_slice_selection_subscription_data_retrieval.go (84%) rename {subscriberdatamanagement => internal/sbi/subscriberdatamanagement}/api_smf_selection_subscription_data_retrieval.go (85%) rename {subscriberdatamanagement => internal/sbi/subscriberdatamanagement}/api_sms_management_subscription_data_retrieval.go (100%) rename {subscriberdatamanagement => internal/sbi/subscriberdatamanagement}/api_sms_subscription_data_retrieval.go (100%) rename {subscriberdatamanagement => internal/sbi/subscriberdatamanagement}/api_subscription_creation.go (90%) rename {subscriberdatamanagement => internal/sbi/subscriberdatamanagement}/api_subscription_creation_for_shared_data.go (90%) rename {subscriberdatamanagement => internal/sbi/subscriberdatamanagement}/api_subscription_deletion.go (85%) rename {subscriberdatamanagement => internal/sbi/subscriberdatamanagement}/api_subscription_deletion_for_shared_data.go (84%) rename {subscriberdatamanagement => internal/sbi/subscriberdatamanagement}/api_subscription_modification.go (92%) rename {subscriberdatamanagement => internal/sbi/subscriberdatamanagement}/api_trace_configuration_data_retrieval.go (84%) rename {subscriberdatamanagement => internal/sbi/subscriberdatamanagement}/api_ue_context_in_smf_data_retrieval.go (84%) rename {subscriberdatamanagement => internal/sbi/subscriberdatamanagement}/api_ue_context_in_smsf_data_retrieval.go (100%) rename {subscriberdatamanagement => internal/sbi/subscriberdatamanagement}/routers.go (98%) rename {ueauthentication => internal/sbi/ueauthentication}/api_confirm_auth.go (90%) rename {ueauthentication => internal/sbi/ueauthentication}/api_generate_auth_data.go (90%) rename {ueauthentication => internal/sbi/ueauthentication}/routers.go (95%) rename {uecontextmanagement => internal/sbi/uecontextmanagement}/api_amf3_gpp_access_registration_info_retrieval.go (84%) rename {uecontextmanagement => internal/sbi/uecontextmanagement}/api_amf_non3_gpp_access_registration_info_retrieval.go (84%) rename {uecontextmanagement => internal/sbi/uecontextmanagement}/api_amf_registration_for3_gpp_access.go (90%) rename {uecontextmanagement => internal/sbi/uecontextmanagement}/api_amf_registration_for_non3_gpp_access.go (90%) rename {uecontextmanagement => internal/sbi/uecontextmanagement}/api_parameter_update_in_the_amf_registration_for3_gpp_access.go (89%) rename {uecontextmanagement => internal/sbi/uecontextmanagement}/api_parameter_update_in_the_amf_registration_for_non3_gpp_access.go (89%) rename {uecontextmanagement => internal/sbi/uecontextmanagement}/api_smf_deregistration.go (84%) rename {uecontextmanagement => internal/sbi/uecontextmanagement}/api_smf_registration.go (91%) rename {uecontextmanagement => internal/sbi/uecontextmanagement}/api_smsf3_gpp_access_registration_info_retrieval.go (100%) rename {uecontextmanagement => internal/sbi/uecontextmanagement}/api_smsf_deregistration_for3_gpp_access.go (100%) rename {uecontextmanagement => internal/sbi/uecontextmanagement}/api_smsf_deregistration_for_non3_gpp_access.go (100%) rename {uecontextmanagement => internal/sbi/uecontextmanagement}/api_smsf_non3_gpp_access_registration_info_retrieval.go (100%) rename {uecontextmanagement => internal/sbi/uecontextmanagement}/api_smsf_registration_for3_gpp_access.go (100%) rename {uecontextmanagement => internal/sbi/uecontextmanagement}/api_smsf_registration_for_non3_gpp_access.go (100%) rename {uecontextmanagement => internal/sbi/uecontextmanagement}/routers.go (97%) rename {util => internal/util}/init_context.go (82%) rename {util => internal/util}/search_nf_service.go (100%) rename {util => internal/util}/util.go (60%) create mode 100644 pkg/factory/config.go rename {factory => pkg/factory}/factory.go (82%) rename {service => pkg/service}/init.go (50%) create mode 100644 pkg/suci/suci.go create mode 100644 pkg/suci/suci_test.go delete mode 100644 udm.go diff --git a/.gitignore b/.gitignore index 6729600..c294e4d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,18 @@ +# Swap files +*.swp + # Toolchain -# Goland project folder +# Golang project folder .idea/ + # Visual Studio Code .vscode/ + +# Build +build/ +log/ +vendor/ + # emacs/vim GPATH GRTAGS @@ -10,10 +20,10 @@ GTAGS TAGS tags cscope.* -# mac + +# macOS .DS_Store -# debug +# Debug *.log *.pcap - diff --git a/.golangci.yml b/.golangci.yml index fbb3db5..3ae4931 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -29,12 +29,6 @@ run: # "/" will be replaced by current OS file path separator to properly work # on Windows. skip-files: - - "api_.*\\.go$" - - "model_.*\\.go$" - - "routers.go" - - "client.go" - - "configuration.go" - - "nas.go" # by default isn't set. If set we pass it to "go list -mod={option}". From "go help modules": # If invoked with -mod=readonly, the go command is disallowed from the implicit # automatic updating of go.mod described above. Instead, it fails when any changes @@ -249,13 +243,14 @@ linters: # Additional - lll - godox - #- gomnd - #- goconst + # - gomnd + # - goconst # - gocognit # - maligned # - nestif # - gomodguard - nakedret + # - golint - gci - misspell - gofumpt @@ -266,9 +261,9 @@ linters: - dogsled - bodyclose - asciicheck - #- stylecheck - # - unparam - # - wsl + # - stylecheck + # - unparam + # - wsl #disable-all: false fast: true diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index f465a20..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,9 +0,0 @@ -# Change Log ---- -2020-03-xx-xx ---- -- Implemented enchacements: - -- Fixed bugs: - -- Closed issues: diff --git a/LICENSE.txt b/LICENSE similarity index 100% rename from LICENSE.txt rename to LICENSE diff --git a/cmd/main.go b/cmd/main.go new file mode 100644 index 0000000..30ce168 --- /dev/null +++ b/cmd/main.go @@ -0,0 +1,85 @@ +package main + +import ( + "fmt" + "os" + "path/filepath" + "runtime/debug" + + "github.com/asaskevich/govalidator" + "github.com/urfave/cli" + + "github.com/free5gc/udm/internal/logger" + "github.com/free5gc/udm/internal/util" + "github.com/free5gc/udm/pkg/service" + "github.com/free5gc/util/version" +) + +var UDM = &service.UDM{} + +func main() { + defer func() { + if p := recover(); p != nil { + // Print stack for panic to log. Fatalf() will let program exit. + logger.AppLog.Fatalf("panic: %v\n%s", p, string(debug.Stack())) + } + }() + + app := cli.NewApp() + app.Name = "udm" + app.Usage = "5G Unified Data Management (UDM)" + app.Action = action + app.Flags = UDM.GetCliCmd() + if err := app.Run(os.Args); err != nil { + fmt.Printf("UDM Run error: %v\n", err) + } +} + +func action(c *cli.Context) error { + if err := initLogFile(c.String("log"), c.String("log5gc")); err != nil { + logger.AppLog.Errorf("%+v", err) + return err + } + + if err := UDM.Initialize(c); err != nil { + switch errType := err.(type) { + case govalidator.Errors: + validErrs := err.(govalidator.Errors).Errors() + for _, validErr := range validErrs { + logger.CfgLog.Errorf("%+v", validErr) + } + default: + logger.CfgLog.Errorf("%+v", errType) + } + logger.CfgLog.Errorf("[-- PLEASE REFER TO SAMPLE CONFIG FILE COMMENTS --]") + return fmt.Errorf("Failed to initialize !!") + } + + logger.AppLog.Infoln(c.App.Name) + logger.AppLog.Infoln("UDM version: ", version.GetVersion()) + + UDM.Start() + + return nil +} + +func initLogFile(logNfPath, log5gcPath string) error { + UDM.KeyLogPath = util.UdmDefaultKeyLogPath + + if err := logger.LogFileHook(logNfPath, log5gcPath); err != nil { + return err + } + + if logNfPath != "" { + nfDir, _ := filepath.Split(logNfPath) + tmpDir := filepath.Join(nfDir, "key") + if err := os.MkdirAll(tmpDir, 0775); err != nil { + logger.InitLog.Errorf("Make directory %s failed: %+v", tmpDir, err) + return err + } + _, name := filepath.Split(util.UdmDefaultKeyLogPath) + UDM.KeyLogPath = filepath.Join(tmpDir, name) + } + + return nil +} diff --git a/factory/config.go b/factory/config.go deleted file mode 100644 index ee760f7..0000000 --- a/factory/config.go +++ /dev/null @@ -1,61 +0,0 @@ -/* - * UDM Configuration Factory - */ - -package factory - -import ( - "github.com/free5gc/logger_util" - "github.com/free5gc/util_3gpp/suci" -) - -const ( - UDM_EXPECTED_CONFIG_VERSION = "1.0.1" -) - -type Config struct { - Info *Info `yaml:"info"` - Configuration *Configuration `yaml:"configuration"` - Logger *logger_util.Logger `yaml:"logger"` -} - -type Info struct { - Version string `yaml:"version,omitempty"` - Description string `yaml:"description,omitempty"` -} - -const ( - UDM_DEFAULT_IPV4 = "127.0.0.3" - UDM_DEFAULT_PORT = "8000" - UDM_DEFAULT_PORT_INT = 8000 -) - -type Configuration struct { - UdmName string `yaml:"udmName,omitempty"` - Sbi *Sbi `yaml:"sbi,omitempty"` - ServiceNameList []string `yaml:"serviceNameList,omitempty"` - NrfUri string `yaml:"nrfUri,omitempty"` - SuciProfiles []suci.SuciProfile `yaml:"SuciProfile,omitempty"` -} - -type Sbi struct { - Scheme string `yaml:"scheme"` - RegisterIPv4 string `yaml:"registerIPv4,omitempty"` // IP that is registered at NRF. - // IPv6Addr string `yaml:"ipv6Addr,omitempty"` - BindingIPv4 string `yaml:"bindingIPv4,omitempty"` // IP used to run the server in the node. - Port int `yaml:"port,omitempty"` - Tls *Tls `yaml:"tls,omitempty"` -} - -type Tls struct { - Log string `yaml:"log,omitempty"` - Pem string `yaml:"pem,omitempty"` - Key string `yaml:"key,omitempty"` -} - -func (c *Config) GetVersion() string { - if c.Info != nil && c.Info.Version != "" { - return c.Info.Version - } - return "" -} diff --git a/go.mod b/go.mod index 7608ecd..f6bc810 100644 --- a/go.mod +++ b/go.mod @@ -4,23 +4,14 @@ go 1.14 require ( github.com/antihax/optional v1.0.0 - github.com/antonfisher/nested-logrus-formatter v1.3.0 - github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect - github.com/free5gc/UeauCommon v1.0.0 - github.com/free5gc/http2_util v1.0.0 - github.com/free5gc/http_wrapper v1.0.0 - github.com/free5gc/idgenerator v1.0.0 - github.com/free5gc/logger_conf v1.0.0 - github.com/free5gc/logger_util v1.0.0 - github.com/free5gc/milenage v1.0.0 - github.com/free5gc/openapi v1.0.0 - github.com/free5gc/path_util v1.0.0 - github.com/free5gc/util_3gpp v1.0.1 - github.com/free5gc/version v1.0.0 - github.com/gin-gonic/gin v1.6.3 - github.com/google/uuid v1.1.2 - github.com/russross/blackfriday/v2 v2.1.0 // indirect - github.com/sirupsen/logrus v1.7.0 + github.com/antonfisher/nested-logrus-formatter v1.3.1 + github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d + github.com/free5gc/openapi v1.0.4 + github.com/free5gc/util v1.0.1 + github.com/gin-gonic/gin v1.7.3 + github.com/google/uuid v1.3.0 + github.com/sirupsen/logrus v1.8.1 github.com/urfave/cli v1.22.5 + golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 gopkg.in/yaml.v2 v2.4.0 ) diff --git a/go.sum b/go.sum index 52bd691..748b54e 100644 --- a/go.sum +++ b/go.sum @@ -35,52 +35,34 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03 github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/antihax/optional v1.0.0 h1:xK2lYat7ZLaVVcIuj82J8kIro4V6kDe0AUDFboUCwcg= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= -github.com/antonfisher/nested-logrus-formatter v1.3.0 h1:8zixYquU1Odk+vzAaAQPAdRh1ZjmUXNQ1T+dUBvlhVo= -github.com/antonfisher/nested-logrus-formatter v1.3.0/go.mod h1:6WTfyWFkBc9+zyBaKIqRrg/KwMqBbodBjgbHjDz7zjA= +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/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= 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= -github.com/cpuguy83/go-md2man/v2 v2.0.0 h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng4PGlyM= -github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= -github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= 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/UeauCommon v1.0.0 h1:ykhHNOcGpk6hLpVrGcMuKBbc+PgSmrwxCELnyFH9xKs= -github.com/free5gc/UeauCommon v1.0.0/go.mod h1:Ly9JlJN4c1uCALizCmEha1Nu78ibQjbpQvSrt04nGfw= -github.com/free5gc/http2_util v1.0.0 h1:0laMypHUNizAE5zsLoeJQq0R4XrfbvsLCW4NHCPpc44= -github.com/free5gc/http2_util v1.0.0/go.mod h1:GN2BCD8IINjtnAKYGwe+dEeTBRFEv4lQnZblFIIhbdE= -github.com/free5gc/http_wrapper v1.0.0 h1:NdnDHkItXxUzoxggiQsnR9SObBdi6KmwcN+QUJs4CoQ= -github.com/free5gc/http_wrapper v1.0.0/go.mod h1:vVArDqfCo7fvmYGi9WRPj4yurSu86GxRh3iQ70aq+OE= -github.com/free5gc/idgenerator v1.0.0 h1:e55Cn2p8dGCGYv5VoJ6oOsTj3SIVLToNLuS2CDOulZA= -github.com/free5gc/idgenerator v1.0.0/go.mod h1:+iGY7VUgUX88lqPhGAPGy/b2SxtNJMvymdJbNyjk4HU= -github.com/free5gc/logger_conf v1.0.0 h1:cMqqB8L4HjE57tP36mBmiVUPIcHv8Ayr12jKfeiwqZU= -github.com/free5gc/logger_conf v1.0.0/go.mod h1:DHecLXVV1qA5Z+lSoUvZdZ6tCtZidTNmtx99jsCfgLE= -github.com/free5gc/logger_util v1.0.0 h1:hLTCTnKlEqJURrBwooNFQLavWPdJzS0o9KGIYUNKdJI= -github.com/free5gc/logger_util v1.0.0/go.mod h1:TK/bAJbm/l2TMNmbsKn83+xUmDNqts69IEir/nCa8w0= -github.com/free5gc/milenage v1.0.0 h1:OMSdAuJpOW71REje4iahCVt0sBJa5FNmJK+iDQtYJzo= -github.com/free5gc/milenage v1.0.0/go.mod h1:QJYEh/7FTg2AXCo80BOrdwbAvm3q8OpVckR3SjwTvw8= -github.com/free5gc/openapi v1.0.0 h1:DaGVt05b1pSDBOailKAlLj6hAk6vunN0Nhzvl/xcWCY= -github.com/free5gc/openapi v1.0.0/go.mod h1:7OzxoWBj6KQgznMW2ZiUtZdCGY+t89v4wtgKLhluKgU= -github.com/free5gc/path_util v1.0.0 h1:vJPGTymaWtavz6fJ/7k6WKEYv5BQLAq/O04RP54sab0= -github.com/free5gc/path_util v1.0.0/go.mod h1:OpmcebEKrMPnH7Jg5lZ8y9ZWJNAjQ4l9FGWXUv58Mo0= -github.com/free5gc/util_3gpp v1.0.1 h1:Ds93Ll9e3tKT5Wz50W5pAKgYpjHR+oxOeNKqSCWP+zI= -github.com/free5gc/util_3gpp v1.0.1/go.mod h1:Pk9xccNPnppwcND6MJqR7duZhjuGl6VlMeONARxiLv4= -github.com/free5gc/version v1.0.0 h1:Kn4uOhyHT1IAgerBgWRHag4xLMDXrRsqubLeMv5Nb/w= -github.com/free5gc/version v1.0.0/go.mod h1:wOTwzjk7sqeysX1b/Z4x+pWBHFuZOPtQj3h+IJXSpmQ= +github.com/evanphx/json-patch v0.5.2/go.mod h1:ZWS5hhDbVDyob71nXKNL0+PWn6ToqBHMikGIFbs31qQ= +github.com/free5gc/openapi v1.0.4 h1:bC6oqXy8Z+3e532xLMFmrTHvdyv4sNGDPezQSslw5gQ= +github.com/free5gc/openapi v1.0.4/go.mod h1:KRCnnp0GeK0Bl4gnrX79cQAidKXNENf8VRdG0y9R0Fc= +github.com/free5gc/util v1.0.1 h1:A8bynjzZXkYMLOq9FN5J4Yg5mdjXhYoXc/FFFwSLPss= +github.com/free5gc/util v1.0.1/go.mod h1:VsA8FaZAxZW6eKzF/VXN2kuctl19Tj+NYH7ZxkZ+YCA= 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.6.3 h1:ahKqKTFpO5KTPHxWZjEdPScmYaGtLo8Y4DMHoEsnp14= -github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= +github.com/gin-gonic/gin v1.7.3 h1:aMBzLJ/GMEYmv1UWs2FFTcPISLrQH2mRgL9Glz8xows= +github.com/gin-gonic/gin v1.7.3/go.mod h1:jD2toBW3GZUr5UMcdrwQA10I7RuaFOl/SGeDjXkfUtY= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= @@ -90,10 +72,35 @@ github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8c github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no= github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= -github.com/go-playground/validator/v10 v10.2.0 h1:KgJ0snyC2R9VXYN2rneOtQcw5aHQB1Vv0sFl1UcHBOY= -github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI= github.com/go-playground/validator/v10 v10.4.1 h1:pH2c5ADXtd66mxoE0Zm9SUhxE20r7aM3F26W0hOn+GE= github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/gobuffalo/attrs v0.0.0-20190224210810-a9411de4debd/go.mod h1:4duuawTqi2wkkpB4ePgWMaai6/Kc6WEz83bhFwpHzj0= +github.com/gobuffalo/depgen v0.0.0-20190329151759-d478694a28d3/go.mod h1:3STtPUQYuzV0gBVOY3vy6CfMm/ljR4pABfrTeHNLHUY= +github.com/gobuffalo/depgen v0.1.0/go.mod h1:+ifsuy7fhi15RWncXQQKjWS9JPkdah5sZvtHc2RXGlg= +github.com/gobuffalo/envy v1.6.15/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI= +github.com/gobuffalo/envy v1.7.0/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI= +github.com/gobuffalo/flect v0.1.0/go.mod h1:d2ehjJqGOH/Kjqcoz+F7jHTBbmDb38yXA598Hb50EGs= +github.com/gobuffalo/flect v0.1.1/go.mod h1:8JCgGVbRjJhVgD6399mQr4fx5rRfGKVzFjbj6RE/9UI= +github.com/gobuffalo/flect v0.1.3/go.mod h1:8JCgGVbRjJhVgD6399mQr4fx5rRfGKVzFjbj6RE/9UI= +github.com/gobuffalo/genny v0.0.0-20190329151137-27723ad26ef9/go.mod h1:rWs4Z12d1Zbf19rlsn0nurr75KqhYp52EAGGxTbBhNk= +github.com/gobuffalo/genny v0.0.0-20190403191548-3ca520ef0d9e/go.mod h1:80lIj3kVJWwOrXWWMRzzdhW3DsrdjILVil/SFKBzF28= +github.com/gobuffalo/genny v0.1.0/go.mod h1:XidbUqzak3lHdS//TPu2OgiFB+51Ur5f7CSnXZ/JDvo= +github.com/gobuffalo/genny v0.1.1/go.mod h1:5TExbEyY48pfunL4QSXxlDOmdsD44RRq4mVZ0Ex28Xk= +github.com/gobuffalo/gitgen v0.0.0-20190315122116-cc086187d211/go.mod h1:vEHJk/E9DmhejeLeNt7UVvlSGv3ziL+djtTr3yyzcOw= +github.com/gobuffalo/gogen v0.0.0-20190315121717-8f38393713f5/go.mod h1:V9QVDIxsgKNZs6L2IYiGR8datgMhB577vzTDqypH360= +github.com/gobuffalo/gogen v0.1.0/go.mod h1:8NTelM5qd8RZ15VjQTFkAW6qOMx5wBbW4dSCS3BY8gg= +github.com/gobuffalo/gogen v0.1.1/go.mod h1:y8iBtmHmGc4qa3urIyo1shvOD8JftTtfcKi+71xfDNE= +github.com/gobuffalo/logger v0.0.0-20190315122211-86e12af44bc2/go.mod h1:QdxcLw541hSGtBnhUc4gaNIXRjiDppFGaDqzbrBd3v8= +github.com/gobuffalo/mapi v1.0.1/go.mod h1:4VAGh89y6rVOvm5A8fKFxYG+wIW6LO1FMTG9hnKStFc= +github.com/gobuffalo/mapi v1.0.2/go.mod h1:4VAGh89y6rVOvm5A8fKFxYG+wIW6LO1FMTG9hnKStFc= +github.com/gobuffalo/packd v0.0.0-20190315124812-a385830c7fc0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWeG2RIxq4= +github.com/gobuffalo/packd v0.1.0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWeG2RIxq4= +github.com/gobuffalo/packr/v2 v2.0.9/go.mod h1:emmyGweYTm6Kdper+iywB6YK5YzuKchGtJQZ0Odn4pQ= +github.com/gobuffalo/packr/v2 v2.2.0/go.mod h1:CaAwI0GPIAv+5wKLtv8Afwl+Cm78K/I/VCm/3ptBN+0= +github.com/gobuffalo/syncx v0.0.0-20190224160051-33c29581e754/go.mod h1:HhnNqWY95UYwwW3uSASeV7vtgYkT2t16hJgV3AEPUpw= +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/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -108,7 +115,6 @@ github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71 github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.3 h1:gyjaxf+svBWX08ZjK86iN9geUJF0H6gp2IRKX6Nf6/I= github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= @@ -118,9 +124,9 @@ github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrU github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.4.3 h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM= -github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= @@ -129,8 +135,9 @@ github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.1 h1:JFrFEBb2xKufg6XkJsJr+WbKb4FQlURi5RUcBveYu9k= github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM= +github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= @@ -142,22 +149,30 @@ github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hf github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y= -github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= +github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 h1:2VTzZjLZBgl62/EtslCrtky5vbi9dd7HrQPQIx6wqiw= github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542/go.mod h1:Ow0tF8D4Kplbc8s8sSb3V2oUCygFHVp8gC3Dn6U4MNI= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= +github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= github.com/json-iterator/go v1.1.9 h1:9yzud/Ht36ygwatGx56VwCZtlI/2AD15T1X2sjSuGns= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/json-iterator/go v1.1.10 h1:Kz6Cvnvv2wGdaG/V8yMvfkmNiXq9Ya2KUv4rouJJr68= -github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= +github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= +github.com/karrick/godirwalk v1.8.0/go.mod h1:H5KPZjojv4lE+QYImBI8xVtrBRgYrIVsaRPx4tDPEn4= +github.com/karrick/godirwalk v1.10.3/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/klauspost/compress v1.9.5/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= +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.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -165,64 +180,80 @@ 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.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= +github.com/markbates/oncer v0.0.0-20181203154359-bf2de49a0be2/go.mod h1:Ld9puTsIW75CHf65OeIOkyKbteujpZVXDpWK6YGZbxE= +github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kNSCBdG0= github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -github.com/mitchellh/mapstructure v1.4.0 h1:7ks8ZkOP5/ujthUsT07rNv+nkLXCQWKNHuwzOAesEks= -github.com/mitchellh/mapstructure v1.4.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mitchellh/mapstructure v1.4.1 h1:CpVNEelQCZBooIPDn+AR3NpivK/TIKU8bDxdASFVQag= +github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc= 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= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLDQ0W1YjYsBW+p8U2u7vzgW2SQVmlNazg= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= -github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32 h1:W6apQkHrMkS0Muv8G/TipAy/FJl/rCYT0+EuS8+Z0z4= github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uYLpLIr5fm8diHn0JbqRycJi6w0Ms= +github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE= +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= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rogpeppe/go-internal v1.2.2/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= -github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= -github.com/sirupsen/logrus v1.7.0 h1:ShrD1U9pZB12TX0cVy0DtePoCH97K8EtX+mg7ZARUtM= -github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= +github.com/sirupsen/logrus v1.4.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= +github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE= +github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= +github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= +github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= +github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= 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/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 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo= github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= -github.com/ugorji/go v1.2.1 h1:dz+JxTe7GZQdErTo7SREc1jQj/hFP1k7jyIAwODoW+k= -github.com/ugorji/go v1.2.1/go.mod h1:cSVypSfTLm2o9fKxXvQgn3rMmkPXovcWor6Qn5tbFmI= github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs= github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= -github.com/ugorji/go/codec v1.2.1 h1:/TRfW3XKkvWvmAYyCUaQlhoCDGjcvNR8xVVA/l5p/jQ= -github.com/ugorji/go/codec v1.2.1/go.mod h1:s/WxCRi46t8rA+fowL40EnmD7ec0XhR7ZypxeBNdzsM= 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/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= +github.com/xdg-go/scram v1.0.2/go.mod h1:1WAq6h33pAW+iRreB34OORO2Nf7qel3VV3fjBj+hCSs= +github.com/xdg-go/stringprep v1.0.2/go.mod h1:8F9zXuvzgwmyT5DUm4GUfZGDdT3W+LCvS6+da4O5kxM= +github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +go.mongodb.org/mongo-driver v1.7.1/go.mod h1:Q4oFMbo1+MSNqICAdYMlC/zSTrwCogR4R8NzkI+yfU8= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +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-20190422162423-af44ce270edf/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20201208171446-5f87f3452ae9 h1:sYNJzB4J8toYPQTM6pAkcmBRgw9SnQKP9oXCHfgy604= -golang.org/x/crypto v0.0.0-20201208171446-5f87f3452ae9/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -265,7 +296,6 @@ golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191021144547-ec77196f6094/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -280,29 +310,35 @@ golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/ golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20201209123823-ac852fbbde11 h1:lwlPPsmjDKK0J6eG6xDWd5XPehI0R024zxjDnw3esPA= -golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d h1:20cMwl2fHAzkJMEA+8J4JgqBQcQGzbisXo31MIeenXI= +golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= 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/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5 h1:Lm4OryKCca1vehdsWogr9N4t7NfZxLbJoc/H0w4K4S4= -golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210810183815-faf39c7919d5 h1:Ati8dO7+U7mxpkPSxBZQEvzHVUYB/MqCklCN8ig5w/o= +golang.org/x/oauth2 v0.0.0-20210810183815-faf39c7919d5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190412183630-56d357773e84/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190419153524-e8e3143a4f4a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190531175056-4c3a928424d2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -311,7 +347,6 @@ golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200116001909-b77594299b42 h1:vEOn+mP2zCOVzKckCZy6YsCtDblrpj/w7B9nxGNELpg= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -326,17 +361,17 @@ golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201211090839-8ad439b19e0f h1:QdHQnPce6K4XQewki9WNbG5KOROuDzqO3NaYjI1cXJ0= -golang.org/x/sys v0.0.0-20201211090839-8ad439b19e0f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da h1:b3NXsE2LusjYGGjL5bxEVZZORm/YEFFrWFjR8eFrw/c= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/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.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.4 h1:0YWbFKbhXG/wIiuHDSKpS0Iy7FSA+u45VtBMfQcFTTc= -golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -346,9 +381,14 @@ golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3 golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190329151228-23e29df326fe/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190416151739-9c9e1878f421/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190420181800-aa740d480789/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190531172133-b3315ee88b7d/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= @@ -406,9 +446,8 @@ google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7 google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.6 h1:lMO5rYAqUxkmaj76jAkRUvt5JZgFymx/+Q5Mzfivuhc= google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= -google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= @@ -461,14 +500,12 @@ google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpAD google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= -gopkg.in/h2non/gentleman.v1 v1.0.4/go.mod h1:JYuHVdFzS4MKOXe0o+chKJ4hCe6tqKKw9XH9YP6WFrg= -gopkg.in/h2non/gock.v1 v1.0.16 h1:F11k+OafeuFENsjei5t2vMTSTs9L62AdyTe4E1cgdG8= -gopkg.in/h2non/gock.v1 v1.0.16/go.mod h1:XVuDAssexPLwgxCLMvDTWNU5eqklsydR6I5phZ9oPB8= +gopkg.in/h2non/gock.v1 v1.1.2 h1:jBbHXgGBK/AoPVfJh5x4r/WxIrElvbLel8TCZkkZJoY= +gopkg.in/h2non/gock.v1 v1.1.2/go.mod h1:n7UGz/ckNChHiK05rDoiC4MYSunEC/lyaUm2WWaDva0= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= diff --git a/context/context.go b/internal/context/context.go similarity index 99% rename from context/context.go rename to internal/context/context.go index c827e06..a437e0d 100644 --- a/context/context.go +++ b/internal/context/context.go @@ -7,11 +7,11 @@ import ( "strings" "sync" - "github.com/free5gc/idgenerator" "github.com/free5gc/openapi" "github.com/free5gc/openapi/Nnrf_NFDiscovery" "github.com/free5gc/openapi/models" - "github.com/free5gc/util_3gpp/suci" + "github.com/free5gc/udm/pkg/suci" + "github.com/free5gc/util/idgenerator" ) var udmContext UDMContext @@ -30,7 +30,6 @@ func init() { } type UDMContext struct { - Name string NfId string GroupId string SBIPort int diff --git a/logger/logger.go b/internal/logger/logger.go similarity index 71% rename from logger/logger.go rename to internal/logger/logger.go index 78dd00b..03fdd26 100644 --- a/logger/logger.go +++ b/internal/logger/logger.go @@ -7,8 +7,7 @@ import ( formatter "github.com/antonfisher/nested-logrus-formatter" "github.com/sirupsen/logrus" - "github.com/free5gc/logger_conf" - "github.com/free5gc/logger_util" + logger_util "github.com/free5gc/util/logger" ) var ( @@ -24,6 +23,7 @@ var ( PpLog *logrus.Entry EeLog *logrus.Entry UtilLog *logrus.Entry + SuciLog *logrus.Entry CallbackLog *logrus.Entry ContextLog *logrus.Entry ConsumerLog *logrus.Entry @@ -42,16 +42,6 @@ func init() { FieldsOrder: []string{"component", "category"}, } - free5gcLogHook, err := logger_util.NewFileHook(logger_conf.Free5gcLogFile, os.O_CREATE|os.O_APPEND|os.O_RDWR, 0o666) - if err == nil { - log.Hooks.Add(free5gcLogHook) - } - - selfLogHook, err := logger_util.NewFileHook(logger_conf.NfLogDir+"udm.log", os.O_CREATE|os.O_APPEND|os.O_RDWR, 0o666) - if err == nil { - log.Hooks.Add(selfLogHook) - } - AppLog = log.WithFields(logrus.Fields{"component": "UDM", "category": "App"}) InitLog = log.WithFields(logrus.Fields{"component": "UDM", "category": "Init"}) CfgLog = log.WithFields(logrus.Fields{"component": "UDM", "category": "CFG"}) @@ -63,16 +53,43 @@ func init() { PpLog = log.WithFields(logrus.Fields{"component": "UDM", "category": "PP"}) EeLog = log.WithFields(logrus.Fields{"component": "UDM", "category": "EE"}) UtilLog = log.WithFields(logrus.Fields{"component": "UDM", "category": "Util"}) + SuciLog = log.WithFields(logrus.Fields{"component": "UDM", "category": "Suci"}) CallbackLog = log.WithFields(logrus.Fields{"component": "UDM", "category": "CB"}) ContextLog = log.WithFields(logrus.Fields{"component": "UDM", "category": "CTX"}) ConsumerLog = log.WithFields(logrus.Fields{"component": "UDM", "category": "Consumer"}) GinLog = log.WithFields(logrus.Fields{"component": "UDM", "category": "GIN"}) } +func LogFileHook(logNfPath string, log5gcPath string) error { + if fullPath, err := logger_util.CreateFree5gcLogFile(log5gcPath); err == nil { + if fullPath != "" { + free5gcLogHook, hookErr := logger_util.NewFileHook(fullPath, os.O_CREATE|os.O_APPEND|os.O_RDWR, 0o666) + if hookErr != nil { + return hookErr + } + log.Hooks.Add(free5gcLogHook) + } + } else { + return err + } + + if fullPath, err := logger_util.CreateNfLogFile(logNfPath, "udm.log"); err == nil { + selfLogHook, hookErr := logger_util.NewFileHook(fullPath, os.O_CREATE|os.O_APPEND|os.O_RDWR, 0o666) + if hookErr != nil { + return hookErr + } + log.Hooks.Add(selfLogHook) + } else { + return err + } + + return nil +} + func SetLogLevel(level logrus.Level) { log.SetLevel(level) } -func SetReportCaller(set bool) { - log.SetReportCaller(set) +func SetReportCaller(enable bool) { + log.SetReportCaller(enable) } diff --git a/consumer/nf_discovery.go b/internal/sbi/consumer/nf_discovery.go similarity index 93% rename from consumer/nf_discovery.go rename to internal/sbi/consumer/nf_discovery.go index 8edbf74..79c441e 100644 --- a/consumer/nf_discovery.go +++ b/internal/sbi/consumer/nf_discovery.go @@ -7,9 +7,9 @@ import ( "github.com/free5gc/openapi/Nnrf_NFDiscovery" "github.com/free5gc/openapi/models" - udm_context "github.com/free5gc/udm/context" - "github.com/free5gc/udm/logger" - "github.com/free5gc/udm/util" + udm_context "github.com/free5gc/udm/internal/context" + "github.com/free5gc/udm/internal/logger" + "github.com/free5gc/udm/internal/util" ) const ( diff --git a/consumer/nf_management.go b/internal/sbi/consumer/nf_management.go similarity index 97% rename from consumer/nf_management.go rename to internal/sbi/consumer/nf_management.go index 3af460e..9e4abee 100644 --- a/consumer/nf_management.go +++ b/internal/sbi/consumer/nf_management.go @@ -10,8 +10,8 @@ import ( "github.com/free5gc/openapi" "github.com/free5gc/openapi/Nnrf_NFManagement" "github.com/free5gc/openapi/models" - udm_context "github.com/free5gc/udm/context" - "github.com/free5gc/udm/logger" + udm_context "github.com/free5gc/udm/internal/context" + "github.com/free5gc/udm/internal/logger" ) func BuildNFInstance(udmContext *udm_context.UDMContext) (profile models.NfProfile, err error) { diff --git a/eventexposure/api_create_ee_subscription.go b/internal/sbi/eventexposure/api_create_ee_subscription.go similarity index 89% rename from eventexposure/api_create_ee_subscription.go rename to internal/sbi/eventexposure/api_create_ee_subscription.go index 66b7dba..3f876b2 100644 --- a/eventexposure/api_create_ee_subscription.go +++ b/internal/sbi/eventexposure/api_create_ee_subscription.go @@ -14,11 +14,11 @@ import ( "github.com/gin-gonic/gin" - "github.com/free5gc/http_wrapper" "github.com/free5gc/openapi" "github.com/free5gc/openapi/models" - "github.com/free5gc/udm/logger" - "github.com/free5gc/udm/producer" + "github.com/free5gc/udm/internal/logger" + "github.com/free5gc/udm/internal/sbi/producer" + "github.com/free5gc/util/httpwrapper" ) // HTTPCreateEeSubscription - Subscribe @@ -51,7 +51,7 @@ func HTTPCreateEeSubscription(c *gin.Context) { return } - req := http_wrapper.NewRequest(c.Request, eeSubscriptionReq) + req := httpwrapper.NewRequest(c.Request, eeSubscriptionReq) req.Params["ueIdentity"] = c.Params.ByName("ueIdentity") rsp := producer.HandleCreateEeSubscription(req) diff --git a/eventexposure/api_delete_ee_subscription.go b/internal/sbi/eventexposure/api_delete_ee_subscription.go similarity index 79% rename from eventexposure/api_delete_ee_subscription.go rename to internal/sbi/eventexposure/api_delete_ee_subscription.go index cc048d0..8b7343e 100644 --- a/eventexposure/api_delete_ee_subscription.go +++ b/internal/sbi/eventexposure/api_delete_ee_subscription.go @@ -12,13 +12,13 @@ package eventexposure import ( "github.com/gin-gonic/gin" - "github.com/free5gc/http_wrapper" - "github.com/free5gc/udm/producer" + "github.com/free5gc/udm/internal/sbi/producer" + "github.com/free5gc/util/httpwrapper" ) // DeleteEeSubscription - Unsubscribe func HTTPDeleteEeSubscription(c *gin.Context) { - req := http_wrapper.NewRequest(c.Request, nil) + req := httpwrapper.NewRequest(c.Request, nil) req.Params["ueIdentity"] = c.Params.ByName("ueIdentity") req.Params["subscriptionID"] = c.Params.ByName("subscriptionId") diff --git a/eventexposure/api_update_ee_subscription.go b/internal/sbi/eventexposure/api_update_ee_subscription.go similarity index 90% rename from eventexposure/api_update_ee_subscription.go rename to internal/sbi/eventexposure/api_update_ee_subscription.go index 56d3b7d..f310ce2 100644 --- a/eventexposure/api_update_ee_subscription.go +++ b/internal/sbi/eventexposure/api_update_ee_subscription.go @@ -14,11 +14,11 @@ import ( "github.com/gin-gonic/gin" - "github.com/free5gc/http_wrapper" "github.com/free5gc/openapi" "github.com/free5gc/openapi/models" - "github.com/free5gc/udm/logger" - "github.com/free5gc/udm/producer" + "github.com/free5gc/udm/internal/logger" + "github.com/free5gc/udm/internal/sbi/producer" + "github.com/free5gc/util/httpwrapper" ) // UpdateEeSubscription - Patch @@ -51,7 +51,7 @@ func HTTPUpdateEeSubscription(c *gin.Context) { return } - req := http_wrapper.NewRequest(c.Request, patchList) + req := httpwrapper.NewRequest(c.Request, patchList) req.Params["ueIdentity"] = c.Params.ByName("ueIdentity") req.Params["subscriptionID"] = c.Params.ByName("subscriptionId") diff --git a/eventexposure/routers.go b/internal/sbi/eventexposure/routers.go similarity index 95% rename from eventexposure/routers.go rename to internal/sbi/eventexposure/routers.go index 0f2c798..281f4ec 100644 --- a/eventexposure/routers.go +++ b/internal/sbi/eventexposure/routers.go @@ -15,8 +15,8 @@ import ( "github.com/gin-gonic/gin" - "github.com/free5gc/logger_util" - "github.com/free5gc/udm/logger" + "github.com/free5gc/udm/internal/logger" + logger_util "github.com/free5gc/util/logger" ) // Route is the information for every URI. diff --git a/httpcallback/data_change_notification_to_nf.go b/internal/sbi/httpcallback/data_change_notification_to_nf.go similarity index 89% rename from httpcallback/data_change_notification_to_nf.go rename to internal/sbi/httpcallback/data_change_notification_to_nf.go index 71f46e7..dfc6be4 100644 --- a/httpcallback/data_change_notification_to_nf.go +++ b/internal/sbi/httpcallback/data_change_notification_to_nf.go @@ -5,11 +5,11 @@ import ( "github.com/gin-gonic/gin" - "github.com/free5gc/http_wrapper" "github.com/free5gc/openapi" "github.com/free5gc/openapi/models" - "github.com/free5gc/udm/logger" - "github.com/free5gc/udm/producer" + "github.com/free5gc/udm/internal/logger" + "github.com/free5gc/udm/internal/sbi/producer" + "github.com/free5gc/util/httpwrapper" ) func HTTPDataChangeNotificationToNF(c *gin.Context) { @@ -42,7 +42,7 @@ func HTTPDataChangeNotificationToNF(c *gin.Context) { return } - req := http_wrapper.NewRequest(c.Request, dataChangeNotify) + req := httpwrapper.NewRequest(c.Request, dataChangeNotify) req.Params["supi"] = c.Params.ByName("supi") rsp := producer.HandleDataChangeNotificationToNFRequest(req) diff --git a/httpcallback/router.go b/internal/sbi/httpcallback/router.go similarity index 94% rename from httpcallback/router.go rename to internal/sbi/httpcallback/router.go index ff0eeb7..2d926b6 100644 --- a/httpcallback/router.go +++ b/internal/sbi/httpcallback/router.go @@ -7,8 +7,8 @@ import ( "github.com/gin-gonic/gin" "github.com/sirupsen/logrus" - "github.com/free5gc/logger_util" - "github.com/free5gc/udm/logger" + "github.com/free5gc/udm/internal/logger" + logger_util "github.com/free5gc/util/logger" ) var HttpLog *logrus.Entry diff --git a/parameterprovision/api_subscription_data_update.go b/internal/sbi/parameterprovision/api_subscription_data_update.go similarity index 90% rename from parameterprovision/api_subscription_data_update.go rename to internal/sbi/parameterprovision/api_subscription_data_update.go index 61f852c..aec820c 100644 --- a/parameterprovision/api_subscription_data_update.go +++ b/internal/sbi/parameterprovision/api_subscription_data_update.go @@ -14,11 +14,11 @@ import ( "github.com/gin-gonic/gin" - "github.com/free5gc/http_wrapper" "github.com/free5gc/openapi" "github.com/free5gc/openapi/models" - "github.com/free5gc/udm/logger" - "github.com/free5gc/udm/producer" + "github.com/free5gc/udm/internal/logger" + "github.com/free5gc/udm/internal/sbi/producer" + "github.com/free5gc/util/httpwrapper" ) // Update - provision parameters @@ -53,7 +53,7 @@ func HTTPUpdate(c *gin.Context) { return } - req := http_wrapper.NewRequest(c.Request, ppDataReq) + req := httpwrapper.NewRequest(c.Request, ppDataReq) req.Params["gspi"] = c.Params.ByName("gpsi") rsp := producer.HandleUpdateRequest(req) diff --git a/parameterprovision/api_subscription_data_update_test.go b/internal/sbi/parameterprovision/api_subscription_data_update_test.go similarity index 100% rename from parameterprovision/api_subscription_data_update_test.go rename to internal/sbi/parameterprovision/api_subscription_data_update_test.go diff --git a/parameterprovision/routers.go b/internal/sbi/parameterprovision/routers.go similarity index 94% rename from parameterprovision/routers.go rename to internal/sbi/parameterprovision/routers.go index e17df06..601518a 100644 --- a/parameterprovision/routers.go +++ b/internal/sbi/parameterprovision/routers.go @@ -15,8 +15,8 @@ import ( "github.com/gin-gonic/gin" - "github.com/free5gc/logger_util" - "github.com/free5gc/udm/logger" + "github.com/free5gc/udm/internal/logger" + logger_util "github.com/free5gc/util/logger" ) // Route is the information for every URI. diff --git a/producer/callback.go b/internal/sbi/producer/callback.go similarity index 58% rename from producer/callback.go rename to internal/sbi/producer/callback.go index 381f38d..c4c84ca 100644 --- a/producer/callback.go +++ b/internal/sbi/producer/callback.go @@ -3,14 +3,14 @@ package producer import ( "net/http" - "github.com/free5gc/http_wrapper" "github.com/free5gc/openapi/models" - "github.com/free5gc/udm/logger" - "github.com/free5gc/udm/producer/callback" + "github.com/free5gc/udm/internal/logger" + "github.com/free5gc/udm/internal/sbi/producer/callback" + "github.com/free5gc/util/httpwrapper" ) // HandleDataChangeNotificationToNFRequest ... Send Data Change Notification -func HandleDataChangeNotificationToNFRequest(request *http_wrapper.Request) *http_wrapper.Response { +func HandleDataChangeNotificationToNFRequest(request *httpwrapper.Request) *httpwrapper.Response { // step 1: log logger.CallbackLog.Infof("Handle DataChangeNotificationToNF") @@ -22,8 +22,8 @@ func HandleDataChangeNotificationToNFRequest(request *http_wrapper.Request) *htt // step 4: process the return value from step 3 if problemDetails != nil { - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } else { - return http_wrapper.NewResponse(http.StatusNoContent, nil, nil) + return httpwrapper.NewResponse(http.StatusNoContent, nil, nil) } } diff --git a/producer/callback/callback.go b/internal/sbi/producer/callback/callback.go similarity index 96% rename from producer/callback/callback.go rename to internal/sbi/producer/callback/callback.go index 14d47d8..b0ecc4f 100644 --- a/producer/callback/callback.go +++ b/internal/sbi/producer/callback/callback.go @@ -7,8 +7,8 @@ import ( "github.com/free5gc/openapi/Nudm_SubscriberDataManagement" "github.com/free5gc/openapi/Nudm_UEContextManagement" "github.com/free5gc/openapi/models" - udm_context "github.com/free5gc/udm/context" - "github.com/free5gc/udm/logger" + udm_context "github.com/free5gc/udm/internal/context" + "github.com/free5gc/udm/internal/logger" ) func DataChangeNotificationProcedure(notifyItems []models.NotifyItem, supi string) *models.ProblemDetails { diff --git a/producer/event_exposure.go b/internal/sbi/producer/event_exposure.go similarity index 89% rename from producer/event_exposure.go rename to internal/sbi/producer/event_exposure.go index 8880476..0c5a045 100644 --- a/producer/event_exposure.go +++ b/internal/sbi/producer/event_exposure.go @@ -5,13 +5,13 @@ import ( "strconv" "strings" - "github.com/free5gc/http_wrapper" "github.com/free5gc/openapi/models" - udm_context "github.com/free5gc/udm/context" - "github.com/free5gc/udm/logger" + udm_context "github.com/free5gc/udm/internal/context" + "github.com/free5gc/udm/internal/logger" + "github.com/free5gc/util/httpwrapper" ) -func HandleCreateEeSubscription(request *http_wrapper.Request) *http_wrapper.Response { +func HandleCreateEeSubscription(request *httpwrapper.Request) *httpwrapper.Response { logger.EeLog.Infoln("Handle Create EE Subscription") eesubscription := request.Body.(models.EeSubscription) @@ -19,15 +19,15 @@ func HandleCreateEeSubscription(request *http_wrapper.Request) *http_wrapper.Res createdEESubscription, problemDetails := CreateEeSubscriptionProcedure(ueIdentity, eesubscription) if createdEESubscription != nil { - return http_wrapper.NewResponse(http.StatusCreated, nil, createdEESubscription) + return httpwrapper.NewResponse(http.StatusCreated, nil, createdEESubscription) } else if problemDetails != nil { - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } else { problemDetails = &models.ProblemDetails{ Status: http.StatusInternalServerError, Cause: "UNSPECIFIED_NF_FAILURE", } - return http_wrapper.NewResponse(http.StatusInternalServerError, nil, problemDetails) + return httpwrapper.NewResponse(http.StatusInternalServerError, nil, problemDetails) } } @@ -124,12 +124,12 @@ func CreateEeSubscriptionProcedure(ueIdentity string, } } -func HandleDeleteEeSubscription(request *http_wrapper.Request) *http_wrapper.Response { +func HandleDeleteEeSubscription(request *httpwrapper.Request) *httpwrapper.Response { ueIdentity := request.Params["ueIdentity"] subscriptionID := request.Params["subscriptionID"] DeleteEeSubscriptionProcedure(ueIdentity, subscriptionID) - return http_wrapper.NewResponse(http.StatusNoContent, nil, nil) + return httpwrapper.NewResponse(http.StatusNoContent, nil, nil) } // TODO: complete this procedure based on TS 29503 5.5 @@ -165,7 +165,7 @@ func DeleteEeSubscriptionProcedure(ueIdentity string, subscriptionID string) { } } -func HandleUpdateEeSubscription(request *http_wrapper.Request) *http_wrapper.Response { +func HandleUpdateEeSubscription(request *httpwrapper.Request) *httpwrapper.Response { logger.EeLog.Infoln("Handle Update EE subscription") logger.EeLog.Warnln("Update EE Subscription is not implemented") @@ -175,9 +175,9 @@ func HandleUpdateEeSubscription(request *http_wrapper.Request) *http_wrapper.Res problemDetails := UpdateEeSubscriptionProcedure(ueIdentity, subscriptionID, patchList) if problemDetails != nil { - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } else { - return http_wrapper.NewResponse(http.StatusNoContent, nil, nil) + return httpwrapper.NewResponse(http.StatusNoContent, nil, nil) } } diff --git a/producer/generate_auth_data.go b/internal/sbi/producer/generate_auth_data.go similarity index 77% rename from producer/generate_auth_data.go rename to internal/sbi/producer/generate_auth_data.go index 5ba805d..a6857c1 100644 --- a/producer/generate_auth_data.go +++ b/internal/sbi/producer/generate_auth_data.go @@ -14,16 +14,16 @@ import ( "github.com/antihax/optional" - "github.com/free5gc/UeauCommon" - "github.com/free5gc/http_wrapper" - "github.com/free5gc/milenage" "github.com/free5gc/openapi" "github.com/free5gc/openapi/Nudr_DataRepository" "github.com/free5gc/openapi/models" - udm_context "github.com/free5gc/udm/context" - "github.com/free5gc/udm/logger" - "github.com/free5gc/udm/util" - "github.com/free5gc/util_3gpp/suci" + udm_context "github.com/free5gc/udm/internal/context" + "github.com/free5gc/udm/internal/logger" + "github.com/free5gc/udm/internal/util" + "github.com/free5gc/udm/pkg/suci" + "github.com/free5gc/util/httpwrapper" + "github.com/free5gc/util/milenage" + "github.com/free5gc/util/ueauth" ) const ( @@ -36,41 +36,36 @@ const ( const ( authenticationRejected string = "AUTHENTICATION_REJECTED" + resyncAMF string = "0000" ) func aucSQN(opc, k, auts, rand []byte) ([]byte, []byte) { AK, SQNms := make([]byte, 6), make([]byte, 6) macS := make([]byte, 8) ConcSQNms := auts[:6] - AMF, err := hex.DecodeString("0000") + AMF, err := hex.DecodeString(resyncAMF) if err != nil { return nil, nil } - logger.UeauLog.Traceln("ConcSQNms", ConcSQNms) + logger.UeauLog.Tracef("aucSQN: ConcSQNms=[%x]", ConcSQNms) err = milenage.F2345(opc, k, rand, nil, nil, nil, nil, AK) if err != nil { - logger.UeauLog.Errorln("milenage F2345 err ", err) + logger.UeauLog.Errorln("aucSQN milenage F2345 err:", err) } for i := 0; i < 6; i++ { SQNms[i] = AK[i] ^ ConcSQNms[i] } - // fmt.Printf("opc=%x\n", opc) - // fmt.Printf("k=%x\n", k) - // fmt.Printf("rand=%x\n", rand) - // fmt.Printf("AMF %x\n", AMF) - // fmt.Printf("SQNms %x\n", SQNms) + logger.UeauLog.Tracef("aucSQN: opc=[%x], k=[%x], rand=[%x], AMF=[%x], SQNms=[%x]\n", opc, k, rand, AMF, SQNms) + // The AMF used to calculate MAC-S assumes a dummy value of all zeros err = milenage.F1(opc, k, rand, SQNms, AMF, nil, macS) if err != nil { - logger.UeauLog.Errorln("milenage F1 err ", err) + logger.UeauLog.Errorln("aucSQN milenage F1 err:", err) } - // fmt.Printf("macS %x\n", macS) - - logger.UeauLog.Traceln("SQNms", SQNms) - logger.UeauLog.Traceln("macS", macS) + logger.UeauLog.Tracef("aucSQN: macS=[%x]\n", macS) return SQNms, macS } @@ -83,7 +78,7 @@ func strictHex(s string, n int) string { } } -func HandleGenerateAuthDataRequest(request *http_wrapper.Request) *http_wrapper.Response { +func HandleGenerateAuthDataRequest(request *httpwrapper.Request) *httpwrapper.Response { // step 1: log logger.UeauLog.Infoln("Handle GenerateAuthDataRequest") @@ -97,18 +92,18 @@ func HandleGenerateAuthDataRequest(request *http_wrapper.Request) *http_wrapper. // step 4: process the return value from step 3 if response != nil { // status code is based on SPEC, and option headers - return http_wrapper.NewResponse(http.StatusOK, nil, response) + return httpwrapper.NewResponse(http.StatusOK, nil, response) } else if problemDetails != nil { - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } problemDetails = &models.ProblemDetails{ Status: http.StatusForbidden, Cause: "UNSPECIFIED", } - return http_wrapper.NewResponse(http.StatusForbidden, nil, problemDetails) + return httpwrapper.NewResponse(http.StatusForbidden, nil, problemDetails) } -func HandleConfirmAuthDataRequest(request *http_wrapper.Request) *http_wrapper.Response { +func HandleConfirmAuthDataRequest(request *httpwrapper.Request) *httpwrapper.Response { logger.UeauLog.Infoln("Handle ConfirmAuthDataRequest") authEvent := request.Body.(models.AuthEvent) @@ -117,9 +112,9 @@ func HandleConfirmAuthDataRequest(request *http_wrapper.Request) *http_wrapper.R problemDetails := ConfirmAuthDataProcedure(authEvent, supi) if problemDetails != nil { - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } else { - return http_wrapper.NewResponse(http.StatusCreated, nil, nil) + return httpwrapper.NewResponse(http.StatusCreated, nil, nil) } } @@ -141,7 +136,7 @@ func ConfirmAuthDataProcedure(authEvent models.AuthEvent, supi string) (problemD Detail: err.Error(), } - logger.UeauLog.Errorln("[ConfirmAuth] ", err.Error()) + logger.UeauLog.Errorln("ConfirmAuth err:", err.Error()) return problemDetails } defer func() { @@ -171,7 +166,7 @@ func GenerateAuthDataProcedure(authInfoRequest models.AuthenticationInfoRequest, return nil, problemDetails } - logger.UeauLog.Tracef("supi conversion => %s\n", supi) + logger.UeauLog.Tracef("supi conversion => [%s]", supi) client, err := createUDMClientToUDR(supi) if err != nil { @@ -201,19 +196,15 @@ func GenerateAuthDataProcedure(authInfoRequest models.AuthenticationInfoRequest, */ hasK, hasOP, hasOPC := false, false, false - var kStr, opStr, opcStr string - - k, op, opc := make([]byte, 16), make([]byte, 16), make([]byte, 16) - - logger.UeauLog.Traceln("K", k) + var k, op, opc []byte if authSubs.PermanentKey != nil { kStr = authSubs.PermanentKey.PermanentKeyValue if len(kStr) == keyStrLen { k, err = hex.DecodeString(kStr) if err != nil { - logger.UeauLog.Errorln("err", err) + logger.UeauLog.Errorln("err:", err) } else { hasK = true } @@ -242,7 +233,7 @@ func GenerateAuthDataProcedure(authInfoRequest models.AuthenticationInfoRequest, if len(opStr) == opStrLen { op, err = hex.DecodeString(opStr) if err != nil { - logger.UeauLog.Errorln("err", err) + logger.UeauLog.Errorln("err:", err) } else { hasOP = true } @@ -267,7 +258,7 @@ func GenerateAuthDataProcedure(authInfoRequest models.AuthenticationInfoRequest, if len(opcStr) == opcStrLen { opc, err = hex.DecodeString(opcStr) if err != nil { - logger.UeauLog.Errorln("err", err) + logger.UeauLog.Errorln("err:", err) } else { hasOPC = true } @@ -291,7 +282,7 @@ func GenerateAuthDataProcedure(authInfoRequest models.AuthenticationInfoRequest, if hasK && hasOP { opc, err = milenage.GenerateOPC(k, op) if err != nil { - logger.UeauLog.Errorln("milenage GenerateOPC err ", err) + logger.UeauLog.Errorln("milenage GenerateOPC err:", err) } } else { problemDetails = &models.ProblemDetails{ @@ -314,12 +305,11 @@ func GenerateAuthDataProcedure(authInfoRequest models.AuthenticationInfoRequest, Detail: err.Error(), } - logger.UeauLog.Errorln("err", err) + logger.UeauLog.Errorln("err:", err) return nil, problemDetails } - logger.UeauLog.Traceln("sqn", sqn) - // fmt.Printf("K=%x\nsqn=%x\nOP=%x\nOPC=%x\n", K, sqn, OP, OPC) + logger.UeauLog.Tracef("K=[%x], sqn=[%x], OP=[%x], OPC=[%x]", k, sqn, op, opc) RAND := make([]byte, 16) _, err = cryptoRand.Read(RAND) @@ -330,7 +320,7 @@ func GenerateAuthDataProcedure(authInfoRequest models.AuthenticationInfoRequest, Detail: err.Error(), } - logger.UeauLog.Errorln("err", err) + logger.UeauLog.Errorln("err:", err) return nil, problemDetails } @@ -342,19 +332,16 @@ func GenerateAuthDataProcedure(authInfoRequest models.AuthenticationInfoRequest, Detail: err.Error(), } - logger.UeauLog.Errorln("err", err) + logger.UeauLog.Errorln("err:", err) return nil, problemDetails } - // fmt.Printf("RAND=%x\nAMF=%x\n", RAND, AMF) - - // for test - // RAND, _ = hex.DecodeString(TestGenAuthData.MilenageTestSet19.RAND) - // AMF, _ = hex.DecodeString(TestGenAuthData.MilenageTestSet19.AMF) - // fmt.Printf("For test: RAND=%x, AMF=%x\n", RAND, AMF) + logger.UeauLog.Tracef("RAND=[%x], AMF=[%x]", RAND, AMF) - // re-synchroniztion + // re-synchronization if authInfoRequest.ResynchronizationInfo != nil { + logger.UeauLog.Infof("Authentication re-synchronization") + Auts, deCodeErr := hex.DecodeString(authInfoRequest.ResynchronizationInfo.Auts) if deCodeErr != nil { problemDetails = &models.ProblemDetails{ @@ -363,7 +350,7 @@ func GenerateAuthDataProcedure(authInfoRequest models.AuthenticationInfoRequest, Detail: deCodeErr.Error(), } - logger.UeauLog.Errorln("err", deCodeErr) + logger.UeauLog.Errorln("err:", deCodeErr) return nil, problemDetails } @@ -375,7 +362,7 @@ func GenerateAuthDataProcedure(authInfoRequest models.AuthenticationInfoRequest, Detail: deCodeErr.Error(), } - logger.UeauLog.Errorln("err", deCodeErr) + logger.UeauLog.Errorln("err:", deCodeErr) return nil, problemDetails } @@ -389,14 +376,14 @@ func GenerateAuthDataProcedure(authInfoRequest models.AuthenticationInfoRequest, Detail: deCodeErr.Error(), } - logger.UeauLog.Errorln("err", deCodeErr) + logger.UeauLog.Errorln("err:", deCodeErr) return nil, problemDetails } // increment sqn authSubs.SequenceNumber bigSQN := big.NewInt(0) sqnStr = hex.EncodeToString(SQNms) - fmt.Printf("SQNstr %s\n", sqnStr) + logger.UeauLog.Tracef("SQNstr=[%s]", sqnStr) bigSQN.SetString(sqnStr, 16) bigInc := big.NewInt(ind + 1) @@ -429,7 +416,7 @@ func GenerateAuthDataProcedure(authInfoRequest models.AuthenticationInfoRequest, Detail: err.Error(), } - logger.UeauLog.Errorln("err", err) + logger.UeauLog.Errorln("err:", err) return nil, problemDetails } @@ -458,7 +445,7 @@ func GenerateAuthDataProcedure(authInfoRequest models.AuthenticationInfoRequest, Detail: err.Error(), } - logger.UeauLog.Errorln("update sqn error", err) + logger.UeauLog.Errorln("update sqn error:", err) return nil, problemDetails } defer func() { @@ -476,27 +463,27 @@ func GenerateAuthDataProcedure(authInfoRequest models.AuthenticationInfoRequest, // Generate macA, macS err = milenage.F1(opc, k, RAND, sqn, AMF, macA, macS) if err != nil { - logger.UeauLog.Errorln("milenage F1 err ", err) + logger.UeauLog.Errorln("milenage F1 err:", err) } // Generate RES, CK, IK, AK, AKstar // RES == XRES (expected RES) for server err = milenage.F2345(opc, k, RAND, RES, CK, IK, AK, AKstar) if err != nil { - logger.UeauLog.Errorln("milenage F2345 err ", err) + logger.UeauLog.Errorln("milenage F2345 err:", err) } - // fmt.Printf("milenage RES = %s\n", hex.EncodeToString(RES)) + logger.UeauLog.Tracef("milenage RES=[%s]", hex.EncodeToString(RES)) // Generate AUTN - // fmt.Printf("SQN=%x\nAK =%x\n", SQN, AK) - // fmt.Printf("AMF=%x, macA=%x\n", AMF, macA) + logger.UeauLog.Tracef("SQN=[%x], AK=[%x]", sqn, AK) + logger.UeauLog.Tracef("AMF=[%x], macA=[%x]", AMF, macA) SQNxorAK := make([]byte, 6) for i := 0; i < len(sqn); i++ { SQNxorAK[i] = sqn[i] ^ AK[i] } - // fmt.Printf("SQN xor AK = %x\n", SQNxorAK) + logger.UeauLog.Tracef("SQN xor AK=[%x]", SQNxorAK) AUTN := append(append(SQNxorAK, AMF...), macA...) - fmt.Printf("AUTN = %x\n", AUTN) + logger.UeauLog.Tracef("AUTN=[%x]", AUTN) var av models.AuthenticationVector if authSubs.AuthenticationMethod == models.AuthMethod__5_G_AKA { @@ -504,22 +491,28 @@ func GenerateAuthDataProcedure(authInfoRequest models.AuthenticationInfoRequest, // derive XRES* key := append(CK, IK...) - FC := UeauCommon.FC_FOR_RES_STAR_XRES_STAR_DERIVATION + FC := ueauth.FC_FOR_RES_STAR_XRES_STAR_DERIVATION P0 := []byte(authInfoRequest.ServingNetworkName) P1 := RAND P2 := RES - kdfValForXresStar := UeauCommon.GetKDFValue( - key, FC, P0, UeauCommon.KDFLen(P0), P1, UeauCommon.KDFLen(P1), P2, UeauCommon.KDFLen(P2)) + kdfValForXresStar, err := ueauth.GetKDFValue( + key, FC, P0, ueauth.KDFLen(P0), P1, ueauth.KDFLen(P1), P2, ueauth.KDFLen(P2)) + if err != nil { + logger.UeauLog.Errorf("Get kdfValForXresStar err: %+v", err) + } xresStar := kdfValForXresStar[len(kdfValForXresStar)/2:] - // fmt.Printf("xresStar = %x\n", xresStar) + logger.UeauLog.Tracef("xresStar=[%x]", xresStar) // derive Kausf - FC = UeauCommon.FC_FOR_KAUSF_DERIVATION + FC = ueauth.FC_FOR_KAUSF_DERIVATION P0 = []byte(authInfoRequest.ServingNetworkName) P1 = SQNxorAK - kdfValForKausf := UeauCommon.GetKDFValue(key, FC, P0, UeauCommon.KDFLen(P0), P1, UeauCommon.KDFLen(P1)) - // fmt.Printf("Kausf = %x\n", kdfValForKausf) + kdfValForKausf, err := ueauth.GetKDFValue(key, FC, P0, ueauth.KDFLen(P0), P1, ueauth.KDFLen(P1)) + if err != nil { + logger.UeauLog.Errorf("Get kdfValForKausf err: %+v", err) + } + logger.UeauLog.Tracef("Kausf=[%x]", kdfValForKausf) // Fill in rand, xresStar, autn, kausf av.Rand = hex.EncodeToString(RAND) @@ -532,11 +525,14 @@ func GenerateAuthDataProcedure(authInfoRequest models.AuthenticationInfoRequest, // derive CK' and IK' key := append(CK, IK...) - FC := UeauCommon.FC_FOR_CK_PRIME_IK_PRIME_DERIVATION + FC := ueauth.FC_FOR_CK_PRIME_IK_PRIME_DERIVATION P0 := []byte(authInfoRequest.ServingNetworkName) P1 := SQNxorAK - kdfVal := UeauCommon.GetKDFValue(key, FC, P0, UeauCommon.KDFLen(P0), P1, UeauCommon.KDFLen(P1)) - // fmt.Printf("kdfVal = %x (len = %d)\n", kdfVal, len(kdfVal)) + kdfVal, err := ueauth.GetKDFValue(key, FC, P0, ueauth.KDFLen(P0), P1, ueauth.KDFLen(P1)) + if err != nil { + logger.UeauLog.Errorf("Get kdfVal err: %+v", err) + } + logger.UeauLog.Tracef("kdfVal=[%x] (len=%d)", kdfVal, len(kdfVal)) // For TS 35.208 test set 19 & RFC 5448 test vector 1 // CK': 0093 962d 0dd8 4aa5 684b 045c 9edf fa04 @@ -544,7 +540,7 @@ func GenerateAuthDataProcedure(authInfoRequest models.AuthenticationInfoRequest, ckPrime := kdfVal[:len(kdfVal)/2] ikPrime := kdfVal[len(kdfVal)/2:] - // fmt.Printf("ckPrime: %x\nikPrime: %x\n", ckPrime, ikPrime) + logger.UeauLog.Tracef("ckPrime=[%x], kPrime=[%x]", ckPrime, ikPrime) // Fill in rand, xres, autn, ckPrime, ikPrime av.Rand = hex.EncodeToString(RAND) diff --git a/producer/parameter_provision.go b/internal/sbi/producer/parameter_provision.go similarity index 77% rename from producer/parameter_provision.go rename to internal/sbi/producer/parameter_provision.go index db5a586..56c1a42 100644 --- a/producer/parameter_provision.go +++ b/internal/sbi/producer/parameter_provision.go @@ -4,14 +4,14 @@ import ( "context" "net/http" - "github.com/free5gc/http_wrapper" "github.com/free5gc/openapi" "github.com/free5gc/openapi/models" - "github.com/free5gc/udm/logger" - "github.com/free5gc/udm/util" + "github.com/free5gc/udm/internal/logger" + "github.com/free5gc/udm/internal/util" + "github.com/free5gc/util/httpwrapper" ) -func HandleUpdateRequest(request *http_wrapper.Request) *http_wrapper.Response { +func HandleUpdateRequest(request *httpwrapper.Request) *httpwrapper.Response { // step 1: log logger.PpLog.Infoln("Handle UpdateRequest") @@ -24,9 +24,9 @@ func HandleUpdateRequest(request *http_wrapper.Request) *http_wrapper.Response { // step 4: process the return value from step 3 if problemDetails != nil { - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } else { - return http_wrapper.NewResponse(http.StatusNoContent, nil, nil) + return httpwrapper.NewResponse(http.StatusNoContent, nil, nil) } } diff --git a/producer/subscriber_data_management.go b/internal/sbi/producer/subscriber_data_management.go similarity index 89% rename from producer/subscriber_data_management.go rename to internal/sbi/producer/subscriber_data_management.go index e523435..aac2054 100644 --- a/producer/subscriber_data_management.go +++ b/internal/sbi/producer/subscriber_data_management.go @@ -10,17 +10,17 @@ import ( "github.com/antihax/optional" - "github.com/free5gc/http_wrapper" "github.com/free5gc/openapi" "github.com/free5gc/openapi/Nudm_SubscriberDataManagement" Nudr "github.com/free5gc/openapi/Nudr_DataRepository" "github.com/free5gc/openapi/models" - udm_context "github.com/free5gc/udm/context" - "github.com/free5gc/udm/logger" - "github.com/free5gc/udm/util" + udm_context "github.com/free5gc/udm/internal/context" + "github.com/free5gc/udm/internal/logger" + "github.com/free5gc/udm/internal/util" + "github.com/free5gc/util/httpwrapper" ) -func HandleGetAmDataRequest(request *http_wrapper.Request) *http_wrapper.Response { +func HandleGetAmDataRequest(request *httpwrapper.Request) *httpwrapper.Response { // step 1: log logger.SdmLog.Infof("Handle GetAmData") @@ -28,7 +28,7 @@ func HandleGetAmDataRequest(request *http_wrapper.Request) *http_wrapper.Respons supi := request.Params["supi"] plmnIDStruct, problemDetails := getPlmnIDStruct(request.Query) if problemDetails != nil { - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } plmnID := plmnIDStruct.Mcc + plmnIDStruct.Mnc supportedFeatures := request.Query.Get("supported-features") @@ -39,15 +39,15 @@ func HandleGetAmDataRequest(request *http_wrapper.Request) *http_wrapper.Respons // step 4: process the return value from step 3 if response != nil { // status code is based on SPEC, and option headers - return http_wrapper.NewResponse(http.StatusOK, nil, response) + return httpwrapper.NewResponse(http.StatusOK, nil, response) } else if problemDetails != nil { - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } problemDetails = &models.ProblemDetails{ Status: http.StatusForbidden, Cause: "UNSPECIFIED", } - return http_wrapper.NewResponse(http.StatusForbidden, nil, problemDetails) + return httpwrapper.NewResponse(http.StatusForbidden, nil, problemDetails) } // TS 29.503 5.2.2.2.3 @@ -100,7 +100,7 @@ func getAmDataProcedure(supi string, plmnID string, supportedFeatures string) ( } } -func HandleGetIdTranslationResultRequest(request *http_wrapper.Request) *http_wrapper.Response { +func HandleGetIdTranslationResultRequest(request *httpwrapper.Request) *httpwrapper.Response { // step 1: log logger.SdmLog.Infof("Handle GetIdTranslationResultRequest") @@ -113,15 +113,15 @@ func HandleGetIdTranslationResultRequest(request *http_wrapper.Request) *http_wr // step 4: process the return value from step 3 if response != nil { // status code is based on SPEC, and option headers - return http_wrapper.NewResponse(http.StatusOK, nil, response) + return httpwrapper.NewResponse(http.StatusOK, nil, response) } else if problemDetails != nil { - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } problemDetails = &models.ProblemDetails{ Status: http.StatusForbidden, Cause: "UNSPECIFIED", } - return http_wrapper.NewResponse(http.StatusForbidden, nil, problemDetails) + return httpwrapper.NewResponse(http.StatusForbidden, nil, problemDetails) } // TS 29.503 5.2.2.2.10 @@ -160,9 +160,7 @@ func getIdTranslationResultProcedure(gpsi string) (response *models.IdTranslatio }() if res.StatusCode == http.StatusOK { - idList := udm_context.UDM_Self().GpsiSupiList - idList = idTranslationResultResp - if idList.SupiList != nil { + if idList := idTranslationResultResp; idList.SupiList != nil { // GetCorrespondingSupi get corresponding Supi(here IMSI) matching the given Gpsi from the queried SUPI list from UDR idTranslationResult.Supi = udm_context.GetCorrespondingSupi(idList) idTranslationResult.Gpsi = gpsi @@ -186,7 +184,7 @@ func getIdTranslationResultProcedure(gpsi string) (response *models.IdTranslatio } } -func HandleGetSupiRequest(request *http_wrapper.Request) *http_wrapper.Response { +func HandleGetSupiRequest(request *httpwrapper.Request) *httpwrapper.Response { // step 1: log logger.SdmLog.Infof("Handle GetSupiRequest") @@ -194,7 +192,7 @@ func HandleGetSupiRequest(request *http_wrapper.Request) *http_wrapper.Response supi := request.Params["supi"] plmnIDStruct, problemDetails := getPlmnIDStruct(request.Query) if problemDetails != nil { - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } plmnID := plmnIDStruct.Mcc + plmnIDStruct.Mnc dataSetNames := strings.Split(request.Query.Get("dataset-names"), ",") @@ -206,15 +204,15 @@ func HandleGetSupiRequest(request *http_wrapper.Request) *http_wrapper.Response // step 4: process the return value from step 3 if response != nil { // status code is based on SPEC, and option headers - return http_wrapper.NewResponse(http.StatusOK, nil, response) + return httpwrapper.NewResponse(http.StatusOK, nil, response) } else if problemDetails != nil { - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } problemDetails = &models.ProblemDetails{ Status: http.StatusForbidden, Cause: "UNSPECIFIED", } - return http_wrapper.NewResponse(http.StatusForbidden, nil, problemDetails) + return httpwrapper.NewResponse(http.StatusForbidden, nil, problemDetails) } // TS 29.503 5.2.2.2.9 @@ -492,7 +490,7 @@ func getSupiProcedure(supi string, plmnID string, dataSetNames []string, support return &subscriptionDataSets, nil } -func HandleGetSharedDataRequest(request *http_wrapper.Request) *http_wrapper.Response { +func HandleGetSharedDataRequest(request *httpwrapper.Request) *httpwrapper.Response { // step 1: log logger.SdmLog.Infof("Handle GetSharedData") @@ -505,15 +503,15 @@ func HandleGetSharedDataRequest(request *http_wrapper.Request) *http_wrapper.Res // step 4: process the return value from step 3 if response != nil { // status code is based on SPEC, and option headers - return http_wrapper.NewResponse(http.StatusOK, nil, response) + return httpwrapper.NewResponse(http.StatusOK, nil, response) } else if problemDetails != nil { - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } problemDetails = &models.ProblemDetails{ Status: http.StatusForbidden, Cause: "UNSPECIFIED", } - return http_wrapper.NewResponse(http.StatusForbidden, nil, problemDetails) + return httpwrapper.NewResponse(http.StatusForbidden, nil, problemDetails) } // TS 29.503 5.2.2.2.11 @@ -565,7 +563,7 @@ func getSharedDataProcedure(sharedDataIds []string, supportedFeatures string) ( } } -func HandleGetSmDataRequest(request *http_wrapper.Request) *http_wrapper.Response { +func HandleGetSmDataRequest(request *httpwrapper.Request) *httpwrapper.Response { // step 1: log logger.SdmLog.Infof("Handle GetSmData") @@ -573,7 +571,7 @@ func HandleGetSmDataRequest(request *http_wrapper.Request) *http_wrapper.Respons supi := request.Params["supi"] plmnIDStruct, problemDetails := getPlmnIDStruct(request.Query) if problemDetails != nil { - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } plmnID := plmnIDStruct.Mcc + plmnIDStruct.Mnc Dnn := request.Query.Get("dnn") @@ -586,15 +584,15 @@ func HandleGetSmDataRequest(request *http_wrapper.Request) *http_wrapper.Respons // step 4: process the return value from step 3 if response != nil { // status code is based on SPEC, and option headers - return http_wrapper.NewResponse(http.StatusOK, nil, response) + return httpwrapper.NewResponse(http.StatusOK, nil, response) } else if problemDetails != nil { - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } problemDetails = &models.ProblemDetails{ Status: http.StatusForbidden, Cause: "UNSPECIFIED", } - return http_wrapper.NewResponse(http.StatusForbidden, nil, problemDetails) + return httpwrapper.NewResponse(http.StatusForbidden, nil, problemDetails) } // TS 29.503 5.2.2.2.5 @@ -678,7 +676,7 @@ func getSmDataProcedure(supi string, plmnID string, Dnn string, Snssai string, s } } -func HandleGetNssaiRequest(request *http_wrapper.Request) *http_wrapper.Response { +func HandleGetNssaiRequest(request *httpwrapper.Request) *httpwrapper.Response { // step 1: log logger.SdmLog.Infof("Handle GetNssai") @@ -686,7 +684,7 @@ func HandleGetNssaiRequest(request *http_wrapper.Request) *http_wrapper.Response supi := request.Params["supi"] plmnIDStruct, problemDetails := getPlmnIDStruct(request.Query) if problemDetails != nil { - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } plmnID := plmnIDStruct.Mcc + plmnIDStruct.Mnc supportedFeatures := request.Query.Get("supported-features") @@ -697,15 +695,15 @@ func HandleGetNssaiRequest(request *http_wrapper.Request) *http_wrapper.Response // step 4: process the return value from step 3 if response != nil { // status code is based on SPEC, and option headers - return http_wrapper.NewResponse(http.StatusOK, nil, response) + return httpwrapper.NewResponse(http.StatusOK, nil, response) } else if problemDetails != nil { - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } problemDetails = &models.ProblemDetails{ Status: http.StatusForbidden, Cause: "UNSPECIFIED", } - return http_wrapper.NewResponse(http.StatusForbidden, nil, problemDetails) + return httpwrapper.NewResponse(http.StatusForbidden, nil, problemDetails) } // TS 29.503 5.2.2.2.2 @@ -762,7 +760,7 @@ func getNssaiProcedure(supi string, plmnID string, supportedFeatures string) ( } } -func HandleGetSmfSelectDataRequest(request *http_wrapper.Request) *http_wrapper.Response { +func HandleGetSmfSelectDataRequest(request *httpwrapper.Request) *httpwrapper.Response { // step 1: log logger.SdmLog.Infof("Handle GetSmfSelectData") @@ -770,7 +768,7 @@ func HandleGetSmfSelectDataRequest(request *http_wrapper.Request) *http_wrapper. supi := request.Params["supi"] plmnIDStruct, problemDetails := getPlmnIDStruct(request.Query) if problemDetails != nil { - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } plmnID := plmnIDStruct.Mcc + plmnIDStruct.Mnc supportedFeatures := request.Query.Get("supported-features") @@ -781,15 +779,15 @@ func HandleGetSmfSelectDataRequest(request *http_wrapper.Request) *http_wrapper. // step 4: process the return value from step 3 if response != nil { // status code is based on SPEC, and option headers - return http_wrapper.NewResponse(http.StatusOK, nil, response) + return httpwrapper.NewResponse(http.StatusOK, nil, response) } else if problemDetails != nil { - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } problemDetails = &models.ProblemDetails{ Status: http.StatusForbidden, Cause: "UNSPECIFIED", } - return http_wrapper.NewResponse(http.StatusForbidden, nil, problemDetails) + return httpwrapper.NewResponse(http.StatusForbidden, nil, problemDetails) } // TS 29.503 5.2.2.2.4 @@ -847,7 +845,7 @@ func getSmfSelectDataProcedure(supi string, plmnID string, supportedFeatures str } } -func HandleSubscribeToSharedDataRequest(request *http_wrapper.Request) *http_wrapper.Response { +func HandleSubscribeToSharedDataRequest(request *httpwrapper.Request) *httpwrapper.Response { // step 1: log logger.SdmLog.Infof("Handle SubscribeToSharedData") @@ -860,11 +858,11 @@ func HandleSubscribeToSharedDataRequest(request *http_wrapper.Request) *http_wra // step 4: process the return value from step 3 if response != nil { // status code is based on SPEC, and option headers - return http_wrapper.NewResponse(http.StatusCreated, header, response) + return httpwrapper.NewResponse(http.StatusCreated, header, response) } else if problemDetails != nil { - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } else { - return http_wrapper.NewResponse(http.StatusNotFound, nil, nil) + return httpwrapper.NewResponse(http.StatusNotFound, nil, nil) } } @@ -920,7 +918,7 @@ func subscribeToSharedDataProcedure(sdmSubscription *models.SdmSubscription) ( } } -func HandleSubscribeRequest(request *http_wrapper.Request) *http_wrapper.Response { +func HandleSubscribeRequest(request *httpwrapper.Request) *httpwrapper.Response { // step 1: log logger.SdmLog.Infof("Handle Subscribe") @@ -934,11 +932,11 @@ func HandleSubscribeRequest(request *http_wrapper.Request) *http_wrapper.Respons // step 4: process the return value from step 3 if response != nil { // status code is based on SPEC, and option headers - return http_wrapper.NewResponse(http.StatusCreated, header, response) + return httpwrapper.NewResponse(http.StatusCreated, header, response) } else if problemDetails != nil { - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } else { - return http_wrapper.NewResponse(http.StatusNotFound, nil, nil) + return httpwrapper.NewResponse(http.StatusNotFound, nil, nil) } } @@ -998,7 +996,7 @@ func subscribeProcedure(sdmSubscription *models.SdmSubscription, supi string) ( } } -func HandleUnsubscribeForSharedDataRequest(request *http_wrapper.Request) *http_wrapper.Response { +func HandleUnsubscribeForSharedDataRequest(request *httpwrapper.Request) *httpwrapper.Response { logger.SdmLog.Infof("Handle UnsubscribeForSharedData") // step 2: retrieve request @@ -1008,10 +1006,10 @@ func HandleUnsubscribeForSharedDataRequest(request *http_wrapper.Request) *http_ // step 4: process the return value from step 3 if problemDetails != nil { - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } - return http_wrapper.NewResponse(http.StatusNoContent, nil, nil) + return httpwrapper.NewResponse(http.StatusNoContent, nil, nil) } // TS 29.503 5.2.2.4.3 @@ -1054,7 +1052,7 @@ func unsubscribeForSharedDataProcedure(subscriptionID string) *models.ProblemDet } } -func HandleUnsubscribeRequest(request *http_wrapper.Request) *http_wrapper.Response { +func HandleUnsubscribeRequest(request *httpwrapper.Request) *httpwrapper.Response { logger.SdmLog.Infof("Handle Unsubscribe") // step 2: retrieve request @@ -1066,10 +1064,10 @@ func HandleUnsubscribeRequest(request *http_wrapper.Request) *http_wrapper.Respo // step 4: process the return value from step 3 if problemDetails != nil { - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } - return http_wrapper.NewResponse(http.StatusNoContent, nil, nil) + return httpwrapper.NewResponse(http.StatusNoContent, nil, nil) } // TS 29.503 5.2.2.4.2 @@ -1113,7 +1111,7 @@ func unsubscribeProcedure(supi string, subscriptionID string) *models.ProblemDet } } -func HandleModifyRequest(request *http_wrapper.Request) *http_wrapper.Response { +func HandleModifyRequest(request *httpwrapper.Request) *httpwrapper.Response { // step 1: log logger.SdmLog.Infof("Handle Modify") @@ -1128,15 +1126,15 @@ func HandleModifyRequest(request *http_wrapper.Request) *http_wrapper.Response { // step 4: process the return value from step 3 if response != nil { // status code is based on SPEC, and option headers - return http_wrapper.NewResponse(http.StatusOK, nil, response) + return httpwrapper.NewResponse(http.StatusOK, nil, response) } else if problemDetails != nil { - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } problemDetails = &models.ProblemDetails{ Status: http.StatusForbidden, Cause: "UNSPECIFIED", } - return http_wrapper.NewResponse(http.StatusForbidden, nil, problemDetails) + return httpwrapper.NewResponse(http.StatusForbidden, nil, problemDetails) } // TS 29.503 5.2.2.7.2 @@ -1186,7 +1184,7 @@ func modifyProcedure(sdmSubsModification *models.SdmSubsModification, supi strin } } -func HandleModifyForSharedDataRequest(request *http_wrapper.Request) *http_wrapper.Response { +func HandleModifyForSharedDataRequest(request *httpwrapper.Request) *httpwrapper.Response { // step 1: log logger.SdmLog.Infof("Handle ModifyForSharedData") @@ -1201,15 +1199,15 @@ func HandleModifyForSharedDataRequest(request *http_wrapper.Request) *http_wrapp // step 4: process the return value from step 3 if response != nil { // status code is based on SPEC, and option headers - return http_wrapper.NewResponse(http.StatusOK, nil, response) + return httpwrapper.NewResponse(http.StatusOK, nil, response) } else if problemDetails != nil { - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } problemDetails = &models.ProblemDetails{ Status: http.StatusForbidden, Cause: "UNSPECIFIED", } - return http_wrapper.NewResponse(http.StatusForbidden, nil, problemDetails) + return httpwrapper.NewResponse(http.StatusForbidden, nil, problemDetails) } // TS 29.503 5.2.2.7.3 @@ -1261,7 +1259,7 @@ func modifyForSharedDataProcedure(sdmSubsModification *models.SdmSubsModificatio } } -func HandleGetTraceDataRequest(request *http_wrapper.Request) *http_wrapper.Response { +func HandleGetTraceDataRequest(request *httpwrapper.Request) *httpwrapper.Response { // step 1: log logger.SdmLog.Infof("Handle GetTraceData") @@ -1275,15 +1273,15 @@ func HandleGetTraceDataRequest(request *http_wrapper.Request) *http_wrapper.Resp // step 4: process the return value from step 3 if response != nil { // status code is based on SPEC, and option headers - return http_wrapper.NewResponse(http.StatusOK, nil, response) + return httpwrapper.NewResponse(http.StatusOK, nil, response) } else if problemDetails != nil { - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } problemDetails = &models.ProblemDetails{ Status: http.StatusForbidden, Cause: "UNSPECIFIED", } - return http_wrapper.NewResponse(http.StatusForbidden, nil, problemDetails) + return httpwrapper.NewResponse(http.StatusForbidden, nil, problemDetails) } func getTraceDataProcedure(supi string, plmnID string) ( @@ -1340,7 +1338,7 @@ func getTraceDataProcedure(supi string, plmnID string) ( } } -func HandleGetUeContextInSmfDataRequest(request *http_wrapper.Request) *http_wrapper.Response { +func HandleGetUeContextInSmfDataRequest(request *httpwrapper.Request) *httpwrapper.Response { // step 1: log logger.SdmLog.Infof("Handle GetUeContextInSmfData") @@ -1354,15 +1352,15 @@ func HandleGetUeContextInSmfDataRequest(request *http_wrapper.Request) *http_wra // step 4: process the return value from step 3 if response != nil { // status code is based on SPEC, and option headers - return http_wrapper.NewResponse(http.StatusOK, nil, response) + return httpwrapper.NewResponse(http.StatusOK, nil, response) } else if problemDetails != nil { - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } problemDetails = &models.ProblemDetails{ Status: http.StatusForbidden, Cause: "UNSPECIFIED", } - return http_wrapper.NewResponse(http.StatusForbidden, nil, problemDetails) + return httpwrapper.NewResponse(http.StatusForbidden, nil, problemDetails) } func getUeContextInSmfDataProcedure(supi string, supportedFeatures string) ( diff --git a/producer/ue_context_management.go b/internal/sbi/producer/ue_context_management.go similarity index 89% rename from producer/ue_context_management.go rename to internal/sbi/producer/ue_context_management.go index 76d52ec..b4c9d3e 100644 --- a/producer/ue_context_management.go +++ b/internal/sbi/producer/ue_context_management.go @@ -9,15 +9,15 @@ import ( "github.com/antihax/optional" - "github.com/free5gc/http_wrapper" "github.com/free5gc/openapi" "github.com/free5gc/openapi/Nudr_DataRepository" "github.com/free5gc/openapi/models" - "github.com/free5gc/udm/consumer" - udm_context "github.com/free5gc/udm/context" - "github.com/free5gc/udm/logger" - "github.com/free5gc/udm/producer/callback" - "github.com/free5gc/udm/util" + udm_context "github.com/free5gc/udm/internal/context" + "github.com/free5gc/udm/internal/logger" + "github.com/free5gc/udm/internal/sbi/consumer" + "github.com/free5gc/udm/internal/sbi/producer/callback" + "github.com/free5gc/udm/internal/util" + "github.com/free5gc/util/httpwrapper" ) func createUDMClientToUDR(id string) (*Nudr_DataRepository.APIClient, error) { @@ -75,7 +75,7 @@ func getUdrURI(id string) string { return consumer.SendNFIntancesUDR("", consumer.NFDiscoveryToUDRParamNone) } -func HandleGetAmf3gppAccessRequest(request *http_wrapper.Request) *http_wrapper.Response { +func HandleGetAmf3gppAccessRequest(request *httpwrapper.Request) *httpwrapper.Response { // step 1: log logger.UecmLog.Infof("Handle HandleGetAmf3gppAccessRequest") @@ -89,15 +89,15 @@ func HandleGetAmf3gppAccessRequest(request *http_wrapper.Request) *http_wrapper. // step 4: process the return value from step 3 if response != nil { // status code is based on SPEC, and option headers - return http_wrapper.NewResponse(http.StatusOK, nil, response) + return httpwrapper.NewResponse(http.StatusOK, nil, response) } else if problemDetails != nil { - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } problemDetails = &models.ProblemDetails{ Status: http.StatusForbidden, Cause: "UNSPECIFIED", } - return http_wrapper.NewResponse(http.StatusForbidden, nil, problemDetails) + return httpwrapper.NewResponse(http.StatusForbidden, nil, problemDetails) } func GetAmf3gppAccessProcedure(ueID string, supportedFeatures string) ( @@ -129,7 +129,7 @@ func GetAmf3gppAccessProcedure(ueID string, supportedFeatures string) ( return &amf3GppAccessRegistration, nil } -func HandleGetAmfNon3gppAccessRequest(request *http_wrapper.Request) *http_wrapper.Response { +func HandleGetAmfNon3gppAccessRequest(request *httpwrapper.Request) *httpwrapper.Response { // step 1: log logger.UecmLog.Infoln("Handle GetAmfNon3gppAccessRequest") @@ -145,15 +145,15 @@ func HandleGetAmfNon3gppAccessRequest(request *http_wrapper.Request) *http_wrapp // step 4: process the return value from step 3 if response != nil { // status code is based on SPEC, and option headers - return http_wrapper.NewResponse(http.StatusOK, nil, response) + return httpwrapper.NewResponse(http.StatusOK, nil, response) } else if problemDetails != nil { - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } problemDetails = &models.ProblemDetails{ Status: http.StatusForbidden, Cause: "UNSPECIFIED", } - return http_wrapper.NewResponse(http.StatusForbidden, nil, problemDetails) + return httpwrapper.NewResponse(http.StatusForbidden, nil, problemDetails) } func GetAmfNon3gppAccessProcedure(queryAmfContextNon3gppParamOpts Nudr_DataRepository. @@ -183,7 +183,7 @@ func GetAmfNon3gppAccessProcedure(queryAmfContextNon3gppParamOpts Nudr_DataRepos return &amfNon3GppAccessRegistration, nil } -func HandleRegistrationAmf3gppAccessRequest(request *http_wrapper.Request) *http_wrapper.Response { +func HandleRegistrationAmf3gppAccessRequest(request *httpwrapper.Request) *httpwrapper.Response { // step 1: log logger.UecmLog.Infof("Handle RegistrationAmf3gppAccess") @@ -198,11 +198,11 @@ func HandleRegistrationAmf3gppAccessRequest(request *http_wrapper.Request) *http // step 4: process the return value from step 3 if response != nil { // status code is based on SPEC, and option headers - return http_wrapper.NewResponse(http.StatusCreated, header, response) + return httpwrapper.NewResponse(http.StatusCreated, header, response) } else if problemDetails != nil { - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } else { - return http_wrapper.NewResponse(http.StatusNoContent, nil, nil) + return httpwrapper.NewResponse(http.StatusNoContent, nil, nil) } } @@ -263,7 +263,7 @@ func RegistrationAmf3gppAccessProcedure(registerRequest models.Amf3GppAccessRegi } // TS 29.503 5.3.2.2.3 -func HandleRegisterAmfNon3gppAccessRequest(request *http_wrapper.Request) *http_wrapper.Response { +func HandleRegisterAmfNon3gppAccessRequest(request *httpwrapper.Request) *httpwrapper.Response { // step 1: log logger.UecmLog.Infof("Handle RegisterAmfNon3gppAccessRequest") @@ -277,11 +277,11 @@ func HandleRegisterAmfNon3gppAccessRequest(request *http_wrapper.Request) *http_ // step 4: process the return value from step 3 if response != nil { // status code is based on SPEC, and option headers - return http_wrapper.NewResponse(http.StatusCreated, header, response) + return httpwrapper.NewResponse(http.StatusCreated, header, response) } else if problemDetails != nil { - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } else { - return http_wrapper.NewResponse(http.StatusNoContent, nil, nil) + return httpwrapper.NewResponse(http.StatusNoContent, nil, nil) } } @@ -339,7 +339,7 @@ func RegisterAmfNon3gppAccessProcedure(registerRequest models.AmfNon3GppAccessRe } // TODO: ueID may be SUPI or GPSI, but this function did not handle this condition -func HandleUpdateAmf3gppAccessRequest(request *http_wrapper.Request) *http_wrapper.Response { +func HandleUpdateAmf3gppAccessRequest(request *httpwrapper.Request) *httpwrapper.Response { // step 1: log logger.UecmLog.Infof("Handle UpdateAmf3gppAccessRequest") @@ -352,9 +352,9 @@ func HandleUpdateAmf3gppAccessRequest(request *http_wrapper.Request) *http_wrapp // step 4: process the return value from step 3 if problemDetails != nil { - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } else { - return http_wrapper.NewResponse(http.StatusNoContent, nil, nil) + return httpwrapper.NewResponse(http.StatusNoContent, nil, nil) } } @@ -456,7 +456,7 @@ func UpdateAmf3gppAccessProcedure(request models.Amf3GppAccessRegistrationModifi } // TODO: ueID may be SUPI or GPSI, but this function did not handle this condition -func HandleUpdateAmfNon3gppAccessRequest(request *http_wrapper.Request) *http_wrapper.Response { +func HandleUpdateAmfNon3gppAccessRequest(request *httpwrapper.Request) *httpwrapper.Response { // step 1: log logger.UecmLog.Infof("Handle UpdateAmfNon3gppAccessRequest") @@ -469,9 +469,9 @@ func HandleUpdateAmfNon3gppAccessRequest(request *http_wrapper.Request) *http_wr // step 4: process the return value from step 3 if problemDetails != nil { - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } else { - return http_wrapper.NewResponse(http.StatusNoContent, nil, nil) + return httpwrapper.NewResponse(http.StatusNoContent, nil, nil) } } @@ -564,7 +564,7 @@ func UpdateAmfNon3gppAccessProcedure(request models.AmfNon3GppAccessRegistration return nil } -func HandleDeregistrationSmfRegistrations(request *http_wrapper.Request) *http_wrapper.Response { +func HandleDeregistrationSmfRegistrations(request *httpwrapper.Request) *httpwrapper.Response { // step 1: log logger.UecmLog.Infof("Handle DeregistrationSmfRegistrations") @@ -577,9 +577,9 @@ func HandleDeregistrationSmfRegistrations(request *http_wrapper.Request) *http_w // step 4: process the return value from step 3 if problemDetails != nil { - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } else { - return http_wrapper.NewResponse(http.StatusNoContent, nil, nil) + return httpwrapper.NewResponse(http.StatusNoContent, nil, nil) } } @@ -608,7 +608,7 @@ func DeregistrationSmfRegistrationsProcedure(ueID string, pduSessionID string) ( } // SmfRegistrations -func HandleRegistrationSmfRegistrationsRequest(request *http_wrapper.Request) *http_wrapper.Response { +func HandleRegistrationSmfRegistrationsRequest(request *httpwrapper.Request) *httpwrapper.Response { // step 1: log logger.UecmLog.Infof("Handle RegistrationSmfRegistrations") @@ -623,12 +623,12 @@ func HandleRegistrationSmfRegistrationsRequest(request *http_wrapper.Request) *h // step 4: process the return value from step 3 if response != nil { // status code is based on SPEC, and option headers - return http_wrapper.NewResponse(http.StatusCreated, header, response) + return httpwrapper.NewResponse(http.StatusCreated, header, response) } else if problemDetails != nil { - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } else { // all nil - return http_wrapper.NewResponse(http.StatusNoContent, nil, nil) + return httpwrapper.NewResponse(http.StatusNoContent, nil, nil) } } diff --git a/subscriberdatamanagement/api_access_and_mobility_subscription_data_retrieval.go b/internal/sbi/subscriberdatamanagement/api_access_and_mobility_subscription_data_retrieval.go similarity index 85% rename from subscriberdatamanagement/api_access_and_mobility_subscription_data_retrieval.go rename to internal/sbi/subscriberdatamanagement/api_access_and_mobility_subscription_data_retrieval.go index 6f0827e..d1150f3 100644 --- a/subscriberdatamanagement/api_access_and_mobility_subscription_data_retrieval.go +++ b/internal/sbi/subscriberdatamanagement/api_access_and_mobility_subscription_data_retrieval.go @@ -14,16 +14,16 @@ import ( "github.com/gin-gonic/gin" - "github.com/free5gc/http_wrapper" "github.com/free5gc/openapi" "github.com/free5gc/openapi/models" - "github.com/free5gc/udm/logger" - "github.com/free5gc/udm/producer" + "github.com/free5gc/udm/internal/logger" + "github.com/free5gc/udm/internal/sbi/producer" + "github.com/free5gc/util/httpwrapper" ) // GetAmData - retrieve a UE's Access and Mobility Subscription Data func HTTPGetAmData(c *gin.Context) { - req := http_wrapper.NewRequest(c.Request, nil) + req := httpwrapper.NewRequest(c.Request, nil) req.Params["supi"] = c.Params.ByName("supi") req.Query.Set("plmn-id", c.Query("plmn-id")) req.Query.Set("supported-features", c.Query("plmn-id")) diff --git a/subscriberdatamanagement/api_gpsi_to_supi_translation.go b/internal/sbi/subscriberdatamanagement/api_gpsi_to_supi_translation.go similarity index 84% rename from subscriberdatamanagement/api_gpsi_to_supi_translation.go rename to internal/sbi/subscriberdatamanagement/api_gpsi_to_supi_translation.go index 2780774..2627f48 100644 --- a/subscriberdatamanagement/api_gpsi_to_supi_translation.go +++ b/internal/sbi/subscriberdatamanagement/api_gpsi_to_supi_translation.go @@ -14,16 +14,16 @@ import ( "github.com/gin-gonic/gin" - "github.com/free5gc/http_wrapper" "github.com/free5gc/openapi" "github.com/free5gc/openapi/models" - "github.com/free5gc/udm/logger" - "github.com/free5gc/udm/producer" + "github.com/free5gc/udm/internal/logger" + "github.com/free5gc/udm/internal/sbi/producer" + "github.com/free5gc/util/httpwrapper" ) // GetIdTranslationResult - retrieve a UE's SUPI func HTTPGetIdTranslationResult(c *gin.Context) { - req := http_wrapper.NewRequest(c.Request, nil) + req := httpwrapper.NewRequest(c.Request, nil) req.Params["gpsi"] = c.Params.ByName("gpsi") req.Query.Set("SupportedFeatures", c.Query("supported-features")) diff --git a/subscriberdatamanagement/api_providing_acknowledgement_of_steering_of_roaming.go b/internal/sbi/subscriberdatamanagement/api_providing_acknowledgement_of_steering_of_roaming.go similarity index 100% rename from subscriberdatamanagement/api_providing_acknowledgement_of_steering_of_roaming.go rename to internal/sbi/subscriberdatamanagement/api_providing_acknowledgement_of_steering_of_roaming.go diff --git a/subscriberdatamanagement/api_providing_acknowledgement_of_ue_parameters_update.go b/internal/sbi/subscriberdatamanagement/api_providing_acknowledgement_of_ue_parameters_update.go similarity index 100% rename from subscriberdatamanagement/api_providing_acknowledgement_of_ue_parameters_update.go rename to internal/sbi/subscriberdatamanagement/api_providing_acknowledgement_of_ue_parameters_update.go diff --git a/subscriberdatamanagement/api_retrieval_of_multiple_data_sets.go b/internal/sbi/subscriberdatamanagement/api_retrieval_of_multiple_data_sets.go similarity index 85% rename from subscriberdatamanagement/api_retrieval_of_multiple_data_sets.go rename to internal/sbi/subscriberdatamanagement/api_retrieval_of_multiple_data_sets.go index 975b9f8..ae5fb82 100644 --- a/subscriberdatamanagement/api_retrieval_of_multiple_data_sets.go +++ b/internal/sbi/subscriberdatamanagement/api_retrieval_of_multiple_data_sets.go @@ -14,16 +14,16 @@ import ( "github.com/gin-gonic/gin" - "github.com/free5gc/http_wrapper" "github.com/free5gc/openapi" "github.com/free5gc/openapi/models" - "github.com/free5gc/udm/logger" - "github.com/free5gc/udm/producer" + "github.com/free5gc/udm/internal/logger" + "github.com/free5gc/udm/internal/sbi/producer" + "github.com/free5gc/util/httpwrapper" ) // GetSupi - retrieve multiple data sets func HTTPGetSupi(c *gin.Context) { - req := http_wrapper.NewRequest(c.Request, nil) + req := httpwrapper.NewRequest(c.Request, nil) req.Params["supi"] = c.Params.ByName("supi") req.Query.Set("plmn-id", c.Query("plmn-id")) req.Query.Set("dataset-names", c.Query("dataset-names")) diff --git a/subscriberdatamanagement/api_retrieval_of_shared_data.go b/internal/sbi/subscriberdatamanagement/api_retrieval_of_shared_data.go similarity index 84% rename from subscriberdatamanagement/api_retrieval_of_shared_data.go rename to internal/sbi/subscriberdatamanagement/api_retrieval_of_shared_data.go index 66e7826..2a97023 100644 --- a/subscriberdatamanagement/api_retrieval_of_shared_data.go +++ b/internal/sbi/subscriberdatamanagement/api_retrieval_of_shared_data.go @@ -14,16 +14,16 @@ import ( "github.com/gin-gonic/gin" - "github.com/free5gc/http_wrapper" "github.com/free5gc/openapi" "github.com/free5gc/openapi/models" - "github.com/free5gc/udm/logger" - "github.com/free5gc/udm/producer" + "github.com/free5gc/udm/internal/logger" + "github.com/free5gc/udm/internal/sbi/producer" + "github.com/free5gc/util/httpwrapper" ) // GetSharedData - retrieve shared data func HTTPGetSharedData(c *gin.Context) { - req := http_wrapper.NewRequest(c.Request, nil) + req := httpwrapper.NewRequest(c.Request, nil) req.Query["sharedDataIds"] = c.QueryArray("shared-data-ids") req.Query["supported-features"] = c.QueryArray("supported-features") diff --git a/subscriberdatamanagement/api_session_management_subscription_data_retrieval.go b/internal/sbi/subscriberdatamanagement/api_session_management_subscription_data_retrieval.go similarity index 86% rename from subscriberdatamanagement/api_session_management_subscription_data_retrieval.go rename to internal/sbi/subscriberdatamanagement/api_session_management_subscription_data_retrieval.go index 2afded7..d8c2cb3 100644 --- a/subscriberdatamanagement/api_session_management_subscription_data_retrieval.go +++ b/internal/sbi/subscriberdatamanagement/api_session_management_subscription_data_retrieval.go @@ -14,16 +14,16 @@ import ( "github.com/gin-gonic/gin" - "github.com/free5gc/http_wrapper" "github.com/free5gc/openapi" "github.com/free5gc/openapi/models" - "github.com/free5gc/udm/logger" - "github.com/free5gc/udm/producer" + "github.com/free5gc/udm/internal/logger" + "github.com/free5gc/udm/internal/sbi/producer" + "github.com/free5gc/util/httpwrapper" ) // GetSmData - retrieve a UE's Session Management Subscription Data func HTTPGetSmData(c *gin.Context) { - req := http_wrapper.NewRequest(c.Request, nil) + req := httpwrapper.NewRequest(c.Request, nil) req.Params["supi"] = c.Param("supi") req.Query.Set("plmn-id", c.Query("plmn-id")) req.Query.Set("dnn", c.Query("dnn")) diff --git a/subscriberdatamanagement/api_slice_selection_subscription_data_retrieval.go b/internal/sbi/subscriberdatamanagement/api_slice_selection_subscription_data_retrieval.go similarity index 84% rename from subscriberdatamanagement/api_slice_selection_subscription_data_retrieval.go rename to internal/sbi/subscriberdatamanagement/api_slice_selection_subscription_data_retrieval.go index d0765e8..61cb6c7 100644 --- a/subscriberdatamanagement/api_slice_selection_subscription_data_retrieval.go +++ b/internal/sbi/subscriberdatamanagement/api_slice_selection_subscription_data_retrieval.go @@ -14,16 +14,16 @@ import ( "github.com/gin-gonic/gin" - "github.com/free5gc/http_wrapper" "github.com/free5gc/openapi" "github.com/free5gc/openapi/models" - "github.com/free5gc/udm/logger" - "github.com/free5gc/udm/producer" + "github.com/free5gc/udm/internal/logger" + "github.com/free5gc/udm/internal/sbi/producer" + "github.com/free5gc/util/httpwrapper" ) // GetNssai - retrieve a UE's subscribed NSSAI func HTTPGetNssai(c *gin.Context) { - req := http_wrapper.NewRequest(c.Request, nil) + req := httpwrapper.NewRequest(c.Request, nil) req.Params["supi"] = c.Params.ByName("supi") req.Query.Set("plmn-id", c.Query("plmn-id")) req.Query.Set("supported-features", c.Query("supported-features")) diff --git a/subscriberdatamanagement/api_smf_selection_subscription_data_retrieval.go b/internal/sbi/subscriberdatamanagement/api_smf_selection_subscription_data_retrieval.go similarity index 85% rename from subscriberdatamanagement/api_smf_selection_subscription_data_retrieval.go rename to internal/sbi/subscriberdatamanagement/api_smf_selection_subscription_data_retrieval.go index 589085e..6d1a289 100644 --- a/subscriberdatamanagement/api_smf_selection_subscription_data_retrieval.go +++ b/internal/sbi/subscriberdatamanagement/api_smf_selection_subscription_data_retrieval.go @@ -14,16 +14,16 @@ import ( "github.com/gin-gonic/gin" - "github.com/free5gc/http_wrapper" "github.com/free5gc/openapi" "github.com/free5gc/openapi/models" - "github.com/free5gc/udm/logger" - "github.com/free5gc/udm/producer" + "github.com/free5gc/udm/internal/logger" + "github.com/free5gc/udm/internal/sbi/producer" + "github.com/free5gc/util/httpwrapper" ) // GetSmfSelectData - retrieve a UE's SMF Selection Subscription Data func HTTPGetSmfSelectData(c *gin.Context) { - req := http_wrapper.NewRequest(c.Request, nil) + req := httpwrapper.NewRequest(c.Request, nil) req.Params["supi"] = c.Params.ByName("supi") req.Query.Set("plmn-id", c.Query("plmn-id")) req.Query.Set("supported-features", c.Query("supported-features")) @@ -41,5 +41,4 @@ func HTTPGetSmfSelectData(c *gin.Context) { } else { c.Data(rsp.Status, "application/json", responseBody) } - return } diff --git a/subscriberdatamanagement/api_sms_management_subscription_data_retrieval.go b/internal/sbi/subscriberdatamanagement/api_sms_management_subscription_data_retrieval.go similarity index 100% rename from subscriberdatamanagement/api_sms_management_subscription_data_retrieval.go rename to internal/sbi/subscriberdatamanagement/api_sms_management_subscription_data_retrieval.go diff --git a/subscriberdatamanagement/api_sms_subscription_data_retrieval.go b/internal/sbi/subscriberdatamanagement/api_sms_subscription_data_retrieval.go similarity index 100% rename from subscriberdatamanagement/api_sms_subscription_data_retrieval.go rename to internal/sbi/subscriberdatamanagement/api_sms_subscription_data_retrieval.go diff --git a/subscriberdatamanagement/api_subscription_creation.go b/internal/sbi/subscriberdatamanagement/api_subscription_creation.go similarity index 90% rename from subscriberdatamanagement/api_subscription_creation.go rename to internal/sbi/subscriberdatamanagement/api_subscription_creation.go index d12e90f..51adf05 100644 --- a/subscriberdatamanagement/api_subscription_creation.go +++ b/internal/sbi/subscriberdatamanagement/api_subscription_creation.go @@ -14,11 +14,11 @@ import ( "github.com/gin-gonic/gin" - "github.com/free5gc/http_wrapper" "github.com/free5gc/openapi" "github.com/free5gc/openapi/models" - "github.com/free5gc/udm/logger" - "github.com/free5gc/udm/producer" + "github.com/free5gc/udm/internal/logger" + "github.com/free5gc/udm/internal/sbi/producer" + "github.com/free5gc/util/httpwrapper" ) // Subscribe - subscribe to notifications @@ -53,7 +53,7 @@ func HTTPSubscribe(c *gin.Context) { return } - req := http_wrapper.NewRequest(c.Request, sdmSubscriptionReq) + req := httpwrapper.NewRequest(c.Request, sdmSubscriptionReq) req.Params["supi"] = c.Params.ByName("supi") rsp := producer.HandleSubscribeRequest(req) diff --git a/subscriberdatamanagement/api_subscription_creation_for_shared_data.go b/internal/sbi/subscriberdatamanagement/api_subscription_creation_for_shared_data.go similarity index 90% rename from subscriberdatamanagement/api_subscription_creation_for_shared_data.go rename to internal/sbi/subscriberdatamanagement/api_subscription_creation_for_shared_data.go index 331029e..a6c8744 100644 --- a/subscriberdatamanagement/api_subscription_creation_for_shared_data.go +++ b/internal/sbi/subscriberdatamanagement/api_subscription_creation_for_shared_data.go @@ -14,11 +14,11 @@ import ( "github.com/gin-gonic/gin" - "github.com/free5gc/http_wrapper" "github.com/free5gc/openapi" "github.com/free5gc/openapi/models" - "github.com/free5gc/udm/logger" - "github.com/free5gc/udm/producer" + "github.com/free5gc/udm/internal/logger" + "github.com/free5gc/udm/internal/sbi/producer" + "github.com/free5gc/util/httpwrapper" ) // SubscribeToSharedData - subscribe to notifications for shared data @@ -52,7 +52,7 @@ func HTTPSubscribeToSharedData(c *gin.Context) { return } - req := http_wrapper.NewRequest(c.Request, sharedDataSubsReq) + req := httpwrapper.NewRequest(c.Request, sharedDataSubsReq) rsp := producer.HandleSubscribeToSharedDataRequest(req) // step 5: response for key, val := range rsp.Header { // header response is optional diff --git a/subscriberdatamanagement/api_subscription_deletion.go b/internal/sbi/subscriberdatamanagement/api_subscription_deletion.go similarity index 85% rename from subscriberdatamanagement/api_subscription_deletion.go rename to internal/sbi/subscriberdatamanagement/api_subscription_deletion.go index 4e9614a..c7870d9 100644 --- a/subscriberdatamanagement/api_subscription_deletion.go +++ b/internal/sbi/subscriberdatamanagement/api_subscription_deletion.go @@ -14,16 +14,16 @@ import ( "github.com/gin-gonic/gin" - "github.com/free5gc/http_wrapper" "github.com/free5gc/openapi" "github.com/free5gc/openapi/models" - "github.com/free5gc/udm/logger" - "github.com/free5gc/udm/producer" + "github.com/free5gc/udm/internal/logger" + "github.com/free5gc/udm/internal/sbi/producer" + "github.com/free5gc/util/httpwrapper" ) // Unsubscribe - unsubscribe from notifications func HTTPUnsubscribe(c *gin.Context) { - req := http_wrapper.NewRequest(c.Request, nil) + req := httpwrapper.NewRequest(c.Request, nil) req.Params["supi"] = c.Params.ByName("supi") req.Params["subscriptionId"] = c.Params.ByName("subscriptionId") diff --git a/subscriberdatamanagement/api_subscription_deletion_for_shared_data.go b/internal/sbi/subscriberdatamanagement/api_subscription_deletion_for_shared_data.go similarity index 84% rename from subscriberdatamanagement/api_subscription_deletion_for_shared_data.go rename to internal/sbi/subscriberdatamanagement/api_subscription_deletion_for_shared_data.go index 23ae69e..306d347 100644 --- a/subscriberdatamanagement/api_subscription_deletion_for_shared_data.go +++ b/internal/sbi/subscriberdatamanagement/api_subscription_deletion_for_shared_data.go @@ -14,16 +14,16 @@ import ( "github.com/gin-gonic/gin" - "github.com/free5gc/http_wrapper" "github.com/free5gc/openapi" "github.com/free5gc/openapi/models" - "github.com/free5gc/udm/logger" - "github.com/free5gc/udm/producer" + "github.com/free5gc/udm/internal/logger" + "github.com/free5gc/udm/internal/sbi/producer" + "github.com/free5gc/util/httpwrapper" ) // UnsubscribeForSharedData - unsubscribe from notifications for shared data func HTTPUnsubscribeForSharedData(c *gin.Context) { - req := http_wrapper.NewRequest(c.Request, nil) + req := httpwrapper.NewRequest(c.Request, nil) req.Params["subscriptionId"] = c.Params.ByName("subscriptionId") rsp := producer.HandleUnsubscribeForSharedDataRequest(req) diff --git a/subscriberdatamanagement/api_subscription_modification.go b/internal/sbi/subscriberdatamanagement/api_subscription_modification.go similarity index 92% rename from subscriberdatamanagement/api_subscription_modification.go rename to internal/sbi/subscriberdatamanagement/api_subscription_modification.go index 289f175..b0f543e 100644 --- a/subscriberdatamanagement/api_subscription_modification.go +++ b/internal/sbi/subscriberdatamanagement/api_subscription_modification.go @@ -14,11 +14,11 @@ import ( "github.com/gin-gonic/gin" - "github.com/free5gc/http_wrapper" "github.com/free5gc/openapi" "github.com/free5gc/openapi/models" - "github.com/free5gc/udm/logger" - "github.com/free5gc/udm/producer" + "github.com/free5gc/udm/internal/logger" + "github.com/free5gc/udm/internal/sbi/producer" + "github.com/free5gc/util/httpwrapper" ) // Modify - modify the subscription @@ -52,7 +52,7 @@ func HTTPModify(c *gin.Context) { return } - req := http_wrapper.NewRequest(c.Request, sdmSubsModificationReq) + req := httpwrapper.NewRequest(c.Request, sdmSubsModificationReq) req.Params["supi"] = c.Params.ByName("supi") req.Params["subscriptionId"] = c.Params.ByName("subscriptionId") @@ -102,7 +102,7 @@ func HTTPModifyForSharedData(c *gin.Context) { return } - req := http_wrapper.NewRequest(c.Request, sharedDataSubscriptions) + req := httpwrapper.NewRequest(c.Request, sharedDataSubscriptions) req.Params["supi"] = c.Params.ByName("supi") req.Params["subscriptionId"] = c.Params.ByName("subscriptionId") diff --git a/subscriberdatamanagement/api_trace_configuration_data_retrieval.go b/internal/sbi/subscriberdatamanagement/api_trace_configuration_data_retrieval.go similarity index 84% rename from subscriberdatamanagement/api_trace_configuration_data_retrieval.go rename to internal/sbi/subscriberdatamanagement/api_trace_configuration_data_retrieval.go index 2cdd5f7..6ae6aff 100644 --- a/subscriberdatamanagement/api_trace_configuration_data_retrieval.go +++ b/internal/sbi/subscriberdatamanagement/api_trace_configuration_data_retrieval.go @@ -14,16 +14,16 @@ import ( "github.com/gin-gonic/gin" - "github.com/free5gc/http_wrapper" "github.com/free5gc/openapi" "github.com/free5gc/openapi/models" - "github.com/free5gc/udm/logger" - "github.com/free5gc/udm/producer" + "github.com/free5gc/udm/internal/logger" + "github.com/free5gc/udm/internal/sbi/producer" + "github.com/free5gc/util/httpwrapper" ) // GetTraceData - retrieve a UE's Trace Configuration Data func HTTPGetTraceData(c *gin.Context) { - req := http_wrapper.NewRequest(c.Request, nil) + req := httpwrapper.NewRequest(c.Request, nil) req.Params["supi"] = c.Params.ByName("supi") req.Query.Set("plmn-id", c.Query("plmn-id")) diff --git a/subscriberdatamanagement/api_ue_context_in_smf_data_retrieval.go b/internal/sbi/subscriberdatamanagement/api_ue_context_in_smf_data_retrieval.go similarity index 84% rename from subscriberdatamanagement/api_ue_context_in_smf_data_retrieval.go rename to internal/sbi/subscriberdatamanagement/api_ue_context_in_smf_data_retrieval.go index 0709d10..2486cc7 100644 --- a/subscriberdatamanagement/api_ue_context_in_smf_data_retrieval.go +++ b/internal/sbi/subscriberdatamanagement/api_ue_context_in_smf_data_retrieval.go @@ -14,16 +14,16 @@ import ( "github.com/gin-gonic/gin" - "github.com/free5gc/http_wrapper" "github.com/free5gc/openapi" "github.com/free5gc/openapi/models" - "github.com/free5gc/udm/logger" - "github.com/free5gc/udm/producer" + "github.com/free5gc/udm/internal/logger" + "github.com/free5gc/udm/internal/sbi/producer" + "github.com/free5gc/util/httpwrapper" ) // GetUeContextInSmfData - retrieve a UE's UE Context In SMF Data func HTTPGetUeContextInSmfData(c *gin.Context) { - req := http_wrapper.NewRequest(c.Request, nil) + req := httpwrapper.NewRequest(c.Request, nil) req.Params["supi"] = c.Params.ByName("supi") req.Query.Set("supported-features", c.Query("supported-features")) diff --git a/subscriberdatamanagement/api_ue_context_in_smsf_data_retrieval.go b/internal/sbi/subscriberdatamanagement/api_ue_context_in_smsf_data_retrieval.go similarity index 100% rename from subscriberdatamanagement/api_ue_context_in_smsf_data_retrieval.go rename to internal/sbi/subscriberdatamanagement/api_ue_context_in_smsf_data_retrieval.go diff --git a/subscriberdatamanagement/routers.go b/internal/sbi/subscriberdatamanagement/routers.go similarity index 98% rename from subscriberdatamanagement/routers.go rename to internal/sbi/subscriberdatamanagement/routers.go index cfaa524..0d8a0e6 100644 --- a/subscriberdatamanagement/routers.go +++ b/internal/sbi/subscriberdatamanagement/routers.go @@ -15,8 +15,8 @@ import ( "github.com/gin-gonic/gin" - "github.com/free5gc/logger_util" - "github.com/free5gc/udm/logger" + "github.com/free5gc/udm/internal/logger" + logger_util "github.com/free5gc/util/logger" ) // Route is the information for every URI. @@ -168,6 +168,7 @@ var routes = Routes{ }, } +/* var specialRouter = Routes{ { "GetIdTranslationResult", @@ -190,6 +191,7 @@ var specialRouter = Routes{ HTTPModifyForSharedData, }, } +*/ var oneLayerPathRouter = Routes{ { @@ -286,6 +288,7 @@ var twoLayerPathRouter = Routes{ }, } +/* var threeLayerPathRouter = Routes{ { "Unsubscribe", @@ -443,3 +446,4 @@ var routesBackup = Routes{ HTTPGetIdTranslationResult, }, } +*/ diff --git a/ueauthentication/api_confirm_auth.go b/internal/sbi/ueauthentication/api_confirm_auth.go similarity index 90% rename from ueauthentication/api_confirm_auth.go rename to internal/sbi/ueauthentication/api_confirm_auth.go index a6df260..6e6e79d 100644 --- a/ueauthentication/api_confirm_auth.go +++ b/internal/sbi/ueauthentication/api_confirm_auth.go @@ -14,11 +14,11 @@ import ( "github.com/gin-gonic/gin" - "github.com/free5gc/http_wrapper" "github.com/free5gc/openapi" "github.com/free5gc/openapi/models" - "github.com/free5gc/udm/logger" - "github.com/free5gc/udm/producer" + "github.com/free5gc/udm/internal/logger" + "github.com/free5gc/udm/internal/sbi/producer" + "github.com/free5gc/util/httpwrapper" ) // ConfirmAuth - Create a new confirmation event @@ -52,7 +52,7 @@ func HTTPConfirmAuth(c *gin.Context) { return } - req := http_wrapper.NewRequest(c.Request, authEvent) + req := httpwrapper.NewRequest(c.Request, authEvent) req.Params["supi"] = c.Params.ByName("supi") rsp := producer.HandleConfirmAuthDataRequest(req) diff --git a/ueauthentication/api_generate_auth_data.go b/internal/sbi/ueauthentication/api_generate_auth_data.go similarity index 90% rename from ueauthentication/api_generate_auth_data.go rename to internal/sbi/ueauthentication/api_generate_auth_data.go index ec7da88..a4e0680 100644 --- a/ueauthentication/api_generate_auth_data.go +++ b/internal/sbi/ueauthentication/api_generate_auth_data.go @@ -14,11 +14,11 @@ import ( "github.com/gin-gonic/gin" - "github.com/free5gc/http_wrapper" "github.com/free5gc/openapi" "github.com/free5gc/openapi/models" - "github.com/free5gc/udm/logger" - "github.com/free5gc/udm/producer" + "github.com/free5gc/udm/internal/logger" + "github.com/free5gc/udm/internal/sbi/producer" + "github.com/free5gc/util/httpwrapper" ) // GenerateAuthData - Generate authentication data for the UE @@ -53,7 +53,7 @@ func HttpGenerateAuthData(c *gin.Context) { return } - req := http_wrapper.NewRequest(c.Request, authInfoReq) + req := httpwrapper.NewRequest(c.Request, authInfoReq) req.Params["supiOrSuci"] = c.Param("supiOrSuci") rsp := producer.HandleGenerateAuthDataRequest(req) @@ -70,5 +70,4 @@ func HttpGenerateAuthData(c *gin.Context) { } else { c.Data(rsp.Status, "application/json", responseBody) } - return } diff --git a/ueauthentication/routers.go b/internal/sbi/ueauthentication/routers.go similarity index 95% rename from ueauthentication/routers.go rename to internal/sbi/ueauthentication/routers.go index 53fb187..ec25a32 100644 --- a/ueauthentication/routers.go +++ b/internal/sbi/ueauthentication/routers.go @@ -16,8 +16,8 @@ import ( "github.com/gin-gonic/gin" "github.com/sirupsen/logrus" - "github.com/free5gc/logger_util" - "github.com/free5gc/udm/logger" + "github.com/free5gc/udm/internal/logger" + logger_util "github.com/free5gc/util/logger" ) var HttpLog *logrus.Entry @@ -103,6 +103,7 @@ var routes = Routes{ }, } +/* var specialRoutes = Routes{ { "GenerateAuthData", @@ -111,3 +112,4 @@ var specialRoutes = Routes{ HttpGenerateAuthData, }, } +*/ diff --git a/uecontextmanagement/api_amf3_gpp_access_registration_info_retrieval.go b/internal/sbi/uecontextmanagement/api_amf3_gpp_access_registration_info_retrieval.go similarity index 84% rename from uecontextmanagement/api_amf3_gpp_access_registration_info_retrieval.go rename to internal/sbi/uecontextmanagement/api_amf3_gpp_access_registration_info_retrieval.go index 2ffbd0a..4a0acd5 100644 --- a/uecontextmanagement/api_amf3_gpp_access_registration_info_retrieval.go +++ b/internal/sbi/uecontextmanagement/api_amf3_gpp_access_registration_info_retrieval.go @@ -14,17 +14,16 @@ import ( "github.com/gin-gonic/gin" - // "fmt" - "github.com/free5gc/http_wrapper" "github.com/free5gc/openapi" "github.com/free5gc/openapi/models" - "github.com/free5gc/udm/logger" - "github.com/free5gc/udm/producer" + "github.com/free5gc/udm/internal/logger" + "github.com/free5gc/udm/internal/sbi/producer" + "github.com/free5gc/util/httpwrapper" ) // GetAmf3gppAccess - retrieve the AMF registration for 3GPP access information func HTTPGetAmf3gppAccess(c *gin.Context) { - req := http_wrapper.NewRequest(c.Request, nil) + req := httpwrapper.NewRequest(c.Request, nil) req.Params["ueId"] = c.Param("ueId") req.Query.Add("supported-features", c.Query("supported-features")) @@ -42,5 +41,4 @@ func HTTPGetAmf3gppAccess(c *gin.Context) { } else { c.Data(rsp.Status, "application/json", responseBody) } - return } diff --git a/uecontextmanagement/api_amf_non3_gpp_access_registration_info_retrieval.go b/internal/sbi/uecontextmanagement/api_amf_non3_gpp_access_registration_info_retrieval.go similarity index 84% rename from uecontextmanagement/api_amf_non3_gpp_access_registration_info_retrieval.go rename to internal/sbi/uecontextmanagement/api_amf_non3_gpp_access_registration_info_retrieval.go index 2c98fc7..b33fb42 100644 --- a/uecontextmanagement/api_amf_non3_gpp_access_registration_info_retrieval.go +++ b/internal/sbi/uecontextmanagement/api_amf_non3_gpp_access_registration_info_retrieval.go @@ -14,16 +14,16 @@ import ( "github.com/gin-gonic/gin" - "github.com/free5gc/http_wrapper" "github.com/free5gc/openapi" "github.com/free5gc/openapi/models" - "github.com/free5gc/udm/logger" - "github.com/free5gc/udm/producer" + "github.com/free5gc/udm/internal/logger" + "github.com/free5gc/udm/internal/sbi/producer" + "github.com/free5gc/util/httpwrapper" ) // GetAmfNon3gppAccess - retrieve the AMF registration for non-3GPP access information func HTTPGetAmfNon3gppAccess(c *gin.Context) { - req := http_wrapper.NewRequest(c.Request, nil) + req := httpwrapper.NewRequest(c.Request, nil) req.Params["ueId"] = c.Param("ueId") req.Query.Add("supported-features", c.Query("supported-features")) diff --git a/uecontextmanagement/api_amf_registration_for3_gpp_access.go b/internal/sbi/uecontextmanagement/api_amf_registration_for3_gpp_access.go similarity index 90% rename from uecontextmanagement/api_amf_registration_for3_gpp_access.go rename to internal/sbi/uecontextmanagement/api_amf_registration_for3_gpp_access.go index 03c93a6..7e39c21 100644 --- a/uecontextmanagement/api_amf_registration_for3_gpp_access.go +++ b/internal/sbi/uecontextmanagement/api_amf_registration_for3_gpp_access.go @@ -14,12 +14,11 @@ import ( "github.com/gin-gonic/gin" - // "fmt" - "github.com/free5gc/http_wrapper" "github.com/free5gc/openapi" "github.com/free5gc/openapi/models" - "github.com/free5gc/udm/logger" - "github.com/free5gc/udm/producer" + "github.com/free5gc/udm/internal/logger" + "github.com/free5gc/udm/internal/sbi/producer" + "github.com/free5gc/util/httpwrapper" ) // RegistrationAmf3gppAccess - register as AMF for 3GPP access @@ -53,7 +52,7 @@ func HTTPRegistrationAmf3gppAccess(c *gin.Context) { return } - req := http_wrapper.NewRequest(c.Request, amf3GppAccessRegistration) + req := httpwrapper.NewRequest(c.Request, amf3GppAccessRegistration) req.Params["ueId"] = c.Param("ueId") rsp := producer.HandleRegistrationAmf3gppAccessRequest(req) diff --git a/uecontextmanagement/api_amf_registration_for_non3_gpp_access.go b/internal/sbi/uecontextmanagement/api_amf_registration_for_non3_gpp_access.go similarity index 90% rename from uecontextmanagement/api_amf_registration_for_non3_gpp_access.go rename to internal/sbi/uecontextmanagement/api_amf_registration_for_non3_gpp_access.go index 5f590ff..6190365 100644 --- a/uecontextmanagement/api_amf_registration_for_non3_gpp_access.go +++ b/internal/sbi/uecontextmanagement/api_amf_registration_for_non3_gpp_access.go @@ -14,11 +14,11 @@ import ( "github.com/gin-gonic/gin" - "github.com/free5gc/http_wrapper" "github.com/free5gc/openapi" "github.com/free5gc/openapi/models" - "github.com/free5gc/udm/logger" - "github.com/free5gc/udm/producer" + "github.com/free5gc/udm/internal/logger" + "github.com/free5gc/udm/internal/sbi/producer" + "github.com/free5gc/util/httpwrapper" ) // Register - register as AMF for non-3GPP access @@ -53,7 +53,7 @@ func HTTPRegistrationAmfNon3gppAccess(c *gin.Context) { return } - req := http_wrapper.NewRequest(c.Request, amfNon3GppAccessRegistration) + req := httpwrapper.NewRequest(c.Request, amfNon3GppAccessRegistration) req.Params["ueId"] = c.Param("ueId") rsp := producer.HandleRegisterAmfNon3gppAccessRequest(req) diff --git a/uecontextmanagement/api_parameter_update_in_the_amf_registration_for3_gpp_access.go b/internal/sbi/uecontextmanagement/api_parameter_update_in_the_amf_registration_for3_gpp_access.go similarity index 89% rename from uecontextmanagement/api_parameter_update_in_the_amf_registration_for3_gpp_access.go rename to internal/sbi/uecontextmanagement/api_parameter_update_in_the_amf_registration_for3_gpp_access.go index f41454c..3646f85 100644 --- a/uecontextmanagement/api_parameter_update_in_the_amf_registration_for3_gpp_access.go +++ b/internal/sbi/uecontextmanagement/api_parameter_update_in_the_amf_registration_for3_gpp_access.go @@ -14,12 +14,11 @@ import ( "github.com/gin-gonic/gin" - // "fmt" - "github.com/free5gc/http_wrapper" "github.com/free5gc/openapi" "github.com/free5gc/openapi/models" - "github.com/free5gc/udm/logger" - "github.com/free5gc/udm/producer" + "github.com/free5gc/udm/internal/logger" + "github.com/free5gc/udm/internal/sbi/producer" + "github.com/free5gc/util/httpwrapper" ) // UpdateAmf3gppAccess - Update a parameter in the AMF registration for 3GPP access @@ -54,7 +53,7 @@ func HTTPUpdateAmf3gppAccess(c *gin.Context) { return } - req := http_wrapper.NewRequest(c.Request, amf3GppAccessRegistrationModification) + req := httpwrapper.NewRequest(c.Request, amf3GppAccessRegistrationModification) req.Params["ueId"] = c.Param("ueId") rsp := producer.HandleUpdateAmf3gppAccessRequest(req) diff --git a/uecontextmanagement/api_parameter_update_in_the_amf_registration_for_non3_gpp_access.go b/internal/sbi/uecontextmanagement/api_parameter_update_in_the_amf_registration_for_non3_gpp_access.go similarity index 89% rename from uecontextmanagement/api_parameter_update_in_the_amf_registration_for_non3_gpp_access.go rename to internal/sbi/uecontextmanagement/api_parameter_update_in_the_amf_registration_for_non3_gpp_access.go index 4aadc77..775071e 100644 --- a/uecontextmanagement/api_parameter_update_in_the_amf_registration_for_non3_gpp_access.go +++ b/internal/sbi/uecontextmanagement/api_parameter_update_in_the_amf_registration_for_non3_gpp_access.go @@ -14,11 +14,11 @@ import ( "github.com/gin-gonic/gin" - "github.com/free5gc/http_wrapper" "github.com/free5gc/openapi" "github.com/free5gc/openapi/models" - "github.com/free5gc/udm/logger" - "github.com/free5gc/udm/producer" + "github.com/free5gc/udm/internal/logger" + "github.com/free5gc/udm/internal/sbi/producer" + "github.com/free5gc/util/httpwrapper" ) // UpdateAmfNon3gppAccess - update a parameter in the AMF registration for non-3GPP access @@ -52,7 +52,7 @@ func HTTPUpdateAmfNon3gppAccess(c *gin.Context) { return } - req := http_wrapper.NewRequest(c.Request, amfNon3GppAccessRegistrationModification) + req := httpwrapper.NewRequest(c.Request, amfNon3GppAccessRegistrationModification) req.Params["ueId"] = c.Param("ueId") rsp := producer.HandleUpdateAmfNon3gppAccessRequest(req) @@ -69,5 +69,4 @@ func HTTPUpdateAmfNon3gppAccess(c *gin.Context) { } else { c.Data(rsp.Status, "application/json", responseBody) } - return } diff --git a/uecontextmanagement/api_smf_deregistration.go b/internal/sbi/uecontextmanagement/api_smf_deregistration.go similarity index 84% rename from uecontextmanagement/api_smf_deregistration.go rename to internal/sbi/uecontextmanagement/api_smf_deregistration.go index 512c949..bdbc0a0 100644 --- a/uecontextmanagement/api_smf_deregistration.go +++ b/internal/sbi/uecontextmanagement/api_smf_deregistration.go @@ -14,16 +14,16 @@ import ( "github.com/gin-gonic/gin" - "github.com/free5gc/http_wrapper" "github.com/free5gc/openapi" "github.com/free5gc/openapi/models" - "github.com/free5gc/udm/logger" - "github.com/free5gc/udm/producer" + "github.com/free5gc/udm/internal/logger" + "github.com/free5gc/udm/internal/sbi/producer" + "github.com/free5gc/util/httpwrapper" ) // DeregistrationSmfRegistrations - delete an SMF registration func HTTPDeregistrationSmfRegistrations(c *gin.Context) { - req := http_wrapper.NewRequest(c.Request, nil) + req := httpwrapper.NewRequest(c.Request, nil) req.Params["ueId"] = c.Params.ByName("ueId") req.Params["pduSessionId"] = c.Params.ByName("pduSessionId") diff --git a/uecontextmanagement/api_smf_registration.go b/internal/sbi/uecontextmanagement/api_smf_registration.go similarity index 91% rename from uecontextmanagement/api_smf_registration.go rename to internal/sbi/uecontextmanagement/api_smf_registration.go index 3a396f3..03b2f13 100644 --- a/uecontextmanagement/api_smf_registration.go +++ b/internal/sbi/uecontextmanagement/api_smf_registration.go @@ -14,11 +14,11 @@ import ( "github.com/gin-gonic/gin" - "github.com/free5gc/http_wrapper" "github.com/free5gc/openapi" "github.com/free5gc/openapi/models" - "github.com/free5gc/udm/logger" - "github.com/free5gc/udm/producer" + "github.com/free5gc/udm/internal/logger" + "github.com/free5gc/udm/internal/sbi/producer" + "github.com/free5gc/util/httpwrapper" ) // RegistrationSmfRegistrations - register as SMF @@ -52,7 +52,7 @@ func HTTPRegistrationSmfRegistrations(c *gin.Context) { c.JSON(http.StatusBadRequest, rsp) return } - req := http_wrapper.NewRequest(c.Request, smfRegistration) + req := httpwrapper.NewRequest(c.Request, smfRegistration) req.Params["ueId"] = c.Params.ByName("ueId") req.Params["pduSessionId"] = c.Params.ByName("pduSessionId") diff --git a/uecontextmanagement/api_smsf3_gpp_access_registration_info_retrieval.go b/internal/sbi/uecontextmanagement/api_smsf3_gpp_access_registration_info_retrieval.go similarity index 100% rename from uecontextmanagement/api_smsf3_gpp_access_registration_info_retrieval.go rename to internal/sbi/uecontextmanagement/api_smsf3_gpp_access_registration_info_retrieval.go diff --git a/uecontextmanagement/api_smsf_deregistration_for3_gpp_access.go b/internal/sbi/uecontextmanagement/api_smsf_deregistration_for3_gpp_access.go similarity index 100% rename from uecontextmanagement/api_smsf_deregistration_for3_gpp_access.go rename to internal/sbi/uecontextmanagement/api_smsf_deregistration_for3_gpp_access.go diff --git a/uecontextmanagement/api_smsf_deregistration_for_non3_gpp_access.go b/internal/sbi/uecontextmanagement/api_smsf_deregistration_for_non3_gpp_access.go similarity index 100% rename from uecontextmanagement/api_smsf_deregistration_for_non3_gpp_access.go rename to internal/sbi/uecontextmanagement/api_smsf_deregistration_for_non3_gpp_access.go diff --git a/uecontextmanagement/api_smsf_non3_gpp_access_registration_info_retrieval.go b/internal/sbi/uecontextmanagement/api_smsf_non3_gpp_access_registration_info_retrieval.go similarity index 100% rename from uecontextmanagement/api_smsf_non3_gpp_access_registration_info_retrieval.go rename to internal/sbi/uecontextmanagement/api_smsf_non3_gpp_access_registration_info_retrieval.go diff --git a/uecontextmanagement/api_smsf_registration_for3_gpp_access.go b/internal/sbi/uecontextmanagement/api_smsf_registration_for3_gpp_access.go similarity index 100% rename from uecontextmanagement/api_smsf_registration_for3_gpp_access.go rename to internal/sbi/uecontextmanagement/api_smsf_registration_for3_gpp_access.go diff --git a/uecontextmanagement/api_smsf_registration_for_non3_gpp_access.go b/internal/sbi/uecontextmanagement/api_smsf_registration_for_non3_gpp_access.go similarity index 100% rename from uecontextmanagement/api_smsf_registration_for_non3_gpp_access.go rename to internal/sbi/uecontextmanagement/api_smsf_registration_for_non3_gpp_access.go diff --git a/uecontextmanagement/routers.go b/internal/sbi/uecontextmanagement/routers.go similarity index 97% rename from uecontextmanagement/routers.go rename to internal/sbi/uecontextmanagement/routers.go index bbb3cdf..c609161 100644 --- a/uecontextmanagement/routers.go +++ b/internal/sbi/uecontextmanagement/routers.go @@ -15,8 +15,8 @@ import ( "github.com/gin-gonic/gin" - "github.com/free5gc/logger_util" - "github.com/free5gc/udm/logger" + "github.com/free5gc/udm/internal/logger" + logger_util "github.com/free5gc/util/logger" ) // Route is the information for every URI. diff --git a/util/init_context.go b/internal/util/init_context.go similarity index 82% rename from util/init_context.go rename to internal/util/init_context.go index 2f1865d..6f749ef 100644 --- a/util/init_context.go +++ b/internal/util/init_context.go @@ -6,9 +6,9 @@ import ( "github.com/google/uuid" "github.com/free5gc/openapi/models" - "github.com/free5gc/udm/context" - "github.com/free5gc/udm/factory" - "github.com/free5gc/udm/logger" + "github.com/free5gc/udm/internal/context" + "github.com/free5gc/udm/internal/logger" + "github.com/free5gc/udm/pkg/factory" ) func InitUDMContext(udmContext *context.UDMContext) { @@ -16,13 +16,10 @@ func InitUDMContext(udmContext *context.UDMContext) { logger.UtilLog.Info("udmconfig Info: Version[", config.Info.Version, "] Description[", config.Info.Description, "]") configuration := config.Configuration udmContext.NfId = uuid.New().String() - if configuration.UdmName != "" { - udmContext.Name = configuration.UdmName - } sbi := configuration.Sbi udmContext.UriScheme = "" - udmContext.SBIPort = factory.UDM_DEFAULT_PORT_INT - udmContext.RegisterIPv4 = factory.UDM_DEFAULT_IPV4 + udmContext.SBIPort = factory.UdmSbiDefaultPort + udmContext.RegisterIPv4 = factory.UdmSbiDefaultIPv4 if sbi != nil { if sbi.Scheme != "" { udmContext.UriScheme = models.UriScheme(sbi.Scheme) diff --git a/util/search_nf_service.go b/internal/util/search_nf_service.go similarity index 100% rename from util/search_nf_service.go rename to internal/util/search_nf_service.go diff --git a/util/util.go b/internal/util/util.go similarity index 60% rename from util/util.go rename to internal/util/util.go index 6c0b67d..d4d0d5c 100644 --- a/util/util.go +++ b/internal/util/util.go @@ -6,6 +6,13 @@ import ( "github.com/free5gc/openapi/models" ) +const ( + UdmDefaultKeyLogPath = "./log/udmsslkey.log" + UdmDefaultPemPath = "./config/TLS/udm.pem" + UdmDefaultKeyPath = "./config/TLS/udm.key" + UdmDefaultConfigPath = "./config/udmcfg.yaml" +) + func ProblemDetailsSystemFailure(detail string) *models.ProblemDetails { return &models.ProblemDetails{ Title: "System failure", diff --git a/pkg/factory/config.go b/pkg/factory/config.go new file mode 100644 index 0000000..d5ef6c8 --- /dev/null +++ b/pkg/factory/config.go @@ -0,0 +1,174 @@ +/* + * UDM Configuration Factory + */ + +package factory + +import ( + "fmt" + + "github.com/asaskevich/govalidator" + + "github.com/free5gc/udm/pkg/suci" + logger_util "github.com/free5gc/util/logger" +) + +const ( + UdmExpectedConfigVersion = "1.0.2" + UdmSbiDefaultIPv4 = "127.0.0.3" + UdmSbiDefaultPort = 8000 +) + +type Config struct { + Info *Info `yaml:"info" valid:"required"` + Configuration *Configuration `yaml:"configuration" valid:"required"` + Logger *logger_util.Logger `yaml:"logger" valid:"optional"` +} + +func (c *Config) Validate() (bool, error) { + if info := c.Info; info != nil { + if result, err := info.validate(); err != nil { + return result, err + } + } + + if configuration := c.Configuration; configuration != nil { + if result, err := configuration.validate(); err != nil { + return result, err + } + } + + if logger := c.Logger; logger != nil { + if result, err := logger.Validate(); err != nil { + return result, err + } + } + + result, err := govalidator.ValidateStruct(c) + return result, appendInvalid(err) +} + +type Info struct { + Version string `yaml:"version,omitempty" valid:"type(string)"` + Description string `yaml:"description,omitempty" valid:"type(string)"` +} + +func (i *Info) validate() (bool, error) { + result, err := govalidator.ValidateStruct(i) + return result, appendInvalid(err) +} + +type Configuration struct { + Sbi *Sbi `yaml:"sbi,omitempty" valid:"required"` + ServiceNameList []string `yaml:"serviceNameList,omitempty" valid:"required"` + NrfUri string `yaml:"nrfUri,omitempty" valid:"required, url"` + SuciProfiles []suci.SuciProfile `yaml:"SuciProfile,omitempty"` +} + +func (c *Configuration) validate() (bool, error) { + if sbi := c.Sbi; sbi != nil { + if result, err := sbi.validate(); err != nil { + return result, err + } + } + + if c.ServiceNameList != nil { + var errs govalidator.Errors + for _, v := range c.ServiceNameList { + if v != "nudm-sdm" && v != "nudm-uecm" && v != "nudm-ueau" && v != "nudm-ee" && v != "nudm-pp" { + err := fmt.Errorf("Invalid ServiceNameList: [%s],"+ + " value should be nudm-sdm or nudm-uecm or nudm-ueau or nudm-ee or nudm-pp", v) + errs = append(errs, err) + } + } + if len(errs) > 0 { + return false, error(errs) + } + } + + if c.SuciProfiles != nil { + var errs govalidator.Errors + for _, s := range c.SuciProfiles { + protectScheme := s.ProtectionScheme + if result := govalidator.StringMatches(protectScheme, "^[A-F0-9]{1}$"); !result { + err := fmt.Errorf("Invalid ProtectionScheme: %s, should be a single hexadecimal digit", protectScheme) + errs = append(errs, err) + } + + privateKey := s.PrivateKey + if result := govalidator.StringMatches(privateKey, "^[A-Fa-f0-9]{64}$"); !result { + err := fmt.Errorf("Invalid PrivateKey: %s, should be 64 hexadecimal digits", privateKey) + errs = append(errs, err) + } + + publicKey := s.PublicKey + if result := govalidator.StringMatches(publicKey, "^[A-Fa-f0-9]{64,130}$"); !result { + err := fmt.Errorf("Invalid PublicKey: %s, should be 64(profile A), 66(profile B, compressed),"+ + "or 130(profile B, uncompressed) hexadecimal digits", publicKey) + errs = append(errs, err) + } + } + if len(errs) > 0 { + return false, error(errs) + } + } + + result, err := govalidator.ValidateStruct(c) + return result, err +} + +type Sbi struct { + Scheme string `yaml:"scheme" valid:"scheme"` + RegisterIPv4 string `yaml:"registerIPv4,omitempty" valid:"host,required"` // IP that is registered at NRF. + // IPv6Addr string `yaml:"ipv6Addr,omitempty"` + BindingIPv4 string `yaml:"bindingIPv4,omitempty" valid:"host,required"` // IP used to run the server in the node. + Port int `yaml:"port,omitempty" valid:"port,required"` + Tls *Tls `yaml:"tls,omitempty" valid:"optional"` +} + +func (s *Sbi) validate() (bool, error) { + govalidator.TagMap["scheme"] = govalidator.Validator(func(str string) bool { + return str == "https" || str == "http" + }) + + if tls := s.Tls; tls != nil { + if result, err := tls.validate(); err != nil { + return result, err + } + } + + result, err := govalidator.ValidateStruct(s) + return result, err +} + +type Tls struct { + Pem string `yaml:"pem,omitempty" valid:"type(string),minstringlength(1),required"` + Key string `yaml:"key,omitempty" valid:"type(string),minstringlength(1),required"` +} + +func (t *Tls) validate() (bool, error) { + result, err := govalidator.ValidateStruct(t) + return result, err +} + +func appendInvalid(err error) error { + var errs govalidator.Errors + + if err == nil { + return nil + } + + es := err.(govalidator.Errors).Errors() + for _, e := range es { + errs = append(errs, fmt.Errorf("Invalid %w", e)) + } + + return error(errs) +} + +func (c *Config) GetVersion() string { + if c.Info != nil && c.Info.Version != "" { + return c.Info.Version + } + return "" +} diff --git a/factory/factory.go b/pkg/factory/factory.go similarity index 82% rename from factory/factory.go rename to pkg/factory/factory.go index fdeed16..0745635 100644 --- a/factory/factory.go +++ b/pkg/factory/factory.go @@ -10,7 +10,7 @@ import ( "gopkg.in/yaml.v2" - "github.com/free5gc/udm/logger" + "github.com/free5gc/udm/internal/logger" ) var UdmConfig Config @@ -33,9 +33,9 @@ func InitConfigFactory(f string) error { func CheckConfigVersion() error { currentVersion := UdmConfig.GetVersion() - if currentVersion != UDM_EXPECTED_CONFIG_VERSION { + if currentVersion != UdmExpectedConfigVersion { return fmt.Errorf("config version is [%s], but expected is [%s].", - currentVersion, UDM_EXPECTED_CONFIG_VERSION) + currentVersion, UdmExpectedConfigVersion) } logger.CfgLog.Infof("config version [%s]", currentVersion) diff --git a/service/init.go b/pkg/service/init.go similarity index 50% rename from service/init.go rename to pkg/service/init.go index a34caa6..31f85dc 100644 --- a/service/init.go +++ b/pkg/service/init.go @@ -6,141 +6,110 @@ import ( "os" "os/exec" "os/signal" + "runtime/debug" "sync" "syscall" "github.com/sirupsen/logrus" "github.com/urfave/cli" - "github.com/free5gc/http2_util" - "github.com/free5gc/logger_util" - openApiLogger "github.com/free5gc/openapi/logger" - "github.com/free5gc/path_util" - pathUtilLogger "github.com/free5gc/path_util/logger" - "github.com/free5gc/udm/consumer" - "github.com/free5gc/udm/context" - "github.com/free5gc/udm/eventexposure" - "github.com/free5gc/udm/factory" - "github.com/free5gc/udm/httpcallback" - "github.com/free5gc/udm/logger" - "github.com/free5gc/udm/parameterprovision" - "github.com/free5gc/udm/subscriberdatamanagement" - "github.com/free5gc/udm/ueauthentication" - "github.com/free5gc/udm/uecontextmanagement" - "github.com/free5gc/udm/util" + "github.com/free5gc/udm/internal/context" + "github.com/free5gc/udm/internal/logger" + "github.com/free5gc/udm/internal/sbi/consumer" + "github.com/free5gc/udm/internal/sbi/eventexposure" + "github.com/free5gc/udm/internal/sbi/httpcallback" + "github.com/free5gc/udm/internal/sbi/parameterprovision" + "github.com/free5gc/udm/internal/sbi/subscriberdatamanagement" + "github.com/free5gc/udm/internal/sbi/ueauthentication" + "github.com/free5gc/udm/internal/sbi/uecontextmanagement" + "github.com/free5gc/udm/internal/util" + "github.com/free5gc/udm/pkg/factory" + "github.com/free5gc/util/httpwrapper" + logger_util "github.com/free5gc/util/logger" ) -type UDM struct{} +type UDM struct { + KeyLogPath string +} type ( - // Config information. - Config struct { - udmcfg string + // Commands information. + Commands struct { + config string } ) -var config Config +var commands Commands -var udmCLi = []cli.Flag{ +var cliCmd = []cli.Flag{ cli.StringFlag{ - Name: "free5gccfg", - Usage: "common config file", + Name: "config, c", + Usage: "Load configuration from `FILE`", }, cli.StringFlag{ - Name: "udmcfg", - Usage: "config file", + Name: "log, l", + Usage: "Output NF log to `FILE`", + }, + cli.StringFlag{ + Name: "log5gc, lc", + Usage: "Output free5gc log to `FILE`", }, -} - -var initLog *logrus.Entry - -func init() { - initLog = logger.InitLog } func (*UDM) GetCliCmd() (flags []cli.Flag) { - return udmCLi + return cliCmd } func (udm *UDM) Initialize(c *cli.Context) error { - config = Config{ - udmcfg: c.String("udmcfg"), + commands = Commands{ + config: c.String("config"), } - if config.udmcfg != "" { - if err := factory.InitConfigFactory(config.udmcfg); err != nil { + if commands.config != "" { + if err := factory.InitConfigFactory(commands.config); err != nil { return err } } else { - DefaultUdmConfigPath := path_util.Free5gcPath("free5gc/config/udmcfg.yaml") - if err := factory.InitConfigFactory(DefaultUdmConfigPath); err != nil { + if err := factory.InitConfigFactory(util.UdmDefaultConfigPath); err != nil { return err } } - udm.setLogLevel() - if err := factory.CheckConfigVersion(); err != nil { return err } + if _, validErr := factory.UdmConfig.Validate(); validErr != nil { + return validErr + } + + udm.setLogLevel() + return nil } func (udm *UDM) setLogLevel() { if factory.UdmConfig.Logger == nil { - initLog.Warnln("UDM config without log level setting!!!") + logger.InitLog.Warnln("UDM config without log level setting!!!") return } if factory.UdmConfig.Logger.UDM != nil { if factory.UdmConfig.Logger.UDM.DebugLevel != "" { if level, err := logrus.ParseLevel(factory.UdmConfig.Logger.UDM.DebugLevel); err != nil { - initLog.Warnf("UDM Log level [%s] is invalid, set to [info] level", + logger.InitLog.Warnf("UDM Log level [%s] is invalid, set to [info] level", factory.UdmConfig.Logger.UDM.DebugLevel) logger.SetLogLevel(logrus.InfoLevel) } else { - initLog.Infof("UDM Log level is set to [%s] level", level) + logger.InitLog.Infof("UDM Log level is set to [%s] level", level) logger.SetLogLevel(level) } } else { - initLog.Infoln("UDM Log level is default set to [info] level") + logger.InitLog.Infoln("UDM Log level is default set to [info] level") logger.SetLogLevel(logrus.InfoLevel) } logger.SetReportCaller(factory.UdmConfig.Logger.UDM.ReportCaller) } - - if factory.UdmConfig.Logger.PathUtil != nil { - if factory.UdmConfig.Logger.PathUtil.DebugLevel != "" { - if level, err := logrus.ParseLevel(factory.UdmConfig.Logger.PathUtil.DebugLevel); err != nil { - pathUtilLogger.PathLog.Warnf("PathUtil Log level [%s] is invalid, set to [info] level", - factory.UdmConfig.Logger.PathUtil.DebugLevel) - pathUtilLogger.SetLogLevel(logrus.InfoLevel) - } else { - pathUtilLogger.SetLogLevel(level) - } - } else { - pathUtilLogger.PathLog.Warnln("PathUtil Log level not set. Default set to [info] level") - pathUtilLogger.SetLogLevel(logrus.InfoLevel) - } - pathUtilLogger.SetReportCaller(factory.UdmConfig.Logger.PathUtil.ReportCaller) - } - - if factory.UdmConfig.Logger.OpenApi != nil { - if factory.UdmConfig.Logger.OpenApi.DebugLevel != "" { - if level, err := logrus.ParseLevel(factory.UdmConfig.Logger.OpenApi.DebugLevel); err != nil { - openApiLogger.OpenApiLog.Warnf("OpenAPI Log level [%s] is invalid, set to [info] level", - factory.UdmConfig.Logger.OpenApi.DebugLevel) - openApiLogger.SetLogLevel(logrus.InfoLevel) - } else { - openApiLogger.SetLogLevel(level) - } - } else { - openApiLogger.OpenApiLog.Warnln("OpenAPI Log level not set. Default set to [info] level") - openApiLogger.SetLogLevel(logrus.InfoLevel) - } - openApiLogger.SetReportCaller(factory.UdmConfig.Logger.OpenApi.ReportCaller) - } } func (udm *UDM) FilterCli(c *cli.Context) (args []string) { @@ -162,9 +131,9 @@ func (udm *UDM) Start() { sbi := configuration.Sbi serviceName := configuration.ServiceNameList - initLog.Infof("UDM Config Info: Version[%s] Description[%s]", config.Info.Version, config.Info.Description) + logger.InitLog.Infof("UDM Config Info: Version[%s] Description[%s]", config.Info.Version, config.Info.Description) - initLog.Infoln("Server started") + logger.InitLog.Infoln("Server started") router := logger_util.NewGinWithLogrus(logger.GinLog) @@ -175,13 +144,11 @@ func (udm *UDM) Start() { ueauthentication.AddService(router) uecontextmanagement.AddService(router) - udmLogPath := path_util.Free5gcPath("free5gc/udmsslkey.log") - udmPemPath := path_util.Free5gcPath("free5gc/support/TLS/udm.pem") - udmKeyPath := path_util.Free5gcPath("free5gc/support/TLS/udm.key") + pemPath := util.UdmDefaultPemPath + keyPath := util.UdmDefaultKeyPath if sbi.Tls != nil { - udmLogPath = path_util.Free5gcPath(sbi.Tls.Log) - udmPemPath = path_util.Free5gcPath(sbi.Tls.Pem) - udmKeyPath = path_util.Free5gcPath(sbi.Tls.Key) + pemPath = sbi.Tls.Pem + keyPath = sbi.Tls.Key } self := context.UDM_Self() @@ -207,48 +174,62 @@ func (udm *UDM) Start() { signalChannel := make(chan os.Signal, 1) signal.Notify(signalChannel, os.Interrupt, syscall.SIGTERM) go func() { + 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())) + } + }() + <-signalChannel udm.Terminate() os.Exit(0) }() - server, err := http2_util.NewServer(addr, udmLogPath, router) + server, err := httpwrapper.NewHttp2Server(addr, udm.KeyLogPath, router) if server == nil { - initLog.Errorf("Initialize HTTP server failed: %+v", err) + logger.InitLog.Errorf("Initialize HTTP server failed: %+v", err) return } if err != nil { - initLog.Warnf("Initialize HTTP server: +%v", err) + logger.InitLog.Warnf("Initialize HTTP server: +%v", err) } serverScheme := factory.UdmConfig.Configuration.Sbi.Scheme if serverScheme == "http" { err = server.ListenAndServe() } else if serverScheme == "https" { - err = server.ListenAndServeTLS(udmPemPath, udmKeyPath) + err = server.ListenAndServeTLS(pemPath, keyPath) } if err != nil { - initLog.Fatalf("HTTP server setup failed: %+v", err) + logger.InitLog.Fatalf("HTTP server setup failed: %+v", err) } } func (udm *UDM) Exec(c *cli.Context) error { // UDM.Initialize(cfgPath, c) - initLog.Traceln("args:", c.String("udmcfg")) + logger.InitLog.Traceln("args:", c.String("udmcfg")) args := udm.FilterCli(c) - initLog.Traceln("filter: ", args) + logger.InitLog.Traceln("filter: ", args) command := exec.Command("./udm", args...) stdout, err := command.StdoutPipe() if err != nil { - initLog.Fatalln(err) + logger.InitLog.Fatalln(err) } wg := sync.WaitGroup{} wg.Add(3) go func() { + 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())) + } + }() + in := bufio.NewScanner(stdout) for in.Scan() { fmt.Println(in.Text()) @@ -258,9 +239,16 @@ func (udm *UDM) Exec(c *cli.Context) error { stderr, err := command.StderrPipe() if err != nil { - initLog.Fatalln(err) + logger.InitLog.Fatalln(err) } go func() { + 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())) + } + }() + in := bufio.NewScanner(stderr) for in.Scan() { fmt.Println(in.Text()) @@ -269,6 +257,13 @@ func (udm *UDM) Exec(c *cli.Context) error { }() go func() { + 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())) + } + }() + if err = command.Start(); err != nil { fmt.Printf("UDM Start error: %v", err) } diff --git a/pkg/suci/suci.go b/pkg/suci/suci.go new file mode 100644 index 0000000..a3b0551 --- /dev/null +++ b/pkg/suci/suci.go @@ -0,0 +1,383 @@ +package suci + +import ( + "bytes" + "crypto/aes" + "crypto/cipher" + "crypto/elliptic" + "crypto/hmac" + "crypto/sha256" + "encoding/binary" + "encoding/hex" + "fmt" + "log" + "math" + "math/big" + "math/bits" + "strconv" + "strings" + + "golang.org/x/crypto/curve25519" + + "github.com/free5gc/udm/internal/logger" +) + +type SuciProfile struct { + ProtectionScheme string `yaml:"ProtectionScheme,omitempty"` + PrivateKey string `yaml:"PrivateKey,omitempty"` + PublicKey string `yaml:"PublicKey,omitempty"` +} + +// profile A. +const ( + ProfileAMacKeyLen = 32 // octets + ProfileAEncKeyLen = 16 // octets + ProfileAIcbLen = 16 // octets + ProfileAMacLen = 8 // octets + ProfileAHashLen = 32 // octets +) + +// profile B. +const ( + ProfileBMacKeyLen = 32 // octets + ProfileBEncKeyLen = 16 // octets + ProfileBIcbLen = 16 // octets + ProfileBMacLen = 8 // octets + ProfileBHashLen = 32 // octets +) + +func CompressKey(uncompressed []byte, y *big.Int) []byte { + compressed := uncompressed[0:33] + if y.Bit(0) == 1 { // 0x03 + compressed[0] = 0x03 + } else { // 0x02 + compressed[0] = 0x02 + } + // fmt.Printf("compressed: %x\n", compressed) + return compressed +} + +// modified from https://stackoverflow.com/questions/46283760/ +// how-to-uncompress-a-single-x9-62-compressed-point-on-an-ecdh-p256-curve-in-go. +func uncompressKey(compressedBytes []byte, priv []byte) (*big.Int, *big.Int) { + // Split the sign byte from the rest + signByte := uint(compressedBytes[0]) + xBytes := compressedBytes[1:] + + x := new(big.Int).SetBytes(xBytes) + three := big.NewInt(3) + + // The params for P256 + c := elliptic.P256().Params() + + // The equation is y^2 = x^3 - 3x + b + // x^3, mod P + xCubed := new(big.Int).Exp(x, three, c.P) + + // 3x, mod P + threeX := new(big.Int).Mul(x, three) + threeX.Mod(threeX, c.P) + + // x^3 - 3x + b mod P + ySquared := new(big.Int).Sub(xCubed, threeX) + ySquared.Add(ySquared, c.B) + ySquared.Mod(ySquared, c.P) + + // find the square root mod P + y := new(big.Int).ModSqrt(ySquared, c.P) + if y == nil { + // If this happens then you're dealing with an invalid point. + logger.SuciLog.Errorln("Uncompressed key with invalid point") + return nil, nil + } + + // Finally, check if you have the correct root. If not you want -y mod P + if y.Bit(0) != signByte&1 { + y.Neg(y) + y.Mod(y, c.P) + } + // fmt.Printf("xUncom: %x\nyUncon: %x\n", x, y) + return x, y +} + +func HmacSha256(input, macKey []byte, macLen int) []byte { + h := hmac.New(sha256.New, macKey) + if _, err := h.Write(input); err != nil { + log.Printf("HMAC SHA256 error %+v", err) + } + macVal := h.Sum(nil) + macTag := macVal[:macLen] + // fmt.Printf("macVal: %x\nmacTag: %x\n", macVal, macTag) + return macTag +} + +func Aes128ctr(input, encKey, icb []byte) []byte { + output := make([]byte, len(input)) + block, err := aes.NewCipher(encKey) + if err != nil { + log.Printf("AES128 CTR error %+v", err) + } + stream := cipher.NewCTR(block, icb) + stream.XORKeyStream(output, input) + // fmt.Printf("aes input: %x %x %x\naes output: %x\n", input, encKey, icb, output) + return output +} + +func AnsiX963KDF(sharedKey, publicKey []byte, profileEncKeyLen, profileMacKeyLen, profileHashLen int) []byte { + var counter uint32 = 0x00000001 + var kdfKey []byte + kdfRounds := int(math.Ceil(float64(profileEncKeyLen+profileMacKeyLen) / float64(profileHashLen))) + for i := 1; i <= kdfRounds; i++ { + counterBytes := make([]byte, 4) + binary.BigEndian.PutUint32(counterBytes, counter) + // fmt.Printf("counterBytes: %x\n", counterBytes) + tmpK := sha256.Sum256(append(append(sharedKey, counterBytes...), publicKey...)) + sliceK := tmpK[:] + kdfKey = append(kdfKey, sliceK...) + // fmt.Printf("kdfKey in round %d: %x\n", i, kdfKey) + counter++ + } + return kdfKey +} + +func swapNibbles(input []byte) []byte { + output := make([]byte, len(input)) + for i, b := range input { + output[i] = bits.RotateLeft8(b, 4) + } + return output +} + +func calcSchemeResult(decryptPlainText []byte, supiType string) string { + var schemeResult string + if supiType == typeIMSI { + schemeResult = hex.EncodeToString(swapNibbles(decryptPlainText)) + if schemeResult[len(schemeResult)-1] == 'f' { + schemeResult = schemeResult[:len(schemeResult)-1] + } + } else { + schemeResult = hex.EncodeToString(decryptPlainText) + } + return schemeResult +} + +func profileA(input, supiType, privateKey string) (string, error) { + logger.SuciLog.Infoln("SuciToSupi Profile A") + s, hexDecodeErr := hex.DecodeString(input) + if hexDecodeErr != nil { + logger.SuciLog.Errorln("hex DecodeString error") + return "", hexDecodeErr + } + + // for X25519(profile A), q (The number of elements in the field Fq) = 2^255 - 19 + // len(pubkey) is therefore ceil((log2q)/8+1) = 32octets + ProfileAPubKeyLen := 32 + if len(s) < ProfileAPubKeyLen+ProfileAMacLen { + logger.SuciLog.Errorln("len of input data is too short!") + return "", fmt.Errorf("suci input too short\n") + } + + decryptMac := s[len(s)-ProfileAMacLen:] + decryptPublicKey := s[:ProfileAPubKeyLen] + decryptCipherText := s[ProfileAPubKeyLen : len(s)-ProfileAMacLen] + // fmt.Printf("dePub: %x\ndeCiph: %x\ndeMac: %x\n", decryptPublicKey, decryptCipherText, decryptMac) + + // test data from TS33.501 Annex C.4 + // aHNPriv, _ := hex.DecodeString("c53c2208b61860b06c62e5406a7b330c2b577aa5558981510d128247d38bd1d") + var aHNPriv []byte + if aHNPrivTmp, err := hex.DecodeString(privateKey); err != nil { + log.Printf("Decode error: %+v", err) + } else { + aHNPriv = aHNPrivTmp + } + var decryptSharedKey []byte + if decryptSharedKeyTmp, err := curve25519.X25519(aHNPriv, decryptPublicKey); err != nil { + log.Printf("X25519 error: %+v", err) + } else { + decryptSharedKey = decryptSharedKeyTmp + } + // fmt.Printf("deShared: %x\n", decryptSharedKey) + + kdfKey := AnsiX963KDF(decryptSharedKey, decryptPublicKey, ProfileAEncKeyLen, ProfileAMacKeyLen, ProfileAHashLen) + decryptEncKey := kdfKey[:ProfileAEncKeyLen] + decryptIcb := kdfKey[ProfileAEncKeyLen : ProfileAEncKeyLen+ProfileAIcbLen] + decryptMacKey := kdfKey[len(kdfKey)-ProfileAMacKeyLen:] + // fmt.Printf("\ndeEncKey(size%d): %x\ndeMacKey: %x\ndeIcb: %x\n", len(decryptEncKey), decryptEncKey, decryptMacKey, + // decryptIcb) + + decryptMacTag := HmacSha256(decryptCipherText, decryptMacKey, ProfileAMacLen) + if bytes.Equal(decryptMacTag, decryptMac) { + logger.SuciLog.Infoln("decryption MAC match") + } else { + logger.SuciLog.Errorln("decryption MAC failed") + return "", fmt.Errorf("decryption MAC failed\n") + } + + decryptPlainText := Aes128ctr(decryptCipherText, decryptEncKey, decryptIcb) + + return calcSchemeResult(decryptPlainText, supiType), nil +} + +func profileB(input, supiType, privateKey string) (string, error) { + logger.SuciLog.Infoln("SuciToSupi Profile B") + s, hexDecodeErr := hex.DecodeString(input) + if hexDecodeErr != nil { + logger.SuciLog.Errorln("hex DecodeString error") + return "", hexDecodeErr + } + + var ProfileBPubKeyLen int // p256, module q = 2^256 - 2^224 + 2^192 + 2^96 - 1 + var uncompressed bool + if s[0] == 0x02 || s[0] == 0x03 { + ProfileBPubKeyLen = 33 // ceil(log(2, q)/8) + 1 = 33 + uncompressed = false + } else if s[0] == 0x04 { + ProfileBPubKeyLen = 65 // 2*ceil(log(2, q)/8) + 1 = 65 + uncompressed = true + } else { + logger.SuciLog.Errorln("input error") + return "", fmt.Errorf("suci input error\n") + } + + // fmt.Printf("len:%d %d\n", len(s), ProfileBPubKeyLen + ProfileBMacLen) + if len(s) < ProfileBPubKeyLen+ProfileBMacLen { + logger.SuciLog.Errorln("len of input data is too short!") + return "", fmt.Errorf("suci input too short\n") + } + decryptPublicKey := s[:ProfileBPubKeyLen] + decryptMac := s[len(s)-ProfileBMacLen:] + decryptCipherText := s[ProfileBPubKeyLen : len(s)-ProfileBMacLen] + // fmt.Printf("dePub: %x\ndeCiph: %x\ndeMac: %x\n", decryptPublicKey, decryptCipherText, decryptMac) + + // test data from TS33.501 Annex C.4 + // bHNPriv, _ := hex.DecodeString("F1AB1074477EBCC7F554EA1C5FC368B1616730155E0041AC447D6301975FECDA") + var bHNPriv []byte + if bHNPrivTmp, err := hex.DecodeString(privateKey); err != nil { + log.Printf("Decode error: %+v", err) + } else { + bHNPriv = bHNPrivTmp + } + + var xUncompressed, yUncompressed *big.Int + if uncompressed { + xUncompressed = new(big.Int).SetBytes(decryptPublicKey[1:(ProfileBPubKeyLen/2 + 1)]) + yUncompressed = new(big.Int).SetBytes(decryptPublicKey[(ProfileBPubKeyLen/2 + 1):]) + } else { + xUncompressed, yUncompressed = uncompressKey(decryptPublicKey, bHNPriv) + if xUncompressed == nil || yUncompressed == nil { + logger.SuciLog.Errorln("Uncompressed key has invalid point") + return "", fmt.Errorf("Key uncompression error\n") + } + } + // fmt.Printf("xUncom: %x\nyUncom: %x\n", xUncompressed, yUncompressed) + + // x-coordinate is the shared key + decryptSharedKey, _ := elliptic.P256().ScalarMult(xUncompressed, yUncompressed, bHNPriv) + // fmt.Printf("deShared: %x\n", decryptSharedKey.Bytes()) + + decryptPublicKeyForKDF := decryptPublicKey + if uncompressed { + decryptPublicKeyForKDF = CompressKey(decryptPublicKey, yUncompressed) + } + + kdfKey := AnsiX963KDF(decryptSharedKey.Bytes(), decryptPublicKeyForKDF, ProfileBEncKeyLen, ProfileBMacKeyLen, + ProfileBHashLen) + // fmt.Printf("kdfKey: %x\n", kdfKey) + decryptEncKey := kdfKey[:ProfileBEncKeyLen] + decryptIcb := kdfKey[ProfileBEncKeyLen : ProfileBEncKeyLen+ProfileBIcbLen] + decryptMacKey := kdfKey[len(kdfKey)-ProfileBMacKeyLen:] + // fmt.Printf("\ndeEncKey(size%d): %x\ndeMacKey: %x\ndeIcb: %x\n", len(decryptEncKey), decryptEncKey, decryptMacKey, + // decryptIcb) + + decryptMacTag := HmacSha256(decryptCipherText, decryptMacKey, ProfileBMacLen) + if bytes.Equal(decryptMacTag, decryptMac) { + logger.SuciLog.Infoln("decryption MAC match") + } else { + logger.SuciLog.Errorln("decryption MAC failed") + return "", fmt.Errorf("decryption MAC failed\n") + } + + decryptPlainText := Aes128ctr(decryptCipherText, decryptEncKey, decryptIcb) + + return calcSchemeResult(decryptPlainText, supiType), nil +} + +// suci-0(SUPI type)-mcc-mnc-routingIndentifier-protectionScheme-homeNetworkPublicKeyIdentifier-schemeOutput. +const ( + supiTypePlace = 1 + mccPlace = 2 + mncPlace = 3 + schemePlace = 5 + HNPublicKeyIDPlace = 6 +) + +const ( + typeIMSI = "0" + imsiPrefix = "imsi-" + nullScheme = "0" + profileAScheme = "1" + profileBScheme = "2" +) + +func ToSupi(suci string, suciProfiles []SuciProfile) (string, error) { + suciPart := strings.Split(suci, "-") + logger.SuciLog.Infof("suciPart: %+v", suciPart) + + suciPrefix := suciPart[0] + if suciPrefix == "imsi" || suciPrefix == "nai" { + logger.SuciLog.Infof("Got supi\n") + return suci, nil + } else if suciPrefix == "suci" { + if len(suciPart) < 6 { + return "", fmt.Errorf("Suci with wrong format\n") + } + } else { + return "", fmt.Errorf("Unknown suciPrefix [%s]", suciPrefix) + } + + logger.SuciLog.Infof("scheme %s\n", suciPart[schemePlace]) + scheme := suciPart[schemePlace] + mccMnc := suciPart[mccPlace] + suciPart[mncPlace] + + supiPrefix := imsiPrefix + if suciPrefix == "suci" && suciPart[supiTypePlace] == typeIMSI { + supiPrefix = imsiPrefix + logger.SuciLog.Infof("SUPI type is IMSI\n") + } + + if scheme == nullScheme { // NULL scheme + return supiPrefix + mccMnc + suciPart[len(suciPart)-1], nil + } + + // (HNPublicKeyID-1) is the index of "suciProfiles" slices + keyIndex, err := strconv.Atoi(suciPart[HNPublicKeyIDPlace]) + if err != nil { + return "", fmt.Errorf("Parse HNPublicKeyID error: %+v", err) + } + if keyIndex > len(suciProfiles) { + return "", fmt.Errorf("keyIndex(%d) out of range(%d)", keyIndex, len(suciProfiles)) + } + + protectScheme := suciProfiles[keyIndex-1].ProtectionScheme + privateKey := suciProfiles[keyIndex-1].PrivateKey + + if scheme != protectScheme { + return "", fmt.Errorf("Protect Scheme mismatch [%s:%s]", scheme, protectScheme) + } + + if scheme == profileAScheme { + if profileAResult, err := profileA(suciPart[len(suciPart)-1], suciPart[supiTypePlace], privateKey); err != nil { + return "", err + } else { + return supiPrefix + mccMnc + profileAResult, nil + } + } else if scheme == profileBScheme { + if profileBResult, err := profileB(suciPart[len(suciPart)-1], suciPart[supiTypePlace], privateKey); err != nil { + return "", err + } else { + return supiPrefix + mccMnc + profileBResult, nil + } + } else { + return "", fmt.Errorf("Protect Scheme (%s) is not supported", scheme) + } +} diff --git a/pkg/suci/suci_test.go b/pkg/suci/suci_test.go new file mode 100644 index 0000000..0594321 --- /dev/null +++ b/pkg/suci/suci_test.go @@ -0,0 +1,46 @@ +package suci + +import "testing" + +func TestToSupi(t *testing.T) { + suciProfiles := []SuciProfile{ + { + ProtectionScheme: "1", // Protect Scheme: Profile A + PrivateKey: "c53c22208b61860b06c62e5406a7b330c2b577aa5558981510d128247d38bd1d", + PublicKey: "5a8d38864820197c3394b92613b20b91633cbd897119273bf8e4a6f4eec0a650", + }, + { + ProtectionScheme: "2", // Protect Scheme: Profile B + PrivateKey: "F1AB1074477EBCC7F554EA1C5FC368B1616730155E0041AC447D6301975FECDA", + PublicKey: "0472DA71976234CE833A6907425867B82E074D44EF907DFB4B3E21C1C2256EBCD" + + "15A7DED52FCBB097A4ED250E036C7B9C8C7004C4EEDC4F068CD7BF8D3F900E3B4", + }, + } + testCases := []struct { + suci string + expected string + }{ + { + suci: "suci-0-208-93-0-0-0-00007487", + expected: "imsi-2089300007487", + }, + { + suci: "suci-0-208-93-0-1-1-b2e92f836055a255837debf850b528997ce0201cb82a" + + "dfe4be1f587d07d8457dcb02352410cddd9e730ef3fa87", + expected: "imsi-20893001002086", + }, + { + suci: "suci-0-208-93-0-2-2-039aab8376597021e855679a9778ea0b67396e68c66d" + + "f32c0f41e9acca2da9b9d146a33fc2716ac7dae96aa30a4d", + expected: "imsi-20893001002086", + }, + } + for i, tc := range testCases { + supi, err := ToSupi(tc.suci, suciProfiles) + if err != nil { + t.Errorf("TC%d err: %+v\n", i, err) + } else if supi != tc.expected { + t.Errorf("TC%d fail: supi[%s], expected[%s]\n", i, supi, tc.expected) + } + } +} diff --git a/udm.go b/udm.go deleted file mode 100644 index 8353eb0..0000000 --- a/udm.go +++ /dev/null @@ -1,45 +0,0 @@ -package main - -import ( - "fmt" - "os" - - "github.com/sirupsen/logrus" - "github.com/urfave/cli" - - "github.com/free5gc/udm/logger" - "github.com/free5gc/udm/service" - "github.com/free5gc/version" -) - -var UDM = &service.UDM{} - -var appLog *logrus.Entry - -func init() { - appLog = logger.AppLog -} - -func main() { - app := cli.NewApp() - app.Name = "udm" - fmt.Print(app.Name, "\n") - appLog.Infoln("UDM version: ", version.GetVersion()) - app.Usage = "-free5gccfg common configuration file -udmcfg udm configuration file" - app.Action = action - app.Flags = UDM.GetCliCmd() - if err := app.Run(os.Args); err != nil { - appLog.Errorf("UDM Run error: %v", err) - } -} - -func action(c *cli.Context) error { - if err := UDM.Initialize(c); err != nil { - logger.CfgLog.Errorf("%+v", err) - return fmt.Errorf("Failed to initialize !!") - } - - UDM.Start() - - return nil -}