mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
Merge pull request #10574 from barronpm/dlna-plugin3
Move DLNA to Plugin (Part 1 (Part 2))
This commit is contained in:
commit
3ec2d5592e
@ -9,8 +9,6 @@ using System.Threading;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Emby.Dlna.PlayTo;
|
using Emby.Dlna.PlayTo;
|
||||||
using Emby.Dlna.Ssdp;
|
using Emby.Dlna.Ssdp;
|
||||||
using Jellyfin.Networking.Configuration;
|
|
||||||
using Jellyfin.Networking.Extensions;
|
|
||||||
using MediaBrowser.Common.Configuration;
|
using MediaBrowser.Common.Configuration;
|
||||||
using MediaBrowser.Common.Extensions;
|
using MediaBrowser.Common.Extensions;
|
||||||
using MediaBrowser.Common.Net;
|
using MediaBrowser.Common.Net;
|
||||||
@ -280,7 +278,7 @@ public sealed class DlnaHost : IHostedService, IDisposable
|
|||||||
CacheLifetime = TimeSpan.FromSeconds(1800), // How long SSDP clients can cache this info.
|
CacheLifetime = TimeSpan.FromSeconds(1800), // How long SSDP clients can cache this info.
|
||||||
Location = uri.Uri, // Must point to the URL that serves your devices UPnP description document.
|
Location = uri.Uri, // Must point to the URL that serves your devices UPnP description document.
|
||||||
Address = intf.Address,
|
Address = intf.Address,
|
||||||
PrefixLength = NetworkExtensions.MaskToCidr(intf.Subnet.Prefix),
|
PrefixLength = NetworkUtils.MaskToCidr(intf.Subnet.Prefix),
|
||||||
FriendlyName = "Jellyfin",
|
FriendlyName = "Jellyfin",
|
||||||
Manufacturer = "Jellyfin",
|
Manufacturer = "Jellyfin",
|
||||||
ModelName = "Jellyfin Server",
|
ModelName = "Jellyfin Server",
|
||||||
|
@ -41,7 +41,6 @@ using Emby.Server.Implementations.Updates;
|
|||||||
using Jellyfin.Api.Helpers;
|
using Jellyfin.Api.Helpers;
|
||||||
using Jellyfin.Drawing;
|
using Jellyfin.Drawing;
|
||||||
using Jellyfin.MediaEncoding.Hls.Playlist;
|
using Jellyfin.MediaEncoding.Hls.Playlist;
|
||||||
using Jellyfin.Networking.Configuration;
|
|
||||||
using Jellyfin.Networking.Manager;
|
using Jellyfin.Networking.Manager;
|
||||||
using Jellyfin.Server.Implementations;
|
using Jellyfin.Server.Implementations;
|
||||||
using MediaBrowser.Common;
|
using MediaBrowser.Common;
|
||||||
|
@ -9,7 +9,7 @@ using System.Net;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Jellyfin.Networking.Configuration;
|
using MediaBrowser.Common.Net;
|
||||||
using MediaBrowser.Controller;
|
using MediaBrowser.Controller;
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
using MediaBrowser.Controller.Plugins;
|
using MediaBrowser.Controller.Plugins;
|
||||||
|
@ -6,8 +6,6 @@ using System.Net.Sockets;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Emby.Server.Implementations.Udp;
|
using Emby.Server.Implementations.Udp;
|
||||||
using Jellyfin.Networking.Configuration;
|
|
||||||
using Jellyfin.Networking.Extensions;
|
|
||||||
using MediaBrowser.Common.Configuration;
|
using MediaBrowser.Common.Configuration;
|
||||||
using MediaBrowser.Common.Net;
|
using MediaBrowser.Common.Net;
|
||||||
using MediaBrowser.Controller;
|
using MediaBrowser.Controller;
|
||||||
@ -92,7 +90,7 @@ namespace Emby.Server.Implementations.EntryPoints
|
|||||||
var validInterfaces = _networkManager.GetInternalBindAddresses().Where(i => i.AddressFamily == AddressFamily.InterNetwork);
|
var validInterfaces = _networkManager.GetInternalBindAddresses().Where(i => i.AddressFamily == AddressFamily.InterNetwork);
|
||||||
foreach (var intf in validInterfaces)
|
foreach (var intf in validInterfaces)
|
||||||
{
|
{
|
||||||
var broadcastAddress = NetworkExtensions.GetBroadcastAddress(intf.Subnet);
|
var broadcastAddress = NetworkUtils.GetBroadcastAddress(intf.Subnet);
|
||||||
_logger.LogDebug("Binding UDP server to {Address} on port {PortNumber}", broadcastAddress, PortNumber);
|
_logger.LogDebug("Binding UDP server to {Address} on port {PortNumber}", broadcastAddress, PortNumber);
|
||||||
|
|
||||||
server = new UdpServer(_logger, _appHost, _config, broadcastAddress, PortNumber);
|
server = new UdpServer(_logger, _appHost, _config, broadcastAddress, PortNumber);
|
||||||
|
@ -2,6 +2,7 @@ using System;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Jellyfin.Api.Constants;
|
using Jellyfin.Api.Constants;
|
||||||
using Jellyfin.Data.Queries;
|
using Jellyfin.Data.Queries;
|
||||||
|
using MediaBrowser.Common.Api;
|
||||||
using MediaBrowser.Model.Activity;
|
using MediaBrowser.Model.Activity;
|
||||||
using MediaBrowser.Model.Querying;
|
using MediaBrowser.Model.Querying;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Jellyfin.Api.Constants;
|
using Jellyfin.Api.Constants;
|
||||||
|
using MediaBrowser.Common.Api;
|
||||||
using MediaBrowser.Controller.Security;
|
using MediaBrowser.Controller.Security;
|
||||||
using MediaBrowser.Model.Querying;
|
using MediaBrowser.Model.Querying;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
@ -4,6 +4,7 @@ using System.Threading.Tasks;
|
|||||||
using Jellyfin.Api.Constants;
|
using Jellyfin.Api.Constants;
|
||||||
using Jellyfin.Api.Extensions;
|
using Jellyfin.Api.Extensions;
|
||||||
using Jellyfin.Api.ModelBinders;
|
using Jellyfin.Api.ModelBinders;
|
||||||
|
using MediaBrowser.Common.Api;
|
||||||
using MediaBrowser.Controller.Collections;
|
using MediaBrowser.Controller.Collections;
|
||||||
using MediaBrowser.Controller.Dto;
|
using MediaBrowser.Controller.Dto;
|
||||||
using MediaBrowser.Model.Collections;
|
using MediaBrowser.Model.Collections;
|
||||||
|
@ -6,6 +6,7 @@ using Jellyfin.Api.Attributes;
|
|||||||
using Jellyfin.Api.Constants;
|
using Jellyfin.Api.Constants;
|
||||||
using Jellyfin.Api.Models.ConfigurationDtos;
|
using Jellyfin.Api.Models.ConfigurationDtos;
|
||||||
using Jellyfin.Extensions.Json;
|
using Jellyfin.Extensions.Json;
|
||||||
|
using MediaBrowser.Common.Api;
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
using MediaBrowser.Controller.MediaEncoding;
|
using MediaBrowser.Controller.MediaEncoding;
|
||||||
using MediaBrowser.Model.Configuration;
|
using MediaBrowser.Model.Configuration;
|
||||||
|
@ -6,6 +6,7 @@ using Jellyfin.Api.Helpers;
|
|||||||
using Jellyfin.Data.Dtos;
|
using Jellyfin.Data.Dtos;
|
||||||
using Jellyfin.Data.Entities.Security;
|
using Jellyfin.Data.Entities.Security;
|
||||||
using Jellyfin.Data.Queries;
|
using Jellyfin.Data.Queries;
|
||||||
|
using MediaBrowser.Common.Api;
|
||||||
using MediaBrowser.Controller.Devices;
|
using MediaBrowser.Controller.Devices;
|
||||||
using MediaBrowser.Controller.Session;
|
using MediaBrowser.Controller.Session;
|
||||||
using MediaBrowser.Model.Devices;
|
using MediaBrowser.Model.Devices;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using Jellyfin.Api.Constants;
|
using Jellyfin.Api.Constants;
|
||||||
|
using MediaBrowser.Common.Api;
|
||||||
using MediaBrowser.Controller.Dlna;
|
using MediaBrowser.Controller.Dlna;
|
||||||
using MediaBrowser.Model.Dlna;
|
using MediaBrowser.Model.Dlna;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
@ -7,6 +7,7 @@ using System.Threading.Tasks;
|
|||||||
using Emby.Dlna;
|
using Emby.Dlna;
|
||||||
using Jellyfin.Api.Attributes;
|
using Jellyfin.Api.Attributes;
|
||||||
using Jellyfin.Api.Constants;
|
using Jellyfin.Api.Constants;
|
||||||
|
using MediaBrowser.Common.Api;
|
||||||
using MediaBrowser.Controller.Dlna;
|
using MediaBrowser.Controller.Dlna;
|
||||||
using MediaBrowser.Model.Net;
|
using MediaBrowser.Model.Net;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
@ -5,6 +5,7 @@ using System.IO;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Jellyfin.Api.Constants;
|
using Jellyfin.Api.Constants;
|
||||||
using Jellyfin.Api.Models.EnvironmentDtos;
|
using Jellyfin.Api.Models.EnvironmentDtos;
|
||||||
|
using MediaBrowser.Common.Api;
|
||||||
using MediaBrowser.Common.Extensions;
|
using MediaBrowser.Common.Extensions;
|
||||||
using MediaBrowser.Model.IO;
|
using MediaBrowser.Model.IO;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
@ -13,6 +13,7 @@ using System.Threading.Tasks;
|
|||||||
using Jellyfin.Api.Attributes;
|
using Jellyfin.Api.Attributes;
|
||||||
using Jellyfin.Api.Constants;
|
using Jellyfin.Api.Constants;
|
||||||
using Jellyfin.Api.Helpers;
|
using Jellyfin.Api.Helpers;
|
||||||
|
using MediaBrowser.Common.Api;
|
||||||
using MediaBrowser.Common.Configuration;
|
using MediaBrowser.Common.Configuration;
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
using MediaBrowser.Controller.Drawing;
|
using MediaBrowser.Controller.Drawing;
|
||||||
|
@ -4,6 +4,7 @@ using System.ComponentModel.DataAnnotations;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Jellyfin.Api.Constants;
|
using Jellyfin.Api.Constants;
|
||||||
|
using MediaBrowser.Common.Api;
|
||||||
using MediaBrowser.Controller.Entities;
|
using MediaBrowser.Controller.Entities;
|
||||||
using MediaBrowser.Controller.Entities.Audio;
|
using MediaBrowser.Controller.Entities.Audio;
|
||||||
using MediaBrowser.Controller.Entities.Movies;
|
using MediaBrowser.Controller.Entities.Movies;
|
||||||
|
@ -2,6 +2,7 @@ using System;
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using Jellyfin.Api.Constants;
|
using Jellyfin.Api.Constants;
|
||||||
|
using MediaBrowser.Common.Api;
|
||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Controller.Providers;
|
using MediaBrowser.Controller.Providers;
|
||||||
using MediaBrowser.Model.IO;
|
using MediaBrowser.Model.IO;
|
||||||
|
@ -6,6 +6,7 @@ using System.Threading;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Jellyfin.Api.Constants;
|
using Jellyfin.Api.Constants;
|
||||||
using Jellyfin.Data.Enums;
|
using Jellyfin.Data.Enums;
|
||||||
|
using MediaBrowser.Common.Api;
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
using MediaBrowser.Controller.Entities;
|
using MediaBrowser.Controller.Entities;
|
||||||
using MediaBrowser.Controller.Entities.Audio;
|
using MediaBrowser.Controller.Entities.Audio;
|
||||||
|
@ -15,6 +15,7 @@ using Jellyfin.Api.Models.LibraryDtos;
|
|||||||
using Jellyfin.Data.Entities;
|
using Jellyfin.Data.Entities;
|
||||||
using Jellyfin.Data.Enums;
|
using Jellyfin.Data.Enums;
|
||||||
using Jellyfin.Extensions;
|
using Jellyfin.Extensions;
|
||||||
|
using MediaBrowser.Common.Api;
|
||||||
using MediaBrowser.Common.Extensions;
|
using MediaBrowser.Common.Extensions;
|
||||||
using MediaBrowser.Common.Progress;
|
using MediaBrowser.Common.Progress;
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
|
@ -9,6 +9,7 @@ using System.Threading.Tasks;
|
|||||||
using Jellyfin.Api.Constants;
|
using Jellyfin.Api.Constants;
|
||||||
using Jellyfin.Api.ModelBinders;
|
using Jellyfin.Api.ModelBinders;
|
||||||
using Jellyfin.Api.Models.LibraryStructureDto;
|
using Jellyfin.Api.Models.LibraryStructureDto;
|
||||||
|
using MediaBrowser.Common.Api;
|
||||||
using MediaBrowser.Common.Progress;
|
using MediaBrowser.Common.Progress;
|
||||||
using MediaBrowser.Controller;
|
using MediaBrowser.Controller;
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
|
@ -16,6 +16,7 @@ using Jellyfin.Api.Helpers;
|
|||||||
using Jellyfin.Api.ModelBinders;
|
using Jellyfin.Api.ModelBinders;
|
||||||
using Jellyfin.Api.Models.LiveTvDtos;
|
using Jellyfin.Api.Models.LiveTvDtos;
|
||||||
using Jellyfin.Data.Enums;
|
using Jellyfin.Data.Enums;
|
||||||
|
using MediaBrowser.Common.Api;
|
||||||
using MediaBrowser.Common.Configuration;
|
using MediaBrowser.Common.Configuration;
|
||||||
using MediaBrowser.Common.Net;
|
using MediaBrowser.Common.Net;
|
||||||
using MediaBrowser.Controller.Dto;
|
using MediaBrowser.Controller.Dto;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Jellyfin.Api.Constants;
|
using Jellyfin.Api.Constants;
|
||||||
|
using MediaBrowser.Common.Api;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
using MediaBrowser.Model.Globalization;
|
using MediaBrowser.Model.Globalization;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
@ -4,6 +4,7 @@ using System.ComponentModel.DataAnnotations;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Jellyfin.Api.Constants;
|
using Jellyfin.Api.Constants;
|
||||||
|
using MediaBrowser.Common.Api;
|
||||||
using MediaBrowser.Common.Updates;
|
using MediaBrowser.Common.Updates;
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
using MediaBrowser.Model.Updates;
|
using MediaBrowser.Model.Updates;
|
||||||
|
@ -8,6 +8,7 @@ using System.Threading.Tasks;
|
|||||||
using Jellyfin.Api.Attributes;
|
using Jellyfin.Api.Attributes;
|
||||||
using Jellyfin.Api.Constants;
|
using Jellyfin.Api.Constants;
|
||||||
using Jellyfin.Extensions.Json;
|
using Jellyfin.Extensions.Json;
|
||||||
|
using MediaBrowser.Common.Api;
|
||||||
using MediaBrowser.Common.Plugins;
|
using MediaBrowser.Common.Plugins;
|
||||||
using MediaBrowser.Common.Updates;
|
using MediaBrowser.Common.Updates;
|
||||||
using MediaBrowser.Model.Net;
|
using MediaBrowser.Model.Net;
|
||||||
|
@ -6,6 +6,7 @@ using System.Linq;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Jellyfin.Api.Constants;
|
using Jellyfin.Api.Constants;
|
||||||
|
using MediaBrowser.Common.Api;
|
||||||
using MediaBrowser.Controller;
|
using MediaBrowser.Controller;
|
||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Controller.Providers;
|
using MediaBrowser.Controller.Providers;
|
||||||
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Jellyfin.Api.Constants;
|
using Jellyfin.Api.Constants;
|
||||||
|
using MediaBrowser.Common.Api;
|
||||||
using MediaBrowser.Model.Tasks;
|
using MediaBrowser.Model.Tasks;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
|
@ -10,6 +10,7 @@ using Jellyfin.Api.Helpers;
|
|||||||
using Jellyfin.Api.ModelBinders;
|
using Jellyfin.Api.ModelBinders;
|
||||||
using Jellyfin.Api.Models.SessionDtos;
|
using Jellyfin.Api.Models.SessionDtos;
|
||||||
using Jellyfin.Data.Enums;
|
using Jellyfin.Data.Enums;
|
||||||
|
using MediaBrowser.Common.Api;
|
||||||
using MediaBrowser.Controller.Devices;
|
using MediaBrowser.Controller.Devices;
|
||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Controller.Session;
|
using MediaBrowser.Controller.Session;
|
||||||
|
@ -3,7 +3,8 @@ using System.Linq;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Jellyfin.Api.Constants;
|
using Jellyfin.Api.Constants;
|
||||||
using Jellyfin.Api.Models.StartupDtos;
|
using Jellyfin.Api.Models.StartupDtos;
|
||||||
using Jellyfin.Networking.Configuration;
|
using MediaBrowser.Common.Api;
|
||||||
|
using MediaBrowser.Common.Net;
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
@ -14,6 +14,7 @@ using Jellyfin.Api.Attributes;
|
|||||||
using Jellyfin.Api.Constants;
|
using Jellyfin.Api.Constants;
|
||||||
using Jellyfin.Api.Extensions;
|
using Jellyfin.Api.Extensions;
|
||||||
using Jellyfin.Api.Models.SubtitleDtos;
|
using Jellyfin.Api.Models.SubtitleDtos;
|
||||||
|
using MediaBrowser.Common.Api;
|
||||||
using MediaBrowser.Common.Configuration;
|
using MediaBrowser.Common.Configuration;
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
using MediaBrowser.Controller.Entities;
|
using MediaBrowser.Controller.Entities;
|
||||||
|
@ -6,6 +6,7 @@ using System.Threading.Tasks;
|
|||||||
using Jellyfin.Api.Constants;
|
using Jellyfin.Api.Constants;
|
||||||
using Jellyfin.Api.Helpers;
|
using Jellyfin.Api.Helpers;
|
||||||
using Jellyfin.Api.Models.SyncPlayDtos;
|
using Jellyfin.Api.Models.SyncPlayDtos;
|
||||||
|
using MediaBrowser.Common.Api;
|
||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Controller.Session;
|
using MediaBrowser.Controller.Session;
|
||||||
using MediaBrowser.Controller.SyncPlay;
|
using MediaBrowser.Controller.SyncPlay;
|
||||||
|
@ -6,6 +6,7 @@ using System.Linq;
|
|||||||
using System.Net.Mime;
|
using System.Net.Mime;
|
||||||
using Jellyfin.Api.Attributes;
|
using Jellyfin.Api.Attributes;
|
||||||
using Jellyfin.Api.Constants;
|
using Jellyfin.Api.Constants;
|
||||||
|
using MediaBrowser.Common.Api;
|
||||||
using MediaBrowser.Common.Configuration;
|
using MediaBrowser.Common.Configuration;
|
||||||
using MediaBrowser.Common.Extensions;
|
using MediaBrowser.Common.Extensions;
|
||||||
using MediaBrowser.Common.Net;
|
using MediaBrowser.Common.Net;
|
||||||
|
@ -8,6 +8,7 @@ using Jellyfin.Api.Extensions;
|
|||||||
using Jellyfin.Api.Helpers;
|
using Jellyfin.Api.Helpers;
|
||||||
using Jellyfin.Api.Models.UserDtos;
|
using Jellyfin.Api.Models.UserDtos;
|
||||||
using Jellyfin.Data.Enums;
|
using Jellyfin.Data.Enums;
|
||||||
|
using MediaBrowser.Common.Api;
|
||||||
using MediaBrowser.Common.Extensions;
|
using MediaBrowser.Common.Extensions;
|
||||||
using MediaBrowser.Common.Net;
|
using MediaBrowser.Common.Net;
|
||||||
using MediaBrowser.Controller.Authentication;
|
using MediaBrowser.Controller.Authentication;
|
||||||
|
@ -12,6 +12,7 @@ using Jellyfin.Api.Extensions;
|
|||||||
using Jellyfin.Api.Helpers;
|
using Jellyfin.Api.Helpers;
|
||||||
using Jellyfin.Api.ModelBinders;
|
using Jellyfin.Api.ModelBinders;
|
||||||
using Jellyfin.Api.Models.StreamingDtos;
|
using Jellyfin.Api.Models.StreamingDtos;
|
||||||
|
using MediaBrowser.Common.Api;
|
||||||
using MediaBrowser.Common.Configuration;
|
using MediaBrowser.Common.Configuration;
|
||||||
using MediaBrowser.Common.Net;
|
using MediaBrowser.Common.Net;
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Jellyfin.Networking.Configuration;
|
using MediaBrowser.Common.Net;
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Jellyfin.Networking.Configuration;
|
|
||||||
using MediaBrowser.Common.Extensions;
|
using MediaBrowser.Common.Extensions;
|
||||||
using MediaBrowser.Common.Net;
|
using MediaBrowser.Common.Net;
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
|
@ -1,176 +0,0 @@
|
|||||||
#pragma warning disable CA1819 // Properties should not return arrays
|
|
||||||
|
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace Jellyfin.Networking.Configuration
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Defines the <see cref="NetworkConfiguration" />.
|
|
||||||
/// </summary>
|
|
||||||
public class NetworkConfiguration
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// The default value for <see cref="InternalHttpPort"/>.
|
|
||||||
/// </summary>
|
|
||||||
public const int DefaultHttpPort = 8096;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The default value for <see cref="PublicHttpsPort"/> and <see cref="InternalHttpsPort"/>.
|
|
||||||
/// </summary>
|
|
||||||
public const int DefaultHttpsPort = 8920;
|
|
||||||
|
|
||||||
private string _baseUrl = string.Empty;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets a value used to specify the URL prefix that your Jellyfin instance can be accessed at.
|
|
||||||
/// </summary>
|
|
||||||
public string BaseUrl
|
|
||||||
{
|
|
||||||
get => _baseUrl;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
// Normalize the start of the string
|
|
||||||
if (string.IsNullOrWhiteSpace(value))
|
|
||||||
{
|
|
||||||
// If baseUrl is empty, set an empty prefix string
|
|
||||||
_baseUrl = string.Empty;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (value[0] != '/')
|
|
||||||
{
|
|
||||||
// If baseUrl was not configured with a leading slash, append one for consistency
|
|
||||||
value = "/" + value;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Normalize the end of the string
|
|
||||||
if (value[^1] == '/')
|
|
||||||
{
|
|
||||||
// If baseUrl was configured with a trailing slash, remove it for consistency
|
|
||||||
value = value.Remove(value.Length - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
_baseUrl = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets a value indicating whether to use HTTPS.
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>
|
|
||||||
/// In order for HTTPS to be used, in addition to setting this to true, valid values must also be
|
|
||||||
/// provided for <see cref="CertificatePath"/> and <see cref="CertificatePassword"/>.
|
|
||||||
/// </remarks>
|
|
||||||
public bool EnableHttps { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets a value indicating whether the server should force connections over HTTPS.
|
|
||||||
/// </summary>
|
|
||||||
public bool RequireHttps { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the filesystem path of an X.509 certificate to use for SSL.
|
|
||||||
/// </summary>
|
|
||||||
public string CertificatePath { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the password required to access the X.509 certificate data in the file specified by <see cref="CertificatePath"/>.
|
|
||||||
/// </summary>
|
|
||||||
public string CertificatePassword { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the internal HTTP server port.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The HTTP server port.</value>
|
|
||||||
public int InternalHttpPort { get; set; } = DefaultHttpPort;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the internal HTTPS server port.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The HTTPS server port.</value>
|
|
||||||
public int InternalHttpsPort { get; set; } = DefaultHttpsPort;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the public HTTP port.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The public HTTP port.</value>
|
|
||||||
public int PublicHttpPort { get; set; } = DefaultHttpPort;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the public HTTPS port.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The public HTTPS port.</value>
|
|
||||||
public int PublicHttpsPort { get; set; } = DefaultHttpsPort;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets a value indicating whether Autodiscovery is enabled.
|
|
||||||
/// </summary>
|
|
||||||
public bool AutoDiscovery { get; set; } = true;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets a value indicating whether to enable automatic port forwarding.
|
|
||||||
/// </summary>
|
|
||||||
public bool EnableUPnP { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets a value indicating whether IPv6 is enabled.
|
|
||||||
/// </summary>
|
|
||||||
public bool EnableIPv4 { get; set; } = true;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets a value indicating whether IPv6 is enabled.
|
|
||||||
/// </summary>
|
|
||||||
public bool EnableIPv6 { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets a value indicating whether access from outside of the LAN is permitted.
|
|
||||||
/// </summary>
|
|
||||||
public bool EnableRemoteAccess { get; set; } = true;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the subnets that are deemed to make up the LAN.
|
|
||||||
/// </summary>
|
|
||||||
public string[] LocalNetworkSubnets { get; set; } = Array.Empty<string>();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the interface addresses which Jellyfin will bind to. If empty, all interfaces will be used.
|
|
||||||
/// </summary>
|
|
||||||
public string[] LocalNetworkAddresses { get; set; } = Array.Empty<string>();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the known proxies.
|
|
||||||
/// </summary>
|
|
||||||
public string[] KnownProxies { get; set; } = Array.Empty<string>();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets a value indicating whether address names that match <see cref="VirtualInterfaceNames"/> should be ignored for the purposes of binding.
|
|
||||||
/// </summary>
|
|
||||||
public bool IgnoreVirtualInterfaces { get; set; } = true;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets a value indicating the interface name prefixes that should be ignored. The list can be comma separated and values are case-insensitive. <seealso cref="IgnoreVirtualInterfaces"/>.
|
|
||||||
/// </summary>
|
|
||||||
public string[] VirtualInterfaceNames { get; set; } = new string[] { "veth" };
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets a value indicating whether the published server uri is based on information in HTTP requests.
|
|
||||||
/// </summary>
|
|
||||||
public bool EnablePublishedServerUriByRequest { get; set; } = false;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the PublishedServerUriBySubnet
|
|
||||||
/// Gets or sets PublishedServerUri to advertise for specific subnets.
|
|
||||||
/// </summary>
|
|
||||||
public string[] PublishedServerUriBySubnet { get; set; } = Array.Empty<string>();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the filter for remote IP connectivity. Used in conjunction with <seealso cref="IsRemoteIPFilterBlacklist"/>.
|
|
||||||
/// </summary>
|
|
||||||
public string[] RemoteIPFilter { get; set; } = Array.Empty<string>();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets a value indicating whether <seealso cref="RemoteIPFilter"/> contains a blacklist or a whitelist. Default is a whitelist.
|
|
||||||
/// </summary>
|
|
||||||
public bool IsRemoteIPFilterBlacklist { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
using MediaBrowser.Common.Configuration;
|
|
||||||
|
|
||||||
namespace Jellyfin.Networking.Configuration
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Defines the <see cref="NetworkConfigurationExtensions" />.
|
|
||||||
/// </summary>
|
|
||||||
public static class NetworkConfigurationExtensions
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Retrieves the network configuration.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="config">The <see cref="IConfigurationManager"/>.</param>
|
|
||||||
/// <returns>The <see cref="NetworkConfiguration"/>.</returns>
|
|
||||||
public static NetworkConfiguration GetNetworkConfiguration(this IConfigurationManager config)
|
|
||||||
{
|
|
||||||
return config.GetConfiguration<NetworkConfiguration>(NetworkConfigurationStore.StoreKey);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using MediaBrowser.Common.Configuration;
|
|
||||||
|
|
||||||
namespace Jellyfin.Networking.Configuration
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Defines the <see cref="NetworkConfigurationFactory" />.
|
|
||||||
/// </summary>
|
|
||||||
public class NetworkConfigurationFactory : IConfigurationFactory
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// The GetConfigurations.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>The <see cref="IEnumerable{ConfigurationStore}"/>.</returns>
|
|
||||||
public IEnumerable<ConfigurationStore> GetConfigurations()
|
|
||||||
{
|
|
||||||
return new[]
|
|
||||||
{
|
|
||||||
new NetworkConfigurationStore()
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,24 +0,0 @@
|
|||||||
using MediaBrowser.Common.Configuration;
|
|
||||||
|
|
||||||
namespace Jellyfin.Networking.Configuration
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// A configuration that stores network related settings.
|
|
||||||
/// </summary>
|
|
||||||
public class NetworkConfigurationStore : ConfigurationStore
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// The name of the configuration in the storage.
|
|
||||||
/// </summary>
|
|
||||||
public const string StoreKey = "network";
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="NetworkConfigurationStore"/> class.
|
|
||||||
/// </summary>
|
|
||||||
public NetworkConfigurationStore()
|
|
||||||
{
|
|
||||||
ConfigurationType = typeof(NetworkConfiguration);
|
|
||||||
Key = StoreKey;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -7,9 +7,6 @@ using System.Net;
|
|||||||
using System.Net.NetworkInformation;
|
using System.Net.NetworkInformation;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using Jellyfin.Networking.Configuration;
|
|
||||||
using Jellyfin.Networking.Constants;
|
|
||||||
using Jellyfin.Networking.Extensions;
|
|
||||||
using MediaBrowser.Common.Configuration;
|
using MediaBrowser.Common.Configuration;
|
||||||
using MediaBrowser.Common.Net;
|
using MediaBrowser.Common.Net;
|
||||||
using MediaBrowser.Model.Net;
|
using MediaBrowser.Model.Net;
|
||||||
@ -289,12 +286,12 @@ namespace Jellyfin.Networking.Manager
|
|||||||
|
|
||||||
if (IsIPv4Enabled)
|
if (IsIPv4Enabled)
|
||||||
{
|
{
|
||||||
interfaces.Add(new IPData(IPAddress.Loopback, Network.IPv4RFC5735Loopback, "lo"));
|
interfaces.Add(new IPData(IPAddress.Loopback, NetworkConstants.IPv4RFC5735Loopback, "lo"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsIPv6Enabled)
|
if (IsIPv6Enabled)
|
||||||
{
|
{
|
||||||
interfaces.Add(new IPData(IPAddress.IPv6Loopback, Network.IPv6RFC4291Loopback, "lo"));
|
interfaces.Add(new IPData(IPAddress.IPv6Loopback, NetworkConstants.IPv6RFC4291Loopback, "lo"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -319,24 +316,24 @@ namespace Jellyfin.Networking.Manager
|
|||||||
var subnets = config.LocalNetworkSubnets;
|
var subnets = config.LocalNetworkSubnets;
|
||||||
|
|
||||||
// If no LAN addresses are specified, all private subnets and Loopback are deemed to be the LAN
|
// If no LAN addresses are specified, all private subnets and Loopback are deemed to be the LAN
|
||||||
if (!NetworkExtensions.TryParseToSubnets(subnets, out var lanSubnets, false) || lanSubnets.Count == 0)
|
if (!NetworkUtils.TryParseToSubnets(subnets, out var lanSubnets, false) || lanSubnets.Count == 0)
|
||||||
{
|
{
|
||||||
_logger.LogDebug("Using LAN interface addresses as user provided no LAN details.");
|
_logger.LogDebug("Using LAN interface addresses as user provided no LAN details.");
|
||||||
|
|
||||||
var fallbackLanSubnets = new List<IPNetwork>();
|
var fallbackLanSubnets = new List<IPNetwork>();
|
||||||
if (IsIPv6Enabled)
|
if (IsIPv6Enabled)
|
||||||
{
|
{
|
||||||
fallbackLanSubnets.Add(Network.IPv6RFC4291Loopback); // RFC 4291 (Loopback)
|
fallbackLanSubnets.Add(NetworkConstants.IPv6RFC4291Loopback); // RFC 4291 (Loopback)
|
||||||
fallbackLanSubnets.Add(Network.IPv6RFC4291SiteLocal); // RFC 4291 (Site local)
|
fallbackLanSubnets.Add(NetworkConstants.IPv6RFC4291SiteLocal); // RFC 4291 (Site local)
|
||||||
fallbackLanSubnets.Add(Network.IPv6RFC4193UniqueLocal); // RFC 4193 (Unique local)
|
fallbackLanSubnets.Add(NetworkConstants.IPv6RFC4193UniqueLocal); // RFC 4193 (Unique local)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsIPv4Enabled)
|
if (IsIPv4Enabled)
|
||||||
{
|
{
|
||||||
fallbackLanSubnets.Add(Network.IPv4RFC5735Loopback); // RFC 5735 (Loopback)
|
fallbackLanSubnets.Add(NetworkConstants.IPv4RFC5735Loopback); // RFC 5735 (Loopback)
|
||||||
fallbackLanSubnets.Add(Network.IPv4RFC1918PrivateClassA); // RFC 1918 (private Class A)
|
fallbackLanSubnets.Add(NetworkConstants.IPv4RFC1918PrivateClassA); // RFC 1918 (private Class A)
|
||||||
fallbackLanSubnets.Add(Network.IPv4RFC1918PrivateClassB); // RFC 1918 (private Class B)
|
fallbackLanSubnets.Add(NetworkConstants.IPv4RFC1918PrivateClassB); // RFC 1918 (private Class B)
|
||||||
fallbackLanSubnets.Add(Network.IPv4RFC1918PrivateClassC); // RFC 1918 (private Class C)
|
fallbackLanSubnets.Add(NetworkConstants.IPv4RFC1918PrivateClassC); // RFC 1918 (private Class C)
|
||||||
}
|
}
|
||||||
|
|
||||||
_lanSubnets = fallbackLanSubnets;
|
_lanSubnets = fallbackLanSubnets;
|
||||||
@ -346,7 +343,7 @@ namespace Jellyfin.Networking.Manager
|
|||||||
_lanSubnets = lanSubnets;
|
_lanSubnets = lanSubnets;
|
||||||
}
|
}
|
||||||
|
|
||||||
_excludedSubnets = NetworkExtensions.TryParseToSubnets(subnets, out var excludedSubnets, true)
|
_excludedSubnets = NetworkUtils.TryParseToSubnets(subnets, out var excludedSubnets, true)
|
||||||
? excludedSubnets
|
? excludedSubnets
|
||||||
: new List<IPNetwork>();
|
: new List<IPNetwork>();
|
||||||
}
|
}
|
||||||
@ -364,7 +361,7 @@ namespace Jellyfin.Networking.Manager
|
|||||||
var localNetworkAddresses = config.LocalNetworkAddresses;
|
var localNetworkAddresses = config.LocalNetworkAddresses;
|
||||||
if (localNetworkAddresses.Length > 0 && !string.IsNullOrWhiteSpace(localNetworkAddresses[0]))
|
if (localNetworkAddresses.Length > 0 && !string.IsNullOrWhiteSpace(localNetworkAddresses[0]))
|
||||||
{
|
{
|
||||||
var bindAddresses = localNetworkAddresses.Select(p => NetworkExtensions.TryParseToSubnet(p, out var network)
|
var bindAddresses = localNetworkAddresses.Select(p => NetworkUtils.TryParseToSubnet(p, out var network)
|
||||||
? network.Prefix
|
? network.Prefix
|
||||||
: (interfaces.Where(x => x.Name.Equals(p, StringComparison.OrdinalIgnoreCase))
|
: (interfaces.Where(x => x.Name.Equals(p, StringComparison.OrdinalIgnoreCase))
|
||||||
.Select(x => x.Address)
|
.Select(x => x.Address)
|
||||||
@ -375,12 +372,12 @@ namespace Jellyfin.Networking.Manager
|
|||||||
|
|
||||||
if (bindAddresses.Contains(IPAddress.Loopback) && !interfaces.Any(i => i.Address.Equals(IPAddress.Loopback)))
|
if (bindAddresses.Contains(IPAddress.Loopback) && !interfaces.Any(i => i.Address.Equals(IPAddress.Loopback)))
|
||||||
{
|
{
|
||||||
interfaces.Add(new IPData(IPAddress.Loopback, Network.IPv4RFC5735Loopback, "lo"));
|
interfaces.Add(new IPData(IPAddress.Loopback, NetworkConstants.IPv4RFC5735Loopback, "lo"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bindAddresses.Contains(IPAddress.IPv6Loopback) && !interfaces.Any(i => i.Address.Equals(IPAddress.IPv6Loopback)))
|
if (bindAddresses.Contains(IPAddress.IPv6Loopback) && !interfaces.Any(i => i.Address.Equals(IPAddress.IPv6Loopback)))
|
||||||
{
|
{
|
||||||
interfaces.Add(new IPData(IPAddress.IPv6Loopback, Network.IPv6RFC4291Loopback, "lo"));
|
interfaces.Add(new IPData(IPAddress.IPv6Loopback, NetworkConstants.IPv6RFC4291Loopback, "lo"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -431,7 +428,7 @@ namespace Jellyfin.Networking.Manager
|
|||||||
// Parse all IPs with netmask to a subnet
|
// Parse all IPs with netmask to a subnet
|
||||||
var remoteAddressFilter = new List<IPNetwork>();
|
var remoteAddressFilter = new List<IPNetwork>();
|
||||||
var remoteFilteredSubnets = remoteIPFilter.Where(x => x.Contains('/', StringComparison.OrdinalIgnoreCase)).ToArray();
|
var remoteFilteredSubnets = remoteIPFilter.Where(x => x.Contains('/', StringComparison.OrdinalIgnoreCase)).ToArray();
|
||||||
if (NetworkExtensions.TryParseToSubnets(remoteFilteredSubnets, out var remoteAddressFilterResult, false))
|
if (NetworkUtils.TryParseToSubnets(remoteFilteredSubnets, out var remoteAddressFilterResult, false))
|
||||||
{
|
{
|
||||||
remoteAddressFilter = remoteAddressFilterResult.ToList();
|
remoteAddressFilter = remoteAddressFilterResult.ToList();
|
||||||
}
|
}
|
||||||
@ -442,7 +439,7 @@ namespace Jellyfin.Networking.Manager
|
|||||||
{
|
{
|
||||||
if (IPAddress.TryParse(ip, out var ipp))
|
if (IPAddress.TryParse(ip, out var ipp))
|
||||||
{
|
{
|
||||||
remoteAddressFilter.Add(new IPNetwork(ipp, ipp.AddressFamily == AddressFamily.InterNetwork ? Network.MinimumIPv4PrefixSize : Network.MinimumIPv6PrefixSize));
|
remoteAddressFilter.Add(new IPNetwork(ipp, ipp.AddressFamily == AddressFamily.InterNetwork ? NetworkConstants.MinimumIPv4PrefixSize : NetworkConstants.MinimumIPv6PrefixSize));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -470,13 +467,13 @@ namespace Jellyfin.Networking.Manager
|
|||||||
{
|
{
|
||||||
publishedServerUrls.Add(
|
publishedServerUrls.Add(
|
||||||
new PublishedServerUriOverride(
|
new PublishedServerUriOverride(
|
||||||
new IPData(IPAddress.Any, Network.IPv4Any),
|
new IPData(IPAddress.Any, NetworkConstants.IPv4Any),
|
||||||
startupOverrideKey,
|
startupOverrideKey,
|
||||||
true,
|
true,
|
||||||
true));
|
true));
|
||||||
publishedServerUrls.Add(
|
publishedServerUrls.Add(
|
||||||
new PublishedServerUriOverride(
|
new PublishedServerUriOverride(
|
||||||
new IPData(IPAddress.IPv6Any, Network.IPv6Any),
|
new IPData(IPAddress.IPv6Any, NetworkConstants.IPv6Any),
|
||||||
startupOverrideKey,
|
startupOverrideKey,
|
||||||
true,
|
true,
|
||||||
true));
|
true));
|
||||||
@ -502,13 +499,13 @@ namespace Jellyfin.Networking.Manager
|
|||||||
publishedServerUrls.Clear();
|
publishedServerUrls.Clear();
|
||||||
publishedServerUrls.Add(
|
publishedServerUrls.Add(
|
||||||
new PublishedServerUriOverride(
|
new PublishedServerUriOverride(
|
||||||
new IPData(IPAddress.Any, Network.IPv4Any),
|
new IPData(IPAddress.Any, NetworkConstants.IPv4Any),
|
||||||
replacement,
|
replacement,
|
||||||
true,
|
true,
|
||||||
true));
|
true));
|
||||||
publishedServerUrls.Add(
|
publishedServerUrls.Add(
|
||||||
new PublishedServerUriOverride(
|
new PublishedServerUriOverride(
|
||||||
new IPData(IPAddress.IPv6Any, Network.IPv6Any),
|
new IPData(IPAddress.IPv6Any, NetworkConstants.IPv6Any),
|
||||||
replacement,
|
replacement,
|
||||||
true,
|
true,
|
||||||
true));
|
true));
|
||||||
@ -518,13 +515,13 @@ namespace Jellyfin.Networking.Manager
|
|||||||
{
|
{
|
||||||
publishedServerUrls.Add(
|
publishedServerUrls.Add(
|
||||||
new PublishedServerUriOverride(
|
new PublishedServerUriOverride(
|
||||||
new IPData(IPAddress.Any, Network.IPv4Any),
|
new IPData(IPAddress.Any, NetworkConstants.IPv4Any),
|
||||||
replacement,
|
replacement,
|
||||||
false,
|
false,
|
||||||
true));
|
true));
|
||||||
publishedServerUrls.Add(
|
publishedServerUrls.Add(
|
||||||
new PublishedServerUriOverride(
|
new PublishedServerUriOverride(
|
||||||
new IPData(IPAddress.IPv6Any, Network.IPv6Any),
|
new IPData(IPAddress.IPv6Any, NetworkConstants.IPv6Any),
|
||||||
replacement,
|
replacement,
|
||||||
false,
|
false,
|
||||||
true));
|
true));
|
||||||
@ -542,7 +539,7 @@ namespace Jellyfin.Networking.Manager
|
|||||||
false));
|
false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (NetworkExtensions.TryParseToSubnet(identifier, out var result) && result is not null)
|
else if (NetworkUtils.TryParseToSubnet(identifier, out var result) && result is not null)
|
||||||
{
|
{
|
||||||
var data = new IPData(result.Prefix, result);
|
var data = new IPData(result.Prefix, result);
|
||||||
publishedServerUrls.Add(
|
publishedServerUrls.Add(
|
||||||
@ -608,7 +605,7 @@ namespace Jellyfin.Networking.Manager
|
|||||||
foreach (var details in interfaceList)
|
foreach (var details in interfaceList)
|
||||||
{
|
{
|
||||||
var parts = details.Split(',');
|
var parts = details.Split(',');
|
||||||
if (NetworkExtensions.TryParseToSubnet(parts[0], out var subnet))
|
if (NetworkUtils.TryParseToSubnet(parts[0], out var subnet))
|
||||||
{
|
{
|
||||||
var address = subnet.Prefix;
|
var address = subnet.Prefix;
|
||||||
var index = int.Parse(parts[1], CultureInfo.InvariantCulture);
|
var index = int.Parse(parts[1], CultureInfo.InvariantCulture);
|
||||||
@ -724,12 +721,12 @@ namespace Jellyfin.Networking.Manager
|
|||||||
var loopbackNetworks = new List<IPData>();
|
var loopbackNetworks = new List<IPData>();
|
||||||
if (IsIPv4Enabled)
|
if (IsIPv4Enabled)
|
||||||
{
|
{
|
||||||
loopbackNetworks.Add(new IPData(IPAddress.Loopback, Network.IPv4RFC5735Loopback, "lo"));
|
loopbackNetworks.Add(new IPData(IPAddress.Loopback, NetworkConstants.IPv4RFC5735Loopback, "lo"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsIPv6Enabled)
|
if (IsIPv6Enabled)
|
||||||
{
|
{
|
||||||
loopbackNetworks.Add(new IPData(IPAddress.IPv6Loopback, Network.IPv6RFC4291Loopback, "lo"));
|
loopbackNetworks.Add(new IPData(IPAddress.IPv6Loopback, NetworkConstants.IPv6RFC4291Loopback, "lo"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return loopbackNetworks;
|
return loopbackNetworks;
|
||||||
@ -748,11 +745,11 @@ namespace Jellyfin.Networking.Manager
|
|||||||
if (IsIPv4Enabled && IsIPv6Enabled)
|
if (IsIPv4Enabled && IsIPv6Enabled)
|
||||||
{
|
{
|
||||||
// Kestrel source code shows it uses Sockets.DualMode - so this also covers IPAddress.Any by default
|
// Kestrel source code shows it uses Sockets.DualMode - so this also covers IPAddress.Any by default
|
||||||
result.Add(new IPData(IPAddress.IPv6Any, Network.IPv6Any));
|
result.Add(new IPData(IPAddress.IPv6Any, NetworkConstants.IPv6Any));
|
||||||
}
|
}
|
||||||
else if (IsIPv4Enabled)
|
else if (IsIPv4Enabled)
|
||||||
{
|
{
|
||||||
result.Add(new IPData(IPAddress.Any, Network.IPv4Any));
|
result.Add(new IPData(IPAddress.Any, NetworkConstants.IPv4Any));
|
||||||
}
|
}
|
||||||
else if (IsIPv6Enabled)
|
else if (IsIPv6Enabled)
|
||||||
{
|
{
|
||||||
@ -772,7 +769,7 @@ namespace Jellyfin.Networking.Manager
|
|||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public string GetBindAddress(string source, out int? port)
|
public string GetBindAddress(string source, out int? port)
|
||||||
{
|
{
|
||||||
if (!NetworkExtensions.TryParseHost(source, out var addresses, IsIPv4Enabled, IsIPv6Enabled))
|
if (!NetworkUtils.TryParseHost(source, out var addresses, IsIPv4Enabled, IsIPv6Enabled))
|
||||||
{
|
{
|
||||||
addresses = Array.Empty<IPAddress>();
|
addresses = Array.Empty<IPAddress>();
|
||||||
}
|
}
|
||||||
@ -847,7 +844,7 @@ namespace Jellyfin.Networking.Manager
|
|||||||
// If no source address is given, use the preferred (first) interface
|
// If no source address is given, use the preferred (first) interface
|
||||||
if (source is null)
|
if (source is null)
|
||||||
{
|
{
|
||||||
result = NetworkExtensions.FormatIPString(availableInterfaces.First().Address);
|
result = NetworkUtils.FormatIPString(availableInterfaces.First().Address);
|
||||||
_logger.LogDebug("{Source}: Using first internal interface as bind address: {Result}", source, result);
|
_logger.LogDebug("{Source}: Using first internal interface as bind address: {Result}", source, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -858,14 +855,14 @@ namespace Jellyfin.Networking.Manager
|
|||||||
{
|
{
|
||||||
if (intf.Subnet.Contains(source))
|
if (intf.Subnet.Contains(source))
|
||||||
{
|
{
|
||||||
result = NetworkExtensions.FormatIPString(intf.Address);
|
result = NetworkUtils.FormatIPString(intf.Address);
|
||||||
_logger.LogDebug("{Source}: Found interface with matching subnet, using it as bind address: {Result}", source, result);
|
_logger.LogDebug("{Source}: Found interface with matching subnet, using it as bind address: {Result}", source, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fallback to first available interface
|
// Fallback to first available interface
|
||||||
result = NetworkExtensions.FormatIPString(availableInterfaces[0].Address);
|
result = NetworkUtils.FormatIPString(availableInterfaces[0].Address);
|
||||||
_logger.LogDebug("{Source}: No matching interfaces found, using preferred interface as bind address: {Result}", source, result);
|
_logger.LogDebug("{Source}: No matching interfaces found, using preferred interface as bind address: {Result}", source, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -882,12 +879,12 @@ namespace Jellyfin.Networking.Manager
|
|||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public bool IsInLocalNetwork(string address)
|
public bool IsInLocalNetwork(string address)
|
||||||
{
|
{
|
||||||
if (NetworkExtensions.TryParseToSubnet(address, out var subnet))
|
if (NetworkUtils.TryParseToSubnet(address, out var subnet))
|
||||||
{
|
{
|
||||||
return IPAddress.IsLoopback(subnet.Prefix) || (_lanSubnets.Any(x => x.Contains(subnet.Prefix)) && !_excludedSubnets.Any(x => x.Contains(subnet.Prefix)));
|
return IPAddress.IsLoopback(subnet.Prefix) || (_lanSubnets.Any(x => x.Contains(subnet.Prefix)) && !_excludedSubnets.Any(x => x.Contains(subnet.Prefix)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NetworkExtensions.TryParseHost(address, out var addresses, IsIPv4Enabled, IsIPv6Enabled))
|
if (NetworkUtils.TryParseHost(address, out var addresses, IsIPv4Enabled, IsIPv6Enabled))
|
||||||
{
|
{
|
||||||
foreach (var ept in addresses)
|
foreach (var ept in addresses)
|
||||||
{
|
{
|
||||||
@ -1045,7 +1042,7 @@ namespace Jellyfin.Networking.Manager
|
|||||||
.Select(x => x.Address)
|
.Select(x => x.Address)
|
||||||
.First();
|
.First();
|
||||||
|
|
||||||
result = NetworkExtensions.FormatIPString(bindAddress);
|
result = NetworkUtils.FormatIPString(bindAddress);
|
||||||
_logger.LogDebug("{Source}: External request received, matching external bind address found: {Result}", source, result);
|
_logger.LogDebug("{Source}: External request received, matching external bind address found: {Result}", source, result);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1064,7 +1061,7 @@ namespace Jellyfin.Networking.Manager
|
|||||||
|
|
||||||
if (bindAddress is not null)
|
if (bindAddress is not null)
|
||||||
{
|
{
|
||||||
result = NetworkExtensions.FormatIPString(bindAddress);
|
result = NetworkUtils.FormatIPString(bindAddress);
|
||||||
_logger.LogDebug("{Source}: Internal request received, matching internal bind address found: {Result}", source, result);
|
_logger.LogDebug("{Source}: Internal request received, matching internal bind address found: {Result}", source, result);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1098,14 +1095,14 @@ namespace Jellyfin.Networking.Manager
|
|||||||
{
|
{
|
||||||
if (intf.Subnet.Contains(source))
|
if (intf.Subnet.Contains(source))
|
||||||
{
|
{
|
||||||
result = NetworkExtensions.FormatIPString(intf.Address);
|
result = NetworkUtils.FormatIPString(intf.Address);
|
||||||
_logger.LogDebug("{Source}: Found external interface with matching subnet, using it as bind address: {Result}", source, result);
|
_logger.LogDebug("{Source}: Found external interface with matching subnet, using it as bind address: {Result}", source, result);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fallback to first external interface.
|
// Fallback to first external interface.
|
||||||
result = NetworkExtensions.FormatIPString(extResult[0].Address);
|
result = NetworkUtils.FormatIPString(extResult[0].Address);
|
||||||
_logger.LogDebug("{Source}: Using first external interface as bind address: {Result}", source, result);
|
_logger.LogDebug("{Source}: Using first external interface as bind address: {Result}", source, result);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Jellyfin.Api.Middleware;
|
using Jellyfin.Api.Middleware;
|
||||||
using Jellyfin.Networking.Configuration;
|
using MediaBrowser.Common.Net;
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.OpenApi.Models;
|
using Microsoft.OpenApi.Models;
|
||||||
|
@ -20,11 +20,10 @@ using Jellyfin.Api.Formatters;
|
|||||||
using Jellyfin.Api.ModelBinders;
|
using Jellyfin.Api.ModelBinders;
|
||||||
using Jellyfin.Data.Enums;
|
using Jellyfin.Data.Enums;
|
||||||
using Jellyfin.Extensions.Json;
|
using Jellyfin.Extensions.Json;
|
||||||
using Jellyfin.Networking.Configuration;
|
|
||||||
using Jellyfin.Networking.Constants;
|
|
||||||
using Jellyfin.Networking.Extensions;
|
|
||||||
using Jellyfin.Server.Configuration;
|
using Jellyfin.Server.Configuration;
|
||||||
using Jellyfin.Server.Filters;
|
using Jellyfin.Server.Filters;
|
||||||
|
using MediaBrowser.Common.Api;
|
||||||
|
using MediaBrowser.Common.Net;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
using MediaBrowser.Model.Session;
|
using MediaBrowser.Model.Session;
|
||||||
using Microsoft.AspNetCore.Authentication;
|
using Microsoft.AspNetCore.Authentication;
|
||||||
@ -275,20 +274,20 @@ namespace Jellyfin.Server.Extensions
|
|||||||
{
|
{
|
||||||
if (IPAddress.TryParse(allowedProxies[i], out var addr))
|
if (IPAddress.TryParse(allowedProxies[i], out var addr))
|
||||||
{
|
{
|
||||||
AddIPAddress(config, options, addr, addr.AddressFamily == AddressFamily.InterNetwork ? Network.MinimumIPv4PrefixSize : Network.MinimumIPv6PrefixSize);
|
AddIPAddress(config, options, addr, addr.AddressFamily == AddressFamily.InterNetwork ? NetworkConstants.MinimumIPv4PrefixSize : NetworkConstants.MinimumIPv6PrefixSize);
|
||||||
}
|
}
|
||||||
else if (NetworkExtensions.TryParseToSubnet(allowedProxies[i], out var subnet))
|
else if (NetworkUtils.TryParseToSubnet(allowedProxies[i], out var subnet))
|
||||||
{
|
{
|
||||||
if (subnet is not null)
|
if (subnet is not null)
|
||||||
{
|
{
|
||||||
AddIPAddress(config, options, subnet.Prefix, subnet.PrefixLength);
|
AddIPAddress(config, options, subnet.Prefix, subnet.PrefixLength);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (NetworkExtensions.TryParseHost(allowedProxies[i], out var addresses, config.EnableIPv4, config.EnableIPv6))
|
else if (NetworkUtils.TryParseHost(allowedProxies[i], out var addresses, config.EnableIPv4, config.EnableIPv6))
|
||||||
{
|
{
|
||||||
foreach (var address in addresses)
|
foreach (var address in addresses)
|
||||||
{
|
{
|
||||||
AddIPAddress(config, options, address, address.AddressFamily == AddressFamily.InterNetwork ? Network.MinimumIPv4PrefixSize : Network.MinimumIPv6PrefixSize);
|
AddIPAddress(config, options, address, address.AddressFamily == AddressFamily.InterNetwork ? NetworkConstants.MinimumIPv4PrefixSize : NetworkConstants.MinimumIPv6PrefixSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -306,7 +305,7 @@ namespace Jellyfin.Server.Extensions
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prefixLength == Network.MinimumIPv4PrefixSize)
|
if (prefixLength == NetworkConstants.MinimumIPv4PrefixSize)
|
||||||
{
|
{
|
||||||
options.KnownProxies.Add(addr);
|
options.KnownProxies.Add(addr);
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ using System.IO;
|
|||||||
using System.Xml;
|
using System.Xml;
|
||||||
using System.Xml.Serialization;
|
using System.Xml.Serialization;
|
||||||
using Emby.Server.Implementations;
|
using Emby.Server.Implementations;
|
||||||
using Jellyfin.Networking.Configuration;
|
using MediaBrowser.Common.Net;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace Jellyfin.Server.Migrations.PreStartupRoutines;
|
namespace Jellyfin.Server.Migrations.PreStartupRoutines;
|
||||||
|
@ -7,7 +7,6 @@ using System.Text;
|
|||||||
using Emby.Dlna.Extensions;
|
using Emby.Dlna.Extensions;
|
||||||
using Jellyfin.Api.Middleware;
|
using Jellyfin.Api.Middleware;
|
||||||
using Jellyfin.MediaEncoding.Hls.Extensions;
|
using Jellyfin.MediaEncoding.Hls.Extensions;
|
||||||
using Jellyfin.Networking.Configuration;
|
|
||||||
using Jellyfin.Networking.HappyEyeballs;
|
using Jellyfin.Networking.HappyEyeballs;
|
||||||
using Jellyfin.Server.Extensions;
|
using Jellyfin.Server.Extensions;
|
||||||
using Jellyfin.Server.HealthChecks;
|
using Jellyfin.Server.HealthChecks;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
namespace Jellyfin.Api.Constants;
|
namespace MediaBrowser.Common.Api;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Policies for the API authorization.
|
/// Policies for the API authorization.
|
175
MediaBrowser.Common/Net/NetworkConfiguration.cs
Normal file
175
MediaBrowser.Common/Net/NetworkConfiguration.cs
Normal file
@ -0,0 +1,175 @@
|
|||||||
|
#pragma warning disable CA1819 // Properties should not return arrays
|
||||||
|
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace MediaBrowser.Common.Net;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Defines the <see cref="NetworkConfiguration" />.
|
||||||
|
/// </summary>
|
||||||
|
public class NetworkConfiguration
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The default value for <see cref="InternalHttpPort"/>.
|
||||||
|
/// </summary>
|
||||||
|
public const int DefaultHttpPort = 8096;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The default value for <see cref="PublicHttpsPort"/> and <see cref="InternalHttpsPort"/>.
|
||||||
|
/// </summary>
|
||||||
|
public const int DefaultHttpsPort = 8920;
|
||||||
|
|
||||||
|
private string _baseUrl = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value used to specify the URL prefix that your Jellyfin instance can be accessed at.
|
||||||
|
/// </summary>
|
||||||
|
public string BaseUrl
|
||||||
|
{
|
||||||
|
get => _baseUrl;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
// Normalize the start of the string
|
||||||
|
if (string.IsNullOrWhiteSpace(value))
|
||||||
|
{
|
||||||
|
// If baseUrl is empty, set an empty prefix string
|
||||||
|
_baseUrl = string.Empty;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value[0] != '/')
|
||||||
|
{
|
||||||
|
// If baseUrl was not configured with a leading slash, append one for consistency
|
||||||
|
value = "/" + value;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Normalize the end of the string
|
||||||
|
if (value[^1] == '/')
|
||||||
|
{
|
||||||
|
// If baseUrl was configured with a trailing slash, remove it for consistency
|
||||||
|
value = value.Remove(value.Length - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
_baseUrl = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether to use HTTPS.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// In order for HTTPS to be used, in addition to setting this to true, valid values must also be
|
||||||
|
/// provided for <see cref="CertificatePath"/> and <see cref="CertificatePassword"/>.
|
||||||
|
/// </remarks>
|
||||||
|
public bool EnableHttps { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether the server should force connections over HTTPS.
|
||||||
|
/// </summary>
|
||||||
|
public bool RequireHttps { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the filesystem path of an X.509 certificate to use for SSL.
|
||||||
|
/// </summary>
|
||||||
|
public string CertificatePath { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the password required to access the X.509 certificate data in the file specified by <see cref="CertificatePath"/>.
|
||||||
|
/// </summary>
|
||||||
|
public string CertificatePassword { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the internal HTTP server port.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The HTTP server port.</value>
|
||||||
|
public int InternalHttpPort { get; set; } = DefaultHttpPort;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the internal HTTPS server port.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The HTTPS server port.</value>
|
||||||
|
public int InternalHttpsPort { get; set; } = DefaultHttpsPort;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the public HTTP port.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The public HTTP port.</value>
|
||||||
|
public int PublicHttpPort { get; set; } = DefaultHttpPort;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the public HTTPS port.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The public HTTPS port.</value>
|
||||||
|
public int PublicHttpsPort { get; set; } = DefaultHttpsPort;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether Autodiscovery is enabled.
|
||||||
|
/// </summary>
|
||||||
|
public bool AutoDiscovery { get; set; } = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether to enable automatic port forwarding.
|
||||||
|
/// </summary>
|
||||||
|
public bool EnableUPnP { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether IPv6 is enabled.
|
||||||
|
/// </summary>
|
||||||
|
public bool EnableIPv4 { get; set; } = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether IPv6 is enabled.
|
||||||
|
/// </summary>
|
||||||
|
public bool EnableIPv6 { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether access from outside of the LAN is permitted.
|
||||||
|
/// </summary>
|
||||||
|
public bool EnableRemoteAccess { get; set; } = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the subnets that are deemed to make up the LAN.
|
||||||
|
/// </summary>
|
||||||
|
public string[] LocalNetworkSubnets { get; set; } = Array.Empty<string>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the interface addresses which Jellyfin will bind to. If empty, all interfaces will be used.
|
||||||
|
/// </summary>
|
||||||
|
public string[] LocalNetworkAddresses { get; set; } = Array.Empty<string>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the known proxies.
|
||||||
|
/// </summary>
|
||||||
|
public string[] KnownProxies { get; set; } = Array.Empty<string>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether address names that match <see cref="VirtualInterfaceNames"/> should be ignored for the purposes of binding.
|
||||||
|
/// </summary>
|
||||||
|
public bool IgnoreVirtualInterfaces { get; set; } = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating the interface name prefixes that should be ignored. The list can be comma separated and values are case-insensitive. <seealso cref="IgnoreVirtualInterfaces"/>.
|
||||||
|
/// </summary>
|
||||||
|
public string[] VirtualInterfaceNames { get; set; } = new string[] { "veth" };
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether the published server uri is based on information in HTTP requests.
|
||||||
|
/// </summary>
|
||||||
|
public bool EnablePublishedServerUriByRequest { get; set; } = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the PublishedServerUriBySubnet
|
||||||
|
/// Gets or sets PublishedServerUri to advertise for specific subnets.
|
||||||
|
/// </summary>
|
||||||
|
public string[] PublishedServerUriBySubnet { get; set; } = Array.Empty<string>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the filter for remote IP connectivity. Used in conjunction with <seealso cref="IsRemoteIPFilterBlacklist"/>.
|
||||||
|
/// </summary>
|
||||||
|
public string[] RemoteIPFilter { get; set; } = Array.Empty<string>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether <seealso cref="RemoteIPFilter"/> contains a blacklist or a whitelist. Default is a whitelist.
|
||||||
|
/// </summary>
|
||||||
|
public bool IsRemoteIPFilterBlacklist { get; set; }
|
||||||
|
}
|
19
MediaBrowser.Common/Net/NetworkConfigurationExtensions.cs
Normal file
19
MediaBrowser.Common/Net/NetworkConfigurationExtensions.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
using MediaBrowser.Common.Configuration;
|
||||||
|
|
||||||
|
namespace MediaBrowser.Common.Net;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Defines the <see cref="NetworkConfigurationExtensions" />.
|
||||||
|
/// </summary>
|
||||||
|
public static class NetworkConfigurationExtensions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves the network configuration.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="config">The <see cref="IConfigurationManager"/>.</param>
|
||||||
|
/// <returns>The <see cref="NetworkConfiguration"/>.</returns>
|
||||||
|
public static NetworkConfiguration GetNetworkConfiguration(this IConfigurationManager config)
|
||||||
|
{
|
||||||
|
return config.GetConfiguration<NetworkConfiguration>(NetworkConfigurationStore.StoreKey);
|
||||||
|
}
|
||||||
|
}
|
22
MediaBrowser.Common/Net/NetworkConfigurationFactory.cs
Normal file
22
MediaBrowser.Common/Net/NetworkConfigurationFactory.cs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using MediaBrowser.Common.Configuration;
|
||||||
|
|
||||||
|
namespace MediaBrowser.Common.Net;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Defines the <see cref="NetworkConfigurationFactory" />.
|
||||||
|
/// </summary>
|
||||||
|
public class NetworkConfigurationFactory : IConfigurationFactory
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The GetConfigurations.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The <see cref="IEnumerable{ConfigurationStore}"/>.</returns>
|
||||||
|
public IEnumerable<ConfigurationStore> GetConfigurations()
|
||||||
|
{
|
||||||
|
return new[]
|
||||||
|
{
|
||||||
|
new NetworkConfigurationStore()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
23
MediaBrowser.Common/Net/NetworkConfigurationStore.cs
Normal file
23
MediaBrowser.Common/Net/NetworkConfigurationStore.cs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
using MediaBrowser.Common.Configuration;
|
||||||
|
|
||||||
|
namespace MediaBrowser.Common.Net;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A configuration that stores network related settings.
|
||||||
|
/// </summary>
|
||||||
|
public class NetworkConfigurationStore : ConfigurationStore
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The name of the configuration in the storage.
|
||||||
|
/// </summary>
|
||||||
|
public const string StoreKey = "network";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="NetworkConfigurationStore"/> class.
|
||||||
|
/// </summary>
|
||||||
|
public NetworkConfigurationStore()
|
||||||
|
{
|
||||||
|
ConfigurationType = typeof(NetworkConfiguration);
|
||||||
|
Key = StoreKey;
|
||||||
|
}
|
||||||
|
}
|
@ -1,12 +1,12 @@
|
|||||||
using System.Net;
|
using System.Net;
|
||||||
using Microsoft.AspNetCore.HttpOverrides;
|
using Microsoft.AspNetCore.HttpOverrides;
|
||||||
|
|
||||||
namespace Jellyfin.Networking.Constants;
|
namespace MediaBrowser.Common.Net;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Networking constants.
|
/// Networking constants.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class Network
|
public static class NetworkConstants
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// IPv4 mask bytes.
|
/// IPv4 mask bytes.
|
@ -5,15 +5,14 @@ using System.Net;
|
|||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using Jellyfin.Extensions;
|
using Jellyfin.Extensions;
|
||||||
using Jellyfin.Networking.Constants;
|
|
||||||
using Microsoft.AspNetCore.HttpOverrides;
|
using Microsoft.AspNetCore.HttpOverrides;
|
||||||
|
|
||||||
namespace Jellyfin.Networking.Extensions;
|
namespace MediaBrowser.Common.Net;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Defines the <see cref="NetworkExtensions" />.
|
/// Defines the <see cref="NetworkUtils" />.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static partial class NetworkExtensions
|
public static partial class NetworkUtils
|
||||||
{
|
{
|
||||||
// Use regular expression as CheckHostName isn't RFC5892 compliant.
|
// Use regular expression as CheckHostName isn't RFC5892 compliant.
|
||||||
// Modified from gSkinner's expression at https://stackoverflow.com/questions/11809631/fully-qualified-domain-name-validation
|
// Modified from gSkinner's expression at https://stackoverflow.com/questions/11809631/fully-qualified-domain-name-validation
|
||||||
@ -59,7 +58,7 @@ public static partial class NetworkExtensions
|
|||||||
/// <returns>String value of the subnet mask in dotted decimal notation.</returns>
|
/// <returns>String value of the subnet mask in dotted decimal notation.</returns>
|
||||||
public static IPAddress CidrToMask(byte cidr, AddressFamily family)
|
public static IPAddress CidrToMask(byte cidr, AddressFamily family)
|
||||||
{
|
{
|
||||||
uint addr = 0xFFFFFFFF << ((family == AddressFamily.InterNetwork ? Network.MinimumIPv4PrefixSize : Network.MinimumIPv6PrefixSize) - cidr);
|
uint addr = 0xFFFFFFFF << ((family == AddressFamily.InterNetwork ? NetworkConstants.MinimumIPv4PrefixSize : NetworkConstants.MinimumIPv6PrefixSize) - cidr);
|
||||||
addr = ((addr & 0xff000000) >> 24)
|
addr = ((addr & 0xff000000) >> 24)
|
||||||
| ((addr & 0x00ff0000) >> 8)
|
| ((addr & 0x00ff0000) >> 8)
|
||||||
| ((addr & 0x0000ff00) << 8)
|
| ((addr & 0x0000ff00) << 8)
|
||||||
@ -75,7 +74,7 @@ public static partial class NetworkExtensions
|
|||||||
/// <returns>String value of the subnet mask in dotted decimal notation.</returns>
|
/// <returns>String value of the subnet mask in dotted decimal notation.</returns>
|
||||||
public static IPAddress CidrToMask(int cidr, AddressFamily family)
|
public static IPAddress CidrToMask(int cidr, AddressFamily family)
|
||||||
{
|
{
|
||||||
uint addr = 0xFFFFFFFF << ((family == AddressFamily.InterNetwork ? Network.MinimumIPv4PrefixSize : Network.MinimumIPv6PrefixSize) - cidr);
|
uint addr = 0xFFFFFFFF << ((family == AddressFamily.InterNetwork ? NetworkConstants.MinimumIPv4PrefixSize : NetworkConstants.MinimumIPv6PrefixSize) - cidr);
|
||||||
addr = ((addr & 0xff000000) >> 24)
|
addr = ((addr & 0xff000000) >> 24)
|
||||||
| ((addr & 0x00ff0000) >> 8)
|
| ((addr & 0x00ff0000) >> 8)
|
||||||
| ((addr & 0x0000ff00) << 8)
|
| ((addr & 0x0000ff00) << 8)
|
||||||
@ -100,7 +99,7 @@ public static partial class NetworkExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetAddressBytes
|
// GetAddressBytes
|
||||||
Span<byte> bytes = stackalloc byte[mask.AddressFamily == AddressFamily.InterNetwork ? Network.IPv4MaskBytes : Network.IPv6MaskBytes];
|
Span<byte> bytes = stackalloc byte[mask.AddressFamily == AddressFamily.InterNetwork ? NetworkConstants.IPv4MaskBytes : NetworkConstants.IPv6MaskBytes];
|
||||||
if (!mask.TryWriteBytes(bytes, out var bytesWritten))
|
if (!mask.TryWriteBytes(bytes, out var bytesWritten))
|
||||||
{
|
{
|
||||||
Console.WriteLine("Unable to write address bytes, only ${bytesWritten} bytes written.");
|
Console.WriteLine("Unable to write address bytes, only ${bytesWritten} bytes written.");
|
||||||
@ -224,18 +223,18 @@ public static partial class NetworkExtensions
|
|||||||
}
|
}
|
||||||
else if (IPAddress.TryParse(subnetBlock, out var netmaskAddress))
|
else if (IPAddress.TryParse(subnetBlock, out var netmaskAddress))
|
||||||
{
|
{
|
||||||
result = new IPNetwork(address, NetworkExtensions.MaskToCidr(netmaskAddress));
|
result = new IPNetwork(address, NetworkUtils.MaskToCidr(netmaskAddress));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (address.AddressFamily == AddressFamily.InterNetwork)
|
else if (address.AddressFamily == AddressFamily.InterNetwork)
|
||||||
{
|
{
|
||||||
result = address.Equals(IPAddress.Any) ? Network.IPv4Any : new IPNetwork(address, Network.MinimumIPv4PrefixSize);
|
result = address.Equals(IPAddress.Any) ? NetworkConstants.IPv4Any : new IPNetwork(address, NetworkConstants.MinimumIPv4PrefixSize);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (address.AddressFamily == AddressFamily.InterNetworkV6)
|
else if (address.AddressFamily == AddressFamily.InterNetworkV6)
|
||||||
{
|
{
|
||||||
result = address.Equals(IPAddress.IPv6Any) ? Network.IPv6Any : new IPNetwork(address, Network.MinimumIPv6PrefixSize);
|
result = address.Equals(IPAddress.IPv6Any) ? NetworkConstants.IPv6Any : new IPNetwork(address, NetworkConstants.MinimumIPv6PrefixSize);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
using Jellyfin.Networking.Configuration;
|
using MediaBrowser.Common.Net;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
namespace Jellyfin.Networking.Tests.Configuration;
|
namespace Jellyfin.Networking.Tests.Configuration;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
using FsCheck;
|
using FsCheck;
|
||||||
using FsCheck.Xunit;
|
using FsCheck.Xunit;
|
||||||
using Jellyfin.Networking.Extensions;
|
using MediaBrowser.Common.Net;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
namespace Jellyfin.Networking.Tests
|
namespace Jellyfin.Networking.Tests
|
||||||
@ -26,15 +26,15 @@ namespace Jellyfin.Networking.Tests
|
|||||||
[InlineData("192.168.1.2/255.255.255.0")]
|
[InlineData("192.168.1.2/255.255.255.0")]
|
||||||
[InlineData("192.168.1.2/24")]
|
[InlineData("192.168.1.2/24")]
|
||||||
public static void TryParse_ValidHostStrings_True(string address)
|
public static void TryParse_ValidHostStrings_True(string address)
|
||||||
=> Assert.True(NetworkExtensions.TryParseHost(address, out _, true, true));
|
=> Assert.True(NetworkUtils.TryParseHost(address, out _, true, true));
|
||||||
|
|
||||||
[Property]
|
[Property]
|
||||||
public static Property TryParse_IPv4Address_True(IPv4Address address)
|
public static Property TryParse_IPv4Address_True(IPv4Address address)
|
||||||
=> NetworkExtensions.TryParseHost(address.Item.ToString(), out _, true, true).ToProperty();
|
=> NetworkUtils.TryParseHost(address.Item.ToString(), out _, true, true).ToProperty();
|
||||||
|
|
||||||
[Property]
|
[Property]
|
||||||
public static Property TryParse_IPv6Address_True(IPv6Address address)
|
public static Property TryParse_IPv6Address_True(IPv6Address address)
|
||||||
=> NetworkExtensions.TryParseHost(address.Item.ToString(), out _, true, true).ToProperty();
|
=> NetworkUtils.TryParseHost(address.Item.ToString(), out _, true, true).ToProperty();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// All should be invalid address strings.
|
/// All should be invalid address strings.
|
||||||
@ -47,6 +47,6 @@ namespace Jellyfin.Networking.Tests
|
|||||||
[InlineData("fd23:184f:2029:0:3139:7386:67d7:d517:1231")]
|
[InlineData("fd23:184f:2029:0:3139:7386:67d7:d517:1231")]
|
||||||
[InlineData("[fd23:184f:2029:0:3139:7386:67d7:d517:1231]")]
|
[InlineData("[fd23:184f:2029:0:3139:7386:67d7:d517:1231]")]
|
||||||
public static void TryParse_InvalidAddressString_False(string address)
|
public static void TryParse_InvalidAddressString_False(string address)
|
||||||
=> Assert.False(NetworkExtensions.TryParseHost(address, out _, true, true));
|
=> Assert.False(NetworkUtils.TryParseHost(address, out _, true, true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
using System.Net;
|
using System.Net;
|
||||||
using Jellyfin.Networking.Configuration;
|
|
||||||
using Jellyfin.Networking.Manager;
|
using Jellyfin.Networking.Manager;
|
||||||
|
using MediaBrowser.Common.Net;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.Logging.Abstractions;
|
using Microsoft.Extensions.Logging.Abstractions;
|
||||||
using Moq;
|
using Moq;
|
||||||
|
@ -2,10 +2,9 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using Jellyfin.Networking.Configuration;
|
|
||||||
using Jellyfin.Networking.Extensions;
|
|
||||||
using Jellyfin.Networking.Manager;
|
using Jellyfin.Networking.Manager;
|
||||||
using MediaBrowser.Common.Configuration;
|
using MediaBrowser.Common.Configuration;
|
||||||
|
using MediaBrowser.Common.Net;
|
||||||
using MediaBrowser.Model.Net;
|
using MediaBrowser.Model.Net;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.Logging.Abstractions;
|
using Microsoft.Extensions.Logging.Abstractions;
|
||||||
@ -80,7 +79,7 @@ namespace Jellyfin.Networking.Tests
|
|||||||
[InlineData("[fe80::7add:12ff:febb:c67b%16]")]
|
[InlineData("[fe80::7add:12ff:febb:c67b%16]")]
|
||||||
[InlineData("fd23:184f:2029:0:3139:7386:67d7:d517/56")]
|
[InlineData("fd23:184f:2029:0:3139:7386:67d7:d517/56")]
|
||||||
public static void TryParseValidIPStringsTrue(string address)
|
public static void TryParseValidIPStringsTrue(string address)
|
||||||
=> Assert.True(NetworkExtensions.TryParseToSubnet(address, out _));
|
=> Assert.True(NetworkUtils.TryParseToSubnet(address, out _));
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Checks invalid IP address formats.
|
/// Checks invalid IP address formats.
|
||||||
@ -93,7 +92,7 @@ namespace Jellyfin.Networking.Tests
|
|||||||
[InlineData("fd23:184f:2029:0:3139:7386:67d7:d517:1231")]
|
[InlineData("fd23:184f:2029:0:3139:7386:67d7:d517:1231")]
|
||||||
[InlineData("[fd23:184f:2029:0:3139:7386:67d7:d517:1231]")]
|
[InlineData("[fd23:184f:2029:0:3139:7386:67d7:d517:1231]")]
|
||||||
public static void TryParseInvalidIPStringsFalse(string address)
|
public static void TryParseInvalidIPStringsFalse(string address)
|
||||||
=> Assert.False(NetworkExtensions.TryParseToSubnet(address, out _));
|
=> Assert.False(NetworkUtils.TryParseToSubnet(address, out _));
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Checks if IPv4 address is within a defined subnet.
|
/// Checks if IPv4 address is within a defined subnet.
|
||||||
@ -113,7 +112,7 @@ namespace Jellyfin.Networking.Tests
|
|||||||
public void IPv4SubnetMaskMatchesValidIPAddress(string netMask, string ipAddress)
|
public void IPv4SubnetMaskMatchesValidIPAddress(string netMask, string ipAddress)
|
||||||
{
|
{
|
||||||
var ipa = IPAddress.Parse(ipAddress);
|
var ipa = IPAddress.Parse(ipAddress);
|
||||||
Assert.True(NetworkExtensions.TryParseToSubnet(netMask, out var subnet) && subnet.Contains(IPAddress.Parse(ipAddress)));
|
Assert.True(NetworkUtils.TryParseToSubnet(netMask, out var subnet) && subnet.Contains(IPAddress.Parse(ipAddress)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -133,7 +132,7 @@ namespace Jellyfin.Networking.Tests
|
|||||||
public void IPv4SubnetMaskDoesNotMatchInvalidIPAddress(string netMask, string ipAddress)
|
public void IPv4SubnetMaskDoesNotMatchInvalidIPAddress(string netMask, string ipAddress)
|
||||||
{
|
{
|
||||||
var ipa = IPAddress.Parse(ipAddress);
|
var ipa = IPAddress.Parse(ipAddress);
|
||||||
Assert.False(NetworkExtensions.TryParseToSubnet(netMask, out var subnet) && subnet.Contains(IPAddress.Parse(ipAddress)));
|
Assert.False(NetworkUtils.TryParseToSubnet(netMask, out var subnet) && subnet.Contains(IPAddress.Parse(ipAddress)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -149,7 +148,7 @@ namespace Jellyfin.Networking.Tests
|
|||||||
[InlineData("2001:db8:abcd:0012::0/128", "2001:0DB8:ABCD:0012:0000:0000:0000:0000")]
|
[InlineData("2001:db8:abcd:0012::0/128", "2001:0DB8:ABCD:0012:0000:0000:0000:0000")]
|
||||||
public void IPv6SubnetMaskMatchesValidIPAddress(string netMask, string ipAddress)
|
public void IPv6SubnetMaskMatchesValidIPAddress(string netMask, string ipAddress)
|
||||||
{
|
{
|
||||||
Assert.True(NetworkExtensions.TryParseToSubnet(netMask, out var subnet) && subnet.Contains(IPAddress.Parse(ipAddress)));
|
Assert.True(NetworkUtils.TryParseToSubnet(netMask, out var subnet) && subnet.Contains(IPAddress.Parse(ipAddress)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
@ -160,7 +159,7 @@ namespace Jellyfin.Networking.Tests
|
|||||||
[InlineData("2001:db8:abcd:0012::0/128", "2001:0DB8:ABCD:0012:0000:0000:0000:0001")]
|
[InlineData("2001:db8:abcd:0012::0/128", "2001:0DB8:ABCD:0012:0000:0000:0000:0001")]
|
||||||
public void IPv6SubnetMaskDoesNotMatchInvalidIPAddress(string netMask, string ipAddress)
|
public void IPv6SubnetMaskDoesNotMatchInvalidIPAddress(string netMask, string ipAddress)
|
||||||
{
|
{
|
||||||
Assert.False(NetworkExtensions.TryParseToSubnet(netMask, out var subnet) && subnet.Contains(IPAddress.Parse(ipAddress)));
|
Assert.False(NetworkUtils.TryParseToSubnet(netMask, out var subnet) && subnet.Contains(IPAddress.Parse(ipAddress)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
@ -207,7 +206,7 @@ namespace Jellyfin.Networking.Tests
|
|||||||
NetworkManager.MockNetworkSettings = string.Empty;
|
NetworkManager.MockNetworkSettings = string.Empty;
|
||||||
|
|
||||||
// Check to see if DNS resolution is working. If not, skip test.
|
// Check to see if DNS resolution is working. If not, skip test.
|
||||||
if (!NetworkExtensions.TryParseHost(source, out var host))
|
if (!NetworkUtils.TryParseHost(source, out var host))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using Jellyfin.Networking.Configuration;
|
|
||||||
using Jellyfin.Networking.Manager;
|
using Jellyfin.Networking.Manager;
|
||||||
using Jellyfin.Server.Extensions;
|
using Jellyfin.Server.Extensions;
|
||||||
using MediaBrowser.Common.Configuration;
|
using MediaBrowser.Common.Configuration;
|
||||||
|
using MediaBrowser.Common.Net;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.HttpOverrides;
|
using Microsoft.AspNetCore.HttpOverrides;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user