pull/1219/head
刘河 2019-01-12 01:22:53 +08:00
parent a67cdff02a
commit 0ce6ab1e15
4 changed files with 20 additions and 25 deletions

View File

@ -1,20 +0,0 @@
{
"Server": {
"ip": "123.206.77.88",
"tcp": 8224,
"vkey": "DKibZF5TXvic1g3kY",
"num": 10
},
"SiteList": [
{
"host": "a.server.ourcauc.com",
"url": "10.1.50.203",
"port": 80
},
{
"host": "b.server.ourcauc.com",
"url": "10.1.50.196",
"port": 4000
}
]
}

View File

@ -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)
}

View File

@ -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
}

View File

@ -10,7 +10,6 @@ import (
"log"
"net"
"net/http"
"net/http/httputil"
"net/url"
"strconv"
"strings"
@ -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访问