-
Notifications
You must be signed in to change notification settings - Fork 81
fix!: Represent TCP port as UInt16 #1923
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
Conversation
…nto jbe/tcp_port_fix
@@ -66,7 +66,7 @@ class AuthTokenGeneratorIntegration : SwiftIntegration { | |||
/// - expiration: The expiration for the token in seconds. Default is 900 seconds (15 minutes). | |||
public func generateAuthToken( | |||
endpoint: String, | |||
port: Int16, | |||
port: UInt16, |
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.
Changing Int16 to UInt16 will certainly solve the issue so I am approving, but since this function isnt directly interfacing with C I am of the opinion that this should be Int
everywhere in Swift side until the moment it needs to be another type.
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.
Found this method while googling around that can potentially take an Int and tell you if its a valid port https://developer.apple.com/documentation/kernel/in_port_t
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.
Sticking with UInt16
because it matches exactly the permitted values for TCP port. Using Int
would allow customers to specify invalid port values.
I'm aware that Foundation's URLComponents
uses Int
for port. I don't know their rationale, probably because that is how it bridged over from the original ObjC interface, but I'd prefer to match the TCP allowed values more closely.
Description of changes
[BREAKING] This change breaks public interfaces. SDK minor version is updated to 1.3.0 accordingly.
Changes the type for port number from
Int16
toUInt16
. TCP port may be from 0-65535 which is beyond the range ofInt16
.In this project, this affects the interfaces for the RDS auth token generator. The rest of the changes to port type are in companion PR smithy-lang/smithy-swift#924.
The change is breaking because port number is exposed as a property of several public types and parameters to public functions. The change is being made nonetheless because it is a significant impediment to not allow use of all possible TCP ports.
New/existing dependencies impact assessment, if applicable
No new dependencies were added to this change.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.