mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-25 09:48:32 +02:00
Feat/fileserver (#60)
* cleanup code for URL type * fix makefile for trace mode * refactor, merge Entry, RawEntry and Route into one. * Implement fileserver. * refactor: rename HTTPRoute to ReverseProxyRoute to avoid confusion * refactor: move metrics logger to middleware package - fix prometheus metrics for load balanced routes - route will now fail when health monitor fail to start * fix extra output of ls-* commands by defer initializaing stuff, speed up start time * add test for path traversal attack, small fix on FileServer.Start method * rename rule.on.bypass to pass * refactor and fixed map-to-map deserialization * updated route loading logic * schemas: add "add_prefix" option to modify_request middleware * updated route JSONMarshalling --------- Co-authored-by: yusing <yusing@6uo.me>
This commit is contained in:
29
schemas/providers/routes.d.ts
vendored
29
schemas/providers/routes.d.ts
vendored
@@ -9,7 +9,7 @@ export declare const PROXY_SCHEMES: readonly ["http", "https"];
|
||||
export declare const STREAM_SCHEMES: readonly ["tcp", "udp"];
|
||||
export type ProxyScheme = (typeof PROXY_SCHEMES)[number];
|
||||
export type StreamScheme = (typeof STREAM_SCHEMES)[number];
|
||||
export type Route = ReverseProxyRoute | StreamRoute;
|
||||
export type Route = ReverseProxyRoute | FileServerRoute | StreamRoute;
|
||||
export type Routes = {
|
||||
[key: string]: Route;
|
||||
};
|
||||
@@ -65,6 +65,31 @@ export type ReverseProxyRoute = {
|
||||
*/
|
||||
access_log?: AccessLogConfig;
|
||||
};
|
||||
export type FileServerRoute = {
|
||||
/** Alias (subdomain or FDN)
|
||||
* @minLength 1
|
||||
*/
|
||||
alias?: string;
|
||||
scheme: "fileserver";
|
||||
root: string;
|
||||
/** Path patterns (only patterns that match will be proxied).
|
||||
*
|
||||
* See https://pkg.go.dev/net/http#hdr-Patterns-ServeMux
|
||||
*/
|
||||
path_patterns?: PathPattern[];
|
||||
/** Middlewares */
|
||||
middlewares?: MiddlewaresMap;
|
||||
/** Homepage config
|
||||
*
|
||||
* @examples require(".").homepageExamples
|
||||
*/
|
||||
homepage?: HomepageConfig;
|
||||
/** Access log config
|
||||
*
|
||||
* @examples require(".").accessLogExamples
|
||||
*/
|
||||
access_log?: AccessLogConfig;
|
||||
};
|
||||
export type StreamRoute = {
|
||||
/** Alias (subdomain or FDN)
|
||||
* @minLength 1
|
||||
@@ -74,7 +99,7 @@ export type StreamRoute = {
|
||||
*
|
||||
* @default tcp
|
||||
*/
|
||||
scheme: StreamScheme;
|
||||
scheme?: StreamScheme;
|
||||
/** Stream host
|
||||
*
|
||||
* @default localhost
|
||||
|
||||
@@ -11,7 +11,7 @@ export const STREAM_SCHEMES = ["tcp", "udp"] as const;
|
||||
export type ProxyScheme = (typeof PROXY_SCHEMES)[number];
|
||||
export type StreamScheme = (typeof STREAM_SCHEMES)[number];
|
||||
|
||||
export type Route = ReverseProxyRoute | StreamRoute;
|
||||
export type Route = ReverseProxyRoute | FileServerRoute | StreamRoute;
|
||||
export type Routes = {
|
||||
[key: string]: Route;
|
||||
};
|
||||
@@ -69,6 +69,33 @@ export type ReverseProxyRoute = {
|
||||
access_log?: AccessLogConfig;
|
||||
};
|
||||
|
||||
export type FileServerRoute = {
|
||||
/** Alias (subdomain or FDN)
|
||||
* @minLength 1
|
||||
*/
|
||||
alias?: string;
|
||||
scheme: "fileserver";
|
||||
/* File server root path */
|
||||
root: string;
|
||||
/** Path patterns (only patterns that match will be proxied).
|
||||
*
|
||||
* See https://pkg.go.dev/net/http#hdr-Patterns-ServeMux
|
||||
*/
|
||||
path_patterns?: PathPattern[];
|
||||
/** Middlewares */
|
||||
middlewares?: MiddlewaresMap;
|
||||
/** Homepage config
|
||||
*
|
||||
* @examples require(".").homepageExamples
|
||||
*/
|
||||
homepage?: HomepageConfig;
|
||||
/** Access log config
|
||||
*
|
||||
* @examples require(".").accessLogExamples
|
||||
*/
|
||||
access_log?: AccessLogConfig;
|
||||
}
|
||||
|
||||
export type StreamRoute = {
|
||||
/** Alias (subdomain or FDN)
|
||||
* @minLength 1
|
||||
@@ -78,7 +105,7 @@ export type StreamRoute = {
|
||||
*
|
||||
* @default tcp
|
||||
*/
|
||||
scheme: StreamScheme;
|
||||
scheme?: StreamScheme;
|
||||
/** Stream host
|
||||
*
|
||||
* @default localhost
|
||||
|
||||
Reference in New Issue
Block a user