Fix localdev
This commit is contained in:
@ -12,9 +12,11 @@ namespace NostrStreamer.Services;
|
|||||||
public class LndNode
|
public class LndNode
|
||||||
{
|
{
|
||||||
private readonly Network _network;
|
private readonly Network _network;
|
||||||
|
private readonly ILogger<LndNode> _logger;
|
||||||
|
|
||||||
public LndNode(Config config)
|
public LndNode(Config config, ILogger<LndNode> logger)
|
||||||
{
|
{
|
||||||
|
_logger = logger;
|
||||||
_network = Network.GetNetwork(config.Network) ?? Network.RegTest;
|
_network = Network.GetNetwork(config.Network) ?? Network.RegTest;
|
||||||
var channelOptions = new GrpcChannelOptions();
|
var channelOptions = new GrpcChannelOptions();
|
||||||
ConfigureClient(channelOptions, config.Lnd);
|
ConfigureClient(channelOptions, config.Lnd);
|
||||||
@ -28,7 +30,7 @@ public class LndNode
|
|||||||
public Lightning.LightningClient LightningClient { get; }
|
public Lightning.LightningClient LightningClient { get; }
|
||||||
|
|
||||||
public Router.RouterClient RouterClient { get; }
|
public Router.RouterClient RouterClient { get; }
|
||||||
|
|
||||||
public Invoicesrpc.Invoices.InvoicesClient InvoicesClient { get; }
|
public Invoicesrpc.Invoices.InvoicesClient InvoicesClient { get; }
|
||||||
|
|
||||||
public async Task<AddInvoiceResponse> AddInvoice(ulong mSats, TimeSpan? expire = null, string? memo = null,
|
public async Task<AddInvoiceResponse> AddInvoice(ulong mSats, TimeSpan? expire = null, string? memo = null,
|
||||||
@ -121,7 +123,7 @@ public class LndNode
|
|||||||
throw new InvalidOperationException("CLTV delta too high");
|
throw new InvalidOperationException("CLTV delta too high");
|
||||||
}
|
}
|
||||||
|
|
||||||
var knownBits = new[] {8, 9, 14, 15, 16, 17};
|
var knownBits = new[] { 8, 9, 14, 15, 16, 17 };
|
||||||
for (var x = 0; x < 64; x++)
|
for (var x = 0; x < 64; x++)
|
||||||
{
|
{
|
||||||
var n = 1L << x;
|
var n = 1L << x;
|
||||||
@ -152,26 +154,33 @@ public class LndNode
|
|||||||
return await InvoicesClient.AddHoldInvoiceAsync(req);
|
return await InvoicesClient.AddHoldInvoiceAsync(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ConfigureClient(GrpcChannelOptions opt, LndConfig conf)
|
private void ConfigureClient(GrpcChannelOptions opt, LndConfig conf)
|
||||||
{
|
{
|
||||||
var macaroon = File.ReadAllBytes(Environment.ExpandEnvironmentVariables(conf.MacaroonPath));
|
try
|
||||||
var cert = File.ReadAllBytes(Environment.ExpandEnvironmentVariables(conf.CertPath));
|
|
||||||
|
|
||||||
var asyncInterceptor = new AsyncAuthInterceptor((_, meta) =>
|
|
||||||
{
|
{
|
||||||
meta.Add("macaroon", Convert.ToHexString(macaroon));
|
var macaroon = File.ReadAllBytes(Environment.ExpandEnvironmentVariables(conf.MacaroonPath));
|
||||||
return Task.CompletedTask;
|
var cert = File.ReadAllBytes(Environment.ExpandEnvironmentVariables(conf.CertPath));
|
||||||
});
|
|
||||||
|
|
||||||
var httpHandler = new HttpClientHandler();
|
var asyncInterceptor = new AsyncAuthInterceptor((_, meta) =>
|
||||||
httpHandler.ServerCertificateCustomValidationCallback = (_, certificate2, _, _) =>
|
{
|
||||||
|
meta.Add("macaroon", Convert.ToHexString(macaroon));
|
||||||
|
return Task.CompletedTask;
|
||||||
|
});
|
||||||
|
|
||||||
|
var httpHandler = new HttpClientHandler();
|
||||||
|
httpHandler.ServerCertificateCustomValidationCallback = (_, certificate2, _, _) =>
|
||||||
|
{
|
||||||
|
var serverCert = new X509Certificate2(cert);
|
||||||
|
return certificate2!.Thumbprint == serverCert.Thumbprint;
|
||||||
|
};
|
||||||
|
|
||||||
|
opt.HttpHandler = httpHandler;
|
||||||
|
opt.Credentials = ChannelCredentials.Create(ChannelCredentials.SecureSsl,
|
||||||
|
CallCredentials.FromInterceptor(asyncInterceptor));
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
var serverCert = new X509Certificate2(cert);
|
_logger.LogError(ex, "Configure failed");
|
||||||
return certificate2!.Thumbprint == serverCert.Thumbprint;
|
}
|
||||||
};
|
|
||||||
|
|
||||||
opt.HttpHandler = httpHandler;
|
|
||||||
opt.Credentials = ChannelCredentials.Create(ChannelCredentials.SecureSsl,
|
|
||||||
CallCredentials.FromInterceptor(asyncInterceptor));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,7 +4,7 @@ services:
|
|||||||
srs-origin:
|
srs-origin:
|
||||||
image: ossrs/srs:5
|
image: ossrs/srs:5
|
||||||
volumes:
|
volumes:
|
||||||
- "./docker/srs-origin.conf:/usr/local/srs/conf/srs.conf"
|
- "./docker/srs-origin.conf:/usr/local/srs/conf/docker.conf"
|
||||||
ports:
|
ports:
|
||||||
- "9001:1935"
|
- "9001:1935"
|
||||||
- "9002:1985"
|
- "9002:1985"
|
||||||
@ -13,7 +13,7 @@ services:
|
|||||||
srs-edge:
|
srs-edge:
|
||||||
image: ossrs/srs:5
|
image: ossrs/srs:5
|
||||||
volumes:
|
volumes:
|
||||||
- "./docker/srs-edge.conf:/usr/local/srs/conf/srs.conf"
|
- "./docker/srs-edge.conf:/usr/local/srs/conf/docker.conf"
|
||||||
ports:
|
ports:
|
||||||
- "9005:1935"
|
- "9005:1935"
|
||||||
- "1985:1985"
|
- "1985:1985"
|
||||||
@ -42,4 +42,8 @@ services:
|
|||||||
- "9010:9000"
|
- "9010:9000"
|
||||||
- "9011:9001"
|
- "9011:9001"
|
||||||
volumes:
|
volumes:
|
||||||
- "minio-dvr:/data"
|
- "minio-dvr:/data"
|
||||||
|
redis:
|
||||||
|
image: redis
|
||||||
|
ports:
|
||||||
|
- "6666:6379"
|
@ -118,6 +118,6 @@ vhost full.in.zap.stream {
|
|||||||
vhost __defaultVhost__ {
|
vhost __defaultVhost__ {
|
||||||
forward {
|
forward {
|
||||||
enabled on;
|
enabled on;
|
||||||
backend http://10.100.2.226:5295/api/srs;
|
backend http://host.docker.internal:5295/api/srs;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -32,10 +32,10 @@ vhost hls.zap.stream {
|
|||||||
|
|
||||||
http_hooks {
|
http_hooks {
|
||||||
enabled on;
|
enabled on;
|
||||||
on_publish http://10.100.2.226:5295/api/srs;
|
on_publish http://host.docker.internal:5295/api/srs;
|
||||||
on_unpublish http://10.100.2.226:5295/api/srs;
|
on_unpublish http://host.docker.internal:5295/api/srs;
|
||||||
on_hls http://10.100.2.226:5295/api/srs;
|
on_hls http://host.docker.internal:5295/api/srs;
|
||||||
on_dvr http://10.100.2.226:5295/api/srs;
|
on_dvr http://host.docker.internal:5295/api/srs;
|
||||||
}
|
}
|
||||||
|
|
||||||
dvr {
|
dvr {
|
||||||
|
Reference in New Issue
Block a user