rejetto forum

Software => HFS ~ HTTP File Server => Topic started by: Tsuna on April 28, 2021, 01:52:15 PM

Title: Any way to limit viewing a folder/file from one specific IP?
Post by: Tsuna on April 28, 2021, 01:52:15 PM
Using the latest dev version and having a roadblock where I want to limit a folder such that only a specific IP can view it/access it
But unable to find anything like this in the docs or on the forum

I think it may be possible via a script for that folder? Looking for some guidance on the same
Title: Re: Any way to limit viewing a folder/file from one specific IP?
Post by: NaitLee on April 28, 2021, 02:14:23 PM
Right click on your folder, select "Properties...", then go to "Diff template" tab, put in these:
Code: [Select]
[^]
{.if|{.!=|%ip%|192.168.2.149.}|
{:{.disconnect.}:}
.}
(replace the ip to yours)

Push OK then it works ;)
Title: Re: Any way to limit viewing a folder/file from one specific IP?
Post by: danny on April 28, 2021, 02:34:53 PM
It works:
Code: [Select]
[+]
{.if|{.!=|%ip%|127.0.0.1.}|{:{.disconnect.}:}.}
Title: Re: Any way to limit viewing a folder/file from one specific IP?
Post by: Tsuna on April 28, 2021, 06:03:49 PM
Not working. REEEEEEE

I want that the file can be only accessed by a specific IP I want.

like a folder's file can be accessed through 1.1.1.1 nor can access the file.
Title: Re: Any way to limit viewing a folder/file from one specific IP?
Post by: Mars on April 28, 2021, 07:01:21 PM
if only one particular ip should be able to access the folder, add something similar in the diff template of the folder properties

either by using a forced disconnection
Code: [Select]
[+]
{.if|{.=|%ip%|127.0.0.1.}|{:{.disconnect.}:}.}

or even better by using a redirect which gives the user the impression of an invalid link

Code: [Select]
[+]
{.if|{.=|%ip%|127.0.0.1.}|{:{.redirect|../ .}:}.}


replace 127.0.0.1 by the allowed ip


a more concrete example is to only give access to a specific user without going through permissions

Code: [Select]
[+]
{.if|{.!=|%user%|Tsuna.}|{:{.redirect|../ .}:}.}


note the difference in use between  {.!=|    and  {.=|  , difference or equal usage
Title: Re: Any way to limit viewing a folder/file from one specific IP?
Post by: danny on April 29, 2021, 04:51:17 PM
...the file can be only accessed by a specific IP...
At HFS console, press alt+f6 to edit events file, and add this:
Code: [Select]
[download]
{.if|{.match|myparticularfile.doc|%url%.}|{:{.if|{.!=|%ip%|127.0.0.1.}|{:{.disconnect.}:}.}:}.}
replace  myparticularfile.doc  with target file name (to block for most)
replace  127.0.0.1  with target IP address (to allow for one)

P.S. Other options instead of  myparticularfile.doc may be /folder* or *.doc and you can even add to the list, such as myparticularfile.doc;myotherfile.txt;*.pdf with semicolon in-between. 

P.P.S. If this method seems clunky, then you could use the more normal and flexible users/groups/passwords, located in hfs menu > other options > user accounts.  And, then you can right-click on a particular folder/file to set it private to your users/groups.