summaryrefslogtreecommitdiffhomepage
path: root/ios/MullvadREST/Transport/Socks5/Socks5Error.swift
blob: 62e7c4711d4ab0709640824d0e7ecbc86de45e9c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//
//  Socks5Error.swift
//  MullvadTransport
//
//  Created by pronebird on 21/10/2023.
//

import Foundation
import Network

/// The errors returned by objects implementing socks proxy.
public enum Socks5Error: Error, Sendable {
    /// Unexpected end of stream.
    case unexpectedEndOfStream

    /// Failure to decode the domain name from byte stream into utf8 string.
    case decodeDomainName

    /// Failure to parse IPv4 address from raw data.
    case parseIPv4Address

    /// Failure to parse IPv6 address from raw data.
    case parseIPv6Address

    /// Server replied with invalid socks version.
    case invalidSocksVersion

    /// Server replied with unknown endpoint address type.
    case invalidAddressType

    /// Invalid (unassigned) status code is returned.
    case invalidStatusCode(UInt8)

    /// Server replied with unsupported authentication method.
    case unsupportedAuthMethod

    /// Invalid username or password was provided to the server
    case invalidUsernameOrPassword

    /// None of the auth methods listed by the client are acceptable.
    case unacceptableAuthMethods

    /// Connection request is rejected.
    case connectionRejected(Socks5StatusCode)

    /// Failure to instantiate a TCP listener.
    case createTcpListener(Error)

    /// Socks forwarding proxy was cancelled during startup.
    case cancelledDuringStartup

    /// Local connection failure.
    case localConnectionFailure(NWError)

    /// Remote connection failure.
    case remoteConnectionFailure(NWError)
}