-module(blah@internet). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function]). -export([username/0, email/0, password/0, passphrase/0, domain_name/0, url/0, ip_v4/0, ip_v6/0, mac/0, long_hex_color/0, short_hex_color/0, hex_color/0, status_code/0, status_code_in_class/1]). -export_type([http_status_class/0]). -type http_status_class() :: informational | successful | redirection | client_error | server_error. -spec username() -> binary(). username() -> Adjective = blah@en@word:adjective(), Last_name = blah@name:last_name(), Nonce = gleam@int:random(4, 2048), case Nonce rem 4 of 0 -> _pipe = [Adjective, Last_name], gleam@string:join(_pipe, <<""/utf8>>); 1 -> _pipe@1 = [Adjective, gleam@string:lowercase(Last_name)], gleam@string:join(_pipe@1, <<"."/utf8>>); 2 -> _pipe@2 = [Adjective, gleam@string:lowercase(Last_name)], gleam@string:join(_pipe@2, <<"-"/utf8>>); 3 -> _pipe@3 = [Adjective, gleam@string:lowercase(Last_name)], gleam@string:join(_pipe@3, <<"_"/utf8>>) end. -spec email() -> binary(). email() -> Email_domain = blah@utils:get_random_item( [<<"aol.com"/utf8>>, <<"gmail.com"/utf8>>, <<"hotmail.com"/utf8>>, <<"live.com"/utf8>>, <<"mail.ru"/utf8>>, <<"msn.com"/utf8>>, <<"outlook.com"/utf8>>, <<"proton.me"/utf8>>, <<"protonmail.com"/utf8>>, <<"yahoo.com"/utf8>>, <<"ymail.com"/utf8>>] ), _pipe = [username(), Email_domain], gleam@string:join(_pipe, <<"@"/utf8>>). -spec password() -> binary(). password() -> Length = gleam@int:random(8, 32), blah@en@string:alphanumeric(Length). -spec passphrase() -> binary(). passphrase() -> _pipe@1 = [blah@en@word:adjective(), begin _pipe = blah@name:first_name(), gleam@string:lowercase(_pipe) end, blah@en@word:verb(), blah@en@word:adverb()], gleam@string:join(_pipe@1, <<" "/utf8>>). -spec domain_name() -> binary(). domain_name() -> Adjective = blah@en@word:adjective(), Noun = blah@en@word:noun(), Nonce = gleam@int:random(4, 2048), Hostname = case Nonce rem 3 of 0 -> _pipe = [Adjective, Noun], gleam@string:join(_pipe, <<"."/utf8>>); 1 -> _pipe@1 = [Adjective, Noun], gleam@string:join(_pipe@1, <<"-"/utf8>>); 2 -> _pipe@2 = [Adjective, Noun], gleam@string:join(_pipe@2, <<"_"/utf8>>) end, Suffix = blah@utils:get_random_item( [<<"co"/utf8>>, <<"com"/utf8>>, <<"edu"/utf8>>, <<"gov"/utf8>>, <<"int"/utf8>>, <<"io"/utf8>>, <<"mil"/utf8>>, <<"net"/utf8>>, <<"org"/utf8>>] ), _pipe@3 = [Hostname, Suffix], gleam@string:join(_pipe@3, <<"."/utf8>>). -spec url() -> binary(). url() -> Protocol = blah@utils:get_random_item([<<"http"/utf8>>, <<"https"/utf8>>]), _pipe = [Protocol, <<"://"/utf8>>, domain_name()], gleam@string:join(_pipe, <<""/utf8>>). -spec ip_v4() -> binary(). ip_v4() -> _pipe = gleam@list:repeat(<<""/utf8>>, 4), _pipe@1 = gleam@list:map(_pipe, fun(_) -> gleam@int:random(0, 256) end), _pipe@2 = gleam@list:map(_pipe@1, fun gleam@int:to_string/1), gleam@string:join(_pipe@2, <<"."/utf8>>). -spec ip_v6() -> binary(). ip_v6() -> _pipe = gleam@list:repeat(<<""/utf8>>, 8), _pipe@1 = gleam@list:map(_pipe, fun(_) -> gleam@int:random(0, 65536) end), _pipe@4 = gleam@list:map(_pipe@1, fun(Field) -> _pipe@2 = Field, _pipe@3 = gleam@int:to_base16(_pipe@2), gleam@string:lowercase(_pipe@3) end), gleam@string:join(_pipe@4, <<":"/utf8>>). -spec mac() -> binary(). mac() -> _pipe = gleam@list:repeat(<<""/utf8>>, 6), _pipe@1 = gleam@list:map(_pipe, fun(_) -> gleam@int:random(0, 256) end), _pipe@4 = gleam@list:map(_pipe@1, fun(Field) -> _pipe@2 = Field, _pipe@3 = gleam@int:to_base16(_pipe@2), gleam@string:lowercase(_pipe@3) end), gleam@string:join(_pipe@4, <<":"/utf8>>). -spec long_hex_color() -> binary(). long_hex_color() -> _pipe@5 = [<<"#"/utf8>> | begin _pipe = gleam@list:repeat(<<""/utf8>>, 3), _pipe@1 = gleam@list:map( _pipe, fun(_) -> gleam@int:random(0, 256) end ), gleam@list:map(_pipe@1, fun(Field) -> _pipe@2 = Field, _pipe@3 = gleam@int:to_base16(_pipe@2), _pipe@4 = gleam@string:lowercase(_pipe@3), gleam@string:pad_left(_pipe@4, 2, <<"0"/utf8>>) end) end], gleam@string:join(_pipe@5, <<""/utf8>>). -spec short_hex_color() -> binary(). short_hex_color() -> _pipe@4 = [<<"#"/utf8>> | begin _pipe = gleam@list:repeat(<<""/utf8>>, 3), _pipe@1 = gleam@list:map( _pipe, fun(_) -> gleam@int:random(0, 15) end ), gleam@list:map(_pipe@1, fun(Field) -> _pipe@2 = Field, _pipe@3 = gleam@int:to_base16(_pipe@2), gleam@string:lowercase(_pipe@3) end) end], gleam@string:join(_pipe@4, <<""/utf8>>). -spec hex_color() -> binary(). hex_color() -> Nonce = gleam@int:random(4, 2048), case Nonce rem 2 of 0 -> long_hex_color(); 1 -> short_hex_color() end. -spec status_code() -> integer(). status_code() -> {_, Codes} = blah@utils:get_random_item( [{<<"informational"/utf8>>, [100, 101, 102, 103]}, {<<"successful"/utf8>>, [200, 201, 202, 203, 204, 205, 206, 207, 208, 226]}, {<<"redirection"/utf8>>, [300, 301, 302, 303, 304, 305, 306, 307, 308]}, {<<"client_error"/utf8>>, [400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 421, 422, 423, 424, 425, 426, 428, 429, 431, 451]}, {<<"server_error"/utf8>>, [500, 501, 502, 503, 504, 505, 506, 507, 508, 510, 511]}] ), blah@utils:get_random_item(Codes). -spec status_code_in_class(http_status_class()) -> integer(). status_code_in_class(Class) -> Class_string = case Class of informational -> <<"informational"/utf8>>; successful -> <<"successful"/utf8>>; redirection -> <<"redirection"/utf8>>; client_error -> <<"client_error"/utf8>>; server_error -> <<"server_error"/utf8>> end, [{_, Codes}] = gleam@list:filter( [{<<"informational"/utf8>>, [100, 101, 102, 103]}, {<<"successful"/utf8>>, [200, 201, 202, 203, 204, 205, 206, 207, 208, 226]}, {<<"redirection"/utf8>>, [300, 301, 302, 303, 304, 305, 306, 307, 308]}, {<<"client_error"/utf8>>, [400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 421, 422, 423, 424, 425, 426, 428, 429, 431, 451]}, {<<"server_error"/utf8>>, [500, 501, 502, 503, 504, 505, 506, 507, 508, 510, 511]}], fun(Kv) -> gleam@pair:first(Kv) =:= Class_string end ), blah@utils:get_random_item(Codes).