mirror of
https://gitee.com/IrisVega/frp.git
synced 2024-11-01 22:31:29 +08:00
ci: add subdomain test case
This commit is contained in:
parent
a77c7e8625
commit
3f64d73ea9
@ -103,6 +103,18 @@ use_compression = true
|
||||
http_user = test
|
||||
http_user = test
|
||||
|
||||
[subhost01]
|
||||
type = http
|
||||
local_ip = 127.0.0.1
|
||||
local_port = 10704
|
||||
subdomain = test01
|
||||
|
||||
[subhost02]
|
||||
type = http
|
||||
local_ip = 127.0.0.1
|
||||
local_port = 10704
|
||||
subdomain = test02
|
||||
|
||||
[tcp_port_not_allowed]
|
||||
type = tcp
|
||||
local_ip = 127.0.0.1
|
||||
|
@ -6,3 +6,4 @@ log_file = ./frps.log
|
||||
log_level = debug
|
||||
privilege_token = 123456
|
||||
privilege_allow_ports = 10000-20000,20002,30000-40000
|
||||
subdomain_host = sub.com
|
||||
|
@ -171,6 +171,20 @@ func TestHttp(t *testing.T) {
|
||||
if assert.NoError(err) {
|
||||
assert.Equal(401, code)
|
||||
}
|
||||
|
||||
// subhost01
|
||||
code, body, err = sendHttpMsg("GET", fmt.Sprintf("http://127.0.0.1:%d", TEST_HTTP_FRP_PORT), "test01.sub.com", nil)
|
||||
if assert.NoError(err) {
|
||||
assert.Equal(200, code)
|
||||
assert.Equal("test01.sub.com", body)
|
||||
}
|
||||
|
||||
// subhost02
|
||||
code, body, err = sendHttpMsg("GET", fmt.Sprintf("http://127.0.0.1:%d", TEST_HTTP_FRP_PORT), "test02.sub.com", nil)
|
||||
if assert.NoError(err) {
|
||||
assert.Equal(200, code)
|
||||
assert.Equal("test02.sub.com", body)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPrivilegeAllowPorts(t *testing.T) {
|
||||
|
@ -3,6 +3,7 @@ package tests
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@ -12,6 +13,18 @@ func StartHttpServer() {
|
||||
}
|
||||
|
||||
func request(w http.ResponseWriter, r *http.Request) {
|
||||
match, err := regexp.Match(`.*\.sub\.com`, []byte(r.Host))
|
||||
if err != nil {
|
||||
w.WriteHeader(500)
|
||||
return
|
||||
}
|
||||
|
||||
if match {
|
||||
w.WriteHeader(200)
|
||||
w.Write([]byte(r.Host))
|
||||
return
|
||||
}
|
||||
|
||||
if strings.Contains(r.Host, "127.0.0.1") || strings.Contains(r.Host, "test2.frp.com") ||
|
||||
strings.Contains(r.Host, "test5.frp.com") {
|
||||
w.WriteHeader(200)
|
||||
|
Loading…
Reference in New Issue
Block a user