From 1c8bc0bfa8e3b99ae803e0aac43097896273024b Mon Sep 17 00:00:00 2001
From: fatedier <fatedier@gmail.com>
Date: Thu, 1 Feb 2024 11:53:52 +0800
Subject: [PATCH] make the host/domain matching case-insensitive (#3966)

---
 Release.md               | 4 ++++
 pkg/util/vhost/router.go | 6 ++++++
 2 files changed, 10 insertions(+)

diff --git a/Release.md b/Release.md
index 5d050f4d..38e7cb30 100644
--- a/Release.md
+++ b/Release.md
@@ -5,3 +5,7 @@
 ### Features
 
 * The `Refresh` and `ClearOfflineProxies` buttons have been added to the Dashboard of frps.
+
+### Fixes
+
+* The host/domain matching in the routing rules has been changed to be case-insensitive.
diff --git a/pkg/util/vhost/router.go b/pkg/util/vhost/router.go
index 281e164b..e8e5a53f 100644
--- a/pkg/util/vhost/router.go
+++ b/pkg/util/vhost/router.go
@@ -33,6 +33,8 @@ func NewRouters() *Routers {
 }
 
 func (r *Routers) Add(domain, location, httpUser string, payload interface{}) error {
+	domain = strings.ToLower(domain)
+
 	r.mutex.Lock()
 	defer r.mutex.Unlock()
 
@@ -64,6 +66,8 @@ func (r *Routers) Add(domain, location, httpUser string, payload interface{}) er
 }
 
 func (r *Routers) Del(domain, location, httpUser string) {
+	domain = strings.ToLower(domain)
+
 	r.mutex.Lock()
 	defer r.mutex.Unlock()
 
@@ -86,6 +90,8 @@ func (r *Routers) Del(domain, location, httpUser string) {
 }
 
 func (r *Routers) Get(host, path, httpUser string) (vr *Router, exist bool) {
+	host = strings.ToLower(host)
+
 	r.mutex.RLock()
 	defer r.mutex.RUnlock()