32 lines
579 B
Go
32 lines
579 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"local/args"
|
|
"time"
|
|
)
|
|
|
|
type Config struct {
|
|
Listen string
|
|
Timeout time.Duration
|
|
TLSInsecure bool
|
|
}
|
|
|
|
func NewConfig() *Config {
|
|
as := args.NewArgSet()
|
|
|
|
as.Append(args.INT, "p", "port to listen on", 61113)
|
|
as.Append(args.BOOL, "tls-insecure", "permit tls insecure", false)
|
|
as.Append(args.DURATION, "t", "timeout", time.Minute)
|
|
|
|
if err := as.Parse(); err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
return &Config{
|
|
Listen: fmt.Sprintf(":%v", as.GetInt("p")),
|
|
Timeout: as.GetDuration("t"),
|
|
TLSInsecure: as.GetBool("tls-insecure"),
|
|
}
|
|
}
|