Added a simple http server

This will later be used for serving false content
experimental
Justin Reichardt 2022-08-19 12:28:02 -05:00
parent 011feaf557
commit 8930f00748
2 changed files with 31 additions and 0 deletions

View File

@ -31,7 +31,11 @@ import (
"time"
"fmt"
sysos "jbreich/rhosts/sys"
"jbreich/rhosts/serve"
)
var Exit chan bool
// siteList holds the location of all the sites along with a list of their location
type siteList struct {
location string
@ -147,6 +151,8 @@ func main() {
break
}
}
serve.Start("blank")
<- Exit
}

25
src/serve/serve.go Normal file
View File

@ -0,0 +1,25 @@
// Provides the web server for rhosts to relay altered content
package serve
import(
"net/http"
)
func Start(certLoc string) {
go httpServer()
//go httpsServer(&certLoc)
}
func httpServer() (err error){
err = http.ListenAndServe("127.0.0.1:80",http.HandlerFunc(httpHandler))
return
}
func httpsServer(certLoc *string) (err error){
err = http.ListenAndServeTLS("127.0.0.1:80",*certLoc + "ca.crt", *certLoc + "ca.key",http.HandlerFunc(httpHandler))
return
}
func httpHandler(w http.ResponseWriter, r *http.Request) {
http.Error(w,"Test",200)
}