Compare commits

..

1 Commits

Author SHA1 Message Date
c2965789a0 Bump freedns plugin 2024-10-17 12:57:49 +10:00
23 changed files with 601 additions and 1172 deletions

View File

@ -29,7 +29,6 @@ if (config.debug()) {
app.set('json spaces', 2); app.set('json spaces', 2);
} }
// CORS for everything // CORS for everything
app.use(require('./lib/express/cors')); app.use(require('./lib/express/cors'));

View File

@ -9,22 +9,6 @@ function generateDbConfig() {
if (cfg.engine === 'knex-native') { if (cfg.engine === 'knex-native') {
return cfg.knex; return cfg.knex;
} }
if (cfg.engine === 'pg') {
return {
client: cfg.engine,
connection: {
host: cfg.host,
user: cfg.user,
password: cfg.password,
database: cfg.name,
port: cfg.port
},
migrations: {
tableName: 'migrations'
}
};
}
return { return {
client: cfg.engine, client: cfg.engine,
connection: { connection: {

View File

@ -252,14 +252,10 @@ const internalAccessList = {
let query = accessListModel let query = accessListModel
.query() .query()
.select('access_list.*', accessListModel.raw('COUNT(proxy_host.id) as proxy_host_count')) .select('access_list.*', accessListModel.raw('COUNT(proxy_host.id) as proxy_host_count'))
.leftJoin('proxy_host', function() { .joinRaw('LEFT JOIN `proxy_host` ON `proxy_host`.`access_list_id` = `access_list`.`id` AND `proxy_host`.`is_deleted` = 0')
this.on('proxy_host.access_list_id', '=', 'access_list.id')
.andOn('proxy_host.is_deleted', '=', 0);
})
.where('access_list.is_deleted', 0) .where('access_list.is_deleted', 0)
.andWhere('access_list.id', data.id) .andWhere('access_list.id', data.id)
.allowGraph('[owner,items,clients,proxy_hosts.[certificate,access_list.[clients,items]]]') .allowGraph('[owner,items,clients,proxy_hosts.[certificate,access_list.[clients,items]]]')
.groupBy('access_list.id')
.first(); .first();
if (access_data.permission_visibility !== 'all') { if (access_data.permission_visibility !== 'all') {
@ -377,10 +373,7 @@ const internalAccessList = {
let query = accessListModel let query = accessListModel
.query() .query()
.select('access_list.*', accessListModel.raw('COUNT(proxy_host.id) as proxy_host_count')) .select('access_list.*', accessListModel.raw('COUNT(proxy_host.id) as proxy_host_count'))
.leftJoin('proxy_host', function() { .joinRaw('LEFT JOIN `proxy_host` ON `proxy_host`.`access_list_id` = `access_list`.`id` AND `proxy_host`.`is_deleted` = 0')
this.on('proxy_host.access_list_id', '=', 'access_list.id')
.andOn('proxy_host.is_deleted', '=', 0);
})
.where('access_list.is_deleted', 0) .where('access_list.is_deleted', 0)
.groupBy('access_list.id') .groupBy('access_list.id')
.allowGraph('[owner,items,clients]') .allowGraph('[owner,items,clients]')

View File

@ -22,9 +22,9 @@ const internalAuditLog = {
.allowGraph('[user]'); .allowGraph('[user]');
// Query is used for searching // Query is used for searching
if (typeof search_query === 'string' && search_query.length > 0) { if (typeof search_query === 'string') {
query.where(function () { query.where(function () {
this.whereRaw('CAST(meta AS VARCHAR(65535)) like ? ESCAPE \'\'', '%' + search_query + '%'); this.where('meta', 'like', '%' + search_query + '%');
}); });
} }

View File

@ -409,16 +409,16 @@ const internalDeadHost = {
.where('is_deleted', 0) .where('is_deleted', 0)
.groupBy('id') .groupBy('id')
.allowGraph('[owner,certificate]') .allowGraph('[owner,certificate]')
.orderByRaw('CAST(domain_names AS VARCHAR(65535)) ASC'); .orderBy('domain_names', 'ASC');
if (access_data.permission_visibility !== 'all') { if (access_data.permission_visibility !== 'all') {
query.andWhere('owner_user_id', access.token.getUserId(1)); query.andWhere('owner_user_id', access.token.getUserId(1));
} }
// Query is used for searching // Query is used for searching
if (typeof search_query === 'string' && search_query.length > 0) { if (typeof search_query === 'string') {
query.where(function () { query.where(function () {
this.whereRaw('CAST(domain_names AS VARCHAR(65535)) like ? ESCAPE \'\'', '%' + search_query + '%'); this.where('domain_names', 'like', '%' + search_query + '%');
}); });
} }

View File

@ -129,15 +129,15 @@ const internalHost = {
proxyHostModel proxyHostModel
.query() .query()
.where('is_deleted', 0) .where('is_deleted', 0)
.whereRaw('CAST(domain_names AS VARCHAR(65535)) like ? ESCAPE \'\'', '%'+hostname + '%'), .andWhere('domain_names', 'like', '%' + hostname + '%'),
redirectionHostModel redirectionHostModel
.query() .query()
.where('is_deleted', 0) .where('is_deleted', 0)
.whereRaw('CAST(domain_names AS VARCHAR(65535)) like ? ESCAPE \'\'', '%'+hostname + '%'), .andWhere('domain_names', 'like', '%' + hostname + '%'),
deadHostModel deadHostModel
.query() .query()
.where('is_deleted', 0) .where('is_deleted', 0)
.whereRaw('CAST(domain_names AS VARCHAR(65535)) like ? ESCAPE \'\'', '%'+hostname + '%'), .andWhere('domain_names', 'like', '%' + hostname + '%')
]; ];
return Promise.all(promises) return Promise.all(promises)

View File

@ -409,7 +409,6 @@ const internalProxyHost = {
* @returns {Promise} * @returns {Promise}
*/ */
getAll: (access, expand, search_query) => { getAll: (access, expand, search_query) => {
return access.can('proxy_hosts:list') return access.can('proxy_hosts:list')
.then((access_data) => { .then((access_data) => {
let query = proxyHostModel let query = proxyHostModel
@ -417,17 +416,16 @@ const internalProxyHost = {
.where('is_deleted', 0) .where('is_deleted', 0)
.groupBy('id') .groupBy('id')
.allowGraph('[owner,access_list,certificate]') .allowGraph('[owner,access_list,certificate]')
.orderByRaw('CAST(domain_names AS VARCHAR(65535) ) ASC') .orderBy('domain_names', 'ASC');
;
if (access_data.permission_visibility !== 'all') { if (access_data.permission_visibility !== 'all') {
query.andWhere('owner_user_id', access.token.getUserId(1)); query.andWhere('owner_user_id', access.token.getUserId(1));
} }
// Query is used for searching // Query is used for searching
if (typeof search_query === 'string' && search_query.length > 0) { if (typeof search_query === 'string') {
query.where(function () { query.where(function () {
this.whereRaw('CAST(domain_names AS VARCHAR(65535) ) like ? ESCAPE \'\'', '%'+search_query + '%'); this.where('domain_names', 'like', '%' + search_query + '%');
}); });
} }
@ -438,7 +436,6 @@ const internalProxyHost = {
return query.then(utils.omitRows(omissions())); return query.then(utils.omitRows(omissions()));
}) })
.then((rows) => { .then((rows) => {
if (typeof expand !== 'undefined' && expand !== null && expand.indexOf('certificate') !== -1) { if (typeof expand !== 'undefined' && expand !== null && expand.indexOf('certificate') !== -1) {
return internalHost.cleanAllRowsCertificateMeta(rows); return internalHost.cleanAllRowsCertificateMeta(rows);
} }

View File

@ -20,6 +20,7 @@ const internalRedirectionHost = {
*/ */
create: (access, data) => { create: (access, data) => {
let create_certificate = data.certificate_id === 'new'; let create_certificate = data.certificate_id === 'new';
if (create_certificate) { if (create_certificate) {
delete data.certificate_id; delete data.certificate_id;
} }
@ -408,16 +409,16 @@ const internalRedirectionHost = {
.where('is_deleted', 0) .where('is_deleted', 0)
.groupBy('id') .groupBy('id')
.allowGraph('[owner,certificate]') .allowGraph('[owner,certificate]')
.orderByRaw('CAST(domain_names AS VARCHAR(65535) ) ASC'); .orderBy('domain_names', 'ASC');
if (access_data.permission_visibility !== 'all') { if (access_data.permission_visibility !== 'all') {
query.andWhere('owner_user_id', access.token.getUserId(1)); query.andWhere('owner_user_id', access.token.getUserId(1));
} }
// Query is used for searching // Query is used for searching
if (typeof search_query === 'string' && search_query.length > 0) { if (typeof search_query === 'string') {
query.where(function () { query.where(function () {
this.whereRaw('CAST(domain_names AS VARCHAR(65535) ) like ? ESCAPE \'\'', '%' + search_query + '%'); this.where('domain_names', 'like', '%' + search_query + '%');
}); });
} }

View File

@ -298,18 +298,16 @@ const internalStream = {
.where('is_deleted', 0) .where('is_deleted', 0)
.groupBy('id') .groupBy('id')
.allowGraph('[owner]') .allowGraph('[owner]')
//.orderBy('incoming_port', 'ASC') .orderBy('incoming_port', 'ASC');
.orderByRaw('CAST(incoming_port AS INTEGER) ASC')
;
if (access_data.permission_visibility !== 'all') { if (access_data.permission_visibility !== 'all') {
query.andWhere('owner_user_id', access.token.getUserId(1)); query.andWhere('owner_user_id', access.token.getUserId(1));
} }
// Query is used for searching // Query is used for searching
if (typeof search_query === 'string' && search_query.length > 0) { if (typeof search_query === 'string') {
query.where(function () { query.where(function () {
this.whereRaw('CAST(incoming_port AS VARCHAR(65535)) like ? ESCAPE \'\'', '%' + search_query+ '%'); this.where('incoming_port', 'like', '%' + search_query + '%');
}); });
} }

View File

@ -45,25 +45,6 @@ const configure = () => {
}; };
return; return;
} }
const envPostgresqlHost = process.env.DB_POSTGRESQL_HOST || null;
const envPostgresqlUser = process.env.DB_POSTGRESQL_USER || null;
const envPostgresqlName = process.env.DB_POSTGRESQL_NAME || null;
if (envPostgresqlHost && envPostgresqlUser && envPostgresqlName) {
// we have enough mysql creds to go with mysql
logger.info('Using POSTGRESQL configuration');
instance = {
database: {
engine: 'pg',
host: envPostgresqlHost,
port: process.env.DB_POSTGRESQL_PORT || 5432,
user: envPostgresqlUser,
password: process.env.DB_POSTGRESQL_PASSWORD,
name: envPostgresqlName,
},
keys: getKeys(),
};
return;
}
const envSqliteFile = process.env.DB_SQLITE_FILE || '/data/database.sqlite'; const envSqliteFile = process.env.DB_SQLITE_FILE || '/data/database.sqlite';
logger.info(`Using Sqlite: ${envSqliteFile}`); logger.info(`Using Sqlite: ${envSqliteFile}`);

View File

@ -17,9 +17,6 @@ const boolFields = [
'preserve_path', 'preserve_path',
'ssl_forced', 'ssl_forced',
'block_exploits', 'block_exploits',
'hsts_enabled',
'hsts_subdomains',
'http2_support',
]; ];
class RedirectionHost extends Model { class RedirectionHost extends Model {

View File

@ -21,9 +21,8 @@
"moment": "^2.29.4", "moment": "^2.29.4",
"mysql2": "^3.11.1", "mysql2": "^3.11.1",
"node-rsa": "^1.0.8", "node-rsa": "^1.0.8",
"objection": "^3.0.1", "objection": "3.0.1",
"path": "^0.12.7", "path": "^0.12.7",
"pg": "^8.13.0",
"signale": "1.4.0", "signale": "1.4.0",
"sqlite3": "5.1.6", "sqlite3": "5.1.6",
"temp-write": "^4.0.0" "temp-write": "^4.0.0"

View File

@ -49,7 +49,8 @@
"minLength": 1 "minLength": 1
}, },
"password": { "password": {
"type": "string" "type": "string",
"minLength": 1
} }
} }
} }

View File

@ -15,11 +15,11 @@ const certbot = require('./lib/certbot');
const setupDefaultUser = () => { const setupDefaultUser = () => {
return userModel return userModel
.query() .query()
.select('id') .select(userModel.raw('COUNT(`id`) as `count`'))
.where('is_deleted', 0) .where('is_deleted', 0)
.first()
.then((row) => { .then((row) => {
if (row.length === 0) { if (!row.count) {
// Create a new user and set password // Create a new user and set password
let email = process.env.INITIAL_ADMIN_EMAIL || 'admin@example.com'; let email = process.env.INITIAL_ADMIN_EMAIL || 'admin@example.com';
let password = process.env.INITIAL_ADMIN_PASSWORD || 'changeme'; let password = process.env.INITIAL_ADMIN_PASSWORD || 'changeme';
@ -77,10 +77,11 @@ const setupDefaultUser = () => {
const setupDefaultSettings = () => { const setupDefaultSettings = () => {
return settingModel return settingModel
.query() .query()
.select('id') .select(settingModel.raw('COUNT(`id`) as `count`'))
.where({id: 'default-site'}) .where({id: 'default-site'})
.first()
.then((row) => { .then((row) => {
if (!row.length || !row[0].id) { if (!row.count) {
settingModel settingModel
.query() .query()
.insert({ .insert({

View File

@ -4,7 +4,7 @@
auth_basic "Authorization required"; auth_basic "Authorization required";
auth_basic_user_file /data/access/{{ access_list_id }}; auth_basic_user_file /data/access/{{ access_list_id }};
{% if access_list.pass_auth == 0 or access_list.pass_auth == true %} {% if access_list.pass_auth == 0 %}
proxy_set_header Authorization ""; proxy_set_header Authorization "";
{% endif %} {% endif %}
@ -17,7 +17,7 @@
deny all; deny all;
# Access checks must... # Access checks must...
{% if access_list.satisfy_any == 1 or access_list.satisfy_any == true %} {% if access_list.satisfy_any == 1 %}
satisfy any; satisfy any;
{% else %} {% else %}
satisfy all; satisfy all;

View File

@ -5,16 +5,11 @@
#listen [::]:80; #listen [::]:80;
{% endif %} {% endif %}
{% if certificate -%} {% if certificate -%}
listen 443 ssl; listen 443 ssl{% if http2_support == 1 or http2_support == true %} http2{% endif %};
{% if ipv6 -%} {% if ipv6 -%}
listen [::]:443 ssl; listen [::]:443 ssl{% if http2_support == 1 or http2_support == true %} http2{% endif %};
{% else -%} {% else -%}
#listen [::]:443; #listen [::]:443;
{% endif %} {% endif %}
{% endif %} {% endif %}
server_name {{ domain_names | join: " " }}; server_name {{ domain_names | join: " " }};
{% if http2_support == 1 or http2_support == true %}
http2 on;
{% else -%}
http2 off;
{% endif %}

View File

@ -7,7 +7,11 @@
proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-IP $remote_addr;
proxy_pass {{ forward_scheme }}://{{ forward_host }}:{{ forward_port }}{{ forward_path }}; set $proxy_forward_scheme {{ forward_scheme }};
set $proxy_server "{{ forward_host }}";
set $proxy_port {{ forward_port }};
proxy_pass $proxy_forward_scheme://$proxy_server:$proxy_port{{ forward_path }};
{% include "_access.conf" %} {% include "_access.conf" %}
{% include "_assets.conf" %} {% include "_assets.conf" %}

File diff suppressed because it is too large Load Diff

View File

@ -26,8 +26,6 @@ WORKDIR /root
COPY rootfs / COPY rootfs /
COPY scripts/install-s6 /tmp/install-s6 COPY scripts/install-s6 /tmp/install-s6
RUN /tmp/install-s6 "${TARGETPLATFORM}" && rm -f /tmp/install-s6
RUN chmod 644 -R /root/.cache
RUN rm -f /etc/nginx/conf.d/production.conf \ RUN rm -f /etc/nginx/conf.d/production.conf \
&& chmod 644 /etc/logrotate.d/nginx-proxy-manager \ && chmod 644 /etc/logrotate.d/nginx-proxy-manager \
&& /tmp/install-s6 "${TARGETPLATFORM}" \ && /tmp/install-s6 "${TARGETPLATFORM}" \

View File

@ -1,29 +0,0 @@
# WARNING: This is a CI docker-compose file used for building and testing of the entire app, it should not be used for production.
services:
fullstack:
environment:
DB_POSTGRESQL_HOST: 'db'
DB_POSTGRESQL_PORT: '5432'
DB_POSTGRESQL_USER: 'npm'
DB_POSTGRESQL_PASSWORD: 'npmpass'
DB_POSTGRESQL_NAME: 'npm'
depends_on:
- db-postgresql
db-postgresql:
image: postgres:14.2-alpine
environment:
POSTGRES_PASSWORD: "npmpass"
POSTGRES_USER: "npm"
POSTGRES_DB: "npm"
ports:
- 5432:5432
volumes:
- postgres_vol:/var/lib/postgresql/data
networks:
- fulltest
volumes:
postgres_vol:

View File

@ -1,89 +0,0 @@
# WARNING: This is a DEVELOPMENT docker-compose file, it should not be used for production.
services:
npm1:
image: nginxproxymanager:dev
container_name: npm_core1
build:
context: ./
dockerfile: ./dev/Dockerfile
ports:
- 4080:80
- 4081:81
- 4443:443
networks:
- nginx_proxy_manager
environment:
PUID: 1000
PGID: 1000
FORCE_COLOR: 1
# specifically for dev:
DEBUG: 'true'
DEVELOPMENT: 'true'
LE_STAGING: 'true'
# db:
DB_POSTGRESQL_HOST: 'db1'
DB_POSTGRESQL_PORT: '5432'
DB_POSTGRESQL_USER: 'npm'
DB_POSTGRESQL_PASSWORD: 'npmpass'
DB_POSTGRESQL_NAME: 'npm'
# DB_SQLITE_FILE: "/data/database.sqlite"
# DISABLE_IPV6: "true"
volumes:
- npm_data1:/data
- le_data1:/etc/letsencrypt
- ../backend:/app
- ../frontend:/app/frontend
- ../global:/app/global
depends_on:
- db1
working_dir: /app
db1:
image: postgis/postgis:17-3.5-alpine
container_name: npm_db1
ports:
- 5432:5432
networks:
- nginx_proxy_manager
environment:
POSTGRES_PASSWORD: "npmpass"
POSTGRES_USER: "npm"
POSTGRES_DB: "npm"
volumes:
- db_data1:/var/lib/postgresql/data
pgadmin:
image: dpage/pgadmin4
environment:
PGADMIN_DEFAULT_EMAIL: "admin@example.com"
PGADMIN_DEFAULT_PASSWORD: "changeme"
ports:
- 5080:80
networks:
- nginx_proxy_manager
depends_on:
- db1
swagger1:
image: swaggerapi/swagger-ui:latest
container_name: npm_swagger1
ports:
- 5082:80
environment:
URL: "http://npm:81/api/schema"
PORT: '80'
depends_on:
- npm1
volumes:
npm_data1:
name: npm_core_data
le_data1:
name: npm_le_data
db_data1:
name: npm_db_data1
networks:
nginx_proxy_manager:
name: npm_network

View File

@ -137,13 +137,5 @@ Email: admin@example.com
Password: changeme Password: changeme
``` ```
Immediately after logging in with this default user you will be asked to modify your details and change your password. You can change defaults with: Immediately after logging in with this default user you will be asked to modify your details and change your password.
```
environment:
INITIAL_ADMIN_EMAIL: my@example.com
INITIAL_ADMIN_PASSWORD: mypassword1
```

View File

@ -194,7 +194,7 @@
"freedns": { "freedns": {
"name": "FreeDNS", "name": "FreeDNS",
"package_name": "certbot-dns-freedns", "package_name": "certbot-dns-freedns",
"version": "~=0.1.0", "version": "~=0.2.0",
"dependencies": "", "dependencies": "",
"credentials": "dns_freedns_username = myremoteuser\ndns_freedns_password = verysecureremoteuserpassword", "credentials": "dns_freedns_username = myremoteuser\ndns_freedns_password = verysecureremoteuserpassword",
"full_plugin_name": "dns-freedns" "full_plugin_name": "dns-freedns"
@ -303,14 +303,6 @@
"credentials": "dns_joker_username = <Dynamic DNS Authentication Username>\ndns_joker_password = <Dynamic DNS Authentication Password>\ndns_joker_domain = <Dynamic DNS Domain>", "credentials": "dns_joker_username = <Dynamic DNS Authentication Username>\ndns_joker_password = <Dynamic DNS Authentication Password>\ndns_joker_domain = <Dynamic DNS Domain>",
"full_plugin_name": "dns-joker" "full_plugin_name": "dns-joker"
}, },
"leaseweb": {
"name": "LeaseWeb",
"package_name": "certbot-dns-leaseweb",
"version": "~=1.0.1",
"dependencies": "",
"credentials": "dns_leaseweb_api_token = 01234556789",
"full_plugin_name": "dns-leaseweb"
},
"linode": { "linode": {
"name": "Linode", "name": "Linode",
"package_name": "certbot-dns-linode", "package_name": "certbot-dns-linode",