diff options
author | Jeffrey Armstrong <jeff@approximatrix.com> | 2023-09-20 08:49:58 -0400 |
---|---|---|
committer | Jeffrey Armstrong <jeff@approximatrix.com> | 2023-09-20 08:49:58 -0400 |
commit | 8217283bed26f052ea0d29afec18b224d63d4fb2 (patch) | |
tree | 5e112f6952d6e40ffa5a4e0f8961249f1737ee75 /captain | |
parent | 10547ba1064ca5a1dd04e782b0df99a22b60de3f (diff) | |
download | levitating-8217283bed26f052ea0d29afec18b224d63d4fb2.tar.gz levitating-8217283bed26f052ea0d29afec18b224d63d4fb2.zip |
Transfer buffers for gemini file transfers extended from 64 bytes to 4K to fix client download issues. Minor fixes to the crypt routines to use c_char arrays rather than strings.
Diffstat (limited to 'captain')
-rw-r--r-- | captain/captain.f90 | 2 | ||||
-rw-r--r-- | captain/crypt.f90 | 9 | ||||
-rw-r--r-- | captain/db.f90 | 3 | ||||
-rw-r--r-- | captain/gemini.f90 | 24 |
4 files changed, 24 insertions, 14 deletions
diff --git a/captain/captain.f90 b/captain/captain.f90 index 4d7b17f..0892324 100644 --- a/captain/captain.f90 +++ b/captain/captain.f90 @@ -211,4 +211,4 @@ contains end subroutine parse_options -end program captain
\ No newline at end of file +end program captain diff --git a/captain/crypt.f90 b/captain/crypt.f90 index c14d4bb..c19efdc 100644 --- a/captain/crypt.f90 +++ b/captain/crypt.f90 @@ -28,7 +28,7 @@ contains character(len=*), intent(in)::phrase character(len=:), pointer::hash - character(len=:,kind=c_char), pointer::c_phrase + character(kind=c_char), dimension(:), pointer::c_phrase type(c_ptr)::c_res_ptr, c_salt_ptr character(kind=c_char), dimension(:), pointer::c_res character(len=5, kind=c_char), target::prefix @@ -48,8 +48,11 @@ contains prefix = "$2b$"//c_null_char c_salt_ptr = crypt_gensalt_c(c_loc(prefix), int(16,kind=c_long), c_null_ptr, 0) - allocate(character(len=len_trim(phrase)+1) :: c_phrase) - c_phrase = trim(phrase)//c_null_char + allocate(c_phrase(len_trim(phrase)+1)) + do i = 1,len_trim(phrase) + c_phrase(i) = phrase(i:i) + end do + c_phrase(len_trim(phrase)+1) = c_null_char c_res_ptr = crypt_c(c_loc(c_phrase), c_salt_ptr) if(c_associated(c_res_ptr)) then diff --git a/captain/db.f90 b/captain/db.f90 index c3f30c4..34ee16c 100644 --- a/captain/db.f90 +++ b/captain/db.f90 @@ -1492,6 +1492,9 @@ contains character(len=*), intent(in)::username, password logical::new_admin_db + ! Dangerous debug line.... + ! Print *, trim(username)//":"//trim(password) + new_admin_db = new_user_db(username, password, trim(username)//"@localhost", AUTH_ADMIN_USER) end function new_admin_db diff --git a/captain/gemini.f90 b/captain/gemini.f90 index cb829e8..5eeb956 100644 --- a/captain/gemini.f90 +++ b/captain/gemini.f90 @@ -38,7 +38,7 @@ contains type(c_ptr)::ssl character(*), intent(out)::req - character, dimension(64)::buf + character, dimension(256)::buf integer::bufread integer::i, j @@ -78,10 +78,11 @@ contains end subroutine read_request - function read_into_buffer(unit_number, buffer) + function read_into_buffer(unit_number, buffer, bufsize) implicit none integer, intent(in)::unit_number + integer, intent(in)::bufsize character, dimension(*), intent(out)::buffer integer::read_into_buffer @@ -89,7 +90,7 @@ contains ierr = 0 i = 0 - do while(ierr == 0 .and. i < 64) + do while(ierr == 0 .and. i < bufsize) i = i + 1 read(unit_number, iostat=ierr) buffer(i) end do @@ -133,15 +134,18 @@ contains type(c_ptr)::ssl integer, intent(in)::unit_number character(*), intent(in)::mimetype - character, dimension(64)::buf - integer::buflen, written + + integer, parameter::bufsize = 4096 + + character, dimension(bufsize)::buf + integer::readlen, written call write_status(ssl, GEMINI_CODE_SUCCESS, mimetype) - buflen = read_into_buffer(unit_number, buf) - do while(buflen > 0) - written = ssl_write(ssl, buf(1:buflen)) - buflen = read_into_buffer(unit_number, buf) + readlen = read_into_buffer(unit_number, buf, bufsize) + do while(readlen > 0) + written = ssl_write(ssl, buf(1:readlen)) + readlen = read_into_buffer(unit_number, buf, bufsize) end do end subroutine write_file @@ -383,4 +387,4 @@ contains end subroutine handle_request -end module gemini
\ No newline at end of file +end module gemini |