更新至最新代码
This commit is contained in:
parent
3c114e7cd9
commit
dda7861742
@ -56,8 +56,8 @@ func NewService(pxyCfgs map[string]config.ProxyConf, visitorCfgs map[string]conf
|
||||
pxyCfgs: pxyCfgs,
|
||||
visitorCfgs: visitorCfgs,
|
||||
exit: 0,
|
||||
closedCh: make(chan bool),
|
||||
closed: false,
|
||||
closedCh: make(chan bool),
|
||||
closed: false,
|
||||
}
|
||||
return
|
||||
}
|
||||
@ -229,7 +229,7 @@ func (svr *Service) ReloadConf(pxyCfgs map[string]config.ProxyConf, visitorCfgs
|
||||
func (svr *Service) Close() {
|
||||
atomic.StoreUint32(&svr.exit, 1)
|
||||
svr.ctl.Close()
|
||||
close(svr.closedCh)
|
||||
svr.closedCh <- true
|
||||
}
|
||||
|
||||
func (svr *Service) IsClosed() bool {
|
||||
|
8
cmd/frpc.ini
Normal file
8
cmd/frpc.ini
Normal file
@ -0,0 +1,8 @@
|
||||
[common]
|
||||
server_addr = 127.0.0.1
|
||||
bind_port = 7000
|
||||
|
||||
[http_proxy]
|
||||
type = tcp
|
||||
remote_port = 6000
|
||||
plugin = http_proxy
|
@ -1,2 +1,4 @@
|
||||
[common]
|
||||
bind_port = 7000
|
||||
bind_addr = 127.0.0.1
|
||||
bind_port = 7000
|
||||
allow_ports = 7000, 6000
|
27
cmd/main.go
27
cmd/main.go
@ -2,24 +2,45 @@ package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"runtime"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"net/http"
|
||||
_ "net/http/pprof"
|
||||
|
||||
"github.com/fatedier/frp/cmd/frp"
|
||||
)
|
||||
|
||||
func main() {
|
||||
frp.RunFrps("./frps.ini")
|
||||
_, path, _, _ := runtime.Caller(0)
|
||||
path = path[0:strings.LastIndex(path, "/")]
|
||||
println(path)
|
||||
frp.RunFrps(path + "/frps.ini")
|
||||
|
||||
ch := make(chan bool)
|
||||
go func() {
|
||||
time.Sleep(time.Second * 5)
|
||||
frp.StopFrps()
|
||||
frp.RunFrpc(path + "/frpc.ini")
|
||||
ch <- true
|
||||
}()
|
||||
<-ch
|
||||
|
||||
go func() {
|
||||
log.Println(http.ListenAndServe("localhost:10000", nil))
|
||||
}()
|
||||
// frp.RunFrps("./frps.ini")
|
||||
log.Println(frp.IsFrpsRunning())
|
||||
log.Println("frps is running: ", frp.IsFrpsRunning())
|
||||
|
||||
//frp.StopFrps()
|
||||
//log.Println("frps is running: ", frp.IsFrpsRunning())
|
||||
ch = make(chan bool)
|
||||
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
|
||||
}()
|
||||
<-ch
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user