Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
企猫商务
frp
提交
d099cb14
F
frp
项目概览
企猫商务
/
frp
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
frp
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
d099cb14
编写于
1月 21, 2021
作者:
Y
yuyulei
提交者:
GitHub
1月 21, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Revert "vhost: set DisableKeepAlives = false and fix websocket not work"
上级
b2608058
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
20 addition
and
50 deletion
+20
-50
pkg/util/util/http.go
pkg/util/util/http.go
+1
-1
pkg/util/vhost/http.go
pkg/util/vhost/http.go
+9
-23
tests/ci/health/health_test.go
tests/ci/health/health_test.go
+10
-26
未找到文件。
pkg/util/util/http.go
浏览文件 @
d099cb14
...
...
@@ -74,4 +74,4 @@ func hasPort(host string) bool {
return
true
}
return
host
[
0
]
==
'['
&&
strings
.
Contains
(
host
,
"]:"
)
}
}
\ No newline at end of file
pkg/util/vhost/http.go
浏览文件 @
d099cb14
...
...
@@ -17,7 +17,6 @@ package vhost
import
(
"bytes"
"context"
"encoding/base64"
"errors"
"fmt"
"log"
...
...
@@ -60,25 +59,20 @@ func NewHTTPReverseProxy(option HTTPReverseProxyOptions, vhostRouter *Routers) *
req
.
URL
.
Scheme
=
"http"
url
:=
req
.
Context
()
.
Value
(
RouteInfoURL
)
.
(
string
)
oldHost
:=
util
.
GetHostFromAddr
(
req
.
Context
()
.
Value
(
RouteInfoHost
)
.
(
string
))
rc
:=
rp
.
GetRouteConfig
(
oldHost
,
url
)
if
rc
!=
nil
{
if
rc
.
RewriteHost
!=
""
{
req
.
Host
=
rc
.
RewriteHost
}
// Set {domain}.{location} as URL host here to let http transport reuse connections.
req
.
URL
.
Host
=
rc
.
Domain
+
"."
+
base64
.
StdEncoding
.
EncodeToString
([]
byte
(
rc
.
Location
))
for
k
,
v
:=
range
rc
.
Headers
{
req
.
Header
.
Set
(
k
,
v
)
}
}
else
{
req
.
URL
.
Host
=
req
.
Host
host
:=
rp
.
GetRealHost
(
oldHost
,
url
)
if
host
!=
""
{
req
.
Host
=
host
}
req
.
URL
.
Host
=
req
.
Host
headers
:=
rp
.
GetHeaders
(
oldHost
,
url
)
for
k
,
v
:=
range
headers
{
req
.
Header
.
Set
(
k
,
v
)
}
},
Transport
:
&
http
.
Transport
{
ResponseHeaderTimeout
:
rp
.
responseHeaderTimeout
,
IdleConnTimeout
:
60
*
time
.
Second
,
DisableKeepAlives
:
true
,
DialContext
:
func
(
ctx
context
.
Context
,
network
,
addr
string
)
(
net
.
Conn
,
error
)
{
url
:=
ctx
.
Value
(
RouteInfoURL
)
.
(
string
)
host
:=
util
.
GetHostFromAddr
(
ctx
.
Value
(
RouteInfoHost
)
.
(
string
))
...
...
@@ -113,14 +107,6 @@ func (rp *HTTPReverseProxy) UnRegister(domain string, location string) {
rp
.
vhostRouter
.
Del
(
domain
,
location
)
}
func
(
rp
*
HTTPReverseProxy
)
GetRouteConfig
(
domain
string
,
location
string
)
*
RouteConfig
{
vr
,
ok
:=
rp
.
getVhost
(
domain
,
location
)
if
ok
{
return
vr
.
payload
.
(
*
RouteConfig
)
}
return
nil
}
func
(
rp
*
HTTPReverseProxy
)
GetRealHost
(
domain
string
,
location
string
)
(
host
string
)
{
vr
,
ok
:=
rp
.
getVhost
(
domain
,
location
)
if
ok
{
...
...
tests/ci/health/health_test.go
浏览文件 @
d099cb14
...
...
@@ -139,7 +139,6 @@ func TestHealthCheck(t *testing.T) {
}
httpSvc3
:=
mock
.
NewHTTPServer
(
15005
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
time
.
Sleep
(
time
.
Second
)
w
.
Write
([]
byte
(
"http3"
))
})
err
=
httpSvc3
.
Start
()
...
...
@@ -148,7 +147,6 @@ func TestHealthCheck(t *testing.T) {
}
httpSvc4
:=
mock
.
NewHTTPServer
(
15006
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
time
.
Sleep
(
time
.
Second
)
w
.
Write
([]
byte
(
"http4"
))
})
err
=
httpSvc4
.
Start
()
...
...
@@ -279,30 +277,16 @@ func TestHealthCheck(t *testing.T) {
// ****** load balancing type http ******
result
=
make
([]
string
,
0
)
var
wait
sync
.
WaitGroup
var
mu
sync
.
Mutex
wait
.
Add
(
2
)
go
func
()
{
defer
wait
.
Done
()
code
,
body
,
_
,
err
:=
util
.
SendHTTPMsg
(
"GET"
,
"http://127.0.0.1:14000/xxx"
,
"test.balancing.com"
,
nil
,
""
)
assert
.
NoError
(
err
)
assert
.
Equal
(
200
,
code
)
mu
.
Lock
()
result
=
append
(
result
,
body
)
mu
.
Unlock
()
}()
go
func
()
{
defer
wait
.
Done
()
code
,
body
,
_
,
err
=
util
.
SendHTTPMsg
(
"GET"
,
"http://127.0.0.1:14000/xxx"
,
"test.balancing.com"
,
nil
,
""
)
assert
.
NoError
(
err
)
assert
.
Equal
(
200
,
code
)
mu
.
Lock
()
result
=
append
(
result
,
body
)
mu
.
Unlock
()
}()
wait
.
Wait
()
code
,
body
,
_
,
err
=
util
.
SendHTTPMsg
(
"GET"
,
"http://127.0.0.1:14000/xxx"
,
"test.balancing.com"
,
nil
,
""
)
assert
.
NoError
(
err
)
assert
.
Equal
(
200
,
code
)
result
=
append
(
result
,
body
)
code
,
body
,
_
,
err
=
util
.
SendHTTPMsg
(
"GET"
,
"http://127.0.0.1:14000/xxx"
,
"test.balancing.com"
,
nil
,
""
)
assert
.
NoError
(
err
)
assert
.
Equal
(
200
,
code
)
result
=
append
(
result
,
body
)
assert
.
Contains
(
result
,
"http3"
)
assert
.
Contains
(
result
,
"http4"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录