Skip to content

Commit

Permalink
Merge branch 'RSS-Bridge:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
floviolleau authored Dec 18, 2023
2 parents e0af345 + b34fa2d commit 75a219e
Show file tree
Hide file tree
Showing 249 changed files with 8,605 additions and 5,890 deletions.
4 changes: 2 additions & 2 deletions .devcontainer/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ server {

location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass 127.0.0.1:9000;
fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
}
}
}
6 changes: 6 additions & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Visual Studio Code
.vscode/*

# Generated files
comment*.md
comment*.txt
262 changes: 166 additions & 96 deletions .github/prtester.py

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion .github/workflows/prhtmlgenerator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ jobs:
test-pr:
name: Generate HTML
runs-on: ubuntu-latest
env:
PYTHONUNBUFFERED: 1
# Needs additional permissions https://github.com/actions/first-interaction/issues/10#issuecomment-1041402989
steps:
- name: Check out self
Expand All @@ -22,7 +24,7 @@ jobs:
wget https://raw.githubusercontent.com/$GITHUB_REPOSITORY/${{ github.event.pull_request.base.ref }}/.github/prtester.py;
wget https://patch-diff.githubusercontent.com/raw/$GITHUB_REPOSITORY/pull/$PR.patch;
touch DEBUG;
cat $PR.patch | grep "\bbridges/.*Bridge\.php\b" | sed "s=.*\bbridges/\(.*\)Bridge\.php\b.*=\1=g" | sort | uniq > whitelist.txt
cat $PR.patch | grep "\bbridges/[A-Za-z0-9]*Bridge\.php\b" | sed "s=.*\bbridges/\([A-Za-z0-9]*\)Bridge\.php\b.*=\1=g" | sort | uniq > whitelist.txt
- name: Start Docker - Current
run: |
docker run -d -v $GITHUB_WORKSPACE/whitelist.txt:/app/whitelist.txt -v $GITHUB_WORKSPACE/DEBUG:/app/DEBUG -p 3000:80 ghcr.io/rss-bridge/rss-bridge:latest
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,9 @@ pip-log.txt
DEBUG
config.ini.php
config/*
!config/nginx.conf
!config/php-fpm.conf
!config/php.ini

######################
## VisualStudioCode ##
Expand Down
45 changes: 28 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,36 +1,47 @@
FROM lwthiker/curl-impersonate:0.5-ff-slim-buster AS curlimpersonate

FROM php:8.0.27-fpm-buster AS rssbridge
FROM debian:12-slim AS rssbridge

LABEL description="RSS-Bridge is a PHP project capable of generating RSS and Atom feeds for websites that don't have one."
LABEL repository="https://github.com/RSS-Bridge/rss-bridge"
LABEL website="https://github.com/RSS-Bridge/rss-bridge"

ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install --yes --no-install-recommends \
ca-certificates \
nginx \
zlib1g-dev \
libzip-dev \
libmemcached-dev \
nss-plugin-pem \
libicu-dev && \
docker-php-ext-install zip && \
docker-php-ext-install intl && \
pecl install memcached && \
docker-php-ext-enable memcached && \
docker-php-ext-enable opcache && \
mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"

COPY ./config/nginx.conf /etc/nginx/sites-enabled/default

COPY --chown=www-data:www-data ./ /app/
php-curl \
php-fpm \
php-intl \
# php-json is enabled by default with PHP 8.2 in Debian 12
php-mbstring \
php-memcached \
# php-opcache is enabled by default with PHP 8.2 in Debian 12
# php-openssl is enabled by default with PHP 8.2 in Debian 12
php-sqlite3 \
php-xml \
php-zip \
# php-zlib is enabled by default with PHP 8.2 in Debian 12
&& \
rm -rf /var/lib/apt/lists/*

# logs should go to stdout / stderr
RUN ln -sfT /dev/stderr /var/log/nginx/error.log; \
ln -sfT /dev/stdout /var/log/nginx/access.log; \
chown -R --no-dereference www-data:adm /var/log/nginx/

COPY --from=curlimpersonate /usr/local/lib/libcurl-impersonate-ff.so /usr/local/lib/curl-impersonate/

ENV LD_PRELOAD /usr/local/lib/curl-impersonate/libcurl-impersonate-ff.so

ENV CURL_IMPERSONATE ff91esr

COPY ./config/nginx.conf /etc/nginx/sites-available/default
COPY ./config/php-fpm.conf /etc/php/8.2/fpm/pool.d/rss-bridge.conf
COPY ./config/php.ini /etc/php/8.2/fpm/conf.d/90-rss-bridge.conf

COPY --chown=www-data:www-data ./ /app/

EXPOSE 80

ENTRYPOINT ["/app/docker-entrypoint.sh"]
18 changes: 13 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ Alternatively find another

Requires minimum PHP 7.4.

```shell
apt install nginx php-fpm php-mbstring php-simplexml php-curl
```

```shell
cd /var/www
composer create-project -v --no-dev rss-bridge/rss-bridge
Expand Down Expand Up @@ -150,6 +154,7 @@ Browse http://localhost:3000/
[![Deploy on Scalingo](https://cdn.scalingo.com/deploy/button.svg)](https://my.scalingo.com/deploy?source=https://github.com/sebsauvage/rss-bridge)
[![Deploy to Heroku](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy)
[![Deploy to Cloudron](https://cloudron.io/img/button.svg)](https://www.cloudron.io/store/com.rssbridgeapp.cloudronapp.html)
[![Run on PikaPods](https://www.pikapods.com/static/run-button.svg)](https://www.pikapods.com/pods?run=rssbridge)

The Heroku quick deploy currently does not work. It might possibly work if you fork this repo and
modify the `repository` in `scalingo.json`. See https://github.com/RSS-Bridge/rss-bridge/issues/2688
Expand Down Expand Up @@ -244,6 +249,8 @@ Modify `report_limit` so that an error must occur 3 times before it is reported.
; Defines how often an error must occur before it is reported to the user
report_limit = 3
The report count is reset to 0 each day.
### How to password-protect the instance
HTTP basic access authentication:
Expand All @@ -262,7 +269,7 @@ https://alice:cat@rss-bridge.org/bridge01/?action=display&bridge=FabriceBellardB
### How to create a new output format
[Create a new format](https://rss-bridge.github.io/rss-bridge/Format_API/index.html).
See `formats/PlaintextFormat.php` for an example.
### How to run unit tests and linter
Expand Down Expand Up @@ -334,10 +341,11 @@ This is the feed item structure that bridges are expected to produce.

### Cache backends

* `file`
* `sqlite`
* `memcached`
* `null`
* `File`
* `SQLite`
* `Memcached`
* `Array`
* `Null`

### Licenses

Expand Down
44 changes: 14 additions & 30 deletions actions/ConnectivityAction.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
<?php

/**
* This file is part of RSS-Bridge, a PHP project capable of generating RSS and
* Atom feeds for websites that don't have one.
*
* For the full license information, please view the UNLICENSE file distributed
* with this source code.
*
* @package Core
* @license http://unlicense.org/ UNLICENSE
* @link https://github.com/rss-bridge/rss-bridge
*/

