Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
85220fa
UTF8 Support
Mar 31, 2014
20bf17d
syntax sugar - use assertEqual macro
Mar 31, 2014
c783ef2
Added support for commands options. It's need for commands like 'ls -la'
Oct 9, 2014
cbeace7
Changed Rebar config for sample application
Oct 9, 2014
1d98d88
Changed description for list_files callback
Oct 9, 2014
a687694
Версионность
Oct 31, 2014
b57b379
Исправлена утечка процессов при перезапуске сервиса, исправлены преду…
Nov 10, 2014
4b93bb4
Remove unused test function
ryancrum Nov 12, 2014
38e4c23
Fix comment styles and indentation.
ryancrum Nov 12, 2014
d9f4043
Merge 20bf17dd92dfc5046df4f2441a3871a370e7a2ae into 38e4c230f447cac3e…
Nov 12, 2014
b8b6502
Whitespace/indentation fixes
ryancrum Nov 12, 2014
9018ad6
Fix merge
Nov 24, 2014
25a01a9
Обработка ошибок
Dec 23, 2014
3344703
refs #39599 Исправлена обработка команды CDUP
Jan 30, 2015
7d95e44
Add external meck
platinumthinker Feb 17, 2015
0a914ca
Подтянул изменения из github с корректировками для работы SFTP.
Mar 6, 2015
cb79225
Исправление ошибок
Mar 11, 2015
6dad07a
Перенес тесты в отдельный модуль
Mar 11, 2015
f0526b8
Решена проблема, когда ошибка при запуске FTP-сервера вызывала крах ядра
Mar 12, 2015
d4c90ae
refs #41442 Поддержка алармов, форматирование кода
Mar 13, 2015
347d715
refs #43234 Добавлена возможность задания определенного сетевого инте…
Apr 24, 2015
58d7280
Обновлен gitignore.
anton-ryabkov Jul 1, 2015
0b6530b
Добавлены параметры:
anton-ryabkov Sep 9, 2015
6ba21b6
Create release branches release_3_7_0
platinumthinker Jun 29, 2016
77d4f30
Create release branches release_3_8_0
platinumthinker Sep 5, 2016
3bea48c
Create release branches release_3_9_0
Dec 6, 2016
89ecf93
Убраны warning-и компиляции.
anton-ryabkov Mar 15, 2017
207213d
Create release branches release_3_10_0
Aug 11, 2017
7587979
refs #87622 Поправлена команда SIZE (раньше она возвращала ошибку, а …
anton-ryabkov Oct 12, 2017
e7b4f5a
fix merge conflict
kharitonov1995 Nov 7, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.eunit/*
.rebar/*
deps/*
ebin/*
sample/ebin/*
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
language: erlang
otp_release:
- R16
- R14B04
10 changes: 0 additions & 10 deletions Makefile

This file was deleted.

86 changes: 0 additions & 86 deletions erlang-bifrost.spec

This file was deleted.

49 changes: 24 additions & 25 deletions include/bifrost.hrl
Original file line number Diff line number Diff line change
@@ -1,39 +1,38 @@

-record(connection_state, {
remote_address = undefined, % client's ip
authenticated_state = unauthenticated, % current state
-record(connection_state,
{
authenticated_state = unauthenticated,
user_name,
data_port = undefined,
pasv_listen = undefined,
ip_address = undefined,
rnfr = undefined,

module, % ftp-implementation module
module_state, % its data

ssl_mode = disabled, % 'disabled' - NO SSL
% 'enabled' - allowed SSL and FTP
% 'only' - non secured FTP is not allowed
% old true and false also supported
module,
module_state,
ssl_mode = disabled, % 'disabled' - NO SSL
% 'enabled' - allowed SSL and FTP
% 'only' - non secured FTP is not allowed
% old true and false also supported
ssl_cert = undefined,
ssl_key = undefined,
ssl_ca_cert = undefined,
protection_mode = clear, % clear | private
protection_mode = clear,
pb_size = 0,
control_socket = undefined,
ssl_socket = undefined,

utf8 = true,
recv_block_size = 64*1024,
send_block_size = 64*1024,

prev_cmd_notify = undefined, % previous command notification data {command, Arguments} | undefined
control_timeout = infinity, % control connection timeout for prev-command notification = tcp_gen:timeout()

port_range = 0 % passive mode's port's range:
% 0 = ANY,
% N = {N, 65535}
% {minPort, maxPort}
% another values - will be skipped
}).
recv_block_size = 64*1024,
send_block_size = 64*1024,
prev_cmd_notify = undefined, % previous command notification data { command, Arguments } | undefined
control_timeout = infinity, % control connection timeout for prev-command notification = tcp_gen:timeout()
establish_active_connection_timeout = 60 * 1000 :: pos_integer() | infinity, % timeout on wait establish active connection (60 sec)
establish_passive_connection_timeout = 60 * 1000 :: pos_integer() | infinity, % timeout on wait establish passive connection (60 sec)
port_range = 0 % passive mode's port's range:
% 0 = ANY,
% N = {N, 65535}
% {minPort, maxPort}
% another values - will be skipped
}).

-record(file_info,
{
Expand Down
13 changes: 7 additions & 6 deletions rebar.config
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{cover_enabled, true}.
{erl_opts, [debug_info]}.
%% THIS FILE IS GENERATED FOR release_3_10_0 %%

{deps, [
% {meck, ".*", {git, "git://github.com/eproxus/meck.git", "0.8.1"}}
]}.
{cover_enabled,true}.
{erl_opts,[debug_info]}.
{deps,[{meck,".*",
{git,"git@git.eltex.loc:external/meck.git",
{branch,"release_3_10_0"}}}]}.
{clean_files,["*.eunit","ebin/*.beam"]}.

{clean_files, ["*.eunit", "ebin/*.beam"]}.
18 changes: 0 additions & 18 deletions sample/Makefile

This file was deleted.

10 changes: 4 additions & 6 deletions sample/rebar.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{erl_opts, [ debug_info,
{i, "../include"},
{i, "include"},
{src_dirs, [ "src", "../src" ]}
]}.
{erl_opts, [debug_info]}.

{deps, [] }.
{deps, [
{bifrost, ".*", {git, "https://github.com/dmitrii-zolotarev/bifrost.git", {branch, "master"}}}
]}.
50 changes: 20 additions & 30 deletions sample/src/bifrost_memory_server.erl
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@

-module(bifrost_memory_server).
-include("../include/bifrost.hrl").
-include_lib("eunit/include/eunit.hrl").

-behavior(gen_bifrost_server).

% Bifrost callbacks
-export([login/3,
init/2,
check_user/2,
check_user/2,
current_directory/1,
make_directory/2,
change_directory/2,
list_files/2,
list_files/3,
remove_directory/2,
remove_file/2,
put_file/4,
Expand Down Expand Up @@ -46,17 +47,16 @@

% Initialize the state
init(InitialState, _) ->
error_logger:info_msg("Init ~w...", [?MODULE]),
InitialState.

% All users w/o any requirements
check_user(State, Username) ->
case Username of
"root" ->
{error, "root account is locked for ftp", State};
_Another ->
{ok, State}
end.
case Username of
"root" ->
{error, "root account is locked for ftp", State};
_Another ->
{ok, State}
end.

% Authenticate the user. Return {false, State} to fail.
login(State, _Username, _Password) ->
Expand Down Expand Up @@ -102,8 +102,8 @@ change_directory(State, Directory) ->
{error, State}
end.

disconnect(State, _Reason) ->
{ok, State}.
disconnect(_, Reason) ->
ok.

% Delete a file
remove_file(State, File) ->
Expand Down Expand Up @@ -153,9 +153,9 @@ remove_directory(State, Directory) ->
end.

% List files in the current or specified directory.
list_files(State, "") ->
list_files(State, current_directory(State));
list_files(State, Directory) ->
list_files(State, Options, "") ->
list_files(State, Options, current_directory(State));
list_files(State, _Options, Directory) ->
Target = absolute_path(State, Directory),
Fs = get_fs(get_module_state(State)),
case fetch_path(Fs, Target) of
Expand All @@ -180,23 +180,18 @@ list_files(State, Directory) ->
% Upload notification is arriving during it with FileRetrievalFun == notification
% and _Status done or terminated
put_file(State, _ProvidedFileName, notification, _Status) ->
{ok, State};

{ok, State};
put_file(State, ProvidedFileName, _Mode, FileRetrievalFun) ->
FileName = lists:last(string:tokens(ProvidedFileName, "/")),
Target = absolute_path(State, FileName),
ModState = get_module_state(State),
Fs = get_fs(ModState),
case read_from_fun(FileRetrievalFun) of
{ok, FileBytes, FileSize} ->
NewFs= set_path(Fs, Target, {file,
{ok, FileBytes, FileSize} = read_from_fun(FileRetrievalFun),
NewFs= set_path(Fs, Target, {file,
FileBytes,
new_file_info(FileName, file, FileSize)}),
NewModState = ModState#msrv_state{fs=NewFs},
{ok, set_module_state(State, NewModState)};
{error, Reason} ->
{error, Reason, State}
end.
NewModState = ModState#msrv_state{fs=NewFs},
{ok, set_module_state(State, NewModState)}.

% Returns {ok, fun(ByteCount)}, which is a function that reads ByteCount byes
% and itself returns a continuation until {done, State} is returned.
Expand Down Expand Up @@ -231,17 +226,13 @@ site_help(_) ->
{error, not_found}.

% Memory Server-specific Functions

read_from_fun(Fun) ->
read_from_fun([], 0, Fun).

read_from_fun(Buffer, Count, Fun) ->
case Fun() of
{ok, _Bytes, ReadCount} when Count + ReadCount >= 1024*1024 ->
{error, {550, "No space left on device."} };

{ok, Bytes, ReadCount} ->
read_from_fun(Buffer ++ [Bytes], Count + ReadCount, Fun);

done ->
{ok, Buffer, Count}
end.
Expand Down Expand Up @@ -383,7 +374,6 @@ set_path({dir, Root, FileInfo}, [Current | Rest], Val) ->

% Tests
-ifdef(TEST).
-include_lib("eunit/include/eunit.hrl").

fs_with_paths([], State) ->
State;
Expand Down
10 changes: 1 addition & 9 deletions sample/src/bifrost_sample_app.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,9 @@
-behaviour(application).

-export([start/2, stop/1]).
-define(PORT, 2121).

start(_Type, _Args) ->
case bifrost_sample_sup:start_link([{port, ?PORT}]) of
{ok, Pid} ->
error_logger:info_msg("Started at port ~w...", [?PORT]),
{ok, Pid};
Else ->
error_logger:error_msg("Start error ~p", [Else]),
Else
end.
bifrost_sample_sup:start_link().

stop(_State) ->
ok.
Loading