Skip to content

Commit

Permalink
removed all prints
Browse files Browse the repository at this point in the history
  • Loading branch information
CryptoSax committed Aug 31, 2021
1 parent b2fdcfc commit 6ffad04
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 201 deletions.
11 changes: 0 additions & 11 deletions Sources/ShadowSwift/AddressReader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//

import Foundation

// FIXME: Logger

class AddressReader
Expand All @@ -28,7 +27,6 @@ class AddressReader
guard let addrType = AddrType(rawValue: Int(buffer[0]))
else
{
print("Failed to initialize Socks5Addr, AddrType is unknown: \(Int(buffer[0]))")
return nil
}

Expand All @@ -43,7 +41,6 @@ class AddressReader
guard buffer.count >= addrLength
else
{
print("Unable to initialize a Socks5Addr. Total data size \(buffer.count) is incorrect for a domain length of \(hostLength)")
return nil
}

Expand All @@ -61,14 +58,12 @@ class AddressReader
guard let hostString = String(data: hostData, encoding: .utf8)
else
{
print("Unable to resolve domain name host with provided data: \(String(data: addressData, encoding: .utf8) ?? "could not decode data to string for logging")")
return nil
}

guard let portString = String(data: portData, encoding: .utf8)
else
{
print("Unable to decode portData to string: \(portData)")
return nil
}

Expand All @@ -81,7 +76,6 @@ class AddressReader
guard buffer.count >= addressLength
else
{
print("Received an IPv4 address with an incorrect length: \(buffer.count)")
return nil
}

Expand All @@ -96,14 +90,12 @@ class AddressReader
guard let hostString = String(data: hostData, encoding: .utf8)
else
{
print("Failed to decode host data into a string: \(hostData)")
return nil
}

guard let portString = String(data: portData, encoding: .utf8)
else
{
print("Failed to decode port data into a string: \(portData)")
return nil
}

Expand All @@ -116,7 +108,6 @@ class AddressReader
guard buffer.count >= addressLength
else
{
print("Received an IPv6 address with an incorrect length: \(buffer.count)")
return nil
}

Expand All @@ -129,14 +120,12 @@ class AddressReader
guard let hostString = String(data: hostData, encoding: .utf8)
else
{
print("Failed to decode host data into a string: \(hostData)")
return nil
}

guard let portString = String(data: portData, encoding: .utf8)
else
{
print("Failed to decode port data into a string: \(portData)")
return nil
}

Expand Down
18 changes: 6 additions & 12 deletions Sources/ShadowSwift/Cipher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,13 @@ class Cipher

static func hkdfSHA1(secret: Data, salt: Data, cipherMode: CipherMode) -> Data?
{
print("HKDFSHA1")
print("\nsalt")
print(salt.array)
let info = Data(string: "ss-subkey")
let outputSize = secret.count

let iterations = UInt8(ceil(Double(outputSize) / Double(Insecure.SHA1.byteCount)))
guard iterations <= 255
else
{
print("Key derviation failure: Too many iterations - \(iterations)")
return nil
}

Expand Down Expand Up @@ -211,7 +207,7 @@ class Cipher
}
catch let encryptError
{
print("Error running AESGCM encryption: \(encryptError)")
log.error("Error running AESGCM encryption: \(encryptError)")
}

case .AES_256_GCM:
Expand All @@ -224,7 +220,7 @@ class Cipher
}
catch let encryptError
{
print("Error running AESGCM encryption: \(encryptError)")
log.error("Error running AESGCM encryption: \(encryptError)")
}

case .CHACHA20_IETF_POLY1305:
Expand All @@ -237,7 +233,7 @@ class Cipher
}
catch let encryptError
{
print("Error running ChaChaPoly encryption: \(encryptError)")
log.error("Error running ChaChaPoly encryption: \(encryptError)")
}
}

Expand Down Expand Up @@ -272,7 +268,7 @@ class Cipher
}
catch let decryptError
{
print("Error running AESGCM decryption: \(decryptError)")
log.error("Error running AESGCM decryption: \(decryptError)")
return nil
}
case .AES_256_GCM:
Expand All @@ -283,7 +279,7 @@ class Cipher
}
catch let decryptError
{
print("Error running AESGCM decryption: \(decryptError)")
log.error("Error running AESGCM decryption: \(decryptError)")
return nil
}
case .CHACHA20_IETF_POLY1305:
Expand All @@ -294,7 +290,7 @@ class Cipher
}
catch let decryptError
{
print("Error running ChaChaPoly decryption: \(decryptError)")
log.error("Error running ChaChaPoly decryption: \(decryptError)")
return nil
}
}
Expand All @@ -307,8 +303,6 @@ class Cipher

// We have 8 bytes, nonce should be 12
counterData.append(contentsOf: [0, 0, 0, 0])
print("Nonce counter data size: \(counterData.count)")
print("Nonce counter data: \(counterData[0]), \(counterData[11])")

// We increment our counter every time nonce is used (encrypt/decrypt)
counter += 1
Expand Down
6 changes: 2 additions & 4 deletions Sources/ShadowSwift/ShadowConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@ public struct ShadowConfig: Codable
let decoded = try decoder.decode(ShadowConfig.self, from: data)
self = decoded
}
catch let decodeError
catch
{
print("Error decoding Shadow Config data: \(decodeError)")
return nil
}
}
Expand All @@ -53,9 +52,8 @@ public struct ShadowConfig: Codable
let data = try Data(contentsOf: url)
self.init(from: data)
}
catch (let error)
catch
{
print("Failed to get data from path \(url.path). \nError: \(error)")
return nil
}
}
Expand Down
5 changes: 1 addition & 4 deletions Sources/ShadowSwift/ShadowConnection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,6 @@ open class ShadowConnection: Transport.Connection

func sendSalt() -> Bool
{
print("Sending Salt : \(salt.array)")
guard network.write(data: salt)
else
{
Expand All @@ -379,7 +378,7 @@ open class ShadowConnection: Transport.Connection
guard let serverSalt = maybeSalt
else
{
print("We did not receive salt from the server.")
self.log.debug("We did not receive salt from the server.")
return false
}

Expand Down Expand Up @@ -429,8 +428,6 @@ open class ShadowConnection: Transport.Connection
return
}

print("Sending address: \(encryptedAddress.count)")

let written = network.write(data: encryptedAddress)
if written
{
Expand Down
Loading

0 comments on commit 6ffad04

Please sign in to comment.