frp/cmd/main.go

47 lines
859 B
Go
Raw Normal View History

2018-11-27 14:53:32 +08:00
package main
import (
"log"
2018-12-14 08:50:55 +08:00
"runtime"
"strings"
2018-11-27 14:53:32 +08:00
"time"
2018-12-14 08:50:55 +08:00
"net/http"
_ "net/http/pprof"
2018-11-27 14:53:32 +08:00
"github.com/fatedier/frp/cmd/frp"
)
func main() {
2018-12-14 08:50:55 +08:00
_, path, _, _ := runtime.Caller(0)
path = path[0:strings.LastIndex(path, "/")]
println(path)
frp.RunFrps(path + "/frps.ini")
2018-11-27 14:53:32 +08:00
ch := make(chan bool)
go func() {
time.Sleep(time.Second * 5)
2018-12-14 08:50:55 +08:00
frp.RunFrpc(path + "/frpc.ini")
2018-11-27 14:53:32 +08:00
ch <- true
}()
<-ch
2018-12-14 08:50:55 +08:00
go func() {
log.Println(http.ListenAndServe("localhost:10000", nil))
}()
2018-11-27 14:53:32 +08:00
// frp.RunFrps("./frps.ini")
2018-12-14 08:50:55 +08:00
log.Println("frps is running: ", frp.IsFrpsRunning())
//frp.StopFrps()
//log.Println("frps is running: ", frp.IsFrpsRunning())
2018-11-27 14:53:32 +08:00
ch = make(chan bool)
2018-12-14 08:50:55 +08:00
go func() {
time.Sleep(time.Second * 5)
log.Println("frpc is running: ", frp.IsFrpcRunning())
frp.StopFrpc()
log.Println("frpc is running: ", frp.IsFrpcRunning())
ch <- true
}()
2018-11-27 14:53:32 +08:00
<-ch
}