orber_env.erl

来自「OTP是开放电信平台的简称」· ERL 代码 · 共 1,444 行 · 第 1/4 页

ERL
1,444
字号
	    Port;	{ok, {local, Default, _NATList}} ->	    Default;	_ -> 	    iiop_port()    end.nat_iiop_port(LocalPort) ->    case application:get_env(orber, nat_iiop_port) of	{ok, Port} when integer(Port), Port > 0 ->	    Port;	{ok, {local, Default, NATList}} ->	    orber_tb:keysearch(LocalPort, NATList, Default);	_ -> 	    iiop_port()    end.iiop_out_ports() ->    case application:get_env(orber, iiop_out_ports) of	{ok, {Min, Max}} when integer(Min), integer(Max), Min =< Max ->	    {Min, Max};	{ok, {Max, Min}} when integer(Min), integer(Max), Min < Max ->	    {Min, Max};	_ ->	    0    end.domain() ->     case application:get_env(orber, domain) of	{ok, Domain} when list(Domain) ->	    Domain;	{ok, Domain} when atom(Domain) ->	    atom_to_list(Domain);	_ ->	    "ORBER"    end.ip_address_variable_defined() ->    case application:get_env(orber, ip_address) of	undefined ->	    false;	{ok,{multiple, _}} ->	    false;	_ ->	    [Host] = host(),	    Host    end.nat_host() ->    case application:get_env(orber, nat_ip_address) of	{ok,I} when list(I) ->	    [I];	{ok,{multiple, [I|_] = IList}} when list(I) ->	    IList;	{ok,{local, Default, _NATList}} ->	    [Default];	_ ->	    host()    end.nat_host([Host]) ->    case application:get_env(orber, nat_ip_address) of	{ok,I} when list(I) ->	    [I];	{ok,{multiple, [I|_] = IList}} when list(I) ->	    IList;	{ok,{local, Default, NATList}} ->	    [orber_tb:keysearch(Host, NATList, Default)]; 	_ ->	    host()    end.host() ->    case application:get_env(orber, ip_address) of	{ok,I} when list(I) ->	    [I];	{ok,{multiple, [I|_] = IList}} when list(I) ->	    IList;	%% IPv4. For IPv6 we only accept a string, but we must support this format	%% for IPv4 	{ok, {A1, A2, A3, A4}} when integer(A1+A2+A3+A4) ->	    [integer_to_list(A1) ++ "." ++ integer_to_list(A2) ++ "." ++ integer_to_list(A3)	     ++ "." ++ integer_to_list(A4)];	_ ->	    Flags = get_flags(),	    case ?ORB_FLAG_TEST(Flags, ?ORB_ENV_HOSTNAME_IN_IOR) of		true ->		    {ok, Hostname} = inet:gethostname(),		    [Hostname];		_ ->		    case ?ORB_FLAG_TEST(Flags, ?ORB_ENV_USE_IPV6) of			false ->			    [ip_address(inet)];			true ->			    [ip_address(inet6)]		    end	    end    end.ip_address_local() ->    case application:get_env(orber, ip_address_local) of	{ok,I} when list(I) ->	    [I];	_ ->	    []    end. ip_address() ->    ip_address(ip_version()).ip_address(inet) ->    {ok, Hostname} = inet:gethostname(),    {ok, {A1, A2, A3, A4}} = inet:getaddr(Hostname, inet),    integer_to_list(A1) ++ "." ++ integer_to_list(A2) ++ "." ++ integer_to_list(A3)	++ "." ++ integer_to_list(A4);ip_address(inet6) ->    {ok, Hostname} = inet:gethostname(),    {ok, {A1, A2, A3, A4, A5, A6, A7, A8}} = inet:getaddr(Hostname, inet6),    int16_to_hex(A1) ++ ":" ++int16_to_hex(A2) ++ ":" ++	int16_to_hex(A3) ++ ":" ++ int16_to_hex(A4) ++ ":" ++	int16_to_hex(A5) ++ ":" ++ int16_to_hex(A6) ++ ":" ++	int16_to_hex(A7) ++ ":" ++ int16_to_hex(A8).getaddrstr(Hostname, inet) ->    {ok, {A1, A2, A3, A4}} = inet:getaddr(Hostname, inet),    integer_to_list(A1) ++ "." ++ integer_to_list(A2) ++ "." ++ integer_to_list(A3)	++ "." ++ integer_to_list(A4);getaddrstr(Hostname, inet6) ->    {ok, {A1, A2, A3, A4, A5, A6, A7, A8}} = inet:getaddr(Hostname, inet6),    int16_to_hex(A1) ++ ":" ++int16_to_hex(A2) ++ ":" ++	int16_to_hex(A3) ++ ":" ++ int16_to_hex(A4) ++ ":" ++	int16_to_hex(A5) ++ ":" ++ int16_to_hex(A6) ++ ":" ++	int16_to_hex(A7) ++ ":" ++ int16_to_hex(A8).addr2str({A1, A2, A3, A4}) ->    integer_to_list(A1) ++ "." ++ integer_to_list(A2) ++ "." ++ integer_to_list(A3)	++ "." ++ integer_to_list(A4);addr2str({A1, A2, A3, A4, A5, A6, A7, A8}) ->    int16_to_hex(A1) ++ ":" ++int16_to_hex(A2) ++ ":" ++	int16_to_hex(A3) ++ ":" ++ int16_to_hex(A4) ++ ":" ++	int16_to_hex(A5) ++ ":" ++ int16_to_hex(A6) ++ ":" ++	int16_to_hex(A7) ++ ":" ++ int16_to_hex(A8).    int16_to_hex(0) ->    [$0];int16_to_hex(I) ->    N1 = ((I bsr 8) band 16#ff),    N2 = (I band 16#ff),    [code_character(N1 div 16), code_character(N1 rem 16),     code_character(N2 div 16), code_character(N2 rem 16)].code_character(N) when N < 10 ->    $0 + N;code_character(N) ->    $A + (N - 10).giop_version() ->    case application:get_env(orber, giop_version) of	{ok, {Major, Minor}} ->	    {Major, Minor};	_ ->	    {1, 1}    end.iiop_timeout() ->    case application:get_env(orber, iiop_timeout) of	{ok, Int} when integer(Int) ->	    if		Int > 1000000 ->		    error_logger:error_msg("Orber 'iiop_timeout' badly configured.~n"					   "Time to large (>1000000 sec), swithed to 'infinity'~n"),		    infinity;		true ->		    %% Convert to msec.		    Int*1000	    end;	_ ->	    infinity    end.iiop_connection_timeout() ->    case application:get_env(orber, iiop_connection_timeout) of	{ok, Int} when integer(Int) ->	    if		Int > 1000000 ->		    error_logger:error_msg("Orber 'iiop_connection_timeout' badly configured.~n"					   "Time to large (>1000000 sec), swithed to 'infinity'~n"),		    infinity;		true ->		    %% Convert to msec.		    Int*1000	    end;	_ ->	    infinity    end.iiop_setup_connection_timeout() ->    case application:get_env(orber, iiop_setup_connection_timeout) of	{ok, Int} when integer(Int) ->            %% Convert to msec.	    Int*1000;	_ ->	    infinity    end.iiop_in_connection_timeout() ->    case application:get_env(orber, iiop_in_connection_timeout) of	{ok, Int} when integer(Int) ->	    if		Int > 1000000 ->		    error_logger:error_msg("Orber 'iiop_connection_timeout' badly configured.~n"					   "Time to large (>1000000 sec), swithed to 'infinity'~n"),		    infinity;		true ->		    %% Convert to msec.		    Int*1000	    end;	_ ->	    infinity    end.iiop_max_fragments() ->    case application:get_env(orber, iiop_max_fragments) of	{ok, Max} when integer(Max), Max > 0 ->	    Max;	_ ->	    infinity    end.    iiop_max_in_requests() ->    case application:get_env(orber, iiop_max_in_requests) of	{ok, Max} when integer(Max), Max > 0 ->	    Max;	_ ->	    infinity    end.iiop_max_in_connections() ->    case application:get_env(orber, iiop_max_in_connections) of	{ok, Max} when integer(Max), Max > 0 ->	    Max;	_ ->	    infinity    end.iiop_backlog() ->    case application:get_env(orber, iiop_backlog) of	{ok, Int} when integer(Int), Int >= 0 ->	    Int;	_ ->	    5    end.iiop_in_keepalive() ->    case application:get_env(orber, iiop_in_keepalive) of	{ok, true} ->	    true;	_ ->	    false    end.iiop_out_keepalive() ->    case application:get_env(orber, iiop_out_keepalive) of	{ok, true} ->	    true;	_ ->	    false    end. get_flags() ->    case get(oe_orber_flags) of	undefined ->	    case application:get_env(orber, flags) of		undefined ->		    put(oe_orber_flags, ?ORB_ENV_INIT_FLAGS),		    ?ORB_ENV_INIT_FLAGS;		{ok, Flags} ->		    put(oe_orber_flags, Flags),		    Flags	    end;	Flags when integer(Flags) ->	    Flags    end.typechecking() ->    ?ORB_FLAG_TEST(get_flags(), ?ORB_ENV_LOCAL_TYPECHECKING).exclude_codeset_ctx() ->    ?ORB_FLAG_TEST(get_flags(), ?ORB_ENV_EXCLUDE_CODESET_CTX).exclude_codeset_component() ->    ?ORB_FLAG_TEST(get_flags(), ?ORB_ENV_EXCLUDE_CODESET_COMPONENT).partial_security() ->    ?ORB_FLAG_TEST(get_flags(), ?ORB_ENV_PARTIAL_SECURITY).use_CSIv2() ->    ?ORB_FLAG_TEST(get_flags(), ?ORB_ENV_USE_CSIV2).use_FT() ->    ?ORB_FLAG_TEST(get_flags(), ?ORB_ENV_USE_FT).ip_version() ->    case ?ORB_FLAG_TEST(get_flags(), ?ORB_ENV_USE_IPV6) of	false ->	    inet;	true ->	    inet6    end.light_ifr() ->    ?ORB_FLAG_TEST(get_flags(), ?ORB_ENV_LIGHT_IFR).bidir_context() ->    Flags = get_flags(),    if	?ORB_FLAG_TEST(Flags, ?ORB_ENV_USE_BI_DIR_IIOP) ->	    [#'IOP_ServiceContext'	     {context_id=?IOP_BI_DIR_IIOP,	      context_data = 	      #'IIOP_BiDirIIOPServiceContext'{listen_points = 					      [#'IIOP_ListenPoint'{host=host(), 								   port=iiop_port()}]}}];	true ->	    []    end.objectkeys_gc_time() ->    case application:get_env(orber, objectkeys_gc_time) of	{ok, Int} when integer(Int) ->	    if		Int > 1000000 ->		    error_logger:error_msg("Orber 'objectkeys_gc_time' badly configured.~n"					   "Time to large (>1000000 sec), swithed to 'infinity'~n"),		    infinity;		true ->		    Int	    end;	_ ->	    infinity    end.get_ORBInitRef() ->    case application:get_env(orber, orbInitRef) of	{ok, Ref} when list(Ref) ->	    Ref;	_ ->	    undefined    end.get_ORBDefaultInitRef() ->    case application:get_env(orber, orbDefaultInitRef) of	{ok, Ref} when list(Ref) ->	    Ref;	_ ->	    undefined

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?