gigobyte / HLTV

The unofficial HLTV Node.js API
MIT License
398 stars 107 forks source link

Connect to scorebot via proxy #243

Closed Samuron closed 4 years ago

Samuron commented 4 years ago

Hi! Thank you very much for your work.

Is it possible to connect to scorebot via proxy? The loadPage seems to only affect loading and parsing the url for the scorebot to connect to.

If not, can you conider an API change to accept agent as part of HLTVConfig? It then can be used in defaultLoadPage

const defaultLoadPage = (url) => {
    return new Promise(resolve => {
        request.get(url, { gzip: true, agent: proxy }, (_, __, body) => resolve(body))
    })
}

and in connectToScorebot

const socket = io.connect(url, {agent: proxy});

I can try to come up with a PR to help you with it.

gigobyte commented 4 years ago

I haven't worked with http.Agents so I would appreciate your help. My only request is to name the property in the config httpAgent so that it's more descriptive than just agent.