update
This commit is contained in:
26
package.json
26
package.json
@@ -16,41 +16,41 @@
|
|||||||
"bundle": "(tsbundle website --production --bundler=esbuild)"
|
"bundle": "(tsbundle website --production --bundler=esbuild)"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@git.zone/tsbuild": "^2.6.4",
|
"@git.zone/tsbuild": "^2.6.7",
|
||||||
"@git.zone/tsbundle": "^2.5.1",
|
"@git.zone/tsbundle": "^2.5.1",
|
||||||
"@git.zone/tsrun": "^1.3.3",
|
"@git.zone/tsrun": "^1.3.3",
|
||||||
"@git.zone/tstest": "^2.3.1",
|
"@git.zone/tstest": "^2.3.5",
|
||||||
"@git.zone/tswatch": "^2.1.2",
|
"@git.zone/tswatch": "^2.2.1",
|
||||||
"@types/node": "^24.0.10",
|
"@types/node": "^22",
|
||||||
"node-forge": "^1.3.1"
|
"node-forge": "^1.3.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@api.global/typedrequest": "^3.0.19",
|
"@api.global/typedrequest": "^3.0.19",
|
||||||
"@api.global/typedrequest-interfaces": "^3.0.19",
|
"@api.global/typedrequest-interfaces": "^3.0.19",
|
||||||
"@api.global/typedserver": "^3.0.74",
|
"@api.global/typedserver": "^3.0.77",
|
||||||
"@api.global/typedsocket": "^3.0.0",
|
"@api.global/typedsocket": "^3.0.0",
|
||||||
"@apiclient.xyz/cloudflare": "^6.4.1",
|
"@apiclient.xyz/cloudflare": "^6.4.1",
|
||||||
"@design.estate/dees-catalog": "^1.10.10",
|
"@design.estate/dees-catalog": "^1.10.10",
|
||||||
"@design.estate/dees-element": "^2.0.45",
|
"@design.estate/dees-element": "^2.1.2",
|
||||||
"@push.rocks/projectinfo": "^5.0.1",
|
"@push.rocks/projectinfo": "^5.0.1",
|
||||||
"@push.rocks/qenv": "^6.1.0",
|
"@push.rocks/qenv": "^6.1.3",
|
||||||
"@push.rocks/smartacme": "^8.0.0",
|
"@push.rocks/smartacme": "^8.0.0",
|
||||||
"@push.rocks/smartdata": "^5.15.1",
|
"@push.rocks/smartdata": "^5.16.4",
|
||||||
"@push.rocks/smartdns": "^7.5.0",
|
"@push.rocks/smartdns": "^7.5.0",
|
||||||
"@push.rocks/smartfile": "^11.2.5",
|
"@push.rocks/smartfile": "^11.2.7",
|
||||||
"@push.rocks/smartguard": "^3.1.0",
|
"@push.rocks/smartguard": "^3.1.0",
|
||||||
"@push.rocks/smartjwt": "^2.2.1",
|
"@push.rocks/smartjwt": "^2.2.1",
|
||||||
"@push.rocks/smartlog": "^3.1.8",
|
"@push.rocks/smartlog": "^3.1.8",
|
||||||
"@push.rocks/smartmail": "^2.1.0",
|
"@push.rocks/smartmail": "^2.1.0",
|
||||||
"@push.rocks/smartmetrics": "^2.0.10",
|
"@push.rocks/smartmetrics": "^2.0.10",
|
||||||
"@push.rocks/smartnetwork": "^4.0.2",
|
"@push.rocks/smartnetwork": "^4.1.2",
|
||||||
"@push.rocks/smartpath": "^5.0.5",
|
"@push.rocks/smartpath": "^6.0.0",
|
||||||
"@push.rocks/smartpromise": "^4.0.3",
|
"@push.rocks/smartpromise": "^4.0.3",
|
||||||
"@push.rocks/smartproxy": "^19.6.15",
|
"@push.rocks/smartproxy": "21.1.6",
|
||||||
"@push.rocks/smartrequest": "^2.1.0",
|
"@push.rocks/smartrequest": "^2.1.0",
|
||||||
"@push.rocks/smartrule": "^2.0.1",
|
"@push.rocks/smartrule": "^2.0.1",
|
||||||
"@push.rocks/smartrx": "^3.0.10",
|
"@push.rocks/smartrx": "^3.0.10",
|
||||||
"@push.rocks/smartstate": "^2.0.21",
|
"@push.rocks/smartstate": "^2.0.26",
|
||||||
"@push.rocks/smartunique": "^3.0.9",
|
"@push.rocks/smartunique": "^3.0.9",
|
||||||
"@serve.zone/interfaces": "^5.0.4",
|
"@serve.zone/interfaces": "^5.0.4",
|
||||||
"@tsclass/tsclass": "^9.2.0",
|
"@tsclass/tsclass": "^9.2.0",
|
||||||
|
3169
pnpm-lock.yaml
generated
3169
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -159,7 +159,7 @@ export class DcRouter {
|
|||||||
|
|
||||||
|
|
||||||
this.opsServer = new OpsServer(this);
|
this.opsServer = new OpsServer(this);
|
||||||
await this.opsServer.start();
|
// await this.opsServer.start();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Initialize MetricsManager
|
// Initialize MetricsManager
|
||||||
@@ -387,11 +387,29 @@ export class DcRouter {
|
|||||||
private generateEmailRoutes(emailConfig: IUnifiedEmailServerOptions): plugins.smartproxy.IRouteConfig[] {
|
private generateEmailRoutes(emailConfig: IUnifiedEmailServerOptions): plugins.smartproxy.IRouteConfig[] {
|
||||||
const emailRoutes: plugins.smartproxy.IRouteConfig[] = [];
|
const emailRoutes: plugins.smartproxy.IRouteConfig[] = [];
|
||||||
|
|
||||||
|
// Type definitions for SmartProxy
|
||||||
|
type TRouteActionType = 'forward' | 'socket-handler';
|
||||||
|
type TTlsMode = 'passthrough' | 'terminate' | 'terminate-and-reencrypt';
|
||||||
|
|
||||||
|
// Helper function to extract domains from email patterns
|
||||||
|
const extractDomainsFromRecipients = (recipients: string | string[]): string[] => {
|
||||||
|
const recipientArray = Array.isArray(recipients) ? recipients : [recipients];
|
||||||
|
return recipientArray
|
||||||
|
.map(r => {
|
||||||
|
// Handle wildcards: "*@domain.com" -> "domain.com"
|
||||||
|
// Handle normal: "user@domain.com" -> "domain.com"
|
||||||
|
const parts = r.split('@');
|
||||||
|
return parts.length === 2 && parts[1] !== '*' ? parts[1] : null;
|
||||||
|
})
|
||||||
|
.filter((d): d is string => d !== null)
|
||||||
|
.filter((d, i, arr) => arr.indexOf(d) === i); // Remove duplicates
|
||||||
|
};
|
||||||
|
|
||||||
// Create routes for each email port
|
// Create routes for each email port
|
||||||
for (const port of emailConfig.ports) {
|
for (const port of emailConfig.ports) {
|
||||||
// Create a descriptive name for the route based on the port
|
// Create a descriptive name for the route based on the port
|
||||||
let routeName = 'email-route';
|
let routeName = 'email-route';
|
||||||
let tlsMode = 'passthrough';
|
let tlsMode: TTlsMode = 'passthrough';
|
||||||
|
|
||||||
// Handle different email ports differently
|
// Handle different email ports differently
|
||||||
switch (port) {
|
switch (port) {
|
||||||
@@ -407,7 +425,7 @@ export class DcRouter {
|
|||||||
|
|
||||||
case 465: // SMTPS
|
case 465: // SMTPS
|
||||||
routeName = 'smtps-route';
|
routeName = 'smtps-route';
|
||||||
tlsMode = 'terminate'; // Terminate TLS and re-encrypt to email server
|
tlsMode = 'terminate-and-reencrypt'; // Terminate TLS and re-encrypt to email server
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -438,7 +456,7 @@ export class DcRouter {
|
|||||||
if (emailConfig.useSocketHandler) {
|
if (emailConfig.useSocketHandler) {
|
||||||
// Socket-handler mode
|
// Socket-handler mode
|
||||||
action = {
|
action = {
|
||||||
type: 'socket-handler' as any,
|
type: 'socket-handler' as TRouteActionType,
|
||||||
socketHandler: this.createMailSocketHandler(port)
|
socketHandler: this.createMailSocketHandler(port)
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
@@ -453,15 +471,19 @@ export class DcRouter {
|
|||||||
const internalPort = portMapping[port] || port + 10000;
|
const internalPort = portMapping[port] || port + 10000;
|
||||||
|
|
||||||
action = {
|
action = {
|
||||||
type: 'forward',
|
type: 'forward' as TRouteActionType,
|
||||||
target: {
|
targets: [{
|
||||||
host: 'localhost', // Forward to internal email server
|
host: 'localhost', // Forward to internal email server
|
||||||
port: internalPort
|
port: internalPort
|
||||||
},
|
}]
|
||||||
tls: {
|
|
||||||
mode: tlsMode as any
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Add TLS configuration at action level if needed
|
||||||
|
if (tlsMode !== 'passthrough' || port === 465) {
|
||||||
|
action.tls = {
|
||||||
|
mode: tlsMode
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// For TLS terminate mode, add certificate info
|
// For TLS terminate mode, add certificate info
|
||||||
@@ -485,23 +507,29 @@ export class DcRouter {
|
|||||||
// Add email domain-based routes if configured
|
// Add email domain-based routes if configured
|
||||||
if (emailConfig.routes) {
|
if (emailConfig.routes) {
|
||||||
for (const route of emailConfig.routes) {
|
for (const route of emailConfig.routes) {
|
||||||
emailRoutes.push({
|
const domains = route.match.recipients ?
|
||||||
name: route.name,
|
extractDomainsFromRecipients(route.match.recipients) : [];
|
||||||
match: {
|
|
||||||
ports: emailConfig.ports,
|
// Only create SmartProxy route if we have domains to match
|
||||||
domains: route.match.recipients ? [route.match.recipients.toString().split('@')[1]] : []
|
if (domains.length > 0) {
|
||||||
},
|
emailRoutes.push({
|
||||||
action: {
|
name: route.name,
|
||||||
type: 'forward',
|
match: {
|
||||||
target: route.action.type === 'forward' && route.action.forward ? {
|
ports: emailConfig.ports,
|
||||||
host: route.action.forward.host,
|
domains: domains
|
||||||
port: route.action.forward.port || 25
|
},
|
||||||
} : undefined,
|
action: {
|
||||||
tls: {
|
type: 'forward' as TRouteActionType,
|
||||||
mode: 'passthrough'
|
targets: route.action.type === 'forward' && route.action.forward ? [{
|
||||||
|
host: route.action.forward.host,
|
||||||
|
port: route.action.forward.port || 25
|
||||||
|
}] : [],
|
||||||
|
tls: {
|
||||||
|
mode: 'passthrough' as TTlsMode
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user