-
-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed ListenToSocketInternal so it works after Jellyfin 10.9.2 #51
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
changed NetworkManager's GetAllBindInterfaces method.
Shadowghost
approved these changes
May 26, 2024
crobibero
requested changes
May 26, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting is off
Index: src/Rssdp/SsdpCommunicationsServer.cs
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/Rssdp/SsdpCommunicationsServer.cs b/src/Rssdp/SsdpCommunicationsServer.cs
--- a/src/Rssdp/SsdpCommunicationsServer.cs (revision 2fa639a5a808b16b55399840b961dacf220a9706)
+++ b/src/Rssdp/SsdpCommunicationsServer.cs (date 1716745437738)
@@ -416,19 +416,17 @@
var remoteEndpoint = (IPEndPoint)result.RemoteEndPoint;
var allBindInterfaces = _networkManager.GetAllBindInterfaces();
IPData localEndpointAdapter;
- if (
- allBindInterfaces.Count == 1
- && (
- allBindInterfaces.First().Address.Equals(IPAddress.Any)
- || allBindInterfaces.First().Address.Equals(IPAddress.IPv6Any)
- )
- )
+ if (allBindInterfaces.Count == 1
+ && (allBindInterfaces[0].Address.Equals(IPAddress.Any)
+ || allBindInterfaces[0].Address.Equals(IPAddress.IPv6Any)))
{
- localEndpointAdapter = allBindInterfaces.First();
- } else
+ localEndpointAdapter = allBindInterfaces[0];
+ }
+ else
{
localEndpointAdapter = allBindInterfaces.First(a => a.Index == result.PacketInformation.Interface);
}
+
ProcessMessage(
Encoding.UTF8.GetString(receiveBuffer, 0, result.ReceivedBytes),
remoteEndpoint,
@@ -522,7 +520,7 @@
LocalIPAddress = localIPAddress
});
}
-
+
private Socket CreateSsdpUdpSocket(IPData bindInterface, int localPort)
{
var interfaceAddress = bindInterface.Address;
@@ -548,7 +546,7 @@
throw;
}
}
-
+
private Socket CreateUdpMulticastSocket(IPAddress multicastAddress, IPData bindInterface, int multicastTimeToLive, int localPort)
{
var bindIPAddress = bindInterface.Address;
Fixed formatting |
crobibero
reviewed
May 26, 2024
crobibero
approved these changes
May 26, 2024
Merged
Comment on lines
+419
to
+428
if (allBindInterfaces.Count == 1 | ||
&& (allBindInterfaces[0].Address.Equals(IPAddress.Any) | ||
|| allBindInterfaces[0].Address.Equals(IPAddress.IPv6Any))) | ||
{ | ||
localEndpointAdapter = allBindInterfaces[0]; | ||
} | ||
else | ||
{ | ||
localEndpointAdapter = allBindInterfaces.First(a => a.Index == result.PacketInformation.Interface); | ||
} |
Check notice
Code scanning / CodeQL
Missed ternary opportunity Note
Both branches of this 'if' statement write to the same variable - consider using '?' to express intent better.
This was referenced May 26, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related to this issue.
The last Jellyfin update changed
NetworkManager
'sGetAllBindInterfaces
method.This caused
ListenToSocketInternal
to fail if no local addresses were set, because the new implementation returns anIPData
object without setting itsIndex
property.This causes the
First()
method inListenToSocketInternal
to throw anInvalidOperationException
.To fix this I check if
GetAllBindInterfaces
returns one and just oneIPData
object and if this object corresponds to whatGetAllBindInterfaces
returns in case no local address has been set in Jellyfin.Indeed
GetAllBindInterfaces
will only set those addresses (IPAddress.Any
andIPAddress.IPv6Any
) when no local address has been set.