mirror of
https://github.com/onepanelio/onepanel.git
synced 2025-09-27 01:56:03 +08:00
add websocket proxy back in
This commit is contained in:
1
go.mod
1
go.mod
@@ -39,6 +39,7 @@ require (
|
||||
github.com/sirupsen/logrus v1.4.2
|
||||
github.com/spf13/cobra v0.0.5 // indirect
|
||||
github.com/stretchr/testify v1.4.0
|
||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20200122045848-3419fae592fc
|
||||
github.com/valyala/fasttemplate v1.1.0 // indirect
|
||||
golang.org/x/crypto v0.0.0-20191128160524-b544559bb6d1 // indirect
|
||||
golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa // indirect
|
||||
|
2
go.sum
2
go.sum
@@ -236,6 +236,8 @@ github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20200122045848-3419fae592fc h1:yUaosFVTJwnltaHbSNC3i82I92quFs+OFPRl8kNMVwo=
|
||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20200122045848-3419fae592fc/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
||||
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
|
||||
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
||||
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
||||
|
9
main.go
9
main.go
@@ -23,6 +23,7 @@ import (
|
||||
"github.com/onepanelio/core/server/auth"
|
||||
"github.com/pressly/goose"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/tmc/grpc-websocket-proxy/wsproxy"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
@@ -117,9 +118,11 @@ func startHTTPProxy() {
|
||||
// Allow PUT. Have to include all others as it clears them out.
|
||||
allowedMethods := handlers.AllowedMethods([]string{"HEAD", "GET", "POST", "PUT", "DELETE", "PATCH"})
|
||||
|
||||
if err := http.ListenAndServe(*httpPort, handlers.CORS(
|
||||
handlers.AllowedOriginValidator(ogValidator), allowedHeaders, allowedMethods)(mux),
|
||||
); err != nil {
|
||||
if err := http.ListenAndServe(*httpPort, wsproxy.WebsocketProxy(
|
||||
handlers.CORS(
|
||||
handlers.AllowedOriginValidator(ogValidator), allowedHeaders, allowedMethods)(mux),
|
||||
wsproxy.WithTokenCookieName("auth-token"),
|
||||
)); err != nil {
|
||||
log.Fatalf("Failed to serve HTTP listener: %v", err)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user