parent
46959efd7b
commit
fb00271cef
|
@ -1,7 +1,8 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
// "fmt"
|
||||
"fmt"
|
||||
"time"
|
||||
"net/http"
|
||||
"io/ioutil"
|
||||
|
||||
|
@ -18,49 +19,53 @@ func dumpClient(r *http.Request) {
|
|||
agent = r.UserAgent()
|
||||
|
||||
log.Warn(host, proto, addr, url, agent)
|
||||
return
|
||||
|
||||
fmt.Fprintln(accessf, time.Now(), host, proto, addr, url, agent)
|
||||
// return
|
||||
|
||||
fmt.Fprintln(clientf)
|
||||
fmt.Fprintln(clientf, time.Now())
|
||||
// Basic request information
|
||||
log.Println("Method:", r.Method)
|
||||
log.Println("URL:", r.URL)
|
||||
log.Println("Protocol:", r.Proto)
|
||||
log.Println("Host:", r.Host)
|
||||
log.Println("Remote Address:", r.RemoteAddr)
|
||||
fmt.Fprintln(clientf, "Method:", r.Method)
|
||||
fmt.Fprintln(clientf, "URL:", r.URL)
|
||||
fmt.Fprintln(clientf, "Protocol:", r.Proto)
|
||||
fmt.Fprintln(clientf, "Host:", r.Host)
|
||||
fmt.Fprintln(clientf, "Remote Address:", r.RemoteAddr)
|
||||
|
||||
|
||||
// Headers
|
||||
log.Println("Headers:")
|
||||
fmt.Fprintln(clientf,"Headers:")
|
||||
for name, values := range r.Header {
|
||||
for _, value := range values {
|
||||
log.Println("Headers:", name, value)
|
||||
fmt.Fprintln(clientf, "Headers:", name, value)
|
||||
}
|
||||
}
|
||||
|
||||
// Query parameters
|
||||
log.Println("Query Parameters:")
|
||||
fmt.Fprintln(clientf, "Query Parameters:")
|
||||
for param, values := range r.URL.Query() {
|
||||
for _, value := range values {
|
||||
log.Println("Query:", param, value)
|
||||
fmt.Fprintln(clientf, "Query:", param, value)
|
||||
}
|
||||
}
|
||||
|
||||
// User-Agent
|
||||
log.Println("User-Agent:", r.UserAgent())
|
||||
fmt.Fprintln(clientf, "User-Agent:", r.UserAgent())
|
||||
|
||||
// Content Length
|
||||
log.Println("Content Length:", r.ContentLength)
|
||||
fmt.Fprintln(clientf, "Content Length:", r.ContentLength)
|
||||
|
||||
// Cookies
|
||||
log.Println("Cookies:")
|
||||
fmt.Fprintln(clientf,"Cookies:")
|
||||
for _, cookie := range r.Cookies() {
|
||||
log.Println(cookie.Name, cookie.Value)
|
||||
fmt.Fprintln(clientf, cookie.Name, cookie.Value)
|
||||
}
|
||||
|
||||
// Request Body (if applicable)
|
||||
if r.Body != nil {
|
||||
body, err := ioutil.ReadAll(r.Body)
|
||||
if err == nil {
|
||||
log.Println("Body:", string(body))
|
||||
fmt.Fprintln(clientf, "Body:", string(body))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ go.wit.com/gui/widget git.wit.org/gui/widget
|
|||
go.wit.com/gui/toolkits git.wit.org/gui/toolkits
|
||||
go.wit.com/gui/debugger git.wit.org/gui/debugger
|
||||
go.wit.com/gui/gadgets git.wit.org/gui/gadgets
|
||||
go.wit.com/gui/gadgets/repostatus git.wit.org/jcarr/repostatus
|
||||
go.wit.com/gui/digitalocean git.wit.org/gui/digitalocean
|
||||
go.wit.com/gui/cloudflare git.wit.org/gui/cloudflare
|
||||
|
||||
|
@ -20,11 +21,11 @@ go.wit.com/apps/control-panel-digitalocean git.wit.org/wit/control-panel-digital
|
|||
go.wit.com/apps/control-panel-cloudflare git.wit.org/wit/control-panel-cloudflare
|
||||
go.wit.com/apps/control-panel-vpn git.wit.org/wit/control-panel-vpn
|
||||
go.wit.com/apps/myrepos git.wit.org/jcarr/myrepos
|
||||
go.wit.com/apps/myrepos/repostatus git.wit.org/jcarr/repostatus
|
||||
go.wit.com/apps/go.wit.com git.wit.org/jcarr/go.wit.com
|
||||
|
||||
# Support packages
|
||||
|
||||
go.wit.com/arg git.wit.org/wit/arg
|
||||
go.wit.com/dev/alexflint/go-arg git.wit.org/wit/arg
|
||||
go.wit.com/dev/davecgh/go-spew git.wit.org/jcarr/go-spew
|
||||
go.wit.com/shell git.wit.org/wit/shell
|
||||
go.wit.com/spew github.com/wit-go/spew
|
||||
|
|
5
main.go
5
main.go
|
@ -1,6 +1,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"fmt"
|
||||
"go.wit.com/log"
|
||||
"net/http"
|
||||
|
@ -11,6 +12,8 @@ import (
|
|||
//go:embed files/*
|
||||
var htmlFiles embed.FS
|
||||
|
||||
var accessf, clientf *os.File
|
||||
|
||||
// remove '?' part and trailing '/'
|
||||
func cleanURL(url string) string {
|
||||
url = "/" + strings.Trim(url, "/")
|
||||
|
@ -81,6 +84,8 @@ func findFile(w http.ResponseWriter, filename string) {
|
|||
}
|
||||
|
||||
func main() {
|
||||
accessf, _ = os.OpenFile("/home/jcarr/accessclient.log", os.O_RDWR | os.O_CREATE | os.O_APPEND, 0666)
|
||||
clientf, _ = os.OpenFile("/home/jcarr/httpclient.log", os.O_RDWR | os.O_CREATE | os.O_APPEND, 0666)
|
||||
/*
|
||||
pfile, err := htmlFiles.ReadFile("html/repo.html")
|
||||
if (err != nil) {
|
||||
|
|
Loading…
Reference in New Issue