Author Topic: My questions regarding HFS  (Read 5489 times)

0 Members and 1 Guest are viewing this topic.

Offline IvanRohnson

  • Occasional poster
  • *
  • Posts: 15
    • View Profile
My questions regarding HFS
« 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.

Offline IvanRohnson

  • Occasional poster
  • *
  • Posts: 15
    • View Profile
Re: My questions regarding HFS
« Reply #1 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 ; ?


« Last Edit: May 01, 2016, 12:33:20 PM by IvanRohnson »

Offline IvanRohnson

  • Occasional poster
  • *
  • Posts: 15
    • View Profile
Re: My questions regarding HFS
« Reply #2 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.

Offline bmartino1

  • Tireless poster
  • ****
  • Posts: 848
  • I'm only trying to help i mean no offense.
    • View Profile
    • My HFS Google Drive Shared Link
Re: My questions regarding HFS
« Reply #3 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
I'm only trying to help i mean no offense.
thank you for your time and patience,
Bmartino1

Offline LeoNeeson

  • Tireless poster
  • ****
  • Posts: 579
  • Solitario...
    • View Profile
    • twitter.com/LeoNeeson
Re: My questions regarding HFS
« Reply #4 on: May 06, 2016, 11:01:02 AM »
Maybe rejetto or Mars have an answer for this...
I think a "macro" is the only way to go.
« Last Edit: May 06, 2016, 11:02:40 AM by LeoNeeson »
HFS in Spanish (HFS en Español) / How to compile HFS (Tutorial)
• I'm open to help and share any file you may need (just ask me) ;)

Offline Mars

  • Operator
  • Tireless poster
  • *****
  • Posts: 1878
    • View Profile
Re: My questions regarding HFS
« Reply #5 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.}.}:}.}
  :}.}
:}.}   

Follow members gave a thank to your post:


Offline rejetto

  • Administrator
  • Tireless poster
  • *
  • Posts: 12949
    • View Profile
Re: My questions regarding HFS
« Reply #6 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

Offline IvanRohnson

  • Occasional poster
  • *
  • Posts: 15
    • View Profile
Re: My questions regarding HFS
« Reply #7 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!

Offline Mars

  • Operator
  • Tireless poster
  • *****
  • Posts: 1878
    • View Profile
Re: My questions regarding HFS
« Reply #8 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% .}:}.}

« Last Edit: May 15, 2016, 08:48:14 PM by Mars »

Offline LeoNeeson

  • Tireless poster
  • ****
  • Posts: 579
  • Solitario...
    • View Profile
    • twitter.com/LeoNeeson
Re: My questions regarding HFS
« Reply #9 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?... ???
« Last Edit: May 17, 2016, 01:05:54 PM by LeoNeeson »
HFS in Spanish (HFS en Español) / How to compile HFS (Tutorial)
• I'm open to help and share any file you may need (just ask me) ;)

Offline Mars

  • Operator
  • Tireless poster
  • *****
  • Posts: 1878
    • View Profile
Re: My questions regarding HFS
« Reply #10 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  ;)

Follow members gave a thank to your post:


Offline LeoNeeson

  • Tireless poster
  • ****
  • Posts: 579
  • Solitario...
    • View Profile
    • twitter.com/LeoNeeson
Re: My questions regarding HFS
« Reply #11 on: May 18, 2016, 07:00:53 AM »
:) Thank you, I'll check it out, and then post the results (in a few days).
HFS in Spanish (HFS en Español) / How to compile HFS (Tutorial)
• I'm open to help and share any file you may need (just ask me) ;)

Offline rejetto

  • Administrator
  • Tireless poster
  • *
  • Posts: 12949
    • View Profile
Re: My questions regarding HFS
« Reply #12 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"
« Last Edit: May 19, 2016, 04:30:45 PM by rejetto »

Offline LeoNeeson

  • Tireless poster
  • ****
  • Posts: 579
  • Solitario...
    • View Profile
    • twitter.com/LeoNeeson
Re: My questions regarding HFS
« Reply #13 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.
HFS in Spanish (HFS en Español) / How to compile HFS (Tutorial)
• I'm open to help and share any file you may need (just ask me) ;)

Offline IvanRohnson

  • Occasional poster
  • *
  • Posts: 15
    • View Profile
Re: My questions regarding HFS
« Reply #14 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