@ -101,39 +101,48 @@ func Configure(fname string, configSections string) (*SetupData, error) {
selPrompt = promptui . Select {
selPrompt = promptui . Select {
Templates : selTmpls ,
Templates : selTmpls ,
Label : "Web server mode" ,
Label : "Web server mode" ,
Items : [ ] string { "Insecure (port 80)" , "Secure (port 443)" } ,
Items : [ ] string { "Insecure (port 80)" , "Secure (port 443), manual certificate" , "Secure (port 443), auto certificate " } ,
}
}
sel , _ , err := selPrompt . Run ( )
sel , _ , err := selPrompt . Run ( )
if err != nil {
if err != nil {
return data , err
return data , err
}
}
if sel == 0 {
if sel == 0 {
data . Config . Server . Autocert = false
data . Config . Server . Port = 80
data . Config . Server . Port = 80
data . Config . Server . TLSCertPath = ""
data . Config . Server . TLSCertPath = ""
data . Config . Server . TLSKeyPath = ""
data . Config . Server . TLSKeyPath = ""
} else if sel == 1 {
} else if sel == 1 || sel == 2 {
data . Config . Server . Port = 443
data . Config . Server . Port = 443
data . Config . Server . Autocert = sel == 2
prompt = promptui . Prompt {
Templates : tmpls ,
if sel == 1 {
Label : "Certificate path" ,
// Manual certificate configuration
Validate : validateNonEmpty ,
prompt = promptui . Prompt {
Default : data . Config . Server . TLSCertPath ,
Templates : tmpls ,
}
Label : "Certificate path" ,
data . Config . Server . TLSCertPath , err = prompt . Run ( )
Validate : validateNonEmpty ,
if err != nil {
Default : data . Config . Server . TLSCertPath ,
return data , err
}
}
data . Config . Server . TLSCertPath , err = prompt . Run ( )
if err != nil {
prompt = promptui . Prompt {
return data , err
Templates : tmpls ,
}
Label : "Key path" ,
Validate : validateNonEmpty ,
prompt = promptui . Prompt {
Default : data . Config . Server . TLSKeyPath ,
Templates : tmpls ,
}
Label : "Key path" ,
data . Config . Server . TLSKeyPath , err = prompt . Run ( )
Validate : validateNonEmpty ,
if err != nil {
Default : data . Config . Server . TLSKeyPath ,
return data , err
}
data . Config . Server . TLSKeyPath , err = prompt . Run ( )
if err != nil {
return data , err
}
} else {
// Automatic certificate
data . Config . Server . TLSCertPath = "certs"
data . Config . Server . TLSKeyPath = "certs"
}
}
}
}
} else {
} else {