Skip to content

Commit

Permalink
bug
Browse files Browse the repository at this point in the history
  • Loading branch information
刘河 committed Jan 11, 2019
1 parent a67cdff commit 0ce6ab1
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 25 deletions.
20 changes: 0 additions & 20 deletions config.json

This file was deleted.

5 changes: 5 additions & 0 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@ func DelTask(vKey string) error {
if err := StopServer(vKey); err != nil {
return err
}
for _, v := range CsvDb.Hosts {
if v.Vkey == vKey {
CsvDb.DelHost(v.Host)
}
}
return CsvDb.DelTask(vKey)
}

Expand Down
9 changes: 8 additions & 1 deletion server/tcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,20 @@ func (s *TunnelModeServer) Close() error {

//tcp隧道模式
func ProcessTunnel(c *utils.Conn, s *TunnelModeServer) error {
return s.dealClient(c, s.config, s.config.Target, "", nil)
_, _, rb, err, r := c.GetHost()
if err == nil {
if err := s.auth(r, c, s.config.U, s.config.P); err != nil {
return err
}
}
return s.dealClient(c, s.config, s.config.Target, "", rb)
}

//http代理模式
func ProcessHttp(c *utils.Conn, s *TunnelModeServer) error {
method, addr, rb, err, r := c.GetHost()
if err != nil {
log.Println(err)
c.Close()
return err
}
Expand Down
11 changes: 7 additions & 4 deletions utils/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"log"
"net"
"net/http"
"net/http/httputil"
"net/url"
"strconv"
"strings"
Expand Down Expand Up @@ -245,16 +244,20 @@ func (s *Conn) SetAlive() {

//从tcp报文中解析出host,连接类型等 TODO 多种情况
func (s *Conn) GetHost() (method, address string, rb []byte, err error, r *http.Request) {
r, err = http.ReadRequest(bufio.NewReader(s))
if err != nil {
var b [32 * 1024]byte
var n int
if n, err = s.Read(b[:]); err != nil {
return
}
rb, err = httputil.DumpRequest(r, true)
rb = b[:n]
r, err = http.ReadRequest(bufio.NewReader(bytes.NewReader(rb)))
if err != nil {
return
}
hostPortURL, err := url.Parse(r.Host)
if err != nil {
address = r.Host
err = nil
return
}
if hostPortURL.Opaque == "443" { //https访问
Expand Down

0 comments on commit 0ce6ab1

Please sign in to comment.