/**
* Checks if the website for a given bridge is reachable.
*
Expand All @@ -34,7 +22,7 @@ public function __construct()
public function execute(array $request)
{
if (!Debug::isEnabled()) {
throw new \Exception('This action is only available in debug mode!');
return new Response('This action is only available in debug mode!', 403);
}

$bridgeName = $request['bridge'] ?? null;
Expand All @@ -43,7 +31,7 @@ public function execute(array $request)
}
$bridgeClassName = $this->bridgeFactory->createBridgeClassName($bridgeName);
if (!$bridgeClassName) {
throw new \Exception(sprintf('Bridge not found: %s', $bridgeName));
return new Response('Bridge not found', 404);
}
return $this->reportBridgeConnectivity($bridgeClassName);
}
Expand All @@ -54,29 +42,25 @@ private function reportBridgeConnectivity($bridgeClassName)
throw new \Exception('Bridge is not whitelisted!');
}

$retVal = [
'bridge' => $bridgeClassName,
'successful' => false,
'http_code' => 200,
];

$bridge = $this->bridgeFactory->create($bridgeClassName);
$curl_opts = [
CURLOPT_CONNECTTIMEOUT => 5
CURLOPT_CONNECTTIMEOUT => 5,
CURLOPT_FOLLOWLOCATION => true,
];
$result = [
'bridge' => $bridgeClassName,
'successful' => false,
'http_code' => null,
];
try {
$reply = getContents($bridge::URI, [], $curl_opts, true);

if ($reply['code'] === 200) {
$retVal['successful'] = true;
if (strpos(implode('', $reply['status_lines']), '301 Moved Permanently')) {
$retVal['http_code'] = 301;
}
$response = getContents($bridge::URI, [], $curl_opts, true);
$result['http_code'] = $response['code'];
if (in_array($response['code'], [200])) {
$result['successful'] = true;
}
} catch (\Exception $e) {
$retVal['successful'] = false;
}

return new Response(Json::encode($retVal), 200, ['Content-Type' => 'text/json']);
return new Response(Json::encode($result), 200, ['content-type' => 'text/json']);
}
}
14 changes: 1 addition & 13 deletions actions/DetectAction.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
<?php

/**
* This file is part of RSS-Bridge, a PHP project capable of generating RSS and
* Atom feeds for websites that don't have one.
*
* For the full license information, please view the UNLICENSE file distributed
* with this source code.
*
* @package Core
* @license http://unlicense.org/ UNLICENSE
* @link https://github.com/rss-bridge/rss-bridge
*/

class DetectAction implements ActionInterface
{
public function execute(array $request)
Expand Down Expand Up @@ -45,7 +33,7 @@ public function execute(array $request)
$bridgeParams['format'] = $format;

$url = '?action=display&' . http_build_query($bridgeParams);
return new Response('', 301, ['Location' => $url]);
return new Response('', 301, ['location' => $url]);
}

throw new \Exception('No bridge found for given URL: ' . $targetURL);
Expand Down
Loading

0 comments on commit 75a219e

Please sign in to comment.