Adapt CLI to changes in lib

- Change explicit include of challenges to explicit exclude
- Add CLI switches for HTTP and TLS ports
This commit is contained in:
xenolf 2015-12-27 18:30:04 +01:00
parent 053dc4cfb1
commit 0e857b2fef
4 changed files with 27 additions and 7 deletions

View file

@ -104,13 +104,13 @@ func NewClient(caDirURL string, user User, keyBits int) (*Client, error) {
}
// SetHTTPPort specifies a custom port to be used for HTTP based challenges.
func (c *Client) SetHTTPPort(port int) {
func (c *Client) SetHTTPPort(port string) {
/*if chlng, ok := c.solvers["http-01"]; ok {
}*/
}
// SetHTTPSPort specifies a custom port to be used for HTTPS based challenges.
func (c *Client) SetHTTPSPort(port int) {
func (c *Client) SetHTTPSPort(port string) {
/*if chlng, ok := c.solvers["tls-sni-01"]; ok {
}*/
}

12
cli.go
View file

@ -82,8 +82,16 @@ func main() {
Value: defaultPath,
},
cli.StringSliceFlag{
Name: "solvers, S",
Usage: "Add an explicit solver for challenges. Solvers: \"http-01[:port]\", \"tls-sni-01[:port]\".",
Name: "exclude, x",
Usage: "Explicitly disallow solvers by name from being used. Solvers: \"http-01\", \"tls-sni-01\".",
},
cli.StringFlag{
Name: "httpPort",
Usage: "Set the port to use for HTTP based challenges to listen on.",
},
cli.StringFlag{
Name: "tlsPort",
Usage: "Set the port to use for TLS based challenges to listen on.",
},
}

View file

@ -34,11 +34,23 @@ func setup(c *cli.Context) (*Configuration, *Account, *acme.Client) {
//TODO: move to account struct? Currently MUST pass email.
acc := NewAccount(c.GlobalString("email"), conf)
client, err := acme.NewClient(c.GlobalString("server"), acc, conf.RsaBits(), conf.Solvers())
client, err := acme.NewClient(c.GlobalString("server"), acc, conf.RsaBits())
if err != nil {
logger().Fatalf("Could not create client: %s", err.Error())
}
if len(c.GlobalStringSlice("exclude")) > 0 {
client.ExcludeChallenges(conf.ExcludedSolvers())
}
if c.GlobalIsSet("httpPort") {
client.SetHTTPPort(c.GlobalString("httpPort"))
}
if c.GlobalIsSet("tlsPort") {
client.SetHTTPPort(c.GlobalString("tlsPort"))
}
return conf, acc, client
}

View file

@ -24,8 +24,8 @@ func (c *Configuration) RsaBits() int {
return c.context.GlobalInt("rsa-key-size")
}
func (c *Configuration) Solvers() []string {
return c.context.GlobalStringSlice("solvers")
func (c *Configuration) ExcludedSolvers() []string {
return c.context.GlobalStringSlice("exclude")
}
// ServerPath returns the OS dependent path to the data for a specific CA