mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-09-15 21:00:27 +00:00
Fix hysteria2 realm server
This commit is contained in:
@@ -21,6 +21,9 @@ The realm only carries control-plane signaling. Once hole-punching succeeds, all
|
|||||||
... // Listen Fields
|
... // Listen Fields
|
||||||
|
|
||||||
"tls": {},
|
"tls": {},
|
||||||
|
|
||||||
|
... // HTTP2 Fields
|
||||||
|
|
||||||
"users": [
|
"users": [
|
||||||
{
|
{
|
||||||
"name": "",
|
"name": "",
|
||||||
@@ -35,6 +38,10 @@ The realm only carries control-plane signaling. Once hole-punching succeeds, all
|
|||||||
|
|
||||||
See [Listen Fields](/configuration/shared/listen/) for details.
|
See [Listen Fields](/configuration/shared/listen/) for details.
|
||||||
|
|
||||||
|
### HTTP2 Fields
|
||||||
|
|
||||||
|
See [HTTP2 Fields](/configuration/shared/http2/) for details.
|
||||||
|
|
||||||
### Fields
|
### Fields
|
||||||
|
|
||||||
#### tls
|
#### tls
|
||||||
|
|||||||
@@ -21,6 +21,9 @@ Realm 只承载控制信令。打洞成功后,所有代理流量在客户端
|
|||||||
... // 监听字段
|
... // 监听字段
|
||||||
|
|
||||||
"tls": {},
|
"tls": {},
|
||||||
|
|
||||||
|
... // HTTP2 字段
|
||||||
|
|
||||||
"users": [
|
"users": [
|
||||||
{
|
{
|
||||||
"name": "",
|
"name": "",
|
||||||
@@ -35,6 +38,10 @@ Realm 只承载控制信令。打洞成功后,所有代理流量在客户端
|
|||||||
|
|
||||||
参阅 [监听字段](/zh/configuration/shared/listen/) 了解详情。
|
参阅 [监听字段](/zh/configuration/shared/listen/) 了解详情。
|
||||||
|
|
||||||
|
### HTTP2 字段
|
||||||
|
|
||||||
|
参阅 [HTTP2 字段](/zh/configuration/shared/http2/) 了解详情。
|
||||||
|
|
||||||
### 字段
|
### 字段
|
||||||
|
|
||||||
#### tls
|
#### tls
|
||||||
|
|||||||
@@ -152,5 +152,6 @@ type HysteriaRealmUser struct {
|
|||||||
type HysteriaRealmServiceOptions struct {
|
type HysteriaRealmServiceOptions struct {
|
||||||
ListenOptions
|
ListenOptions
|
||||||
InboundTLSOptionsContainer
|
InboundTLSOptionsContainer
|
||||||
|
HTTP2Options
|
||||||
Users []HysteriaRealmUser `json:"users"`
|
Users []HysteriaRealmUser `json:"users"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/sagernet/sing-box/adapter"
|
"github.com/sagernet/sing-box/adapter"
|
||||||
boxService "github.com/sagernet/sing-box/adapter/service"
|
boxService "github.com/sagernet/sing-box/adapter/service"
|
||||||
@@ -23,6 +24,7 @@ import (
|
|||||||
"github.com/go-chi/chi/v5/middleware"
|
"github.com/go-chi/chi/v5/middleware"
|
||||||
"github.com/go-chi/render"
|
"github.com/go-chi/render"
|
||||||
"golang.org/x/net/http2"
|
"golang.org/x/net/http2"
|
||||||
|
"golang.org/x/net/http2/h2c"
|
||||||
)
|
)
|
||||||
|
|
||||||
func RegisterRealmService(registry *boxService.Registry) {
|
func RegisterRealmService(registry *boxService.Registry) {
|
||||||
@@ -96,7 +98,13 @@ func NewRealmService(ctx context.Context, logger log.ContextLogger, tag string,
|
|||||||
Listen: options.ListenOptions,
|
Listen: options.ListenOptions,
|
||||||
}),
|
}),
|
||||||
httpServer: &http.Server{
|
httpServer: &http.Server{
|
||||||
Handler: chiRouter,
|
Handler: h2c.NewHandler(chiRouter, &http2.Server{
|
||||||
|
IdleTimeout: time.Duration(options.IdleTimeout),
|
||||||
|
ReadIdleTimeout: time.Duration(options.KeepAlivePeriod),
|
||||||
|
MaxUploadBufferPerStream: int32(options.StreamReceiveWindow.Value()),
|
||||||
|
MaxUploadBufferPerConnection: int32(options.ConnectionReceiveWindow.Value()),
|
||||||
|
MaxConcurrentStreams: uint32(options.MaxConcurrentStreams),
|
||||||
|
}),
|
||||||
ConnContext: func(ctx context.Context, _ net.Conn) context.Context {
|
ConnContext: func(ctx context.Context, _ net.Conn) context.Context {
|
||||||
return log.ContextWithNewID(ctx)
|
return log.ContextWithNewID(ctx)
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user