mirror of
https://github.com/zedeus/nitter.git
synced 2026-01-31 07:42:51 -05:00
Compare commits
2 Commits
17fc2628f9
...
51b54852dc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
51b54852dc | ||
|
|
663f5a52e1 |
@@ -26,6 +26,7 @@ enableRSS = true # set this to false to disable RSS feeds
|
|||||||
enableDebug = false # enable request logs and debug endpoints (/.sessions)
|
enableDebug = false # enable request logs and debug endpoints (/.sessions)
|
||||||
proxy = "" # http/https url, SOCKS proxies are not supported
|
proxy = "" # http/https url, SOCKS proxies are not supported
|
||||||
proxyAuth = ""
|
proxyAuth = ""
|
||||||
|
apiProxy = "" # nitter-proxy host, e.g. localhost:7000
|
||||||
disableTid = false # enable this if cookie-based auth is failing
|
disableTid = false # enable this if cookie-based auth is failing
|
||||||
|
|
||||||
# Change default preferences here, see src/prefs_impl.nim for a complete list
|
# Change default preferences here, see src/prefs_impl.nim for a complete list
|
||||||
|
|||||||
@@ -13,10 +13,17 @@ const
|
|||||||
var
|
var
|
||||||
pool: HttpPool
|
pool: HttpPool
|
||||||
disableTid: bool
|
disableTid: bool
|
||||||
|
apiProxy: string
|
||||||
|
|
||||||
proc setDisableTid*(disable: bool) =
|
proc setDisableTid*(disable: bool) =
|
||||||
disableTid = disable
|
disableTid = disable
|
||||||
|
|
||||||
|
proc setApiProxy*(url: string) =
|
||||||
|
if url.len > 0:
|
||||||
|
apiProxy = url.strip(chars={'/'}) & "/"
|
||||||
|
if "http" notin apiProxy:
|
||||||
|
apiProxy = "http://" & apiProxy
|
||||||
|
|
||||||
proc toUrl(req: ApiReq; sessionKind: SessionKind): Uri =
|
proc toUrl(req: ApiReq; sessionKind: SessionKind): Uri =
|
||||||
case sessionKind
|
case sessionKind
|
||||||
of oauth:
|
of oauth:
|
||||||
@@ -56,7 +63,8 @@ proc genHeaders*(session: Session, url: Uri): Future[HttpHeaders] {.async.} =
|
|||||||
"origin": "https://x.com",
|
"origin": "https://x.com",
|
||||||
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36",
|
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36",
|
||||||
"x-twitter-active-user": "yes",
|
"x-twitter-active-user": "yes",
|
||||||
"x-twitter-client-language": "en"
|
"x-twitter-client-language": "en",
|
||||||
|
"priority": "u=1, i"
|
||||||
})
|
})
|
||||||
|
|
||||||
case session.kind
|
case session.kind
|
||||||
@@ -66,6 +74,12 @@ proc genHeaders*(session: Session, url: Uri): Future[HttpHeaders] {.async.} =
|
|||||||
result["x-twitter-auth-type"] = "OAuth2Session"
|
result["x-twitter-auth-type"] = "OAuth2Session"
|
||||||
result["x-csrf-token"] = session.ct0
|
result["x-csrf-token"] = session.ct0
|
||||||
result["cookie"] = getCookieHeader(session.authToken, session.ct0)
|
result["cookie"] = getCookieHeader(session.authToken, session.ct0)
|
||||||
|
result["sec-ch-ua"] = """"Google Chrome";v="142", "Chromium";v="142", "Not A(Brand";v="24""""
|
||||||
|
result["sec-ch-ua-mobile"] = "?0"
|
||||||
|
result["sec-ch-ua-platform"] = "Windows"
|
||||||
|
result["sec-fetch-dest"] = "empty"
|
||||||
|
result["sec-fetch-mode"] = "cors"
|
||||||
|
result["sec-fetch-site"] = "same-site"
|
||||||
if disableTid:
|
if disableTid:
|
||||||
result["authorization"] = bearerToken2
|
result["authorization"] = bearerToken2
|
||||||
else:
|
else:
|
||||||
@@ -92,7 +106,11 @@ template fetchImpl(result, fetchBody) {.dirty.} =
|
|||||||
var resp: AsyncResponse
|
var resp: AsyncResponse
|
||||||
pool.use(await genHeaders(session, url)):
|
pool.use(await genHeaders(session, url)):
|
||||||
template getContent =
|
template getContent =
|
||||||
resp = await c.get($url)
|
# TODO: this is a temporary simple implementation
|
||||||
|
if apiProxy.len > 0:
|
||||||
|
resp = await c.get(($url).replace("https://", apiProxy))
|
||||||
|
else:
|
||||||
|
resp = await c.get($url)
|
||||||
result = await resp.body
|
result = await resp.body
|
||||||
|
|
||||||
getContent()
|
getContent()
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ proc getConfig*(path: string): (Config, parseCfg.Config) =
|
|||||||
enableDebug: cfg.get("Config", "enableDebug", false),
|
enableDebug: cfg.get("Config", "enableDebug", false),
|
||||||
proxy: cfg.get("Config", "proxy", ""),
|
proxy: cfg.get("Config", "proxy", ""),
|
||||||
proxyAuth: cfg.get("Config", "proxyAuth", ""),
|
proxyAuth: cfg.get("Config", "proxyAuth", ""),
|
||||||
|
apiProxy: cfg.get("Config", "apiProxy", ""),
|
||||||
disableTid: cfg.get("Config", "disableTid", false)
|
disableTid: cfg.get("Config", "disableTid", false)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ setHmacKey(cfg.hmacKey)
|
|||||||
setProxyEncoding(cfg.base64Media)
|
setProxyEncoding(cfg.base64Media)
|
||||||
setMaxHttpConns(cfg.httpMaxConns)
|
setMaxHttpConns(cfg.httpMaxConns)
|
||||||
setHttpProxy(cfg.proxy, cfg.proxyAuth)
|
setHttpProxy(cfg.proxy, cfg.proxyAuth)
|
||||||
|
setApiProxy(cfg.apiProxy)
|
||||||
setDisableTid(cfg.disableTid)
|
setDisableTid(cfg.disableTid)
|
||||||
initAboutPage(cfg.staticDir)
|
initAboutPage(cfg.staticDir)
|
||||||
|
|
||||||
|
|||||||
@@ -275,6 +275,7 @@ type
|
|||||||
enableDebug*: bool
|
enableDebug*: bool
|
||||||
proxy*: string
|
proxy*: string
|
||||||
proxyAuth*: string
|
proxyAuth*: string
|
||||||
|
apiProxy*: string
|
||||||
disableTid*: bool
|
disableTid*: bool
|
||||||
|
|
||||||
rssCacheTime*: int
|
rssCacheTime*: int
|
||||||
|
|||||||
Reference in New Issue
Block a user