mirror of
https://github.com/EchoVault/SugarDB.git
synced 2025-10-26 01:10:25 +08:00
Validate flags for tls mode
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"flag"
|
||||
"log"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type Server struct {
|
||||
@@ -12,12 +11,24 @@ type Server struct {
|
||||
cert *string
|
||||
}
|
||||
|
||||
func (server *Server) Start() error {
|
||||
return errors.New("server start to be implemented")
|
||||
func (server *Server) Start() {
|
||||
|
||||
if *server.tls && (len(*server.key) <= 0 || len(*server.cert) <= 0) {
|
||||
fmt.Println("Must provide key and certificate file paths for TLS mode.")
|
||||
return
|
||||
}
|
||||
|
||||
if *server.tls {
|
||||
fmt.Println("TLS mode activated...")
|
||||
} else {
|
||||
fmt.Println("Normal TCP mode...")
|
||||
}
|
||||
|
||||
// Listen to connection
|
||||
}
|
||||
|
||||
func main() {
|
||||
tls := flag.Bool("tls", false, "Start the server in TLS mode.")
|
||||
tls := flag.Bool("tls", false, "Start the server in TLS mode. Default is false")
|
||||
key := flag.String("key", "", "The private key file path.")
|
||||
cert := flag.String("cert", "", "The signed certificate file path.")
|
||||
|
||||
@@ -29,9 +40,5 @@ func main() {
|
||||
cert: cert,
|
||||
}
|
||||
|
||||
err := server.Start()
|
||||
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
server.Start()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user