Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/nitter.nim
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ setCacheTimes(cfg)
setHmacKey(cfg.hmacKey)
setProxyEncoding(cfg.base64Media)
setMaxHttpConns(cfg.httpMaxConns)
setHttpProxy(cfg.proxy, cfg.proxyAuth)
media.setHttpProxy(cfg.proxy, cfg.proxyAuth)
http_pool.setHttpProxy(cfg.proxy, cfg.proxyAuth)
initAboutPage(cfg.staticDir)

waitFor initRedisPool(cfg)
Expand Down
13 changes: 11 additions & 2 deletions src/routes/media.nim
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,17 @@ const
m3u8Mime* = "application/vnd.apple.mpegurl"
maxAge* = "max-age=604800"

var
proxy: Proxy

proc setHttpProxy*(url: string; auth: string) =
if url.len > 0:
proxy = newProxy(url, auth)
else:
proxy = nil

proc safeFetch*(url: string): Future[string] {.async.} =
let client = newAsyncHttpClient()
let client = newAsyncHttpClient(proxy=proxy)
try: result = await client.getContent(url)
except: discard
finally: client.close()
Expand All @@ -32,7 +41,7 @@ proc proxyMedia*(req: jester.Request; url: string): Future[HttpCode] {.async.} =
result = Http200
let
request = req.getNativeReq()
client = newAsyncHttpClient()
client = newAsyncHttpClient(proxy=proxy)

try:
let res = await client.get(url)
Expand Down