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