better logging
This commit is contained in:
parent
84ad9d8f4a
commit
7e15756a68
3
README
3
README
@ -2,7 +2,6 @@ SecretShop: a small Gemini server.
|
|||||||
|
|
||||||
# Features
|
# Features
|
||||||
* Multi-site hosting
|
* Multi-site hosting
|
||||||
* CGI (WIP)
|
|
||||||
* Fully compliant with Jetforce diagnostics
|
* Fully compliant with Jetforce diagnostics
|
||||||
* Probably won't kill your computer
|
* Probably won't kill your computer
|
||||||
|
|
||||||
@ -22,7 +21,7 @@ localhost:
|
|||||||
KeyFile: "localhost.key"
|
KeyFile: "localhost.key"
|
||||||
CertFile: "localhost.crt"
|
CertFile: "localhost.crt"
|
||||||
|
|
||||||
|
Please note that CGIDir currently not used (waiting on spec clarification).
|
||||||
|
|
||||||
# Running
|
# Running
|
||||||
Either run the executable directly or use the SystemD unit file
|
Either run the executable directly or use the SystemD unit file
|
||||||
|
20
server.go
20
server.go
@ -123,19 +123,19 @@ func (c *conn) serve(ctx context.Context) {
|
|||||||
data[count] = b
|
data[count] = b
|
||||||
count = count + 1
|
count = count + 1
|
||||||
}
|
}
|
||||||
|
var res Response
|
||||||
|
var req string
|
||||||
if !strings.Contains(string(data), "\r\n") {
|
if !strings.Contains(string(data), "\r\n") {
|
||||||
c.sendResponse(Response{STATUS_BAD_REQUEST, "Request too large", ""})
|
res = Response{STATUS_BAD_REQUEST, "Request too large", ""}
|
||||||
c.C.Close()
|
req = "TOO_LONG_REQUEST"
|
||||||
return
|
} else if !utf8.Valid(data) {
|
||||||
|
res = Response{STATUS_BAD_REQUEST, "URL contains non UTF8 charcaters", ""}
|
||||||
|
} else {
|
||||||
|
req = string(data[:count-2])
|
||||||
|
res = c.server.ParseRequest(req)
|
||||||
}
|
}
|
||||||
if !utf8.Valid(data) {
|
|
||||||
c.sendResponse(Response{STATUS_BAD_REQUEST, "URL contains non UTF8 charcaters", ""})
|
|
||||||
c.C.Close()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
req := string(data[:count-2])
|
|
||||||
res := c.server.ParseRequest(req)
|
|
||||||
c.sendResponse(res)
|
c.sendResponse(res)
|
||||||
|
log.Printf("%v: %v requested %v; responded with %v %v", c.server.Hostname, c.C.RemoteAddr(), req, res.Status, res.Meta)
|
||||||
c.C.Close()
|
c.C.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user