Skip to content

Commit

Permalink
v0.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
hieyou1 committed Aug 8, 2024
1 parent e16044c commit 1b0d799
Show file tree
Hide file tree
Showing 11 changed files with 178 additions and 86 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## v0.0.5

- Add `ipFallback` to enable a default TLS configuration for those accessing the server that bypass SNI by connecting directly to its IP
- Fix `child_procs` log type
- Add option to serve more than one `host` per child process using an array
- README enhancements

## v0.0.4

- Add `handler` log type
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,15 @@ npm run build
- `tcpFallback`: Set to true to enable the plaintext TCP & HTTP fallback; be sure to also set `tcpPort`.
- `tcpPort`: Port InterTLS should listen on for `tcpFallback`. InterTLS expects plaintext HTTP traffic on this port. Usually 80. Ignored when `tcpFallback` is set to false.
- `servers`: Array of servers for InterTLS to run, manage, and forward traffic to.
- `host`: Hostname of this server. Should match the server name that clients pass in for SNI, and (if using TCP fallback) the HTTP `Host` header.
- `host`: String or string array specifying hostname(s) of this server. Should match the server name that clients pass in for SNI and the HTTP `Host` header if using TCP fallback.
- `tls`: TLS options for this server. Set to `{"dynamic": true}` to dynamically handle TLS, otherwise `cert`, `key`, and `requestCert` are required. `ca` and `rejectUnauthorized` are the two other options that have been tested and are explicitly defined in the schema, and YMMV with other [SecureContextOptions](https://nodejs.org/api/tls.html#tlscreatesecurecontextoptions), but feel free to try them and PR!
- `process`: Node options for this server.
- `main`: Node entrypoint of the server.
- `cwd`: Working directory of the server.
- `env` (optional): Object with environment variables to pass to the server. Defaults to {}.
- `uid` (optional): User ID for the process. Defaults to the user of the process running InterTLS (which is probably not what you want!)
- `gid` (optional): Group ID for the process. Defaults to the group of the process running InterTLS (which is probably not what you want!)
- `ipFallback`: TLS configuration (see `servers.tls` above) for those accessing the server that bypass SNI by connecting directly to its IP.

## Handler options

Expand Down
5 changes: 4 additions & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
"tcpPort": 80,
"servers": [
{
"host": "localhost",
"host": [
"localhost",
"127.0.0.1"
],
"tls": {
"cert": "./servers/example/cert",
"key": "./servers/example/key",
Expand Down
122 changes: 76 additions & 46 deletions config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@
"$ref": "#/definitions/InterTLSConfiguration",
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"DynamicServerTLSConfiguration": {
"additionalProperties": false,
"properties": {
"dynamic": {
"const": true,
"type": "boolean"
}
},
"required": [
"dynamic"
],
"type": "object"
},
"InterTLSConfiguration": {
"additionalProperties": false,
"properties": {
Expand All @@ -11,6 +24,17 @@
"encoding": {
"$ref": "#/definitions/global.BufferEncoding"
},
"ipFallback": {
"anyOf": [
{
"const": false,
"type": "boolean"
},
{
"$ref": "#/definitions/StaticServerTLSConfiguration"
}
]
},
"log": {
"anyOf": [
{
Expand Down Expand Up @@ -67,7 +91,17 @@
"additionalProperties": false,
"properties": {
"host": {
"type": "string"
"anyOf": [
{
"type": "string"
},
{
"items": {
"type": "string"
},
"type": "array"
}
]
},
"process": {
"additionalProperties": false,
Expand Down Expand Up @@ -98,51 +132,7 @@
"type": "object"
},
"tls": {
"anyOf": [
{
"additionalProperties": false,
"properties": {
"dynamic": {
"const": true,
"type": "boolean"
}
},
"required": [
"dynamic"
],
"type": "object"
},
{
"additionalProperties": false,
"properties": {
"ca": {
"type": "string"
},
"cert": {
"type": "string"
},
"dynamic": {
"const": false,
"type": "boolean"
},
"key": {
"type": "string"
},
"rejectUnauthorized": {
"type": "boolean"
},
"requestCert": {
"type": "boolean"
}
},
"required": [
"cert",
"key",
"requestCert"
],
"type": "object"
}
]
"$ref": "#/definitions/ServerTLSConfiguration"
}
},
"required": [
Expand All @@ -152,6 +142,46 @@
],
"type": "object"
},
"ServerTLSConfiguration": {
"anyOf": [
{
"$ref": "#/definitions/DynamicServerTLSConfiguration"
},
{
"$ref": "#/definitions/StaticServerTLSConfiguration"
}
]
},
"StaticServerTLSConfiguration": {
"additionalProperties": false,
"properties": {
"ca": {
"type": "string"
},
"cert": {
"type": "string"
},
"dynamic": {
"const": false,
"type": "boolean"
},
"key": {
"type": "string"
},
"rejectUnauthorized": {
"type": "boolean"
},
"requestCert": {
"type": "boolean"
}
},
"required": [
"cert",
"key",
"requestCert"
],
"type": "object"
},
"global.BufferEncoding": {
"enum": [
"ascii",
Expand Down
26 changes: 15 additions & 11 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
import { Server as TLSServer } from 'tls';
import { Server as TCPServer } from 'net';
export type LogType = "newsock" | "sni" | "ipc" | "child_procs" | "init" | "handler";
export interface DynamicServerTLSConfiguration {
dynamic: true;
}
export interface StaticServerTLSConfiguration {
dynamic?: false;
ca?: string;
cert: string;
key: string;
requestCert: boolean;
rejectUnauthorized?: boolean;
}
export type ServerTLSConfiguration = DynamicServerTLSConfiguration | StaticServerTLSConfiguration;
export interface ServerConfiguration {
host: string;
tls: {
dynamic: true;
} | {
dynamic?: false;
ca?: string;
cert: string;
key: string;
requestCert: boolean;
rejectUnauthorized?: boolean;
};
host: string | string[];
tls: ServerTLSConfiguration;
process: {
main: string;
cwd: string;
Expand All @@ -31,6 +34,7 @@ export interface InterTLSConfiguration {
tcpPort?: string | number;
servers: ServerConfiguration[];
log?: boolean | LogType[];
ipFallback?: false | StaticServerTLSConfiguration;
}
export declare class InterTLS {
private config;
Expand Down
2 changes: 1 addition & 1 deletion dist/index.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 25 additions & 5 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1b0d799

Please sign in to comment.