anchor.diff:           set_csocket/2]).
   
   -type opts() :: ranch_ssl:opts()|ranch_tcp:opts().
  --record(proxy_socket, { lsocket :: inet:socket()|ssl:sslsocket(),
  -                        csocket :: inet:socket()|ssl:sslsocket(),
  -                        opts :: opts(),
  -                        inet_version :: ipv4|ipv6,
  -                        source_address :: inet:ip_address(),
  -                        dest_address :: inet:ip_address(),
  -                        source_port :: inet:port_number(),
  -                        dest_port :: inet:port_number(),
  +-record(proxy_socket, { lsocket :: inet:socket()|ssl:sslsocket()|'undefined',
  +                        csocket :: inet:socket()|ssl:sslsocket()|'undefined',
  +                        opts :: opts()|'undefined',
  +                        inet_version :: ipv4|ipv6|'undefined',
  +                        source_address :: inet:ip_address()|'undefined',
  +                        dest_address :: inet:ip_address()|'undefined',
  +                        source_port :: inet:port_number()|'undefined',
  +                        dest_port :: inet:port_number()|'undefined',
                           connection_info = []}).
   -type proxy_opts() :: [{source_address, inet:ip_address()} |
                          {source_port, inet:port_number()} |
  
positive.code: create_proxy_protocol_header(ipv6, SourceAddress, DestAddress, SourcePort,
                               DestPort) ->
      {ok, io_lib:format("PROXY TCP6 ~s ~s ~s ~s\r\n",
                         [SourceAddress, DestAddress, SourcePort, DestPort])};
  create_proxy_protocol_header(_, _, _, _, _) ->
      {error, invalid_proxy_information}.
  
  get_protocol(SourceAddress, DestAddress) when tuple_size(SourceAddress) =:= 8,
                                                tuple_size(DestAddress) =:= 8 ->
  
negative.code:             DestAddress = proplists:get_value(dest_address, ProxyOpts),
              SourcePort = proplists:get_value(source_port, ProxyOpts),
              DestPort = proplists:get_value(dest_port, ProxyOpts),
              {ok, ProxyHeader} = create_proxy_protocol_header(SourceAddress, DestAddress,
                                                               SourcePort, DestPort),
              ranch_tcp:send(Socket, ProxyHeader),
              {ok, ProxySocket#proxy_socket{source_address = SourceAddress,
                                            dest_address = DestAddress,
                                            source_port = SourcePort,
                                            dest_port = DestPort}};
          {error, Error} ->
              io:format("Timeout"),
              {error, Error}
  