mirror of https://github.com/fatedier/frp
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
530 B
42 lines
530 B
9 years ago
|
package main
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
|
||
|
"frp/utils/conn"
|
||
|
)
|
||
|
|
||
|
var (
|
||
|
PORT int64 = 10701
|
||
|
)
|
||
|
|
||
|
func main() {
|
||
|
l, err := conn.Listen("0.0.0.0", PORT)
|
||
|
if err != nil {
|
||
|
fmt.Printf("echo server listen error: %v\n", err)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
for {
|
||
|
c, err := l.Accept()
|
||
|
if err != nil {
|
||
|
fmt.Printf("echo server accept error: %v\n", err)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
go echoWorker(c)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func echoWorker(c *conn.Conn) {
|
||
|
for {
|
||
|
buff, err := c.ReadLine()
|
||
|
if err != nil {
|
||
|
fmt.Printf("echo server read error: %v\n", err)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
c.Write(buff)
|
||
|
}
|
||
|
}
|