Added support for default load balancer method.
This commit is contained in:
parent
5dae8b1f9e
commit
4696ec4ec2
|
@ -13,4 +13,7 @@ rvpn:
|
||||||
secret: abc123
|
secret: abc123
|
||||||
test3.daplie.me:
|
test3.daplie.me:
|
||||||
secret: abc123
|
secret: abc123
|
||||||
|
loadbalancing:
|
||||||
|
defaultmethod: 'round-robin'
|
||||||
|
|
||||||
|
|
||||||
|
|
8
main.go
8
main.go
|
@ -32,6 +32,7 @@ var (
|
||||||
idle int
|
idle int
|
||||||
dwell int
|
dwell int
|
||||||
cancelcheck int
|
cancelcheck int
|
||||||
|
lbDefaultMethod string
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -59,6 +60,7 @@ func main() {
|
||||||
idle = deadtime.(map[string]interface{})["idle"].(int)
|
idle = deadtime.(map[string]interface{})["idle"].(int)
|
||||||
dwell = deadtime.(map[string]interface{})["dwell"].(int)
|
dwell = deadtime.(map[string]interface{})["dwell"].(int)
|
||||||
cancelcheck = deadtime.(map[string]interface{})["cancelcheck"].(int)
|
cancelcheck = deadtime.(map[string]interface{})["cancelcheck"].(int)
|
||||||
|
lbDefaultMethod = viper.Get("rvpn.loadbalancing.defaultmethod").(string)
|
||||||
|
|
||||||
loginfo.Println("startup")
|
loginfo.Println("startup")
|
||||||
|
|
||||||
|
@ -91,8 +93,10 @@ func main() {
|
||||||
connectionTable = genericlistener.NewTable(dwell, idle)
|
connectionTable = genericlistener.NewTable(dwell, idle)
|
||||||
go connectionTable.Run(ctx)
|
go connectionTable.Run(ctx)
|
||||||
|
|
||||||
genericListeners := genericlistener.NewGenerListeners(ctx, connectionTable, connectionTracking, secretKey, certbundle, wssHostName, adminHostName, cancelcheck)
|
genericListeners := genericlistener.NewGenerListeners(ctx, connectionTable, connectionTracking, secretKey, certbundle, wssHostName,
|
||||||
go genericListeners.Run(ctx, argGenericBinding)
|
adminHostName, cancelcheck, lbDefaultMethod)
|
||||||
|
|
||||||
|
genericListeners.Run(ctx, argGenericBinding)
|
||||||
|
|
||||||
//Run for 10 minutes and then shutdown cleanly
|
//Run for 10 minutes and then shutdown cleanly
|
||||||
time.Sleep(6000 * time.Second)
|
time.Sleep(6000 * time.Second)
|
||||||
|
|
|
@ -34,6 +34,7 @@ const (
|
||||||
ctxWssHostName contextKey = "wsshostname"
|
ctxWssHostName contextKey = "wsshostname"
|
||||||
ctxAdminHostName contextKey = "adminHostName"
|
ctxAdminHostName contextKey = "adminHostName"
|
||||||
ctxCancelCheck contextKey = "cancelcheck"
|
ctxCancelCheck contextKey = "cancelcheck"
|
||||||
|
ctxLoadbalanceDefaultMethod contextKey = "lbdefaultmethod"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
|
@ -56,10 +56,12 @@ type GenericListeners struct {
|
||||||
wssHostName string
|
wssHostName string
|
||||||
adminHostName string
|
adminHostName string
|
||||||
cancelCheck int
|
cancelCheck int
|
||||||
|
lbDefaultMethod string
|
||||||
}
|
}
|
||||||
|
|
||||||
//NewGenerListeners --
|
//NewGenerListeners --
|
||||||
func NewGenerListeners(ctx context.Context, connectionTable *Table, connectionTrack *Tracking, secretKey string, certbundle tls.Certificate, wssHostName string, adminHostName string, cancelCheck int) (p *GenericListeners) {
|
func NewGenerListeners(ctx context.Context, connectionTable *Table, connectionTrack *Tracking, secretKey string, certbundle tls.Certificate,
|
||||||
|
wssHostName string, adminHostName string, cancelCheck int, lbDefaultMethod string) (p *GenericListeners) {
|
||||||
p = new(GenericListeners)
|
p = new(GenericListeners)
|
||||||
p.listeners = make(map[*net.Listener]int)
|
p.listeners = make(map[*net.Listener]int)
|
||||||
p.ctx = ctx
|
p.ctx = ctx
|
||||||
|
@ -71,6 +73,7 @@ func NewGenerListeners(ctx context.Context, connectionTable *Table, connectionTr
|
||||||
p.wssHostName = wssHostName
|
p.wssHostName = wssHostName
|
||||||
p.adminHostName = adminHostName
|
p.adminHostName = adminHostName
|
||||||
p.cancelCheck = cancelCheck
|
p.cancelCheck = cancelCheck
|
||||||
|
p.lbDefaultMethod = lbDefaultMethod
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,6 +96,7 @@ func (gl *GenericListeners) Run(ctx context.Context, initialPort int) {
|
||||||
ctx = context.WithValue(ctx, ctxWssHostName, gl.wssHostName)
|
ctx = context.WithValue(ctx, ctxWssHostName, gl.wssHostName)
|
||||||
ctx = context.WithValue(ctx, ctxAdminHostName, gl.adminHostName)
|
ctx = context.WithValue(ctx, ctxAdminHostName, gl.adminHostName)
|
||||||
ctx = context.WithValue(ctx, ctxCancelCheck, gl.cancelCheck)
|
ctx = context.WithValue(ctx, ctxCancelCheck, gl.cancelCheck)
|
||||||
|
ctx = context.WithValue(ctx, ctxLoadbalanceDefaultMethod, gl.lbDefaultMethod)
|
||||||
|
|
||||||
go func(ctx context.Context) {
|
go func(ctx context.Context) {
|
||||||
for {
|
for {
|
||||||
|
|
Loading…
Reference in New Issue