rejetto forum

Software => HFS ~ HTTP File Server => Topic started by: IvanRohnson on April 30, 2016, 10:09:18 PM

Title: My questions regarding HFS
Post by: IvanRohnson on April 30, 2016, 10:09:18 PM
Hello guys and thank you for amazing piece of software!


I have used Apache for Linux before but I am an Apache/Linux beginner and now I need to use HFS on Windows:

My questions are as following:

Is HFS using real alphabetical indexing for filenames?
Can I restrict direct access to directory, and only allow people to download files ONLY if they know the exact file name? (and use direct link to the file)?
Can I restrict types of clients that can access files hosted by HFS?
For example allow only clients using specific browser/client/software version?
Can I make it so that the filenames/directories are not case-sensitive (just like using apache Module "Spell"?


Thank you in advance for your answers, I need HFS for something more specific. Please note that I am Apache/Linux beginner and if HFS can provide these features it will allow me to achieve what I am trying to do with less effort.
Title: Re: My questions regarding HFS
Post by: IvanRohnson on May 01, 2016, 12:13:31 PM
Hi again, I tested HFS today

> GET /Setup.exe HTTP/1.1
> Accept: text/html, application/xhtml+xml, */*
> Referer: http://localhost/
> Accept-Language: en-US
> User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; MATMJS; rv:11.0) like Gecko
> Accept-Encoding: gzip, deflate
> Host: localhost
> DNT: 1
> Connection: Keep-Alive


Now I remember that the "client" is called "UserAgent"

So the correct question #4 would be:
"How can I allow only specific UserAgents to download files hosted by HFS program?"

[request]
{.if|{.{.header|User-Agent.}!=ALLOWED_USER_AGENT_NAME.}|{:{.disconnect.}:}.}

I will try this in Alt+F6 and report if it works!
BTW, how to comment out stuff in this scrip file? # or / or ; ?


Title: Re: My questions regarding HFS
Post by: IvanRohnson on May 02, 2016, 09:25:19 AM
Unfortunately, what I need is to limit access based on UserAgent only to couple of specific folders. Does anyone know how to do this?

Another thing I need to do is to have files in different folders, for example I would like to have file named "file1.zip" in "folder1", and "file2.zip" in "folder2",

But when someone tries to download using the link /folder1/file2.zip, I need to have him redirected to the correct folder, in this case /folder2/file2.zip  , so that the file will be automatically downloaded.
Title: Re: My questions regarding HFS
Post by: bmartino1 on May 03, 2016, 05:34:32 PM
Hello guys and thank you for amazing piece of software!


I have used Apache for Linux before but I am an Apache/Linux beginner and now I need to use HFS on Windows:

My questions are as following:

Is HFS using real alphabetical indexing for filenames?
Can I restrict direct access to directory, and only allow people to download files ONLY if they know the exact file name? (and use direct link to the file)?
Can I restrict types of clients that can access files hosted by HFS?
For example allow only clients using specific browser/client/software version?
Can I make it so that the filenames/directories are not case-sensitive (just like using apache Module "Spell"?


Thank you in advance for your answers, I need HFS for something more specific. Please note that I am Apache/Linux beginner and if HFS can provide these features it will allow me to achieve what I am trying to do with less effort.

Unknown fully on the way HFS actual reads or touches the fires, i'm not 100% sure what you wanting.... regarding file names and sort....

you can HTML code base info when a browser begins to read the head, and redirect the webpage they view, see w3schools for more info, i never persoanly experimented with it, but in school, there were examples of this, i know it possible....

For you folder to file view, i can only imagine a sciner of "vitural" folder inside HFS the adding the real file to HFS....

Good luck with your endeavoures
http://www.w3schools.com/jsref/prop_nav_useragent.asp
Title: Re: My questions regarding HFS
Post by: LeoNeeson on May 06, 2016, 11:01:02 AM
Maybe rejetto (http://www.rejetto.com/forum/profile/?u=1) or Mars (http://www.rejetto.com/forum/profile/?u=2913) have an answer for this...
I think a "macro" is the only way to go.
Title: Re: My questions regarding HFS
Post by: Mars on May 06, 2016, 07:07:53 PM
the answers are not exhaustive but may help as needed

Is HFS using real alphabetical indexing for filenames?

Menu > Other options > Default sorting

Can I restrict direct access to directory, and only allow people to download files ONLY if they know the exact file name? (and use direct link to the file)?

add desired directory to VFS as real folder, set properties flags: Recursively hidden =ON , Browsable= OFF

the user must know the exact url to access each downloadable file

Can I restrict types of clients that can access files hosted by HFS?
Quote
[]
......
<body>
{.for each|agent|Chrome|MSIE|{:{.if not|{.pos|{.^agent.}|{.header|User-Agent.}.}|{:{.disconnection reason| Your browser is not compatible with this server <p> {.header|User-Agent.}.}:}/if.}:}.}

only users using Chrome or Internet Explorer will not be disconnected
blue values must be substings of  User-Agent

Result by using Firefox

Forbidden
Your browser is not compatible with this server

Mozilla/5.0 (Windows NT 5.1; rv:46.0) Gecko/20100101 Firefox/46.0



Unfortunately, what I need is to limit access based on UserAgent only to couple of specific folders. Does anyone know how to do this?

yes, it's possible to cause browser redirection function to a specific folder based on different user-agent

one solution is to have a common directory for redirection and sub directories as folder1 and folder2 and redirect the user to the common folder when his user-agent is in a specific list separated by "|"


to solve the problem I have used this method:
When the user-agent contains one of substrings in the macro "for each"
and if the path (from root) does not start as defined in macro "set"
then the user is redirected to defined folder.

Quote
[]
......
<body>
{.for each|agent|Chrome|Firefox|{:
  {.set|goto|/redirect_folder/.}
  {.if not|{.=|1|{.pos|{.^goto.}|%folder%.}.}|{:
    {.if|{.pos|{.^agent.}|{.header|User-Agent.}.}|{:{.redirect|{.^goto.}.}:}.}
  :}.}
:}.}   
Title: Re: My questions regarding HFS
Post by: rejetto on May 08, 2016, 04:08:00 PM
Hello guys and thank you for amazing piece of software!

welcome!


> Is HFS using real alphabetical indexing for filenames?

"real" ? i'm not sure what you mean.
HFS accepts sorting as a parameter from the client.

> Can I restrict direct access to directory, and only allow people to download files ONLY if they know the exact file name? (and use direct link to the file)?

it's the "browsable" option, as Mars reported

> Can I restrict types of clients that can access files hosted by HFS?

I saw Mars suggestion, but it's better to not change the template when possible.
Click "edit event scripts" (under Menu - other options), and add this text
Code: [Select]
[+request]
{.disconnection reason|Not allowed|if=
{.and
|{.match|/folder1*;/vedere*|%url%.}
|{.match|\*Chrome*;*MSIE*|{.header|User-Agent.}.}
.}
.}

It's just an example, and may contain errors. Adjust to your needs.

> Can I make it so that the filenames/directories are not case-sensitive (just like using apache Module "Spell"?

HFS 2 is a Windows software, and as such is already as you want
Title: Re: My questions regarding HFS
Post by: IvanRohnson on May 15, 2016, 04:53:46 PM
Thank you very much for your replies, I will test everything soon and post again if I am having trouble.
What I do hope is that you will add all of the things I asked in this topic as "default native features", so that they are more intuitive for use.

"Mars", your post is extremely helpful, but still, it does not solve the following situation:

I want to have a HFS file server that is accessible by everyone no matter of their user agent.

I want to have a specific folder/folders inside the root directory that are only accessible by specific user agent.

Because right now with the script you gave me I can only restrict/allow connection to the entire server based on user agent.

Now regarding "rejetto's" post:
Lets say I use this script:

[+request]
{.disconnection reason|Not allowed|if=
   {.and
      |{.match|/folder1*;/vedere*|%url%.}
      |{.match|\*Chrome*;*MSIE*|{.header|User-Agent.}.}
   .}   
.}


is "folder1" the name of the folder this script is applied to?
What does "vedere" stand for?

Can I modify this script to something like this:
disconnection reason|Allowed|if=

and only allow a specific user agent/s?

Thank you again and I hope you keep updating this amazing piece of software!
Title: Re: My questions regarding HFS
Post by: Mars on May 15, 2016, 06:01:24 PM
Quote
I want to have a specific folder/folders inside the root directory that are only accessible by specific user agent.


it is absolutely necessary to perform an update with HFS version 2.3h

the folder should belong to the VFS for convenience:
example is done with Firefox as web browser

go to -->  properties >> diff template and add one of those example

to have redirection to specific folder :  /defaultfolder/
Code: [Select]
[+]
{.set |gotofolder|/defaultfolder/.}
{.if|{.pos|Firefox|{.header|User-Agent.}.}|{:{.redirect|{.^gotofolder.}.}:}.}
 

disconnection with reason
Code: [Select]
[+]
{.if|{.pos|Firefox|{.header|User-Agent.}.}|{:{.disconnection reason| Your browser is not compatible to acces this folder <p>%folder% .}:}.}

Title: Re: My questions regarding HFS
Post by: LeoNeeson on May 17, 2016, 11:34:53 AM
@Mars/Rejetto: Since we are talking about User-Agents, here is some question I have: can we change the HTTP response header "Server" of HFS (this is a string that displays the name of the server), using Macros? If I'm not wrong (looking in the source code), it's this string: "HFS_HTTP_AGENT". I don't mean recompiling the sources (only changing the template or using some Macro or another config). I'm talking about how HFS identifies itself when some user does a HTTP request to our server. Can be done?... ???
Title: Re: My questions regarding HFS
Post by: Mars on May 17, 2016, 01:25:58 PM
I do not know how far it is possible to modify the response header but there is a macro for it

Quote
    if name = 'add header' then
      if satisfied(md.cd) then
        begin
        result:='';
        // macro 'mime' should be used for content-type, but this test will save precious time to those who will be fooled by the presence this macro
        if ansiStartsText('Content-Type:', p) then
          md.cd.conn.reply.contentType:=trim(substr(p, ':'))
        else if ansiStartsText('Location:', p) then
          with md.cd.conn.reply do
            begin
            mode:=HRM_REDIRECT;
            url:=trim(substr(p, ':'))
            end
        else
          md.cd.conn.addHeader(p);
        end;

procedure ThttpConn.addHeader(s:string; overwrite:boolean=TRUE);
var
    i, j: integer;
    name: string;
begin
if overwrite then
    begin
    // calculate the matching text
    i:=pos(':', s);
    if i = 0 then
        i:=length(s);
    name:=copy(s, 1, i);
    // see if it already exists
    i:=ipos(name, reply.additionalHeaders);
    if (i = 1) or (s[i-1] = #10) then // yes it does
        begin
        j:=posEx(#10, s, i)+1; 
        delete(s, i, j-i+1); // remove it                         
        end;
    end;
reply.additionalHeaders:=reply.additionalHeaders+s+CRLF;
end;

as default in the macro, each content of the header can be overridden

there is more to do tests to examine changes at the browser  ;)
Title: Re: My questions regarding HFS
Post by: LeoNeeson on May 18, 2016, 07:00:53 AM
:) Thank you, I'll check it out, and then post the results (in a few days).
Title: Re: My questions regarding HFS
Post by: rejetto on May 19, 2016, 04:28:46 PM
What I do hope is that you will add all of the things I asked in this topic as "default native features", so that they are more intuitive for use.

it is not so good as you may think.
People have very different needs. I should put 1000 features, you would be just lost and never find what you need. HFS is already crowded with options.
I see 2 possible paths:
- to give a GUI to allow you to make some if-this-then-that, like a sort of simple visual programming that you can use to solve a restricted set of problems, but good nonetheless.
- to let people create plugins, so one can browse through a repository of plugins and find the one he needs, and install it. This is not limited as the previous solution but you are limited by what plugins are actually created by programmers.

> is "folder1" the name of the folder this script is applied to?

yes

> What does "vedere" stand for?

another folder, i forgot to rename it to "folder2"

> Can I modify this script to something like this:
> disconnection reason|Allowed|if=
> and only allow a specific user agent/s?

not, that's just the printed message. The behavior is what comes after the IF=
Anyway, consider the script I have you is already allowing specific user agents. Chrome and IE are allowed.
To invert it, and forbid only Chrome and IE you should remove the "\" before "*Chrome"
Title: Re: My questions regarding HFS
Post by: LeoNeeson on May 22, 2016, 10:16:10 AM
- to let people create plugins, so one can browse through a repository of plugins and find the one he needs, and install it. This is not limited as the previous solution but you are limited by what plugins are actually created by programmers.
I like this option more, because I'm sure there will be programmers who may build custom plugins. Many programs (like XMplay/AIMP3/Winamp) were expanded by using plugins (I know these are music players, but there are other type of software that have a lot of plugins, to extend features).

@Mars: About my question, I've opened a new thread here (http://www.rejetto.com/forum/hfs-~-http-file-server/changing-http-response-header/).
Title: Re: My questions regarding HFS
Post by: IvanRohnson on December 10, 2016, 06:55:05 PM
Hello Again. I am currently using this script, that should limit users which are not using userAgent "Setler" / "Setler2" OR users whose request does not contain "foldernameOne" OR "FolderNameTwo"
to download anything. (At least that's what I think this script should do.

[+request]
{.disconnection reason|Not allowed|if=
   {.and
      |{.match|/FolderNameOne*;/FolderNameTwo*|%url%.}
      |{.match|\*Setler*;*Setler2*|{.header|User-Agent.}.}
   .}   
.}

I need to add the following thing:
When a user with UserAgent "Setler or "Setler2" connects and tries to download a file from lets say "MyPrimaryFolder", and the file does not exist in "MyPrimaryFolder", I want the request to be redirected to "MySecondaryFolder, and if the file is not existent in "MySecondaryFolder" I want the download to be redirected to "MyTertiaryFolder".

Can you guys give me a simple script that I will be able to understand and implement for my needs?  :o


Title: Re: My questions regarding HFS
Post by: IvanRohnson on December 11, 2016, 01:02:26 PM
Actually, it may be even simpler: User tries to download a file from "Folder1", which contains some files and some folders (folder2, folder3 etc. etc.)
SO if the file is not in the "rood" "Folder1", then make HFS try to search if the file is existent in Folder1/Folder2/filename.zip, and if the folder is not existent in Folder2, then try to redirect to Folder1/Folder2/filename.zip until all folders inside Folder1 have been 'searched' for the file.

UPDATE: I am now using a stupid simple solution (not very optimized though)

I separated my files in their appropriate folders, created a "Physical folder" in HFS and then MANUALLY added each file from each folder into that "Physical folder" so that HFS will serve these files upon their request.

Not very clean and optimized solution, because whenever I add a new file to one of the folders, I have to find it and again manually add it to HFS so that it "registers" it and serves it.

May be you can add a n option "Add files from Folder" instead of just "add files"

- a new option that will add all the files from specific folder and when you add a new file, HFS will automatically register it and serve it when someone requests download.
Title: Re: My questions regarding HFS
Post by: IvanRohnson on December 14, 2016, 06:10:39 PM
Hi again, I have a new question/problem.

Skype is conflicting with HFS. Reason is Skype is occupying port 80 so that HFS cannot use it. I also believe that if I first start HFS and then start Skype, Skype will take over port 80 and even cause HFS to crash!!
I need help fixing this, because, I need HFS to work on port 80. Any other port will not do the job for me.
 :'( :'( :'(
Title: Re: My questions regarding HFS
Post by: LeoNeeson on December 15, 2016, 02:16:40 PM
You can change the port Skype uses easily. In Skype go to Tools -> Options -> Advanced -> Connections and uncheck the box "use port 80 and 443 as alternative". That should help. Check here (http://www.steptoinstall.com/install-both-wamp-and-skype-conflict-windows-3-ways.html).
Title: Re: My questions regarding HFS
Post by: IvanRohnson on December 22, 2016, 09:55:05 PM
Thank you soo much Liam Neeson, this helped me, but unfortunately still no one gave me solution to my prevoous questions. Its not a big deal, I am doing everything manual right now, but the files are less than 200-300 so it isn't that hard. I am used to do such a work on a PC...
Title: Re: My questions regarding HFS
Post by: bmartino1 on December 24, 2016, 04:45:33 PM
Hi again, I have a new question/problem.

Skype is conflicting with HFS. Reason is Skype is occupying port 80 so that HFS cannot use it. I also believe that if I first start HFS and then start Skype, Skype will take over port 80 and even cause HFS to crash!!
I need help fixing this, because, I need HFS to work on port 80. Any other port will not do the job for me.
 :'( :'( :'(

 i rember now that skype uses port 80 and 443 for its add base setup and file transfers.

you have to tell it that you system useus a web server and not to use thoses ports:



For those that simply wish to follow written instructions, we have provided them.

Open Skype if it has not already been launched
Go to Tools –> Options from the dropdown menu
Select “Advanced” in the left-hand column, last option
Select “Connection”
Deselect the option that says, “Use port 80 and 443 as alternatives for incoming connections”
Click Save
Exit and then restart Skype
That’s it! You should now be able to do port  80 / 443 ...

-------------
Thank you soo much Liam Neeson, this helped me, but unfortunately still no one gave me solution to my prevoous questions. Its not a big deal, I am doing everything manual right now, but the files are less than 200-300 so it isn't that hard. I am used to do such a work on a PC...

alot has been looked over, you had a list of things to be answerd, please define adn re ask the quetion your haveig an issue with.
Title: Re: My questions regarding HFS
Post by: Oxyandy on December 31, 2016, 01:35:14 AM
May be you can add a n option "Add files from Folder" instead of just "add files"

- a new option that will add all the files from specific folder and when you add a new file, HFS will automatically register it and serve it when someone requests download.

In file tree of HFS (left hand view) right click select "add folder from disk"...
when prompted select "Real Folder"
It works recursively and updates automatically when files are updated / added..
Not sure how you are trying to do it now ?

PS.. You can of course drag/drop folder you wish to share into same left hand pane..
Title: Re: My questions regarding HFS
Post by: IvanRohnson on April 01, 2017, 08:17:05 PM
The thing is, Oxyandy, the RealFolder and Virtual folder have many different options and limitations. I need the RealFodler to have same options as the Virtual folder but it just lacks them. No idea why the devs didn't add the same options for both type of folders.
Title: Re: My questions regarding HFS
Post by: IvanRohnson on March 29, 2019, 05:09:40 PM
In file tree of HFS (left hand view) right click select "add folder from disk"...
when prompted select "Real Folder"
It works recursively and updates automatically when files are updated / added..
Not sure how you are trying to do it now ?

PS.. You can of course drag/drop folder you wish to share into same left hand pane..


OK ,hello again, I need to do ONE more thing urgently: I will add folders from disk as you said (I will add 3 folders) and I provide download link to the root folder only. I then want that HFS searches through all the folders that I have added from disk under "root" and when it finds the file that client requests, to serve it automatically.

IF possible without having to write the name of every folder in Event scripts (just make it search automatically)

Again with simple words: I have my root folder. Inside my root folder I have many folders with different names and files inside.
I give the client a ling that redirects him to the root folder: root/file.zip
If file.zip is not located inside the root folder, HFS must search inside every folder under root automatically until it finds the file, and it must then serve it to the client.

Thanx in advance!
Title: Re: My questions regarding HFS
Post by: bmartino1 on April 04, 2019, 12:27:01 PM
then you will need to bind hfs to the root folder. if its a real folder it should be updateing and searching that folder automaticaly.