🔥 Proxy is a high performance HTTP(S) proxies, SOCKS5 proxies,WEBSOCKET, TCP, UDP proxy server implemented by golang. Now, it supports chain-style proxies,nat forwarding in different lan,TCP/UDP port forwarding, SSH forwarding.Proxy是golang实现的高性能http,https,websocket,tcp,socks5代理服务器,支持内网穿透,链式代理,通讯加密,智能HTTP,SOCKS5代理,黑白名单,限速,限流量,限连接数,跨平台,KCP支持,认证API。
` startT := time.Now() //计算当前时间 logln := func(v ...interface{}) { log.Println(v...) } defer p1.Close() p2, err := session.OpenStream() if err != nil { logln(err) return } defer p2.Close() defer logln("closed", "in:", p1.RemoteAddr(), "out:", fmt.Sprint(p2.RemoteAddr(), "(", p2.ID(), ") time cost:", time.Since(startT))) streamCopy := func(dst io.Writer, src io.ReadCloser) { if _, err := generic.Copy(dst, src); err != nil { if err == smux.ErrInvalidProtocol { log.Println("smux", err, "in:", p1.RemoteAddr(), "out:", fmt.Sprint(p2.RemoteAddr(), "(", p2.ID(), ")")) } else { log.Println(err, "in:", p1.RemoteAddr(), "out:", fmt.Sprint(p2.RemoteAddr(), "(", p2.ID(), ")")) } } } go streamCopy(p1, p2) buf := &bytes.Buffer{} tee := io.TeeReader(p1, buf) http.ReadRequest(bufio.NewReader(tee)) buf0 := make([]byte, bufSize) streamCopy(p2, p1)
` 我希望在流拷贝之前,从p1里面读取出数据并根据数据做一些其他事,然后再去p1和p2拷贝流,我不知道该怎么做我现在尝试http.ReadRequest(bufio.NewReader(tee)),但是流拷贝的时候导致http请求失败,我猜是p1里面的数据被读取过了的原因