Skip to content

Commit

Permalink
refactoring tls flags for alpha and zero
Browse files Browse the repository at this point in the history
  • Loading branch information
aman-bansal committed Nov 13, 2020
1 parent 93b5619 commit 98b2fbb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 20 deletions.
13 changes: 2 additions & 11 deletions dgraph/cmd/alpha/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,17 +187,6 @@ they form a Raft group and provide synchronous replication.
flag.Uint64("normalize_node_limit", 1e4,
"Limit for the maximum number of nodes that can be returned in a query that uses the "+
"normalize directive.")

// TLS configurations
flag.String("tls_dir", "", "Path to directory that has TLS certificates and keys.")
flag.Bool("tls_use_system_ca", true, "Include System CA into CA Certs.")
flag.String("tls_client_auth", "VERIFYIFGIVEN", "Enable TLS client authentication")
flag.Bool("tls_internal_port_enabled", false, "(optional) enable inter node TLS encryption between cluster nodes.")
flag.String("tls_cert", "", "(optional) The Cert file name in tls_dir which is needed to "+
"connect as a client with the other nodes in the cluster.")
flag.String("tls_key", "", "(optional) The private key file name "+
"in tls_dir needed to connect as a client with the other nodes in the cluster.")
flag.String("tls_min_version", "TLS11", "min version of tls supported. Valid values are TLS11, TLS12")
//Custom plugins.
flag.String("custom_tokenizers", "",
"Comma separated list of tokenizer plugins")
Expand All @@ -221,6 +210,8 @@ they form a Raft group and provide synchronous replication.
PostingListCache,PstoreBlockCache,PstoreIndexCache,WstoreBlockCache,WstoreIndexCache).
PostingListCache should be 0 and is a no-op.
`)
// TLS configurations
x.RegisterServerTLSFlags(flag)
}

func setupCustomTokenizers() {
Expand Down
11 changes: 2 additions & 9 deletions dgraph/cmd/zero/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,6 @@ instances to achieve high-availability.
" exporter does not support annotation logs and would discard them.")
flag.Bool("ludicrous_mode", false, "Run zero in ludicrous mode")
flag.String("enterprise_license", "", "Path to the enterprise license file.")
// TLS configurations
flag.String("tls_dir", "", "Path to directory that has TLS certificates and keys.")
flag.Bool("tls_use_system_ca", true, "Include System CA into CA Certs.")
flag.String("tls_client_auth", "VERIFYIFGIVEN", "Enable TLS client authentication")
flag.Bool("tls_internal_port_enabled", false, "(optional) enable inter node TLS encryption between cluster nodes.")
flag.String("tls_cert", "", "(optional) The Cert file name in tls_dir which is needed to "+
"connect as a client with the other nodes in the cluster.")
flag.String("tls_key", "", "(optional) The private key file name "+
"in tls_dir which is needed to connect as a client with the other nodes in the cluster.")
// Cache flags
flag.Int64("cache_mb", 0, "Total size of cache (in MB) to be used in zero.")
flag.String("cache_percentage", "100,0",
Expand All @@ -131,6 +122,8 @@ instances to achieve high-availability.
"log directory. mmap consumes more RAM, but provides better performance.")
flag.Int("badger.compression_level", 3,
"The compression level for Badger. A higher value uses more resources.")
// TLS configurations
x.RegisterServerTLSFlags(flag)
}

func setupListener(addr string, port int, kind string) (listener net.Listener, err error) {
Expand Down
13 changes: 13 additions & 0 deletions x/tls_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,19 @@ type TLSHelperConfig struct {
MinVersion string
}

// RegisterClientTLSFlags registers the required flags to set up a TLS client.
func RegisterServerTLSFlags(flag *pflag.FlagSet) {
flag.String("tls_dir", "", "Path to directory that has TLS certificates and keys.")
flag.Bool("tls_use_system_ca", true, "Include System CA into CA Certs.")
flag.String("tls_client_auth", "VERIFYIFGIVEN", "Enable TLS client authentication")
flag.Bool("tls_internal_port_enabled", false, "(optional) enable inter node TLS encryption between cluster nodes.")
flag.String("tls_cert", "", "(optional) The Cert file name in tls_dir which is needed to "+
"connect as a client with the other nodes in the cluster.")
flag.String("tls_key", "", "(optional) The private key file name "+
"in tls_dir needed to connect as a client with the other nodes in the cluster.")
flag.String("tls_min_version", "TLS11", "min version of tls supported. Valid values are TLS11, TLS12")
}

// RegisterClientTLSFlags registers the required flags to set up a TLS client.
func RegisterClientTLSFlags(flag *pflag.FlagSet) {
flag.String("tls_cacert", "",
Expand Down

0 comments on commit 98b2fbb

Please sign in to comment.