File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,11 @@ public struct MySQLConfiguration {
8
8
public let password : String
9
9
public let database : String ?
10
10
public let tlsConfiguration : TLSConfiguration ?
11
-
11
+
12
+ /// IANA-assigned port number for MySQL
13
+ /// `UInt16(getservbyname("mysql", "tcp").pointee.s_port).byteSwapped`
14
+ public static var ianaPortNumber : Int { 3306 }
15
+
12
16
internal var _hostname : String ?
13
17
14
18
public init ? ( url: String ) {
@@ -31,9 +35,7 @@ public struct MySQLConfiguration {
31
35
guard let hostname = url. host else {
32
36
return nil
33
37
}
34
- guard let port = url. port else {
35
- return nil
36
- }
38
+ let port = url. port ?? Self . ianaPortNumber
37
39
38
40
let tlsConfiguration : TLSConfiguration ?
39
41
if url. query == " ssl=false " {
@@ -70,7 +72,7 @@ public struct MySQLConfiguration {
70
72
71
73
public init (
72
74
hostname: String ,
73
- port: Int = 3306 ,
75
+ port: Int = Self . ianaPortNumber ,
74
76
username: String ,
75
77
password: String ,
76
78
database: String ? = nil ,
You can’t perform that action at this time.
0 commit comments