anchor.diff:              ?MODULE:start(Mode, ListenerPort, Args)
       end.
   
  -
  -%% main_loop/2
  -%% ====================================================================
  -%% @doc oneproxy port dirver's main loop.
  -%% @end
  +%%--------------------------------------------------------------------
  +%% @private
  +%% @doc
  +%% oneproxy port dirver's main loop.
  +%% @end
  +%%--------------------------------------------------------------------
   -spec main_loop(Port :: term(), State :: #oneproxy_state{}) -> no_return().
  -%% ====================================================================
   main_loop(Port, #oneproxy_state{timeout = Timeout, endpoint = EnpointPort} = State) ->
       NewState =
           receive
  -            %% Handle oneproxy logs
  +        %% Handle oneproxy logs
               {Port, {data, {eol, <<?LOG_DEBUG_PREFIX, Log/binary>>}}} ->
                   ?debug("[ oneproxy ~p ] ~s", [EnpointPort, utils:ensure_list(Log)]),
                   State;
  
positive.code: %% ===================================================================
  %% @author Rafal Slota
  %% @copyright (C): 2014 ACK CYFRONET AGH
  %% This software is released under the MIT license
  %% cited in 'LICENSE.txt'.
  %% @end
  %% ===================================================================
  %% @doc: Port driver for oneproxy module.
  %% @end
  %% ===================================================================
  -module(oneproxy).
  -author("Rafal Slota").
  
  
negative.code: get_local_port(Port) ->
      20000 + Port.
  
  %%--------------------------------------------------------------------
  %% @doc
  %% Starts oneproxy in proxy mode. This function either does not return or throws exception.
  %% @end
  %%--------------------------------------------------------------------
  -spec start_proxy(ListenerPort :: non_neg_integer(), CertFile :: string() | binary(),
      VerifyType :: verify_peer | verify_none) -> no_return().
  start_proxy(ListenerPort, CertFile, VerifyType) ->
      start("proxy", ListenerPort, [utils:ensure_list(CertFile),
          utils:ensure_list(VerifyType)]).
  
  %%--------------------------------------------------------------------
  %% @doc
  %% Starts oneproxy in reverse proxy mode with HTTP-based authentication
  %% delegation. This function either does not return or throws exception.
  %% @end
  %%--------------------------------------------------------------------
  -spec start_rproxy(ListenerPort :: non_neg_integer(), ForwardPort :: non_neg_integer(),
      CertFile :: string() | binary(), VerifyType :: verify_peer | verify_none) -> no_return().
  start_rproxy(ListenerPort, ForwardPort, CertFile, VerifyType) ->
      start_rproxy(ListenerPort, ForwardPort, CertFile, VerifyType, http).
  
  %%--------------------------------------------------------------------
  %% @doc
  %% Starts oneproxy in reverse proxy mode. This function either does not return or throws exception.
  %% @end
  %%--------------------------------------------------------------------
  -spec start_rproxy(ListenerPort :: non_neg_integer(), ForwardPort :: non_neg_integer(),
      CertFile :: string() | binary(), VerifyType :: verify_peer | verify_none,
      Http :: http | no_http) -> no_return().
  start_rproxy(ListenerPort, ForwardPort, CertFile, VerifyType, Http) ->
      start("reverse_proxy", ListenerPort, ["127.0.0.1",
          integer_to_list(ForwardPort), utils:ensure_list(CertFile),
          utils:ensure_list(VerifyType), utils:ensure_list(Http)]).
  
  %%--------------------------------------------------------------------
  %% @doc
  %% Returns directory (path) used by oneproxy to save DER CAs and CRLs.
  %% @end
  %%--------------------------------------------------------------------
  -spec get_der_certs_dir() -> string().
  get_der_certs_dir() ->
      {ok, CertDir} = application:get_env(?APP_NAME, ca_dir),
      filename:join(CertDir, ?DER_CERTS_DIR).
  
  %%--------------------------------------------------------------------
  %% @doc
  %% Save all CAs and CRLs from GSI state to given directory in DER format.
  %% @end
  %%--------------------------------------------------------------------
  -spec ca_crl_to_der(Dir :: string()) -> ok | {error, Reason :: any()}.
  ca_crl_to_der(Dir) ->
      case ets:info(gsi_state) of
          undefined ->
  