mirror of
https://github.com/EchoVault/SugarDB.git
synced 2025-10-28 02:01:40 +08:00
Validate flags for tls mode
This commit is contained in:
@@ -1,9 +1,8 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"flag"
|
"flag"
|
||||||
"log"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Server struct {
|
type Server struct {
|
||||||
@@ -12,12 +11,24 @@ type Server struct {
|
|||||||
cert *string
|
cert *string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (server *Server) Start() error {
|
func (server *Server) Start() {
|
||||||
return errors.New("server start to be implemented")
|
|
||||||
|
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() {
|
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.")
|
key := flag.String("key", "", "The private key file path.")
|
||||||
cert := flag.String("cert", "", "The signed certificate file path.")
|
cert := flag.String("cert", "", "The signed certificate file path.")
|
||||||
|
|
||||||
@@ -29,9 +40,5 @@ func main() {
|
|||||||
cert: cert,
|
cert: cert,
|
||||||
}
|
}
|
||||||
|
|
||||||
err := server.Start()
|
server.Start()
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user