mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-04-05 20:52:50 +08:00
Added loadSecurityConfigOnce (#5792)
This commit is contained in:
parent
67edf1d014
commit
b796c21fa9
@ -41,7 +41,7 @@ var (
|
|||||||
func main() {
|
func main() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
util.LoadConfiguration("security", false)
|
util.LoadSecurityConfiguration()
|
||||||
grpcDialOption = security.LoadClientTLS(util.GetViper(), "grpc.client")
|
grpcDialOption = security.LoadClientTLS(util.GetViper(), "grpc.client")
|
||||||
|
|
||||||
vid := uint32(*volumeId)
|
vid := uint32(*volumeId)
|
||||||
|
@ -26,7 +26,7 @@ var (
|
|||||||
func main() {
|
func main() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
util.LoadConfiguration("security", false)
|
util.LoadSecurityConfiguration()
|
||||||
grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.client")
|
grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.client")
|
||||||
|
|
||||||
genFile(grpcDialOption, 0)
|
genFile(grpcDialOption, 0)
|
||||||
|
@ -24,7 +24,7 @@ var (
|
|||||||
func main() {
|
func main() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
util.LoadConfiguration("security", false)
|
util.LoadSecurityConfiguration()
|
||||||
grpcDialOption = security.LoadClientTLS(util.GetViper(), "grpc.client")
|
grpcDialOption = security.LoadClientTLS(util.GetViper(), "grpc.client")
|
||||||
|
|
||||||
vid := uint32(*volumeId)
|
vid := uint32(*volumeId)
|
||||||
|
@ -25,7 +25,7 @@ var (
|
|||||||
func main() {
|
func main() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
util2.LoadConfiguration("security", false)
|
util2.LoadSecurityConfiguration()
|
||||||
grpcDialOption := security.LoadClientTLS(util2.GetViper(), "grpc.client")
|
grpcDialOption := security.LoadClientTLS(util2.GetViper(), "grpc.client")
|
||||||
|
|
||||||
vid := needle.VolumeId(*volumeId)
|
vid := needle.VolumeId(*volumeId)
|
||||||
|
@ -66,7 +66,7 @@ var cmdBackup = &Command{
|
|||||||
|
|
||||||
func runBackup(cmd *Command, args []string) bool {
|
func runBackup(cmd *Command, args []string) bool {
|
||||||
|
|
||||||
util.LoadConfiguration("security", false)
|
util.LoadSecurityConfiguration()
|
||||||
grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.client")
|
grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.client")
|
||||||
|
|
||||||
if *s.volumeId == -1 {
|
if *s.volumeId == -1 {
|
||||||
|
@ -111,7 +111,7 @@ var (
|
|||||||
|
|
||||||
func runBenchmark(cmd *Command, args []string) bool {
|
func runBenchmark(cmd *Command, args []string) bool {
|
||||||
|
|
||||||
util.LoadConfiguration("security", false)
|
util.LoadSecurityConfiguration()
|
||||||
b.grpcDialOption = security.LoadClientTLS(util.GetViper(), "grpc.client")
|
b.grpcDialOption = security.LoadClientTLS(util.GetViper(), "grpc.client")
|
||||||
|
|
||||||
fmt.Printf("This is SeaweedFS version %s %s %s\n", util.Version(), runtime.GOOS, runtime.GOARCH)
|
fmt.Printf("This is SeaweedFS version %s %s %s\n", util.Version(), runtime.GOOS, runtime.GOARCH)
|
||||||
|
@ -47,7 +47,7 @@ var cmdDownload = &Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
func runDownload(cmd *Command, args []string) bool {
|
func runDownload(cmd *Command, args []string) bool {
|
||||||
util.LoadConfiguration("security", false)
|
util.LoadSecurityConfiguration()
|
||||||
grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.client")
|
grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.client")
|
||||||
|
|
||||||
for _, fid := range args {
|
for _, fid := range args {
|
||||||
|
@ -178,7 +178,7 @@ func runFiler(cmd *Command, args []string) bool {
|
|||||||
go http.ListenAndServe(fmt.Sprintf(":%d", *f.debugPort), nil)
|
go http.ListenAndServe(fmt.Sprintf(":%d", *f.debugPort), nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
util.LoadConfiguration("security", false)
|
util.LoadSecurityConfiguration()
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
case *f.metricsHttpIp != "":
|
case *f.metricsHttpIp != "":
|
||||||
|
@ -59,7 +59,7 @@ var cmdFilerBackup = &Command{
|
|||||||
|
|
||||||
func runFilerBackup(cmd *Command, args []string) bool {
|
func runFilerBackup(cmd *Command, args []string) bool {
|
||||||
|
|
||||||
util.LoadConfiguration("security", false)
|
util.LoadSecurityConfiguration()
|
||||||
util.LoadConfiguration("replication", true)
|
util.LoadConfiguration("replication", true)
|
||||||
|
|
||||||
grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.client")
|
grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.client")
|
||||||
|
@ -59,7 +59,7 @@ var cmdFilerCat = &Command{
|
|||||||
|
|
||||||
func runFilerCat(cmd *Command, args []string) bool {
|
func runFilerCat(cmd *Command, args []string) bool {
|
||||||
|
|
||||||
util.LoadConfiguration("security", false)
|
util.LoadSecurityConfiguration()
|
||||||
|
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
return false
|
return false
|
||||||
|
@ -83,7 +83,7 @@ var cmdFilerCopy = &Command{
|
|||||||
|
|
||||||
func runCopy(cmd *Command, args []string) bool {
|
func runCopy(cmd *Command, args []string) bool {
|
||||||
|
|
||||||
util.LoadConfiguration("security", false)
|
util.LoadSecurityConfiguration()
|
||||||
|
|
||||||
if len(args) <= 1 {
|
if len(args) <= 1 {
|
||||||
return false
|
return false
|
||||||
|
@ -56,7 +56,7 @@ The backup writes to another filer store specified in a backup_filer.toml.
|
|||||||
|
|
||||||
func runFilerMetaBackup(cmd *Command, args []string) bool {
|
func runFilerMetaBackup(cmd *Command, args []string) bool {
|
||||||
|
|
||||||
util.LoadConfiguration("security", false)
|
util.LoadSecurityConfiguration()
|
||||||
metaBackup.grpcDialOption = security.LoadClientTLS(util.GetViper(), "grpc.client")
|
metaBackup.grpcDialOption = security.LoadClientTLS(util.GetViper(), "grpc.client")
|
||||||
|
|
||||||
// load backup_filer.toml
|
// load backup_filer.toml
|
||||||
|
@ -45,7 +45,7 @@ var (
|
|||||||
|
|
||||||
func runFilerMetaTail(cmd *Command, args []string) bool {
|
func runFilerMetaTail(cmd *Command, args []string) bool {
|
||||||
|
|
||||||
util.LoadConfiguration("security", false)
|
util.LoadSecurityConfiguration()
|
||||||
grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.client")
|
grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.client")
|
||||||
clientId := util.RandomInt32()
|
clientId := util.RandomInt32()
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ var cmdFilerRemoteGateway = &Command{
|
|||||||
|
|
||||||
func runFilerRemoteGateway(cmd *Command, args []string) bool {
|
func runFilerRemoteGateway(cmd *Command, args []string) bool {
|
||||||
|
|
||||||
util.LoadConfiguration("security", false)
|
util.LoadSecurityConfiguration()
|
||||||
grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.client")
|
grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.client")
|
||||||
remoteGatewayOptions.grpcDialOption = grpcDialOption
|
remoteGatewayOptions.grpcDialOption = grpcDialOption
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ var cmdFilerRemoteSynchronize = &Command{
|
|||||||
|
|
||||||
func runFilerRemoteSynchronize(cmd *Command, args []string) bool {
|
func runFilerRemoteSynchronize(cmd *Command, args []string) bool {
|
||||||
|
|
||||||
util.LoadConfiguration("security", false)
|
util.LoadSecurityConfiguration()
|
||||||
grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.client")
|
grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.client")
|
||||||
remoteSyncOptions.grpcDialOption = grpcDialOption
|
remoteSyncOptions.grpcDialOption = grpcDialOption
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ var cmdFilerReplicate = &Command{
|
|||||||
|
|
||||||
func runFilerReplicate(cmd *Command, args []string) bool {
|
func runFilerReplicate(cmd *Command, args []string) bool {
|
||||||
|
|
||||||
util.LoadConfiguration("security", false)
|
util.LoadSecurityConfiguration()
|
||||||
util.LoadConfiguration("replication", true)
|
util.LoadConfiguration("replication", true)
|
||||||
util.LoadConfiguration("notification", true)
|
util.LoadConfiguration("notification", true)
|
||||||
config := util.GetViper()
|
config := util.GetViper()
|
||||||
|
@ -118,7 +118,7 @@ var cmdFilerSynchronize = &Command{
|
|||||||
|
|
||||||
func runFilerSynchronize(cmd *Command, args []string) bool {
|
func runFilerSynchronize(cmd *Command, args []string) bool {
|
||||||
|
|
||||||
util.LoadConfiguration("security", false)
|
util.LoadSecurityConfiguration()
|
||||||
grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.client")
|
grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.client")
|
||||||
|
|
||||||
grace.SetupProfiling(*syncCpuProfile, *syncMemProfile)
|
grace.SetupProfiling(*syncCpuProfile, *syncMemProfile)
|
||||||
|
@ -47,7 +47,7 @@ func runIam(cmd *Command, args []string) bool {
|
|||||||
func (iamopt *IamOptions) startIamServer() bool {
|
func (iamopt *IamOptions) startIamServer() bool {
|
||||||
filerAddress := pb.ServerAddress(*iamopt.filer)
|
filerAddress := pb.ServerAddress(*iamopt.filer)
|
||||||
|
|
||||||
util.LoadConfiguration("security", false)
|
util.LoadSecurityConfiguration()
|
||||||
grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.client")
|
grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.client")
|
||||||
for {
|
for {
|
||||||
err := pb.WithGrpcFilerClient(false, 0, filerAddress, grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
err := pb.WithGrpcFilerClient(false, 0, filerAddress, grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
|
@ -105,7 +105,7 @@ var (
|
|||||||
|
|
||||||
func runMaster(cmd *Command, args []string) bool {
|
func runMaster(cmd *Command, args []string) bool {
|
||||||
|
|
||||||
util.LoadConfiguration("security", false)
|
util.LoadSecurityConfiguration()
|
||||||
util.LoadConfiguration("master", false)
|
util.LoadConfiguration("master", false)
|
||||||
|
|
||||||
grace.SetupProfiling(*masterCpuProfile, *masterMemProfile)
|
grace.SetupProfiling(*masterCpuProfile, *masterMemProfile)
|
||||||
|
@ -68,7 +68,7 @@ var cmdMasterFollower = &Command{
|
|||||||
|
|
||||||
func runMasterFollower(cmd *Command, args []string) bool {
|
func runMasterFollower(cmd *Command, args []string) bool {
|
||||||
|
|
||||||
util.LoadConfiguration("security", false)
|
util.LoadSecurityConfiguration()
|
||||||
util.LoadConfiguration("master", false)
|
util.LoadConfiguration("master", false)
|
||||||
|
|
||||||
if *mf.portGrpc == 0 {
|
if *mf.portGrpc == 0 {
|
||||||
|
@ -66,7 +66,7 @@ func RunMount(option *MountOptions, umask os.FileMode) bool {
|
|||||||
|
|
||||||
// try to connect to filer
|
// try to connect to filer
|
||||||
filerAddresses := pb.ServerAddresses(*option.filer).ToAddresses()
|
filerAddresses := pb.ServerAddresses(*option.filer).ToAddresses()
|
||||||
util.LoadConfiguration("security", false)
|
util.LoadSecurityConfiguration()
|
||||||
grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.client")
|
grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.client")
|
||||||
var cipher bool
|
var cipher bool
|
||||||
var err error
|
var err error
|
||||||
|
@ -54,7 +54,7 @@ var cmdMqBroker = &Command{
|
|||||||
|
|
||||||
func runMqBroker(cmd *Command, args []string) bool {
|
func runMqBroker(cmd *Command, args []string) bool {
|
||||||
|
|
||||||
util.LoadConfiguration("security", false)
|
util.LoadSecurityConfiguration()
|
||||||
|
|
||||||
mqBrokerStandaloneOptions.masters = pb.ServerAddresses(*mqBrokerStandaloneOptions.mastersString).ToAddressMap()
|
mqBrokerStandaloneOptions.masters = pb.ServerAddresses(*mqBrokerStandaloneOptions.mastersString).ToAddressMap()
|
||||||
|
|
||||||
|
@ -165,7 +165,7 @@ var cmdS3 = &Command{
|
|||||||
|
|
||||||
func runS3(cmd *Command, args []string) bool {
|
func runS3(cmd *Command, args []string) bool {
|
||||||
|
|
||||||
util.LoadConfiguration("security", false)
|
util.LoadSecurityConfiguration()
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
case *s3StandaloneOptions.metricsHttpIp != "":
|
case *s3StandaloneOptions.metricsHttpIp != "":
|
||||||
|
@ -179,7 +179,7 @@ func runServer(cmd *Command, args []string) bool {
|
|||||||
go http.ListenAndServe(fmt.Sprintf(":%d", *serverOptions.debugPort), nil)
|
go http.ListenAndServe(fmt.Sprintf(":%d", *serverOptions.debugPort), nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
util.LoadConfiguration("security", false)
|
util.LoadSecurityConfiguration()
|
||||||
util.LoadConfiguration("master", false)
|
util.LoadConfiguration("master", false)
|
||||||
|
|
||||||
grace.SetupProfiling(*serverOptions.cpuprofile, *serverOptions.memprofile)
|
grace.SetupProfiling(*serverOptions.cpuprofile, *serverOptions.memprofile)
|
||||||
|
@ -35,7 +35,7 @@ var cmdShell = &Command{
|
|||||||
|
|
||||||
func runShell(command *Command, args []string) bool {
|
func runShell(command *Command, args []string) bool {
|
||||||
|
|
||||||
util.LoadConfiguration("security", false)
|
util.LoadSecurityConfiguration()
|
||||||
shellOptions.GrpcDialOption = security.LoadClientTLS(util.GetViper(), "grpc.client")
|
shellOptions.GrpcDialOption = security.LoadClientTLS(util.GetViper(), "grpc.client")
|
||||||
shellOptions.Directory = "/"
|
shellOptions.Directory = "/"
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ var cmdUpload = &Command{
|
|||||||
|
|
||||||
func runUpload(cmd *Command, args []string) bool {
|
func runUpload(cmd *Command, args []string) bool {
|
||||||
|
|
||||||
util.LoadConfiguration("security", false)
|
util.LoadSecurityConfiguration()
|
||||||
grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.client")
|
grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.client")
|
||||||
|
|
||||||
defaultReplication, err := readMasterConfiguration(grpcDialOption, pb.ServerAddress(*upload.master))
|
defaultReplication, err := readMasterConfiguration(grpcDialOption, pb.ServerAddress(*upload.master))
|
||||||
|
@ -125,7 +125,7 @@ var (
|
|||||||
|
|
||||||
func runVolume(cmd *Command, args []string) bool {
|
func runVolume(cmd *Command, args []string) bool {
|
||||||
|
|
||||||
util.LoadConfiguration("security", false)
|
util.LoadSecurityConfiguration()
|
||||||
|
|
||||||
// If --pprof is set we assume the caller wants to be able to collect
|
// If --pprof is set we assume the caller wants to be able to collect
|
||||||
// cpu and memory profiles via go tool pprof
|
// cpu and memory profiles via go tool pprof
|
||||||
|
@ -60,7 +60,7 @@ var cmdWebDav = &Command{
|
|||||||
|
|
||||||
func runWebDav(cmd *Command, args []string) bool {
|
func runWebDav(cmd *Command, args []string) bool {
|
||||||
|
|
||||||
util.LoadConfiguration("security", false)
|
util.LoadSecurityConfiguration()
|
||||||
|
|
||||||
glog.V(0).Infof("Starting Seaweed WebDav Server %s at https port %d", util.Version(), *webDavStandaloneOptions.port)
|
glog.V(0).Infof("Starting Seaweed WebDav Server %s at https port %d", util.Version(), *webDavStandaloneOptions.port)
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
ConfigurationFileDirectory DirectoryValueType
|
ConfigurationFileDirectory DirectoryValueType
|
||||||
|
loadSecurityConfigOnce sync.Once
|
||||||
)
|
)
|
||||||
|
|
||||||
type DirectoryValueType string
|
type DirectoryValueType string
|
||||||
@ -31,6 +32,12 @@ type Configuration interface {
|
|||||||
SetDefault(key string, value interface{})
|
SetDefault(key string, value interface{})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func LoadSecurityConfiguration(){
|
||||||
|
loadSecurityConfigOnce.Do(func() {
|
||||||
|
LoadConfiguration("security", false)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func LoadConfiguration(configFileName string, required bool) (loaded bool) {
|
func LoadConfiguration(configFileName string, required bool) (loaded bool) {
|
||||||
|
|
||||||
// find a filer store
|
// find a filer store
|
||||||
|
Loading…
Reference in New Issue
Block a user