Skip to content

Commit

Permalink
updated
Browse files Browse the repository at this point in the history
  • Loading branch information
gilgameshskytrooper committed Jan 7, 2018
1 parent 626d5fc commit 58c9987
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
6 changes: 3 additions & 3 deletions prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -1484,9 +1484,9 @@ func main() {
//Pass on the AJAX post /upload handler to the uploadHandler() function
http.HandleFunc("/upload", uploadHandler)
log.Println("Listening...")
tlserr := http.ListenAndServeTLS(":3000", "server.crt", "server.key", nil)
if tlserr != nil {
fmt.Println("If you want the program to utilize TLS (i.e. host an encrypted HTTPS front end, please do the following in command line in the same directory as prometheus.go to first create a private self-signed rsa key, then a public key (x509) key based on the private key:\n\topenssl genrsa -out server.key 2048\n\topenssl req -new -x509 -sha256 -key server.key -out server.crt -days 3650\nThen make sure you finish filling in the details asked in command line.\n\nFor now, unencrypted http will be used.")
if utils.Exists(utils.Pwd()+"/server.crt") && utils.Exists(utils.Pwd()+"/server.key") {
log.Fatal(http.ListenAndServeTLS(":3000", utils.Pwd()+"/server.crt", utils.Pwd()+"/server.key", nil))
fmt.Println("If you want the program to utilize TLS (i.e. host an encrypted HTTPS front end, please do the following in command line in the same directory as the bigdisk executable to first create a private self-signed rsa key, then a public key (x509) key based on the private key:\n\topenssl genrsa -out server.key 2048\n\topenssl req -new -x509 -sha256 -key server.key -out server.crt -days 3650\nThen make sure you finish filling in the details asked in command line.\n\nFor now, unencrypted http will be used.")
log.Fatal(http.ListenAndServe(":3000", nil))
}

Expand Down
12 changes: 12 additions & 0 deletions utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,3 +408,15 @@ func WriteEnableLed(arg string) {
fmt.Println("Error writing back enableemail file for " + Pwd() + "/public/json/enableled")
}
}

func Exists(path string) bool {
_, err := os.Stat(path)
if err == nil {
return true
}
if os.IsNotExist(err) {
return false
}
return true
}

0 comments on commit 58c9987

Please sign in to comment.