web shares (#463)

This commit is contained in:
Michael Quigley 2024-09-10 14:11:43 -04:00
parent 597776a835
commit 82d8f4ba2e
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62
2 changed files with 39 additions and 0 deletions

View File

@ -87,6 +87,41 @@ func (i *agentGrpcImpl) PublicShare(_ context.Context, req *agentGrpc.PublicShar
logrus.Errorf("error running proxy backend: %v", err)
}
}()
case "web":
cfg := &proxy.CaddyWebBackendConfig{
IdentityPath: zif,
WebRoot: req.Target,
ShrToken: shr.Token,
}
be, err := proxy.NewCaddyWebBackend(cfg)
if err != nil {
return nil, err
}
agentShr := &share{
shr: shr,
target: req.Target,
basicAuth: req.BasicAuth,
frontendSelection: shr.FrontendEndpoints,
shareMode: sdk.PublicShareMode,
backendMode: sdk.BackendMode(req.BackendMode),
insecure: req.Insecure,
oauthProvider: req.OauthProvider,
oauthEmailAddressPatterns: req.OauthEmailAddressPatterns,
oauthCheckInterval: shrReq.OauthAuthorizationCheckInterval,
closed: req.Closed,
accessGrants: req.AccessGrants,
handler: be,
}
i.a.shares[shr.Token] = agentShr
go func() {
if err := agentShr.handler.Run(); err != nil {
logrus.Errorf("error running web backend: %v", err)
}
}()
}
return &agentGrpc.PublicShareReply{Token: shr.Token}, nil

View File

@ -81,6 +81,10 @@ func (c *CaddyWebBackend) Run() error {
return caddy.Run(c.caddyCfg)
}
func (c *CaddyWebBackend) Stop() error {
return caddy.Stop()
}
func (c *CaddyWebBackend) Requests() func() int32 {
return func() int32 { return 0 }
}