Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for custom resolvers certificates #302

Merged
merged 1 commit into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/docker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class DockerModule {
const Dolphin = require('dolphin');

this.redbird = redbird;
this.log = redbird.log;
this.log = redbird.logger;

const targets: Record<string, Record<string, string>> = (this.targets = {});
this.ports = {};
Expand Down
2 changes: 1 addition & 1 deletion lib/etcd-backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class ETCDModule {

// Create Redbird Instance and Log
this.redbird = redbird;
const log = redbird.log;
const log = redbird.logger;
const _this = this;

// Create node-etcd Instance
Expand Down
16 changes: 2 additions & 14 deletions lib/interfaces/proxy-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,7 @@ import http, { IncomingMessage, ServerResponse } from 'http';
import httpProxy, { ProxyTargetUrl } from 'http-proxy';
import { Socket } from 'net';
import pino from 'pino';

type ResolverFnResult = string | { path: string; url: string } | null | undefined;

export type ResolverFn = (
host: string,
url: string,
req?: IncomingMessage
) => ResolverFnResult | Promise<ResolverFnResult>;

export interface Resolver {
fn: ResolverFn;
priority: number;
}
import { Resolver } from './resolver.js';

export interface SSLConfig {
port?: number;
Expand All @@ -39,7 +27,7 @@ export interface ProxyOptions {
httpProxy?: httpProxy.ServerOptions;

// Enable Logging
log?: pino.LoggerOptions;
logger?: pino.Logger;

// Enable Cluster Mode
cluster?: number;
Expand Down
16 changes: 4 additions & 12 deletions lib/interfaces/proxy-route.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { ProxyTargetUrl } from './proxy-target-url.js';
import { RouteOptions } from './route-options.js';

/**
* ProxyRoute interface
* @description
Expand All @@ -8,16 +11,5 @@ export interface ProxyRoute {
path?: string;
rr?: number;
isResolved?: boolean;
opts?: {
onRequest?: (req: any, res: any, target: ProxyTargetUrl) => void;
};
}

export interface ProxyTargetUrl {
host: string;
hostname: string;
port: number;
pathname: string;
useTargetHostHeader: boolean;
href: string;
opts?: RouteOptions;
}
8 changes: 8 additions & 0 deletions lib/interfaces/proxy-target-url.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export interface ProxyTargetUrl {
host: string;
hostname: string;
port: number;
pathname: string;
useTargetHostHeader: boolean;
href: string;
}
19 changes: 19 additions & 0 deletions lib/interfaces/resolver.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { IncomingMessage } from 'http';
import { RouteOptions } from './route-options.js';

export type ResolverFnResult =
| string
| { path?: string; url: string; opts?: RouteOptions }
| null
| undefined;

export type ResolverFn = (
host: string,
url: string,
req?: IncomingMessage
) => ResolverFnResult | Promise<ResolverFnResult>;

export interface Resolver {
fn: ResolverFn;
priority: number;
}
12 changes: 12 additions & 0 deletions lib/interfaces/route-options.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { ProxyTargetUrl } from './proxy-target-url.js';

export interface RouteOptions {
useTargetHostHeader?: boolean;
ssl?: {
key?: string;
cert?: string;
ca?: string;
letsencrypt?: { email: string; production: boolean; lazy?: boolean };
};
onRequest?: (req: any, res: any, target: ProxyTargetUrl) => void;
}
Loading
Loading