Skip to content

Commit bd9129d

Browse files
authored
Merge pull request #184 from RuntimeTools/4.1
Update to Swift 4.1 and Kitura 2.3
2 parents 84d706a + 7814944 commit bd9129d

File tree

6 files changed

+58
-36
lines changed

6 files changed

+58
-36
lines changed

.swift-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.0.3
1+
4.1

.travis.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Travis CI build file for Kitura sample app.
1+
# Travis CI build file for SwiftMetrics.
22
# Kitura runs on OS X and Linux (Ubuntu).
33
# See the following URLs for further details on Travis CI
44
# https://docs.travis-ci.com/user/customizing-the-build/
@@ -13,12 +13,20 @@ branches:
1313

1414
matrix:
1515
include:
16+
- os: linux
17+
dist: trusty
18+
sudo: required
19+
env: SWIFT_SNAPSHOT=4.0.3
1620
- os: linux
1721
dist: trusty
1822
sudo: required
1923
- os: osx
2024
osx_image: xcode9.2
2125
sudo: required
26+
env: SWIFT_SNAPSHOT=4.0.3
27+
- os: osx
28+
osx_image: xcode9.3
29+
sudo: required
2230

2331
before_install:
2432
- git clone https://github.com/IBM-Swift/Package-Builder.git

Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ let package = Package(
3333
.executable(name: "SwiftMetricsCommonSample", targets: ["SwiftMetricsCommonSample"]),
3434
],
3535
dependencies: [
36-
.package(url: "https://github.com/IBM-Swift/Kitura.git", from: "2.1.0"),
37-
.package(url: "https://github.com/IBM-Swift/Kitura-WebSocket.git", from: "1.0.0"),
36+
.package(url: "https://github.com/IBM-Swift/Kitura.git", from: "2.3.0"),
37+
.package(url: "https://github.com/IBM-Swift/Kitura-WebSocket.git", from: "2.0.0"),
3838
.package(url: "https://github.com/IBM-Swift/SwiftyRequest.git", from: "1.0.0"),
3939
.package(url: "https://github.com/IBM-Swift/Swift-cfenv.git", from: "6.0.0"),
4040
.package(url: "https://github.com/IBM-Swift/SwiftyJSON.git", from: "17.0.0"),

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,13 @@ Application Metrics for Swift provides the following built-in data collection so
3232

3333
The Application Metrics for Swift agent supports the following runtime environments:
3434

35-
* **Swift v3 GA** on:
35+
* **Swift v4.1 GA** on:
36+
* 64-bit runtime on Linux (Ubuntu 14.04, 16.04)
37+
* 64-bit runtime on macOS (x64)
38+
* **Swift v4 GA** on:
39+
* 64-bit runtime on Linux (Ubuntu 14.04, 16.04)
40+
* 64-bit runtime on macOS (x64)
41+
* **Swift v3.1.1 GA** using SwiftMetrics version 1.2.5 on:
3642
* 64-bit runtime on Linux (Ubuntu 14.04, 15.10)
3743
* 64-bit runtime on macOS (x64)
3844

Sources/SwiftBAMDC/SwiftDataCollector.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ public func getISOTimeStamp(time : Date) -> String {
455455
let formatter = DateFormatter()
456456

457457
formatter.dateFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'SSS'Z'"
458-
formatter.timeZone = TimeZone(abbreviation: "UTC") as TimeZone!
458+
formatter.timeZone = TimeZone(abbreviation: "UTC")
459459

460460
return formatter.string(from: time)
461461
}

Sources/SwiftBAMDC/SwiftMetricsBAMConfig.swift

Lines changed: 38 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -616,56 +616,64 @@ public class TokenUtil {
616616
let i = cipher_init(key: key)
617617

618618
if let ky = i["key"], let vl = i["iv"] {
619-
let c = Cryptor(operation: .encrypt,
620-
algorithm: .aes,
621-
options: .pkcs7Padding,
622-
key: ky,
623-
iv: vl)
619+
do {
620+
let c = try Cryptor(operation: .encrypt,
621+
algorithm: .aes,
622+
options: .pkcs7Padding,
623+
key: ky,
624+
iv: vl)
624625

625-
let b = c.update(string: value)?.final()
626+
let b = c.update(string: value)?.final()
626627

627-
if let bv = b {
628-
let d = Data(bytes: bv, count: bv.count).base64EncodedData()
628+
if let bv = b {
629+
let d = Data(bytes: bv, count: bv.count).base64EncodedData()
629630

630-
let s = String(data: d, encoding: String.Encoding.utf8)
631+
let s = String(data: d, encoding: String.Encoding.utf8)
631632

632-
if let sv = s {
633-
Log.debug("[SwiftMetricsBAMConfig] Encrypt successful: \(key) val: \(sv)")
634-
return sv
633+
if let sv = s {
634+
Log.debug("[SwiftMetricsBAMConfig] Encrypt successful: \(key) val: \(sv)")
635+
return sv
636+
}
635637
}
638+
} catch {
639+
// do nothing
636640
}
637641
}
638642

639-
Log.debug("[SwiftMetricsBAMConfig] Encrypt failed: \(key)")
643+
Log.error("[SwiftMetricsBAMConfig] Encrypt failed: \(key)")
640644
return ""
641645
}
642646

643647
public static func unobfuscate(key: String, value: String) -> String {
644648
let i = cipher_init(key: key)
645649

646650
if let ky = i["key"], let vl = i["iv"] {
647-
let c = Cryptor(operation: .decrypt,
648-
algorithm: .aes,
649-
options: .pkcs7Padding,
650-
key: ky,
651-
iv: vl)
652-
let b = Data(base64Encoded: value)
653-
if let bv = b {
654-
let p = c.update(data: bv)?.final()
655-
656-
if let pv = p {
657-
let d = Data(bytes: pv, count: pv.count)
658-
let s = String(data: d, encoding: String.Encoding.utf8)
659-
660-
if let sv = s {
661-
Log.debug("[SwiftMetricsBAMConfig] Decrypt successful: \(key) val: \(value)")
662-
return sv
651+
do {
652+
let c = try Cryptor(operation: .decrypt,
653+
algorithm: .aes,
654+
options: .pkcs7Padding,
655+
key: ky,
656+
iv: vl)
657+
let b = Data(base64Encoded: value)
658+
if let bv = b {
659+
let p = c.update(data: bv)?.final()
660+
661+
if let pv = p {
662+
let d = Data(bytes: pv, count: pv.count)
663+
let s = String(data: d, encoding: String.Encoding.utf8)
664+
665+
if let sv = s {
666+
Log.debug("[SwiftMetricsBAMConfig] Decrypt successful: \(key) val: \(value)")
667+
return sv
668+
}
663669
}
664670
}
671+
} catch {
672+
// do nothing
665673
}
666674
}
667675

668-
Log.debug("[SwiftMetricsBAMConfig] Decrypt failed: \(key) val: \(value)")
676+
Log.error("[SwiftMetricsBAMConfig] Decrypt failed: \(key) val: \(value)")
669677

670678
return ""
671679
}

0 commit comments

Comments
 (0)