Skip to content

Commit 85240c5

Browse files
committed
Merge branch 'master' into thread-rss
2 parents 78c6250 + 1fc6a40 commit 85240c5

Some content is hidden

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

68 files changed

+860
-491
lines changed

.dockerignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
*.png
2+
*.md
3+
LICENSE
4+
docker-compose.yml
5+
Dockerfile
6+
tests/

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ nitter
33
*.db
44
/tests/__pycache__
55
/tests/geckodriver.log
6-
/tmp
6+
/tests/downloaded_files/*
77
/tools/gencss
88
/public/css/style.css
9+
nitter.conf

Dockerfile

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1-
FROM nimlang/nim:alpine as nim
2-
1+
FROM nimlang/nim:1.6.2-alpine-regular as nim
2+
LABEL maintainer="[email protected]"
33
EXPOSE 8080
44

5-
RUN apk --no-cache add libsass-dev libffi-dev openssl-dev redis openssh-client
5+
RUN apk --no-cache add libsass-dev
66

77
COPY . /src/nitter
88
WORKDIR /src/nitter
99

10-
RUN nimble build -y -d:release --passC:"-flto" --passL:"-flto" \
10+
RUN nimble build -y -d:release -d:danger --passC:"-flto" --passL:"-flto" \
1111
&& strip -s nitter \
1212
&& nimble scss
1313

14-
FROM redis:6.0.4-alpine
14+
FROM alpine:latest
1515
WORKDIR /src/
16-
RUN apk --no-cache add pcre-dev sqlite-dev
17-
COPY --from=nim /src/nitter/nitter /src/nitter/start.sh /src/nitter/nitter.conf ./
16+
RUN apk --no-cache add pcre
17+
COPY --from=nim /src/nitter/nitter ./
18+
COPY --from=nim /src/nitter/nitter.example.conf ./nitter.conf
1819
COPY --from=nim /src/nitter/public ./public
19-
CMD ["./start.sh"]
20+
CMD ./nitter

README.md

+43-14
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
[![Test Matrix](https://github.com/zedeus/nitter/workflows/CI/CD/badge.svg)](https://github.com/zedeus/nitter/actions?query=workflow%3ACI/CD)
44
[![License](https://img.shields.io/github/license/zedeus/nitter?style=flat)](#license)
55

6-
A free and open source alternative Twitter front-end focused on privacy. \
7-
Inspired by the [Invidious](https://github.com/iv-org/invidious) project.
6+
A free and open source alternative Twitter front-end focused on privacy and
7+
performance. \
8+
Inspired by the [Invidious](https://github.com/iv-org/invidious)
9+
project.
810

911
- No JavaScript or ads
1012
- All requests go through the backend, client never talks to Twitter
@@ -39,12 +41,14 @@ maintained by the community.
3941

4042
## Why?
4143

42-
It's basically impossible to use Twitter without JavaScript enabled. If you try,
43-
you're redirected to the legacy mobile version which is awful both functionally
44-
and aesthetically. For privacy-minded folks, preventing JavaScript analytics and
45-
potential IP-based tracking is important, but apart from using the legacy mobile
46-
version and a VPN, it's impossible. This is is especially relevant now that Twitter
47-
[removed the ability](https://www.eff.org/deeplinks/2020/04/twitter-removes-privacy-option-and-shows-why-we-need-strong-privacy-laws)
44+
It's impossible to use Twitter without JavaScript enabled. For privacy-minded
45+
folks, preventing JavaScript analytics and IP-based tracking is important, but
46+
apart from using a VPN and uBlock/uMatrix, it's impossible. Despite being behind
47+
a VPN and using heavy-duty adblockers, you can get accurately tracked with your
48+
[browser's fingerprint](https://restoreprivacy.com/browser-fingerprinting/),
49+
[no JavaScript required](https://noscriptfingerprint.com/). This all became
50+
particularly important after Twitter [removed the
51+
ability](https://www.eff.org/deeplinks/2020/04/twitter-removes-privacy-option-and-shows-why-we-need-strong-privacy-laws)
4852
for users to control whether their data gets sent to advertisers.
4953

5054
Using an instance of Nitter (hosted on a VPS for example), you can browse
@@ -62,6 +66,11 @@ Twitter account.
6266

6367
## Installation
6468

69+
### Dependencies
70+
* libpcre
71+
* libsass
72+
* redis
73+
6574
To compile Nitter you need a Nim installation, see
6675
[nim-lang.org](https://nim-lang.org/install.html) for details. It is possible to
6776
install it system-wide or in the user directory you create below.
@@ -84,29 +93,47 @@ $ git clone https://github.com/zedeus/nitter
8493
$ cd nitter
8594
$ nimble build -d:release
8695
$ nimble scss
87-
$ mkdir ./tmp
96+
$ cp nitter.example.conf nitter.conf
8897
```
8998

9099
Set your hostname, port, HMAC key, https (must be correct for cookies), and
91100
Redis info in `nitter.conf`. To run Redis, either run
92101
`redis-server --daemonize yes`, or `systemctl enable --now redis` (or
93102
redis-server depending on the distro). Run Nitter by executing `./nitter` or
94103
using the systemd service below. You should run Nitter behind a reverse proxy
95-
such as [Nginx](https://github.com/zedeus/nitter/wiki/Nginx) or Apache for
96-
security reasons.
104+
such as [Nginx](https://github.com/zedeus/nitter/wiki/Nginx) or
105+
[Apache](https://github.com/zedeus/nitter/wiki/Apache) for security and
106+
performance reasons.
107+
108+
### Docker
109+
110+
#### NOTE: For ARM64/ARM support, please use [unixfox's image](https://quay.io/repository/unixfox/nitter?tab=tags), more info [here](https://github.com/zedeus/nitter/issues/399#issuecomment-997263495)
111+
112+
To run Nitter with Docker, you'll need to install and run Redis separately
113+
before you can run the container. See below for how to also run Redis using
114+
Docker.
97115

98116
To build and run Nitter in Docker:
99117
```bash
100118
docker build -t nitter:latest .
101-
docker run -v $(pwd)/nitter.conf:/src/nitter.conf -d -p 8080:8080 nitter:latest
119+
docker run -v $(pwd)/nitter.conf:/src/nitter.conf -d --network host nitter:latest
102120
```
103121

104122
A prebuilt Docker image is provided as well:
105123
```bash
106-
docker run -v $(pwd)/nitter.conf:/src/nitter.conf -d -p 8080:8080 zedeus/nitter:latest
124+
docker run -v $(pwd)/nitter.conf:/src/nitter.conf -d --network host zedeus/nitter:latest
107125
```
108126

109-
Note the Docker commands expect a `nitter.conf` file in the directory you run them.
127+
Using docker-compose to run both Nitter and Redis as different containers:
128+
Change `redisHost` from `localhost` to `redis` in `nitter.conf`, then run:
129+
```bash
130+
docker-compose up -d
131+
```
132+
133+
Note the Docker commands expect a `nitter.conf` file in the directory you run
134+
them.
135+
136+
### systemd
110137

111138
To run Nitter via systemd you can use this service file:
112139

@@ -137,6 +164,8 @@ WantedBy=multi-user.target
137164
Then enable and run the service:
138165
`systemctl enable --now nitter.service`
139166

167+
### Logging
168+
140169
Nitter currently prints some errors to stdout, and there is no real logging
141170
implemented. If you're running Nitter with systemd, you can check stdout like
142171
this: `journalctl -u nitter.service` (add `--follow` to see just the last 15

config.nims

+8-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,11 @@
66

77
# disable annoying warnings
88
warning("GcUnsafe2", off)
9-
warning("ObservableStores", off)
9+
hint("XDeclaredButNotUsed", off)
10+
hint("User", off)
11+
12+
const
13+
nimVersion = (major: NimMajor, minor: NimMinor, patch: NimPatch)
14+
15+
when nimVersion >= (1, 6, 0):
16+
warning("HoleEnumConv", off)

docker-compose.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
version: "3.8"
2+
services:
3+
redis:
4+
image: redis:6-alpine
5+
restart: unless-stopped
6+
volumes:
7+
- redis-data:/var/lib/redis
8+
nitter:
9+
image: zedeus/nitter:latest
10+
restart: unless-stopped
11+
depends_on:
12+
- redis
13+
ports:
14+
- "8080:8080"
15+
volumes:
16+
- ./nitter.conf:/src/nitter.conf
17+
volumes:
18+
redis-data:

nitter.conf renamed to nitter.example.conf

+10-4
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,22 @@ hostname = "nitter.net"
1010
[Cache]
1111
listMinutes = 240 # how long to cache list info (not the tweets, so keep it high)
1212
rssMinutes = 10 # how long to cache rss queries
13-
redisHost = "localhost"
13+
redisHost = "localhost" # Change to "redis" if using docker-compose
1414
redisPort = 6379
15-
redisConnections = 20 # connection pool size
15+
redisPassword = ""
16+
redisConnections = 20 # connection pool size
1617
redisMaxConnections = 30
1718
# max, new connections are opened when none are available, but if the pool size
1819
# goes above this, they're closed when released. don't worry about this unless
1920
# you receive tons of requests per second
2021

2122
[Config]
22-
hmacKey = "secretkey" # random key for cryptographic signing of video urls
23-
base64Media = false # use base64 encoding for proxied media urls
23+
hmacKey = "secretkey" # random key for cryptographic signing of video urls
24+
base64Media = false # use base64 encoding for proxied media urls
25+
enableRSS = true # set this to false to disable RSS feeds
26+
enableDebug = false # enable request logs and debug endpoints
27+
proxy = "" # http/https url, SOCKS proxies are not supported
28+
proxyAuth = ""
2429
tokenCount = 10
2530
# minimum amount of usable tokens. tokens are used to authorize API requests,
2631
# but they expire after ~1 hour, and have a limit of 187 requests.
@@ -33,6 +38,7 @@ tokenCount = 10
3338
theme = "Nitter"
3439
replaceTwitter = "nitter.net"
3540
replaceYouTube = "piped.kavin.rocks"
41+
replaceReddit = "teddit.net"
3642
replaceInstagram = ""
3743
proxyVideos = true
3844
hlsPlayback = false

nitter.nimble

+11-10
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,22 @@ bin = @["nitter"]
1010

1111
# Dependencies
1212

13-
requires "nim >= 1.2.0"
13+
requires "nim >= 1.4.8"
1414
requires "jester >= 0.5.0"
15-
requires "karax >= 1.1.2"
15+
requires "karax#c71bc92"
1616
requires "sass#e683aa1"
17-
requires "regex#2e32fdc"
18-
requires "nimcrypto >= 0.4.11"
17+
requires "regex#eeefb4f"
18+
requires "nimcrypto#a5742a9"
1919
requires "markdown#abdbe5e"
20-
requires "packedjson#7198cc8"
21-
requires "supersnappy#1.1.5"
22-
requires "redpool#57aeb25"
23-
requires "https://github.com/zedeus/redis#94bcbf1"
24-
requires "https://github.com/disruptek/frosty#0.3.1"
20+
requires "packedjson#d11d167"
21+
requires "supersnappy#2.1.1"
22+
requires "redpool#f880f49"
23+
requires "https://github.com/zedeus/redis#d0a0e6f"
24+
requires "zippy#0.7.3"
25+
requires "flatty#0.2.3"
2526

2627

2728
# Tasks
2829

2930
task scss, "Generate css":
30-
exec "nim c --hint[Processing]:off -r tools/gencss"
31+
exec "nim c --hint[Processing]:off -d:danger -r tools/gencss"

public/android-chrome-512x512.png

2.26 KB
Loading

public/js/hlsPlayback.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// @license http://www.gnu.org/licenses/agpl-3.0.html AGPL-3.0
2+
// SPDX-License-Identifier: AGPL-3.0-only
23
function playVideo(overlay) {
34
const video = overlay.parentElement.querySelector('video');
45
const url = video.getAttribute("data-url");
@@ -16,7 +17,7 @@ function playVideo(overlay) {
1617
});
1718
} else if (video.canPlayType('application/vnd.apple.mpegurl')) {
1819
video.src = url;
19-
video.addEventListened('canplay', function() {
20+
video.addEventListener('canplay', function() {
2021
video.play();
2122
});
2223
}

public/js/infiniteScroll.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// @license http://www.gnu.org/licenses/agpl-3.0.html AGPL-3.0
2+
// SPDX-License-Identifier: AGPL-3.0-only
23
function insertBeforeLast(node, elem) {
34
node.insertBefore(elem, node.childNodes[node.childNodes.length - 2]);
45
}

public/md/about.md

+13-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# About
22

33
Nitter is a free and open source alternative Twitter front-end focused on
4-
privacy. The source is available on GitHub at <https://github.com/zedeus/nitter>
4+
privacy and performance. The source is available on GitHub at
5+
<https://github.com/zedeus/nitter>
56

67
* No JavaScript or ads
78
* All requests go through the backend, client never talks to Twitter
@@ -20,16 +21,20 @@ maintained by the community.
2021

2122
## Why use Nitter?
2223

23-
It's basically impossible to use Twitter without JavaScript enabled. If you try,
24-
you're redirected to the legacy mobile version which is awful both functionally
25-
and aesthetically. For privacy-minded folks, preventing JavaScript analytics and
26-
potential IP-based tracking is important, but apart from using the legacy mobile
27-
version and a VPN, it's impossible.
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
30+
particularly important after Twitter [removed the
31+
ability](https://www.eff.org/deeplinks/2020/04/twitter-removes-privacy-option-and-shows-why-we-need-strong-privacy-laws)
32+
for users to control whether their data gets sent to advertisers.
2833

2934
Using an instance of Nitter (hosted on a VPS for example), you can browse
3035
Twitter without JavaScript while retaining your privacy. In addition to
3136
respecting your privacy, Nitter is on average around 15 times lighter than
32-
Twitter, and in some cases serves pages faster.
37+
Twitter, and in most cases serves pages faster (eg. timelines load 2-4x faster).
3338

3439
In the future a simple account system will be added that lets you follow Twitter
3540
users, allowing you to have a clean chronological timeline without needing a
@@ -46,5 +51,4 @@ XMR: 42hKayRoEAw4D6G6t8mQHPJHQcXqofjFuVfavqKeNMNUZfeJLJAcNU19i1bGdDvcdN6romiSscW
4651

4752
## Contact
4853

49-
Feel free to join our Freenode IRC channel at #nitter, or our
50-
[Matrix channel](https://matrix.to/#/#nitter:matrix.org).
54+
Feel free to join our [Matrix channel](https://matrix.to/#/#nitter:matrix.org).

public/site.webmanifest

+5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
"src": "/android-chrome-384x384.png",
1212
"sizes": "384x384",
1313
"type": "image/png"
14+
},
15+
{
16+
"src": "/android-chrome-512x512.png",
17+
"sizes": "512x512",
18+
"type": "image/png"
1419
}
1520
],
1621
"theme_color": "#333333",

screenshot.png

45.7 KB
Loading

src/agents.nim

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# SPDX-License-Identifier: AGPL-3.0-only
12
import random, strformat, strutils, sequtils
23

34
randomize()
@@ -30,7 +31,7 @@ proc windows(): string =
3031
trident = ["", "; Trident/5.0", "; Trident/6.0", "; Trident/7.0"]
3132
"Windows " & sample(nt) & sample(enc) & sample(arch) & sample(trident)
3233

33-
let macs = toSeq(6..15).mapIt($it) & @["14_4", "10_1", "9_3"]
34+
const macs = toSeq(6..15).mapIt($it) & @["14_4", "10_1", "9_3"]
3435

3536
proc mac(): string =
3637
"Macintosh; Intel Mac OS X 10_" & sample(macs) & sample(enc)

0 commit comments

Comments
 (0)