-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor packages, update go.mod, and add config validator
- Loading branch information
1 parent
b2dcd71
commit 114bd26
Showing
30 changed files
with
762 additions
and
578 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,29 @@ | ||
# Swap files | ||
*.swp | ||
|
||
# Toolchain | ||
# Goland project folder | ||
# Golang project folder | ||
.idea/ | ||
|
||
# Visual Studio Code | ||
.vscode/ | ||
|
||
# Build | ||
build/ | ||
log/ | ||
vendor/ | ||
|
||
# emacs/vim | ||
GPATH | ||
GRTAGS | ||
GTAGS | ||
TAGS | ||
tags | ||
cscope.* | ||
# mac | ||
|
||
# macOS | ||
.DS_Store | ||
|
||
# debug | ||
# Debug | ||
*.log | ||
*.pcap | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* | ||
* | ||
* AUSF Service | ||
* | ||
* API version: 1.0.0 | ||
* Generated by: OpenAPI Generator (https://openapi-generator.tech) | ||
*/ | ||
|
||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
"runtime/debug" | ||
|
||
"github.com/asaskevich/govalidator" | ||
"github.com/urfave/cli" | ||
|
||
"github.com/free5gc/ausf/internal/logger" | ||
"github.com/free5gc/ausf/internal/util" | ||
"github.com/free5gc/ausf/pkg/service" | ||
"github.com/free5gc/util/version" | ||
) | ||
|
||
var AUSF = &service.AUSF{} | ||
|
||
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 = "ausf" | ||
app.Usage = "5G Authentication Server Function (AUSF)" | ||
app.Action = action | ||
app.Flags = AUSF.GetCliCmd() | ||
if err := app.Run(os.Args); err != nil { | ||
logger.AppLog.Errorf("AUSF 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 := AUSF.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("AUSF version: ", version.GetVersion()) | ||
|
||
AUSF.Start() | ||
|
||
return nil | ||
} | ||
|
||
func initLogFile(logNfPath, log5gcPath string) error { | ||
AUSF.KeyLogPath = util.AusfDefaultKeyLogPath | ||
|
||
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.AusfDefaultKeyLogPath) | ||
AUSF.KeyLogPath = filepath.Join(tmpDir, name) | ||
} | ||
|
||
return nil | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.