chromium/net/socket/socks_client_socket.cc

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "net/socket/socks_client_socket.h"

#include <utility>

#include "base/compiler_specific.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/sys_byteorder.h"
#include "net/base/address_list.h"
#include "net/base/io_buffer.h"
#include "net/dns/public/dns_query_type.h"
#include "net/dns/public/secure_dns_policy.h"
#include "net/log/net_log.h"
#include "net/log/net_log_event_type.h"
#include "net/traffic_annotation/network_traffic_annotation.h"

namespace net {

// Every SOCKS server requests a user-id from the client. It is optional
// and we send an empty string.
static const char kEmptyUserId[] =;

// For SOCKS4, the client sends 8 bytes  plus the size of the user-id.
static const unsigned int kWriteHeaderSize =;

// For SOCKS4 the server sends 8 bytes for acknowledgement.
static const unsigned int kReadHeaderSize =;

// Server Response codes for SOCKS.
static const uint8_t kServerResponseOk =;
static const uint8_t kServerResponseRejected =;
static const uint8_t kServerResponseNotReachable =;
static const uint8_t kServerResponseMismatchedUserId =;

static const uint8_t kSOCKSVersion4 =;
static const uint8_t kSOCKSStreamRequest =;

// A struct holding the essential details of the SOCKS4 Server Request.
// The port in the header is stored in network byte order.
struct SOCKS4ServerRequest {};
static_assert;

// A struct holding details of the SOCKS4 Server Response.
struct SOCKS4ServerResponse {};
static_assert;

SOCKSClientSocket::SOCKSClientSocket(
    std::unique_ptr<StreamSocket> transport_socket,
    const HostPortPair& destination,
    const NetworkAnonymizationKey& network_anonymization_key,
    RequestPriority priority,
    HostResolver* host_resolver,
    SecureDnsPolicy secure_dns_policy,
    const NetworkTrafficAnnotationTag& traffic_annotation)
    :{}

SOCKSClientSocket::~SOCKSClientSocket() {}

int SOCKSClientSocket::Connect(CompletionOnceCallback callback) {}

void SOCKSClientSocket::Disconnect() {}

bool SOCKSClientSocket::IsConnected() const {}

bool SOCKSClientSocket::IsConnectedAndIdle() const {}

const NetLogWithSource& SOCKSClientSocket::NetLog() const {}

bool SOCKSClientSocket::WasEverUsed() const {}

NextProto SOCKSClientSocket::GetNegotiatedProtocol() const {}

bool SOCKSClientSocket::GetSSLInfo(SSLInfo* ssl_info) {}

int64_t SOCKSClientSocket::GetTotalReceivedBytes() const {}

void SOCKSClientSocket::ApplySocketTag(const SocketTag& tag) {}

// Read is called by the transport layer above to read. This can only be done
// if the SOCKS handshake is complete.
int SOCKSClientSocket::Read(IOBuffer* buf,
                            int buf_len,
                            CompletionOnceCallback callback) {}

int SOCKSClientSocket::ReadIfReady(IOBuffer* buf,
                                   int buf_len,
                                   CompletionOnceCallback callback) {}

int SOCKSClientSocket::CancelReadIfReady() {}

// Write is called by the transport layer. This can only be done if the
// SOCKS handshake is complete.
int SOCKSClientSocket::Write(
    IOBuffer* buf,
    int buf_len,
    CompletionOnceCallback callback,
    const NetworkTrafficAnnotationTag& traffic_annotation) {}

int SOCKSClientSocket::SetReceiveBufferSize(int32_t size) {}

int SOCKSClientSocket::SetSendBufferSize(int32_t size) {}

void SOCKSClientSocket::DoCallback(int result) {}

void SOCKSClientSocket::OnIOComplete(int result) {}

void SOCKSClientSocket::OnReadWriteComplete(CompletionOnceCallback callback,
                                            int result) {}

int SOCKSClientSocket::DoLoop(int last_io_result) {}

int SOCKSClientSocket::DoResolveHost() {}

int SOCKSClientSocket::DoResolveHostComplete(int result) {}

// Builds the buffer that is to be sent to the server.
const std::string SOCKSClientSocket::BuildHandshakeWriteBuffer() const {}

// Writes the SOCKS handshake data to the underlying socket connection.
int SOCKSClientSocket::DoHandshakeWrite() {}

int SOCKSClientSocket::DoHandshakeWriteComplete(int result) {}

int SOCKSClientSocket::DoHandshakeRead() {}

int SOCKSClientSocket::DoHandshakeReadComplete(int result) {}

int SOCKSClientSocket::GetPeerAddress(IPEndPoint* address) const {}

int SOCKSClientSocket::GetLocalAddress(IPEndPoint* address) const {}

ResolveErrorInfo SOCKSClientSocket::GetResolveErrorInfo() const {}

}  // namespace net