Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
G
gost
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
gost
Commits
b31d0e9c
Commit
b31d0e9c
authored
Apr 10, 2017
by
Adam Stankiewicz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow whitelisting and blacklisting of http/http2
parent
ff263567
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
3 deletions
+14
-3
http.go
http.go
+14
-3
No files found.
http.go
View file @
b31d0e9c
...
@@ -5,14 +5,15 @@ import (
...
@@ -5,14 +5,15 @@ import (
"crypto/tls"
"crypto/tls"
"encoding/base64"
"encoding/base64"
"errors"
"errors"
"github.com/ginuerzh/pht"
"github.com/golang/glog"
"golang.org/x/net/http2"
"io"
"io"
"net"
"net"
"net/http"
"net/http"
"net/http/httputil"
"net/http/httputil"
"time"
"time"
"github.com/ginuerzh/pht"
"github.com/golang/glog"
"golang.org/x/net/http2"
)
)
type
HttpServer
struct
{
type
HttpServer
struct
{
...
@@ -75,6 +76,11 @@ func (s *HttpServer) HandleRequest(req *http.Request) {
...
@@ -75,6 +76,11 @@ func (s *HttpServer) HandleRequest(req *http.Request) {
return
return
}
}
if
!
s
.
Base
.
Node
.
Can
(
"tcp"
,
req
.
Host
)
{
glog
.
Errorf
(
"Unauthorized to tcp connect to %s"
,
req
.
Host
)
return
}
c
,
err
:=
s
.
Base
.
Chain
.
Dial
(
req
.
Host
)
c
,
err
:=
s
.
Base
.
Chain
.
Dial
(
req
.
Host
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
V
(
LWARNING
)
.
Infof
(
"[http] %s -> %s : %s"
,
s
.
conn
.
RemoteAddr
(),
req
.
Host
,
err
)
glog
.
V
(
LWARNING
)
.
Infof
(
"[http] %s -> %s : %s"
,
s
.
conn
.
RemoteAddr
(),
req
.
Host
,
err
)
...
@@ -184,6 +190,11 @@ func (s *Http2Server) HandleRequest(w http.ResponseWriter, req *http.Request) {
...
@@ -184,6 +190,11 @@ func (s *Http2Server) HandleRequest(w http.ResponseWriter, req *http.Request) {
w
.
Header
()
.
Set
(
"Proxy-Agent"
,
"gost/"
+
Version
)
w
.
Header
()
.
Set
(
"Proxy-Agent"
,
"gost/"
+
Version
)
if
!
s
.
Base
.
Node
.
Can
(
"tcp"
,
target
)
{
glog
.
Errorf
(
"Unauthorized to tcp connect to %s"
,
target
)
return
}
// HTTP2 as transport
// HTTP2 as transport
if
req
.
Header
.
Get
(
"Proxy-Switch"
)
==
"gost"
{
if
req
.
Header
.
Get
(
"Proxy-Switch"
)
==
"gost"
{
conn
,
err
:=
s
.
Upgrade
(
w
,
req
)
conn
,
err
:=
s
.
Upgrade
(
w
,
req
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment