feat(core): Improve wildcard domain matching and enhance NetworkProxy integration in PortProxy. Added support for TLD wildcards and complex wildcard patterns in the router, and refactored TLS renegotiation handling for stricter SNI enforcement.
This commit is contained in:
@ -197,6 +197,52 @@ tap.test('should match wildcard subdomains', async () => {
|
||||
expect(result).toEqual(wildcardConfig);
|
||||
});
|
||||
|
||||
// Test TLD wildcards (example.*)
|
||||
tap.test('should match TLD wildcards', async () => {
|
||||
const tldWildcardConfig = createProxyConfig('example.*');
|
||||
router.setNewProxyConfigs([tldWildcardConfig]);
|
||||
|
||||
// Test that example.com matches example.*
|
||||
const req1 = createMockRequest('example.com');
|
||||
const result1 = router.routeReq(req1);
|
||||
expect(result1).toBeTruthy();
|
||||
expect(result1).toEqual(tldWildcardConfig);
|
||||
|
||||
// Test that example.org matches example.*
|
||||
const req2 = createMockRequest('example.org');
|
||||
const result2 = router.routeReq(req2);
|
||||
expect(result2).toBeTruthy();
|
||||
expect(result2).toEqual(tldWildcardConfig);
|
||||
|
||||
// Test that subdomain.example.com doesn't match example.*
|
||||
const req3 = createMockRequest('subdomain.example.com');
|
||||
const result3 = router.routeReq(req3);
|
||||
expect(result3).toBeUndefined();
|
||||
});
|
||||
|
||||
// Test complex pattern matching (*.lossless*)
|
||||
tap.test('should match complex wildcard patterns', async () => {
|
||||
const complexWildcardConfig = createProxyConfig('*.lossless*');
|
||||
router.setNewProxyConfigs([complexWildcardConfig]);
|
||||
|
||||
// Test that sub.lossless.com matches *.lossless*
|
||||
const req1 = createMockRequest('sub.lossless.com');
|
||||
const result1 = router.routeReq(req1);
|
||||
expect(result1).toBeTruthy();
|
||||
expect(result1).toEqual(complexWildcardConfig);
|
||||
|
||||
// Test that api.lossless.org matches *.lossless*
|
||||
const req2 = createMockRequest('api.lossless.org');
|
||||
const result2 = router.routeReq(req2);
|
||||
expect(result2).toBeTruthy();
|
||||
expect(result2).toEqual(complexWildcardConfig);
|
||||
|
||||
// Test that losslessapi.com matches *.lossless*
|
||||
const req3 = createMockRequest('losslessapi.com');
|
||||
const result3 = router.routeReq(req3);
|
||||
expect(result3).toBeUndefined(); // Should not match as it doesn't have a subdomain
|
||||
});
|
||||
|
||||
// Test default configuration fallback
|
||||
tap.test('should fall back to default configuration', async () => {
|
||||
const defaultConfig = createProxyConfig('*');
|
||||
|
Reference in New Issue
Block a user