mirror of
https://github.com/lightninglabs/aperture.git
synced 2026-02-16 23:14:26 +01:00
aperture: allow updating services at runtime
In order to be able to dynamically update the proxy's backend configuration, we add a new method that can overwrite the list of backend services.
This commit is contained in:
12
aperture.go
12
aperture.go
@@ -124,6 +124,7 @@ type Aperture struct {
|
||||
challenger *LndChallenger
|
||||
httpsServer *http.Server
|
||||
torHTTPServer *http.Server
|
||||
proxy *proxy.Proxy
|
||||
|
||||
wg sync.WaitGroup
|
||||
quit chan struct{}
|
||||
@@ -172,11 +173,11 @@ func (a *Aperture) Start(errChan chan error) error {
|
||||
}
|
||||
|
||||
// Create the proxy and connect it to lnd.
|
||||
servicesProxy, err := createProxy(a.cfg, a.challenger, a.etcdClient)
|
||||
a.proxy, err = createProxy(a.cfg, a.challenger, a.etcdClient)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
handler := http.HandlerFunc(servicesProxy.ServeHTTP)
|
||||
handler := http.HandlerFunc(a.proxy.ServeHTTP)
|
||||
a.httpsServer = &http.Server{
|
||||
Addr: a.cfg.ListenAddr,
|
||||
Handler: handler,
|
||||
@@ -255,6 +256,13 @@ func (a *Aperture) Start(errChan chan error) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// UpdateServices instructs the proxy to re-initialize its internal
|
||||
// configuration of backend services. This can be used to add or remove backends
|
||||
// at run time or enable/disable authentication on the fly.
|
||||
func (a *Aperture) UpdateServices(services []*proxy.Service) error {
|
||||
return a.proxy.UpdateServices(services)
|
||||
}
|
||||
|
||||
// Stop gracefully shuts down the Aperture service.
|
||||
func (a *Aperture) Stop() error {
|
||||
var returnErr error
|
||||
|
||||
Reference in New Issue
Block a user