Skip to content

Commit

Permalink
Merge branch 'master' into thread-rss
Browse files Browse the repository at this point in the history
  • Loading branch information
duxovni committed Jan 9, 2022
2 parents 78c6250 + 1fc6a40 commit ba5182c
Show file tree
Hide file tree
Showing 68 changed files with 861 additions and 493 deletions.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*.png
*.md
LICENSE
docker-compose.yml
Dockerfile
tests/
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ nitter
*.db
/tests/__pycache__
/tests/geckodriver.log
/tmp
/tests/downloaded_files/*
/tools/gencss
/public/css/style.css
nitter.conf
17 changes: 9 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
FROM nimlang/nim:alpine as nim
MAINTAINER [email protected]
FROM nimlang/nim:1.6.2-alpine-regular as nim
LABEL maintainer="[email protected]"
EXPOSE 8080

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

COPY . /src/nitter
WORKDIR /src/nitter

RUN nimble build -y -d:release --passC:"-flto" --passL:"-flto" \
RUN nimble build -y -d:release -d:danger --passC:"-flto" --passL:"-flto" \
&& strip -s nitter \
&& nimble scss

FROM redis:6.0.4-alpine
FROM alpine:latest
WORKDIR /src/
RUN apk --no-cache add pcre-dev sqlite-dev
COPY --from=nim /src/nitter/nitter /src/nitter/start.sh /src/nitter/nitter.conf ./
RUN apk --no-cache add pcre
COPY --from=nim /src/nitter/nitter ./
COPY --from=nim /src/nitter/nitter.example.conf ./nitter.conf
COPY --from=nim /src/nitter/public ./public
CMD ["./start.sh"]
CMD ./nitter
57 changes: 43 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
[![Test Matrix](https://github.com/zedeus/nitter/workflows/CI/CD/badge.svg)](https://github.com/zedeus/nitter/actions?query=workflow%3ACI/CD)
[![License](https://img.shields.io/github/license/zedeus/nitter?style=flat)](#license)

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

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

## Why?

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

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

## Installation

### Dependencies
* libpcre
* libsass
* redis

To compile Nitter you need a Nim installation, see
[nim-lang.org](https://nim-lang.org/install.html) for details. It is possible to
install it system-wide or in the user directory you create below.
Expand All @@ -84,29 +93,47 @@ $ git clone https://github.com/zedeus/nitter
$ cd nitter
$ nimble build -d:release
$ nimble scss
$ mkdir ./tmp
$ cp nitter.example.conf nitter.conf
```

Set your hostname, port, HMAC key, https (must be correct for cookies), and
Redis info in `nitter.conf`. To run Redis, either run
`redis-server --daemonize yes`, or `systemctl enable --now redis` (or
redis-server depending on the distro). Run Nitter by executing `./nitter` or
using the systemd service below. You should run Nitter behind a reverse proxy
such as [Nginx](https://github.com/zedeus/nitter/wiki/Nginx) or Apache for
security reasons.
such as [Nginx](https://github.com/zedeus/nitter/wiki/Nginx) or
[Apache](https://github.com/zedeus/nitter/wiki/Apache) for security and
performance reasons.

### Docker

#### 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)

To run Nitter with Docker, you'll need to install and run Redis separately
before you can run the container. See below for how to also run Redis using
Docker.

To build and run Nitter in Docker:
```bash
docker build -t nitter:latest .
docker run -v $(pwd)/nitter.conf:/src/nitter.conf -d -p 8080:8080 nitter:latest
docker run -v $(pwd)/nitter.conf:/src/nitter.conf -d --network host nitter:latest
```

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

Note the Docker commands expect a `nitter.conf` file in the directory you run them.
Using docker-compose to run both Nitter and Redis as different containers:
Change `redisHost` from `localhost` to `redis` in `nitter.conf`, then run:
```bash
docker-compose up -d
```

Note the Docker commands expect a `nitter.conf` file in the directory you run
them.

### systemd

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

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

### Logging

Nitter currently prints some errors to stdout, and there is no real logging
implemented. If you're running Nitter with systemd, you can check stdout like
this: `journalctl -u nitter.service` (add `--follow` to see just the last 15
Expand Down
9 changes: 8 additions & 1 deletion config.nims
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,11 @@

# disable annoying warnings
warning("GcUnsafe2", off)
warning("ObservableStores", off)
hint("XDeclaredButNotUsed", off)
hint("User", off)

const
nimVersion = (major: NimMajor, minor: NimMinor, patch: NimPatch)

when nimVersion >= (1, 6, 0):
warning("HoleEnumConv", off)
18 changes: 18 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: "3.8"
services:
redis:
image: redis:6-alpine
restart: unless-stopped
volumes:
- redis-data:/var/lib/redis
nitter:
image: zedeus/nitter:latest
restart: unless-stopped
depends_on:
- redis
ports:
- "8080:8080"
volumes:
- ./nitter.conf:/src/nitter.conf
volumes:
redis-data:
14 changes: 10 additions & 4 deletions nitter.conf → nitter.example.conf
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,22 @@ hostname = "nitter.net"
[Cache]
listMinutes = 240 # how long to cache list info (not the tweets, so keep it high)
rssMinutes = 10 # how long to cache rss queries
redisHost = "localhost"
redisHost = "localhost" # Change to "redis" if using docker-compose
redisPort = 6379
redisConnections = 20 # connection pool size
redisPassword = ""
redisConnections = 20 # connection pool size
redisMaxConnections = 30
# max, new connections are opened when none are available, but if the pool size
# goes above this, they're closed when released. don't worry about this unless
# you receive tons of requests per second

[Config]
hmacKey = "secretkey" # random key for cryptographic signing of video urls
base64Media = false # use base64 encoding for proxied media urls
hmacKey = "secretkey" # random key for cryptographic signing of video urls
base64Media = false # use base64 encoding for proxied media urls
enableRSS = true # set this to false to disable RSS feeds
enableDebug = false # enable request logs and debug endpoints
proxy = "" # http/https url, SOCKS proxies are not supported
proxyAuth = ""
tokenCount = 10
# minimum amount of usable tokens. tokens are used to authorize API requests,
# but they expire after ~1 hour, and have a limit of 187 requests.
Expand All @@ -33,6 +38,7 @@ tokenCount = 10
theme = "Nitter"
replaceTwitter = "nitter.net"
replaceYouTube = "piped.kavin.rocks"
replaceReddit = "teddit.net"
replaceInstagram = ""
proxyVideos = true
hlsPlayback = false
Expand Down
21 changes: 11 additions & 10 deletions nitter.nimble
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,22 @@ bin = @["nitter"]

# Dependencies

requires "nim >= 1.2.0"
requires "nim >= 1.4.8"
requires "jester >= 0.5.0"
requires "karax >= 1.1.2"
requires "karax#c71bc92"
requires "sass#e683aa1"
requires "regex#2e32fdc"
requires "nimcrypto >= 0.4.11"
requires "regex#eeefb4f"
requires "nimcrypto#a5742a9"
requires "markdown#abdbe5e"
requires "packedjson#7198cc8"
requires "supersnappy#1.1.5"
requires "redpool#57aeb25"
requires "https://github.com/zedeus/redis#94bcbf1"
requires "https://github.com/disruptek/frosty#0.3.1"
requires "packedjson#d11d167"
requires "supersnappy#2.1.1"
requires "redpool#f880f49"
requires "https://github.com/zedeus/redis#d0a0e6f"
requires "zippy#0.7.3"
requires "flatty#0.2.3"


# Tasks

task scss, "Generate css":
exec "nim c --hint[Processing]:off -r tools/gencss"
exec "nim c --hint[Processing]:off -d:danger -r tools/gencss"
Binary file added public/android-chrome-512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion public/js/hlsPlayback.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// @license http://www.gnu.org/licenses/agpl-3.0.html AGPL-3.0
// SPDX-License-Identifier: AGPL-3.0-only
function playVideo(overlay) {
const video = overlay.parentElement.querySelector('video');
const url = video.getAttribute("data-url");
Expand All @@ -16,7 +17,7 @@ function playVideo(overlay) {
});
} else if (video.canPlayType('application/vnd.apple.mpegurl')) {
video.src = url;
video.addEventListened('canplay', function() {
video.addEventListener('canplay', function() {
video.play();
});
}
Expand Down
1 change: 1 addition & 0 deletions public/js/infiniteScroll.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// @license http://www.gnu.org/licenses/agpl-3.0.html AGPL-3.0
// SPDX-License-Identifier: AGPL-3.0-only
function insertBeforeLast(node, elem) {
node.insertBefore(elem, node.childNodes[node.childNodes.length - 2]);
}
Expand Down
22 changes: 13 additions & 9 deletions public/md/about.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# About

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

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

## Why use Nitter?

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

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

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

## Contact

Feel free to join our Freenode IRC channel at #nitter, or our
[Matrix channel](https://matrix.to/#/#nitter:matrix.org).
Feel free to join our [Matrix channel](https://matrix.to/#/#nitter:matrix.org).
5 changes: 5 additions & 0 deletions public/site.webmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
"src": "/android-chrome-384x384.png",
"sizes": "384x384",
"type": "image/png"
},
{
"src": "/android-chrome-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
],
"theme_color": "#333333",
Expand Down
Binary file modified screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion src/agents.nim
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# SPDX-License-Identifier: AGPL-3.0-only
import random, strformat, strutils, sequtils

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

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

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

0 comments on commit ba5182c

Please sign in to comment.