dashotv / flame

DashoTV torrent and nzb service
Apache License 2.0
2 stars 0 forks source link

PostForm dosn't work for auth #2

Closed subvillion closed 8 months ago

subvillion commented 3 years ago

https://github.com/dashotv/flame/blob/b642f7e26661f3ad40c7255e47ba17aeb0682483/qbt/requests.go#L65

I see this copypaste garbage from repo to repo, and it's work just because localhost auth disabled by default in qbt

Worked auth with real client-server looks like that:

func (client *Client) post(endpoint string, opts map[string]string) (*http.Response, error) {
    var postBody *strings.Reader
    if opts != nil {
        form := url.Values{}
        for k, v := range opts {
            form.Add(k, v)
        }

        postBody = strings.NewReader(form.Encode())
    } else {
        postBody = nil
    }

    req, err := http.NewRequest("POST", client.URL+endpoint, postBody)
    if err != nil {
        return nil, wrapper.Wrap(err, "failed to build request")
    }

    req.Header.Set("Content-Type", "application/x-www-form-urlencoded; charset=utf-8")
    req.Header.Set("User-Agent", "dashotv/flame/qbt v0.1")

    resp, err := client.http.Do(req)
    if err != nil {
        return nil, wrapper.Wrap(err, "failed to perform request")
    }

    return resp, nil
}
shawncatz commented 8 months ago

Apologies just seeing this now... I apparently haven't really been paying attention to the github site for these repos... I'll take a look. I do believe you're correct and I have my auth disabled for localhost/localnetwork...

shawncatz commented 8 months ago

realized this is referencing the older implementation that I had here... the newer stuff still isnt great, but I think it handles the auth correctly