155 lines
5.8 KiB
Markdown
155 lines
5.8 KiB
Markdown
# nullresolve
|
|
|
|
`nullresolve` is the serve.zone fallback response service for requests that reach the edge but cannot be served by an application backend, upstream origin, DNS path, or security policy.
|
|
|
|
## Issue Reporting and Security
|
|
|
|
For reporting bugs, issues, or security vulnerabilities, please visit [community.foss.global/](https://community.foss.global/). This is the central community hub for all issue reporting. Developers who sign and comply with our contribution agreement and go through identification can also get a [code.foss.global/](https://code.foss.global/) account to submit Pull Requests directly.
|
|
|
|
## What It Does
|
|
|
|
Instead of returning a raw proxy error, `nullresolve` serves clear HTML status pages through `@api.global/typedserver`'s `InfoHtml` helper. It is designed to be the last stop in a routing chain: if nothing else can answer, this service gives the client a controlled response.
|
|
|
|
Typical uses:
|
|
|
|
- unmatched or unassigned route fallback
|
|
- explicit status pages for blocked IPs and firewall events
|
|
- Cloudflare-style `5xx`, `1xxx`, WAF, country, attack, and Always Online status pages
|
|
- simple custom HTML info pages from query parameters
|
|
|
|
## Package Status
|
|
|
|
The current package name in `package.json` is still `@losslessone_private/nullresolve`, but the service belongs to the serve.zone workspace and is documented here as `nullresolve`. Do not rename the package in consuming code unless the package metadata changes.
|
|
|
|
## Install
|
|
|
|
In this workspace, install dependencies with pnpm and run package scripts from the repo root.
|
|
|
|
```bash
|
|
pnpm install
|
|
```
|
|
|
|
For internal registry consumption using the current package name:
|
|
|
|
```bash
|
|
pnpm add @losslessone_private/nullresolve
|
|
```
|
|
|
|
## Quick Start
|
|
|
|
```typescript
|
|
import { NullResolve } from '@losslessone_private/nullresolve';
|
|
|
|
const service = new NullResolve({
|
|
port: 8080,
|
|
serviceDomain: 'nullresolve.example.com',
|
|
});
|
|
|
|
await service.start();
|
|
|
|
process.once('SIGTERM', async () => {
|
|
await service.stop();
|
|
process.exit(0);
|
|
});
|
|
```
|
|
|
|
The package also exports CLI-style singleton helpers:
|
|
|
|
```typescript
|
|
import { runCli, stop } from '@losslessone_private/nullresolve';
|
|
|
|
await runCli();
|
|
await stop();
|
|
```
|
|
|
|
## Routes
|
|
|
|
`NullResolve.start()` creates a `UtilityServiceServer` and registers two custom routes.
|
|
|
|
| Route | Purpose |
|
|
| --- | --- |
|
|
| `GET /status/:code` | Render a predefined status page. `:code` can be a normal HTTP status code or a named status template. |
|
|
| `GET /custom` | Render a status page from query parameters. |
|
|
|
|
Named status templates currently handled by the service:
|
|
|
|
| Code | Purpose |
|
|
| --- | --- |
|
|
| `ipblock` | IP allow/block policy response. |
|
|
| `firewall` | Firewall block response. |
|
|
| `500class` | Upstream/server error response placeholder. |
|
|
| `1000class` | DNS resolution failure placeholder. |
|
|
| `alwaysonline` | No cached copy / Always Online placeholder. |
|
|
| `waf` | Firewall challenge placeholder. |
|
|
| `country` | Country challenge placeholder. |
|
|
| `attack` | Under-attack challenge placeholder. |
|
|
|
|
Examples:
|
|
|
|
```text
|
|
/status/404
|
|
/status/ipblock
|
|
/status/firewall
|
|
/custom?title=Maintenance&heading=Service%20Unavailable&text=Please%20try%20again%20later
|
|
```
|
|
|
|
## Configuration
|
|
|
|
The public constructor options are intentionally small.
|
|
|
|
```typescript
|
|
interface INullResolveOptions {
|
|
port?: number;
|
|
serviceDomain?: string;
|
|
}
|
|
```
|
|
|
|
| Option | Purpose |
|
|
| --- | --- |
|
|
| `port` | Optional port passed to the UtilityServiceServer. |
|
|
| `serviceDomain` | Service domain advertised to the UtilityServiceServer. Set this explicitly for new deployments. |
|
|
|
|
`nullresolve.config.ts` currently contains the Sentry DSN used by `InfoHtml` status pages.
|
|
|
|
## Operational Behavior
|
|
|
|
- `start()` is idempotent while the server is already running.
|
|
- `stop()` is safe to call when the server has not been started.
|
|
- The service does not proxy, cache, or resolve upstream content; it only renders fallback HTML responses.
|
|
- The `serviceServer` property is exposed for inspection after startup, but route setup is internal to the class.
|
|
|
|
## Development
|
|
|
|
```bash
|
|
pnpm run build
|
|
pnpm test
|
|
pnpm start
|
|
```
|
|
|
|
Useful source entry points:
|
|
|
|
- `ts/index.ts` exports `NullResolve`, `runCli()`, and `stop()`.
|
|
- `ts/nullresolve.classes.nullresolve.ts` defines options, server startup, and route behavior.
|
|
- `ts/nullresolve.config.ts` contains service-level status-page configuration.
|
|
|
|
## License and Legal Information
|
|
|
|
This repository contains open-source code licensed under the MIT License. A copy of the license can be found in the [license](./license) file.
|
|
|
|
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
|
|
|
|
### Trademarks
|
|
|
|
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH or third parties, and are not included within the scope of the MIT license granted herein.
|
|
|
|
Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines or the guidelines of the respective third-party owners, and any usage must be approved in writing. Third-party trademarks used herein are the property of their respective owners and used only in a descriptive manner, e.g. for an implementation of an API or similar.
|
|
|
|
### Company Information
|
|
|
|
Task Venture Capital GmbH
|
|
Registered at District Court Bremen HRB 35230 HB, Germany
|
|
|
|
For any legal inquiries or further information, please contact us via email at hello@task.vc.
|
|
|
|
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
|