Skip to content

Commit

Permalink
nil pointer fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
p4gefau1t committed Mar 24, 2020
1 parent 787b5e3 commit c39f2b9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ client-mux.json
"remote_addr": "your_awesome_server",
"remote_port": 443,
"password": [
"your_awesome_password"
"your_awesome_password"
],
"ssl": {
"cert": "server.crt",
Expand Down Expand Up @@ -273,7 +273,7 @@ client.json
"remote_addr": "your_awesome_server",
"remote_port": 443,
"password": [
"your_awesome_password"
"your_awesome_password"
],
"ssl": {
"cert": "server.crt",
Expand Down
28 changes: 17 additions & 11 deletions proxy/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ func (s *Server) handleConn(conn net.Conn) {
}

func (s *Server) handleInvalidConn(conn net.Conn, tlsConn *tls.Conn) {
//HACK
//obtain the bytes buffered by the tls conn

if len(s.config.TLS.HTTPResponse) > 0 {
logger.Warn("trying to response a plain http response")
Expand All @@ -119,17 +117,25 @@ func (s *Server) handleInvalidConn(conn net.Conn, tlsConn *tls.Conn) {
return
}

v := reflect.ValueOf(*tlsConn)
buf := v.FieldByName("rawInput").FieldByName("buf").Bytes()
logger.Debug("payload:" + string(buf))
if s.config.TLS.FallbackAddr != nil {
//HACK
//obtain the bytes buffered by the tls conn
v := reflect.ValueOf(*tlsConn)
buf := v.FieldByName("rawInput").FieldByName("buf").Bytes()
logger.Debug("payload:" + string(buf))

remote, err := net.Dial("tcp", s.config.TLS.FallbackAddr.String())
if err != nil {
logger.Warn(common.NewError("failed to dial to tls fallback server").Base(err))
remote, err := net.Dial("tcp", s.config.TLS.FallbackAddr.String())
if err != nil {
logger.Warn(common.NewError("failed to dial to tls fallback server").Base(err))
}
logger.Warn("proxying this invalid tls conn to the tls fallback server")
remote.Write(buf)
go proxyConn(conn, remote)
} else {
logger.Warn("fallback port is unspecified, closing")
conn.Close()
}
logger.Warn("proxying this invalid tls conn to the tls fallback server")
remote.Write(buf)
go proxyConn(conn, remote)

}

func (s *Server) Run() error {
Expand Down

0 comments on commit c39f2b9

Please sign in to comment.