mirror of
https://github.com/fatedier/frp.git
synced 2024-12-12 09:41:19 +01:00
utils/conn: fix a socket error in windows
This commit is contained in:
parent
04014bb78f
commit
2640c0b570
@ -6,7 +6,7 @@
|
||||
|
||||
>frp 是一个高性能的反向代理应用,可以帮助你轻松的进行内网穿透,对外网提供服务,对于 http 服务还支持虚拟主机功能,访问80端口,可以根据域名路由到后端不同的 http 服务。
|
||||
|
||||
## frp 的作用?
|
||||
## frp 的作用
|
||||
|
||||
* 利用处于内网或防火墙后的机器,对外网环境提供 http 服务。
|
||||
* 对于 http 服务支持基于域名的虚拟主机,支持自定义域名绑定,使多个域名可以共用一个80端口。
|
||||
@ -15,7 +15,7 @@
|
||||
|
||||
## 开发状态
|
||||
|
||||
frp 目前正在前期开发阶段,master分支用于发布稳定版本,dev分支用于开发,您可以尝试下载最新的 release 版本进行测试。
|
||||
frp 目前正在前期开发阶段,master 分支用于发布稳定版本,dev 分支用于开发,您可以尝试下载最新的 release 版本进行测试。
|
||||
|
||||
**在 1.0 版本以前,交互协议都可能会被改变,不能保证向后兼容。**
|
||||
|
||||
|
@ -46,7 +46,7 @@ Options:
|
||||
-L log_file set output log file, including console
|
||||
--log-level=<log_level> set log level: debug, info, warn, error
|
||||
--addr=<bind_addr> listen addr for client, example: 0.0.0.0:7000
|
||||
--reload reload ini file and configures in common section won't be changed
|
||||
--reload reload ini file and configures in common section won't be changed
|
||||
-h --help show this screen
|
||||
-v --version show version
|
||||
`
|
||||
|
@ -19,6 +19,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@ -129,10 +130,13 @@ func (c *Conn) GetLocalAddr() (addr string) {
|
||||
|
||||
func (c *Conn) ReadLine() (buff string, err error) {
|
||||
buff, err = c.Reader.ReadString('\n')
|
||||
if err == io.EOF {
|
||||
c.mutex.Lock()
|
||||
c.closeFlag = true
|
||||
c.mutex.Unlock()
|
||||
if err != nil {
|
||||
// wsarecv error in windows means connection closed
|
||||
if err == io.EOF || strings.Contains(err.Error(), "wsarecv: An existing connection was forcibly closed") {
|
||||
c.mutex.Lock()
|
||||
c.closeFlag = true
|
||||
c.mutex.Unlock()
|
||||
}
|
||||
}
|
||||
return buff, err
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"frp/utils/conn"
|
||||
)
|
||||
@ -31,6 +32,9 @@ func main() {
|
||||
func echoWorker(c *conn.Conn) {
|
||||
for {
|
||||
buff, err := c.ReadLine()
|
||||
if err == io.EOF {
|
||||
break
|
||||
}
|
||||
if err != nil {
|
||||
fmt.Printf("echo server read error: %v\n", err)
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user