Skip to content

Commit 9d85a51

Browse files
zedeusDrSocketthe-blank-xjackyzy823somini
authored
Replace guest tokens with account sessions (#1210)
* Replace tokens with guest accounts, swap endpoints * Filter out account limits that already reset * Track rate limits, reset after 24 hours * Add missing limitedAt assignment * Add guest accounts variable to GitHub action * Unify some guest account logs * Fix compilation error * Reduce max concurrent pending requests per account * Fix compilation on older versions of Nim * Tweak /.tokens, add amount of limited accounts * Switch back to old user search endpoint * Fix tweetDetail stats * Switch to using typeahead for user search * Revert "Switch to using typeahead for user search" This reverts commit a3e11e3. * Switch to TweetDetail for tweets * Cleanup * Fix cards not being displayed * Improve .tokens output * Handle ProtocolError and BadClientError equally * Improve rate limit handling, minor refactor * Fix accounts logging * Add 429 logging * Add empty oauth token logging * Fix negative pending requests bug * Add media proxying error logging * Shorten media proxy error log * Retry rate limited requests with different account * Fix crash on missing quote tweet data crash * Increase photo rail cache ttl * Improve guest accounts loading, add JSONL support * Improve Liberapay css for Firefox compatibility * fix(nitter): add graphql user search (#1047) * fix(nitter): add graphql user search * fix(nitter): rm gitignore 2nd guest_accounts * fix(nitter): keep query from user search in result. remove personal mods * fix(nitter): removce useless line gitignore * Fix multi-user timelines * Update nimcrypto and jsony * Bump minimum Nim version * Replace /.tokens with /.health and /.accounts * Fix compilation on Nim 1.6.x * Run tests on multiple Nim versions * Fix guest accounts CI setup * Fix guest accounts CI setup attempt 2 * Prevent annoying warnings on devel * Fix missing CI file argument * Fix guest accounts CI setup attempt 3 * Remove redundant "active" field from /.health * Fix guest accounts CI setup attempt 4 * Fix outdated test * Move CI workflow to buildjet * Purge expired accounts after parsing * Don't requests made before reset * Fix #670 * Bump Nim in the ARM64 Dockerfile, add nitter user * Fix ARM64 Dockerfile versions * Fix #1106 Closes #831 * Enable disabled tests * Add simple job_details card support * Fix jobDetails error on old Nim versions * Add support for business and gov verification Also improve icon rendering on Firefox * Fix compilation with old Nim again * Fix search queries in user search RSS feeds (#1126) Fixes #992 * Fix broken video playback by forcing fmp4 * Fix for #1147, Proxy for audio URL and upgrade hls.js (#1178) * Revert "Fix broken video playback by forcing fmp4" This reverts commit 52db03b. * Fix audio url in video m3u8 * Upgrade hls.js to 1.5.1 and use full version * Update auth.nim (#1164) Avoid expiring the tokens for now. See: - #983 (comment) - #1155 (comment) Thanks @cmj * Replace old v1 photo rail API with gql * Raise NoAccountsError when all accounts limited * Move limited flag to be account-level * Capture "account locked" API error * Update authority header * Add regex for x.com links * Update endpoint versions, switch tweet endpoint * Return 403 on hmac error * Add lazy loading for images * Fix missing video thumbnail being too small * Silence 404 proxy errors * Skip null fetch errors * Increase max concurrent reqs per account * Rename accounts/guest accounts to sessions The new file loaded by default is now ./sessions.jsonl JSONL is also required, .json support dropped. * Update Dockerfiles * Update README, added an important note * Add Python script to create account sessions * Change main page search to "Tweets" search * Remove old tokenCount from nitter.example.conf * Fix tests * Fix empty image URLs in photo rail --------- Co-authored-by: LS <[email protected]> Co-authored-by: blankie <[email protected]> Co-authored-by: jackyzy823 <[email protected]> Co-authored-by: somini <[email protected]>
1 parent b62d73d commit 9d85a51

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+981
-794
lines changed

.github/workflows/run-tests.yml

+17-6
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,34 @@ on:
1010

1111
jobs:
1212
test:
13-
runs-on: ubuntu-latest
13+
runs-on: buildjet-2vcpu-ubuntu-2204
14+
strategy:
15+
matrix:
16+
nim:
17+
- "1.6.x"
18+
- "2.0.x"
19+
- "2.2.x"
20+
- "devel"
1421
steps:
1522
- uses: actions/checkout@v3
1623
with:
1724
fetch-depth: 0
1825
- name: Cache nimble
1926
id: cache-nimble
20-
uses: actions/cache@v3
27+
uses: buildjet/cache@v3
2128
with:
2229
path: ~/.nimble
23-
key: nimble-${{ hashFiles('*.nimble') }}
24-
restore-keys: "nimble-"
30+
key: ${{ matrix.nim }}-nimble-${{ hashFiles('*.nimble') }}
31+
restore-keys: |
32+
${{ matrix.nim }}-nimble-
2533
- uses: actions/setup-python@v4
2634
with:
2735
python-version: "3.10"
2836
cache: "pip"
2937
- uses: jiro4989/setup-nim-action@v1
3038
with:
31-
nim-version: "1.x"
39+
nim-version: ${{ matrix.nim }}
40+
repo-token: ${{ secrets.GITHUB_TOKEN }}
3241
- run: nimble build -d:release -Y
3342
- run: pip install seleniumbase
3443
- run: seleniumbase install chromedriver
@@ -37,9 +46,11 @@ jobs:
3746
run: |
3847
sudo apt install libsass-dev -y
3948
cp nitter.example.conf nitter.conf
49+
sed -i 's/enableDebug = false/enableDebug = true/g' nitter.conf
4050
nimble md
4151
nimble scss
52+
echo '${{ secrets.SESSIONS }}' > ./sessions.jsonl
4253
- name: Run tests
4354
run: |
4455
./nitter &
45-
pytest -n4 tests
56+
pytest -n3 tests

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@ nitter
1010
/public/css/style.css
1111
/public/md/*.html
1212
nitter.conf
13+
guest_accounts.json*
14+
sessions.json*
1315
dump.rdb

Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM nimlang/nim:2.0.0-alpine-regular as nim
1+
FROM nimlang/nim:2.2.0-alpine-regular as nim
22
LABEL maintainer="[email protected]"
33

44
RUN apk --no-cache add libsass-dev pcre
@@ -9,7 +9,7 @@ COPY nitter.nimble .
99
RUN nimble install -y --depsOnly
1010

1111
COPY . .
12-
RUN nimble build -d:danger -d:lto -d:strip \
12+
RUN nimble build -d:danger -d:lto -d:strip --mm:refc \
1313
&& nimble scss \
1414
&& nimble md
1515

Dockerfile.arm64

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
1-
FROM alpine:3.18 as nim
1+
FROM alpine:3.21.2 as nim
22
LABEL maintainer="[email protected]"
33

4-
RUN apk --no-cache add gcc git libc-dev libsass-dev "nim=1.6.14-r0" nimble pcre
4+
RUN apk --no-cache add libsass-dev pcre gcc git libc-dev nim nimble
55

66
WORKDIR /src/nitter
77

88
COPY nitter.nimble .
99
RUN nimble install -y --depsOnly
1010

1111
COPY . .
12-
RUN nimble build -d:danger -d:lto -d:strip \
12+
RUN nimble build -d:danger -d:lto -d:strip --mm:refc \
1313
&& nimble scss \
1414
&& nimble md
1515

16-
FROM alpine:3.18
16+
FROM alpine:3.21.2
1717
WORKDIR /src/
18-
RUN apk --no-cache add ca-certificates pcre openssl1.1-compat
18+
RUN apk --no-cache add pcre ca-certificates openssl
1919
COPY --from=nim /src/nitter/nitter ./
2020
COPY --from=nim /src/nitter/nitter.example.conf ./nitter.conf
2121
COPY --from=nim /src/nitter/public ./public
2222
EXPOSE 8080
23+
RUN adduser -h /src/ -D -s /bin/sh nitter
24+
USER nitter
2325
CMD ./nitter

README.md

+34-23
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,35 @@
44
[![Test Matrix](https://github.com/zedeus/nitter/workflows/Docker/badge.svg)](https://github.com/zedeus/nitter/actions/workflows/build-docker.yml)
55
[![License](https://img.shields.io/github/license/zedeus/nitter?style=flat)](#license)
66

7+
> [!NOTE]
8+
> Running a Nitter instance now requires real accounts, since Twitter removed the previous methods. \
9+
> This does not affect users. \
10+
> For instructions on how to obtain session tokens, see [Creating session tokens](https://github.com/zedeus/nitter/wiki/Creating-session-tokens).
11+
712
A free and open source alternative Twitter front-end focused on privacy and
813
performance. \
9-
Inspired by the [Invidious](https://github.com/iv-org/invidious)
10-
project.
14+
Inspired by the [Invidious](https://github.com/iv-org/invidious) project.
1115

1216
- No JavaScript or ads
1317
- All requests go through the backend, client never talks to Twitter
1418
- Prevents Twitter from tracking your IP or JavaScript fingerprint
15-
- Uses Twitter's unofficial API (no rate limits or developer account required)
19+
- Uses Twitter's unofficial API (no developer account required)
1620
- Lightweight (for [@nim_lang](https://nitter.net/nim_lang), 60KB vs 784KB from twitter.com)
1721
- RSS feeds
1822
- Themes
1923
- Mobile support (responsive design)
2024
- AGPLv3 licensed, no proprietary instances permitted
2125

22-
Liberapay: https://liberapay.com/zedeus \
23-
Patreon: https://patreon.com/nitter \
24-
BTC: bc1qp7q4qz0fgfvftm5hwz3vy284nue6jedt44kxya \
25-
ETH: 0x66d84bc3fd031b62857ad18c62f1ba072b011925 \
26-
LTC: ltc1qhsz5nxw6jw9rdtw9qssjeq2h8hqk2f85rdgpkr \
27-
XMR: 42hKayRoEAw4D6G6t8mQHPJHQcXqofjFuVfavqKeNMNUZfeJLJAcNU19i1bGdDvcdN6romiSscWGWJCczFLe9RFhM3d1zpL
26+
<details>
27+
<summary>Donations</summary>
28+
Liberapay: https://liberapay.com/zedeus<br>
29+
Patreon: https://patreon.com/nitter<br>
30+
BTC: bc1qpqpzjkcpgluhzf7x9yqe7jfe8gpfm5v08mdr55<br>
31+
ETH: 0x24a0DB59A923B588c7A5EBd0dBDFDD1bCe9c4460<br>
32+
XMR: 42hKayRoEAw4D6G6t8mQHPJHQcXqofjFuVfavqKeNMNUZfeJLJAcNU19i1bGdDvcdN6romiSscWGWJCczFLe9RFhM3d1zpL<br>
33+
SOL: ANsyGNXFo6osuFwr1YnUqif2RdoYRhc27WdyQNmmETSW<br>
34+
ZEC: u1vndfqtzyy6qkzhkapxelel7ams38wmfeccu3fdpy2wkuc4erxyjm8ncjhnyg747x6t0kf0faqhh2hxyplgaum08d2wnj4n7cyu9s6zhxkqw2aef4hgd4s6vh5hpqvfken98rg80kgtgn64ff70djy7s8f839z00hwhuzlcggvefhdlyszkvwy3c7yw623vw3rvar6q6evd3xcvveypt
35+
</details>
2836

2937
## Roadmap
3038

@@ -42,12 +50,13 @@ maintained by the community.
4250

4351
## Why?
4452

45-
It's impossible to use Twitter without JavaScript enabled. For privacy-minded
46-
folks, preventing JavaScript analytics and IP-based tracking is important, but
47-
apart from using a VPN and uBlock/uMatrix, it's impossible. Despite being behind
48-
a VPN and using heavy-duty adblockers, you can get accurately tracked with your
49-
[browser's fingerprint](https://restoreprivacy.com/browser-fingerprinting/),
50-
[no JavaScript required](https://noscriptfingerprint.com/). This all became
53+
It's impossible to use Twitter without JavaScript enabled, and as of 2024 you
54+
need to sign up. For privacy-minded folks, preventing JavaScript analytics and
55+
IP-based tracking is important, but apart from using a VPN and uBlock/uMatrix,
56+
it's impossible. Despite being behind a VPN and using heavy-duty adblockers,
57+
you can get accurately tracked with your [browser's
58+
fingerprint](https://restoreprivacy.com/browser-fingerprinting/), [no
59+
JavaScript required](https://noscriptfingerprint.com/). This all became
5160
particularly important after Twitter [removed the
5261
ability](https://www.eff.org/deeplinks/2020/04/twitter-removes-privacy-option-and-shows-why-we-need-strong-privacy-laws)
5362
for users to control whether their data gets sent to advertisers.
@@ -71,19 +80,21 @@ Twitter account.
7180

7281
- libpcre
7382
- libsass
74-
- redis
83+
- redis/valkey
7584

7685
To compile Nitter you need a Nim installation, see
77-
[nim-lang.org](https://nim-lang.org/install.html) for details. It is possible to
78-
install it system-wide or in the user directory you create below.
86+
[nim-lang.org](https://nim-lang.org/install.html) for details. It is possible
87+
to install it system-wide or in the user directory you create below.
7988

8089
To compile the scss files, you need to install `libsass`. On Ubuntu and Debian,
8190
you can use `libsass-dev`.
8291

83-
Redis is required for caching and in the future for account info. It should be
84-
available on most distros as `redis` or `redis-server` (Ubuntu/Debian).
85-
Running it with the default config is fine, Nitter's default config is set to
86-
use the default Redis port and localhost.
92+
Redis is required for caching and in the future for account info. As of 2024
93+
Redis is no longer open source, so using the fork Valkey is recommended. It
94+
should be available on most distros as `redis` or `redis-server`
95+
(Ubuntu/Debian), or `valkey`/`valkey-server`. Running it with the default
96+
config is fine, Nitter's default config is set to use the default port and
97+
localhost.
8798

8899
Here's how to create a `nitter` user, clone the repo, and build the project
89100
along with the scss and md files.
@@ -93,7 +104,7 @@ along with the scss and md files.
93104
# su nitter
94105
$ git clone https://github.com/zedeus/nitter
95106
$ cd nitter
96-
$ nimble build -d:release
107+
$ nimble build -d:danger --mm:refc
97108
$ nimble scss
98109
$ nimble md
99110
$ cp nitter.example.conf nitter.conf

config.nims

+1-6
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,7 @@
77

88
# disable annoying warnings
99
warning("GcUnsafe2", off)
10+
warning("HoleEnumConv", off)
1011
hint("XDeclaredButNotUsed", off)
1112
hint("XCannotRaiseY", off)
1213
hint("User", off)
13-
14-
const
15-
nimVersion = (major: NimMajor, minor: NimMinor, patch: NimPatch)
16-
17-
when nimVersion >= (1, 6, 0):
18-
warning("HoleEnumConv", off)

nitter.example.conf

+1-7
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,9 @@ redisMaxConnections = 30
2323
hmacKey = "secretkey" # random key for cryptographic signing of video urls
2424
base64Media = false # use base64 encoding for proxied media urls
2525
enableRSS = true # set this to false to disable RSS feeds
26-
enableDebug = false # enable request logs and debug endpoints (/.tokens)
26+
enableDebug = false # enable request logs and debug endpoints (/.sessions)
2727
proxy = "" # http/https url, SOCKS proxies are not supported
2828
proxyAuth = ""
29-
tokenCount = 10
30-
# minimum amount of usable tokens. tokens are used to authorize API requests,
31-
# but they expire after ~1 hour, and have a limit of 500 requests per endpoint.
32-
# the limits reset every 15 minutes, and the pool is filled up so there's
33-
# always at least `tokenCount` usable tokens. only increase this if you receive
34-
# major bursts all the time and don't have a rate limiting setup via e.g. nginx
3529

3630
# Change default preferences here, see src/prefs_impl.nim for a complete list
3731
[Preferences]

nitter.nimble

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ requires "nim >= 1.6.10"
1414
requires "jester#baca3f"
1515
requires "karax#5cf360c"
1616
requires "sass#7dfdd03"
17-
requires "nimcrypto#4014ef9"
17+
requires "nimcrypto#a079df9"
1818
requires "markdown#158efe3"
1919
requires "packedjson#9e6fbb6"
2020
requires "supersnappy#6c94198"
2121
requires "redpool#8b7c1db"
2222
requires "https://github.com/zedeus/redis#d0a0e6f"
2323
requires "zippy#ca5989a"
2424
requires "flatty#e668085"
25-
requires "jsony#ea811be"
26-
25+
requires "jsony#1de1f08"
26+
requires "oauth#b8c163b"
2727

2828
# Tasks
2929

public/js/hls.light.min.js

-5
This file was deleted.

public/js/hls.min.js

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/md/about.md

+23-21
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ Nitter is a free and open source alternative Twitter front-end focused on
44
privacy and performance. The source is available on GitHub at
55
<https://github.com/zedeus/nitter>
66

7-
* No JavaScript or ads
8-
* All requests go through the backend, client never talks to Twitter
9-
* Prevents Twitter from tracking your IP or JavaScript fingerprint
10-
* Uses Twitter's unofficial API (no rate limits or developer account required)
11-
* Lightweight (for [@nim_lang](/nim_lang), 60KB vs 784KB from twitter.com)
12-
* RSS feeds
13-
* Themes
14-
* Mobile support (responsive design)
15-
* AGPLv3 licensed, no proprietary instances permitted
7+
- No JavaScript or ads
8+
- All requests go through the backend, client never talks to Twitter
9+
- Prevents Twitter from tracking your IP or JavaScript fingerprint
10+
- Uses Twitter's unofficial API (no developer account required)
11+
- Lightweight (for [@nim_lang](/nim_lang), 60KB vs 784KB from twitter.com)
12+
- RSS feeds
13+
- Themes
14+
- Mobile support (responsive design)
15+
- AGPLv3 licensed, no proprietary instances permitted
1616

1717
Nitter's GitHub wiki contains
1818
[instances](https://github.com/zedeus/nitter/wiki/Instances) and
@@ -21,12 +21,13 @@ maintained by the community.
2121

2222
## Why use Nitter?
2323

24-
It's impossible to use Twitter without JavaScript enabled. For privacy-minded
25-
folks, preventing JavaScript analytics and IP-based tracking is important, but
26-
apart from using a VPN and uBlock/uMatrix, it's impossible. Despite being behind
27-
a VPN and using heavy-duty adblockers, you can get accurately tracked with your
28-
[browser's fingerprint](https://restoreprivacy.com/browser-fingerprinting/),
29-
[no JavaScript required](https://noscriptfingerprint.com/). This all became
24+
It's impossible to use Twitter without JavaScript enabled, and as of 2024 you
25+
need to sign up. For privacy-minded folks, preventing JavaScript analytics and
26+
IP-based tracking is important, but apart from using a VPN and uBlock/uMatrix,
27+
it's impossible. Despite being behind a VPN and using heavy-duty adblockers,
28+
you can get accurately tracked with your [browser's
29+
fingerprint](https://restoreprivacy.com/browser-fingerprinting/), [no
30+
JavaScript required](https://noscriptfingerprint.com/). This all became
3031
particularly important after Twitter [removed the
3132
ability](https://www.eff.org/deeplinks/2020/04/twitter-removes-privacy-option-and-shows-why-we-need-strong-privacy-laws)
3233
for users to control whether their data gets sent to advertisers.
@@ -42,12 +43,13 @@ Twitter account.
4243

4344
## Donating
4445

45-
Liberapay: <https://liberapay.com/zedeus> \
46-
Patreon: <https://patreon.com/nitter> \
47-
BTC: bc1qp7q4qz0fgfvftm5hwz3vy284nue6jedt44kxya \
48-
ETH: 0x66d84bc3fd031b62857ad18c62f1ba072b011925 \
49-
LTC: ltc1qhsz5nxw6jw9rdtw9qssjeq2h8hqk2f85rdgpkr \
50-
XMR: 42hKayRoEAw4D6G6t8mQHPJHQcXqofjFuVfavqKeNMNUZfeJLJAcNU19i1bGdDvcdN6romiSscWGWJCczFLe9RFhM3d1zpL
46+
Liberapay: https://liberapay.com/zedeus \
47+
Patreon: https://patreon.com/nitter \
48+
BTC: bc1qpqpzjkcpgluhzf7x9yqe7jfe8gpfm5v08mdr55 \
49+
ETH: 0x24a0DB59A923B588c7A5EBd0dBDFDD1bCe9c4460 \
50+
XMR: 42hKayRoEAw4D6G6t8mQHPJHQcXqofjFuVfavqKeNMNUZfeJLJAcNU19i1bGdDvcdN6romiSscWGWJCczFLe9RFhM3d1zpL \
51+
SOL: ANsyGNXFo6osuFwr1YnUqif2RdoYRhc27WdyQNmmETSW \
52+
ZEC: u1vndfqtzyy6qkzhkapxelel7ams38wmfeccu3fdpy2wkuc4erxyjm8ncjhnyg747x6t0kf0faqhh2hxyplgaum08d2wnj4n7cyu9s6zhxkqw2aef4hgd4s6vh5hpqvfken98rg80kgtgn64ff70djy7s8f839z00hwhuzlcggvefhdlyszkvwy3c7yw623vw3rvar6q6evd3xcvveypt
5153

5254
## Contact
5355

0 commit comments

Comments
 (0)