mirror of
				https://github.com/caddyserver/caddy.git
				synced 2025-11-03 19:17:29 -05:00 
			
		
		
		
	caddytls: Refactor sni matcher (#6812)
	
		
			
	
		
	
	
		
	
		
			Some checks failed
		
		
	
	
		
			
				
	
				Lint / lint (macos-14, mac) (push) Waiting to run
				
			
		
			
				
	
				Lint / lint (windows-latest, windows) (push) Waiting to run
				
			
		
			
				
	
				Tests / test (./cmd/caddy/caddy, ~1.22.3, ubuntu-latest, 0, 1.22, linux) (push) Failing after 1m24s
				
			
		
			
				
	
				Tests / test (./cmd/caddy/caddy, ~1.23.0, ubuntu-latest, 0, 1.23, linux) (push) Failing after 1m24s
				
			
		
			
				
	
				Tests / test (s390x on IBM Z) (push) Has been skipped
				
			
		
			
				
	
				Tests / goreleaser-check (push) Has been skipped
				
			
		
			
				
	
				Cross-Build / build (~1.22.3, 1.22, aix) (push) Successful in 1m34s
				
			
		
			
				
	
				Cross-Build / build (~1.22.3, 1.22, darwin) (push) Successful in 1m22s
				
			
		
			
				
	
				Cross-Build / build (~1.22.3, 1.22, dragonfly) (push) Successful in 1m25s
				
			
		
			
				
	
				Cross-Build / build (~1.22.3, 1.22, freebsd) (push) Successful in 1m26s
				
			
		
			
				
	
				Cross-Build / build (~1.22.3, 1.22, illumos) (push) Successful in 1m22s
				
			
		
			
				
	
				Cross-Build / build (~1.22.3, 1.22, linux) (push) Successful in 1m39s
				
			
		
			
				
	
				Cross-Build / build (~1.22.3, 1.22, netbsd) (push) Successful in 1m27s
				
			
		
			
				
	
				Cross-Build / build (~1.22.3, 1.22, openbsd) (push) Successful in 1m22s
				
			
		
			
				
	
				Cross-Build / build (~1.22.3, 1.22, solaris) (push) Successful in 1m21s
				
			
		
			
				
	
				Cross-Build / build (~1.22.3, 1.22, windows) (push) Successful in 1m37s
				
			
		
			
				
	
				Cross-Build / build (~1.23.0, 1.23, aix) (push) Successful in 1m13s
				
			
		
			
				
	
				Cross-Build / build (~1.23.0, 1.23, darwin) (push) Successful in 1m26s
				
			
		
			
				
	
				Cross-Build / build (~1.23.0, 1.23, dragonfly) (push) Successful in 1m15s
				
			
		
			
				
	
				Cross-Build / build (~1.23.0, 1.23, freebsd) (push) Successful in 1m24s
				
			
		
			
				
	
				Cross-Build / build (~1.23.0, 1.23, illumos) (push) Successful in 1m16s
				
			
		
			
				
	
				Cross-Build / build (~1.23.0, 1.23, linux) (push) Successful in 1m17s
				
			
		
			
				
	
				Cross-Build / build (~1.23.0, 1.23, netbsd) (push) Successful in 1m14s
				
			
		
			
				
	
				Cross-Build / build (~1.23.0, 1.23, openbsd) (push) Successful in 1m26s
				
			
		
			
				
	
				Cross-Build / build (~1.23.0, 1.23, solaris) (push) Successful in 1m18s
				
			
		
			
				
	
				Cross-Build / build (~1.23.0, 1.23, windows) (push) Successful in 1m38s
				
			
		
			
				
	
				Lint / lint (ubuntu-latest, linux) (push) Successful in 1m57s
				
			
		
			
				
	
				Lint / govulncheck (push) Successful in 1m28s
				
			
		
			
				
	
				Tests / test (./cmd/caddy/caddy, ~1.22.3, macos-14, 0, 1.22, mac) (push) Has been cancelled
				
			
		
			
				
	
				Tests / test (./cmd/caddy/caddy, ~1.23.0, macos-14, 0, 1.23, mac) (push) Has been cancelled
				
			
		
			
				
	
				Tests / test (./cmd/caddy/caddy.exe, ~1.22.3, windows-latest, True, 1.22, windows) (push) Has been cancelled
				
			
		
			
				
	
				Tests / test (./cmd/caddy/caddy.exe, ~1.23.0, windows-latest, True, 1.23, windows) (push) Has been cancelled
				
			
		
		
	
	
				
					
				
			
		
			Some checks failed
		
		
	
	Lint / lint (macos-14, mac) (push) Waiting to run
				
			Lint / lint (windows-latest, windows) (push) Waiting to run
				
			Tests / test (./cmd/caddy/caddy, ~1.22.3, ubuntu-latest, 0, 1.22, linux) (push) Failing after 1m24s
				
			Tests / test (./cmd/caddy/caddy, ~1.23.0, ubuntu-latest, 0, 1.23, linux) (push) Failing after 1m24s
				
			Tests / test (s390x on IBM Z) (push) Has been skipped
				
			Tests / goreleaser-check (push) Has been skipped
				
			Cross-Build / build (~1.22.3, 1.22, aix) (push) Successful in 1m34s
				
			Cross-Build / build (~1.22.3, 1.22, darwin) (push) Successful in 1m22s
				
			Cross-Build / build (~1.22.3, 1.22, dragonfly) (push) Successful in 1m25s
				
			Cross-Build / build (~1.22.3, 1.22, freebsd) (push) Successful in 1m26s
				
			Cross-Build / build (~1.22.3, 1.22, illumos) (push) Successful in 1m22s
				
			Cross-Build / build (~1.22.3, 1.22, linux) (push) Successful in 1m39s
				
			Cross-Build / build (~1.22.3, 1.22, netbsd) (push) Successful in 1m27s
				
			Cross-Build / build (~1.22.3, 1.22, openbsd) (push) Successful in 1m22s
				
			Cross-Build / build (~1.22.3, 1.22, solaris) (push) Successful in 1m21s
				
			Cross-Build / build (~1.22.3, 1.22, windows) (push) Successful in 1m37s
				
			Cross-Build / build (~1.23.0, 1.23, aix) (push) Successful in 1m13s
				
			Cross-Build / build (~1.23.0, 1.23, darwin) (push) Successful in 1m26s
				
			Cross-Build / build (~1.23.0, 1.23, dragonfly) (push) Successful in 1m15s
				
			Cross-Build / build (~1.23.0, 1.23, freebsd) (push) Successful in 1m24s
				
			Cross-Build / build (~1.23.0, 1.23, illumos) (push) Successful in 1m16s
				
			Cross-Build / build (~1.23.0, 1.23, linux) (push) Successful in 1m17s
				
			Cross-Build / build (~1.23.0, 1.23, netbsd) (push) Successful in 1m14s
				
			Cross-Build / build (~1.23.0, 1.23, openbsd) (push) Successful in 1m26s
				
			Cross-Build / build (~1.23.0, 1.23, solaris) (push) Successful in 1m18s
				
			Cross-Build / build (~1.23.0, 1.23, windows) (push) Successful in 1m38s
				
			Lint / lint (ubuntu-latest, linux) (push) Successful in 1m57s
				
			Lint / govulncheck (push) Successful in 1m28s
				
			Tests / test (./cmd/caddy/caddy, ~1.22.3, macos-14, 0, 1.22, mac) (push) Has been cancelled
				
			Tests / test (./cmd/caddy/caddy, ~1.23.0, macos-14, 0, 1.23, mac) (push) Has been cancelled
				
			Tests / test (./cmd/caddy/caddy.exe, ~1.22.3, windows-latest, True, 1.22, windows) (push) Has been cancelled
				
			Tests / test (./cmd/caddy/caddy.exe, ~1.23.0, windows-latest, True, 1.23, windows) (push) Has been cancelled
				
			This commit is contained in:
		
							parent
							
								
									066d770409
								
							
						
					
					
						commit
						d7872c3bfa
					
				@ -56,7 +56,7 @@ func (MatchServerName) CaddyModule() caddy.ModuleInfo {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// Match matches hello based on SNI.
 | 
					// Match matches hello based on SNI.
 | 
				
			||||||
func (m MatchServerName) Match(hello *tls.ClientHelloInfo) bool {
 | 
					func (m MatchServerName) Match(hello *tls.ClientHelloInfo) bool {
 | 
				
			||||||
	repl := caddy.NewReplacer()
 | 
						var repl *caddy.Replacer
 | 
				
			||||||
	// caddytls.TestServerNameMatcher calls this function without any context
 | 
						// caddytls.TestServerNameMatcher calls this function without any context
 | 
				
			||||||
	if ctx := hello.Context(); ctx != nil {
 | 
						if ctx := hello.Context(); ctx != nil {
 | 
				
			||||||
		// In some situations the existing context may have no replacer
 | 
							// In some situations the existing context may have no replacer
 | 
				
			||||||
@ -65,6 +65,10 @@ func (m MatchServerName) Match(hello *tls.ClientHelloInfo) bool {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if repl == nil {
 | 
				
			||||||
 | 
							repl = caddy.NewReplacer()
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for _, name := range m {
 | 
						for _, name := range m {
 | 
				
			||||||
		rs := repl.ReplaceAll(name, "")
 | 
							rs := repl.ReplaceAll(name, "")
 | 
				
			||||||
		if certmagic.MatchWildcard(hello.ServerName, rs) {
 | 
							if certmagic.MatchWildcard(hello.ServerName, rs) {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user