pkg/bencode,server/http: more general interfaces

Fixes #156.
This commit is contained in:
Jimmy Zelinskie 2016-04-03 23:05:00 -04:00
parent 07d79b2d56
commit 8d1244d1c2
2 changed files with 5 additions and 5 deletions

View file

@ -113,7 +113,7 @@ func unmarshal(r *bufio.Reader) (interface{}, error) {
}
}
func readTerminator(r *bufio.Reader, term byte) (bool, error) {
func readTerminator(r io.ByteScanner, term byte) (bool, error) {
tok, err := r.ReadByte()
if err != nil {
return false, err

View file

@ -106,23 +106,23 @@ func scrapeRequest(r *http.Request, cfg *httpConfig) (*chihaya.ScrapeRequest, er
// requestedIP returns the IP address for a request. If there are multiple in
// the request, one IPv4 and one IPv6 will be returned.
func requestedIP(q *query.Query, r *http.Request, cfg *httpConfig) (v4, v6 net.IP, err error) {
func requestedIP(p chihaya.Params, r *http.Request, cfg *httpConfig) (v4, v6 net.IP, err error) {
var done bool
if cfg.AllowIPSpoofing {
if str, e := q.String("ip"); e == nil {
if str, e := p.String("ip"); e == nil {
if v4, v6, done = getIPs(str, v4, v6, cfg); done {
return
}
}
if str, e := q.String("ipv4"); e == nil {
if str, e := p.String("ipv4"); e == nil {
if v4, v6, done = getIPs(str, v4, v6, cfg); done {
return
}
}
if str, e := q.String("ipv6"); e == nil {
if str, e := p.String("ipv6"); e == nil {
if v4, v6, done = getIPs(str, v4, v6, cfg); done {
return
}