rejetto forum

Software => HFS ~ HTTP File Server => Topic started by: morituruz on December 01, 2016, 08:49:11 AM

Title: Feature request: folder access by IP address
Post by: morituruz on December 01, 2016, 08:49:11 AM
Hello and thanks for this great software  :)
I know about User Accounts but i need more «simple» solution.
Example: i want to allow users from my LAN (10.0.0.0/24) to access some folder in HFS, and hide this folder from others.
Title: Re: Feature request: folder access by IP address
Post by: bmartino1 on December 01, 2016, 03:31:45 PM
i belive this can be doen with the macros and the template in hfs

http://www.rejetto.com/wiki/index.php?title=HFS:_scripting_commands

other wise, maybe some html programing, it seems to be a 301 redirect
http://stackoverflow.com/questions/8985502/htaccess-redirect-to-all-ips-but-mine
Title: Re: Feature request: folder access by IP address
Post by: dj on December 02, 2016, 02:36:43 PM
Change ip and Add diff template
Code: [Select]
[list]
{.if |{.%ip%=192.168.1.2.}|

<div id='files_outer'>
<div style='height:1.6em;'></div> {.comment| this is quite ugly, i know, but if i use any vertical padding with height:100% i'll get a scrollbar .}
{.if not| %number% |{: <div style='font-size:200%; padding:1em;'>{.!No {.if|{.length|{.?search.}.}|results|files.}.}</div> :}|{:
        <form method='post'>
            <table id='files'>
            {.set|sortlink| {:<a href="{.trim|
                    {.get|url|sort=$1| {.if| {.{.?sort.} = $1.} |  rev={.not|{.?rev.} .} /if.} /get.}
                /trim.}">{.!$2.}{.if| {.{.?sort.} = $1.} | &{.if|{.?rev.}|u|d.}arr;.}</a>:} .}
            <th>{.^sortlink|n|Name.}{.^sortlink|e|.extension.}
            <th>{.^sortlink|s|Size.}
            <th>{.^sortlink|t|Timestamp.}
            <th>{.^sortlink|d|Hits.}
            %list%
            </table>
        </form>
:}.}
</div>

|forbidden.}

update for your case:
{.if |{.regexp|10\.0\.0\.|%ip%.}|
or {.if |{.{.regexp|.*\.|%host%.}={.regexp|.*\.|%ip%.}.}| or {.if |{.match|10.0.0.*|%ip%.}|
Title: Re: Feature request: folder access by IP address
Post by: morituruz on December 11, 2017, 10:25:19 AM
So year later i discovered that i received a pretty good reply :D
Thank you very much!

Actually i need to deny download of *.html files so now I have that code in hfs.events:
Code: [Select]
[request]
{.if
| {.and
| {.not
| {.or
| {.match | 127.0.0.1 | %ip% .}
| {.match | 10.0.*.* | %ip% .}
.}
.}
| {.match | */some_url_path/* | %url% .}
.}
|
{:{.disconnection reason| IP: %ip%.}:}
.}

Surprisingly wiki page http://www.rejetto.com/wiki/?title=HFS:_Event_scripts does not exist anymore.
Title: Re: Feature request: folder access by IP address
Post by: LeoNeeson on December 11, 2017, 11:05:44 AM
Cool! :)

Fortunately, Archive (https://web.archive.org/web/2010/www.rejetto.com/wiki/?title=HFS:_Event_scripts). (http://archive.is/DEJLx)org (https://web.archive.org/web/2010/www.rejetto.com/wiki/?title=HFS:_Event_scripts) still has a copy of it.
Title: Re: Feature request: folder access by IP address
Post by: morituruz on December 11, 2017, 12:00:52 PM
Thanks to the wiki engine nothing was actually deleted :)
http://www.rejetto.com/wiki/index.php?title=HFS:_Event_scripts&oldid=5612
Title: Re: Feature request: folder access by IP address
Post by: LeoNeeson on December 12, 2017, 01:40:46 AM
Hi rejetto, please check your Wiki, since it seems there is a problem with it because I can't login. It shows this error: "There seems to be a problem with your login session; this action has been cancelled as a precaution against session hijacking. Go back to the previous page, reload that page and then try again.". I've tried to login with another browser, but it shows the same error.

See the screenshot: https://i.imgur.com/erYmd81.png
(https://i.imgur.com/erYmd81m.png) (https://imgur.com/a/9k6sb)

Searching on Google, here (https://stackoverflow.com/questions/38812604/cant-log-in-to-mediawiki-canceled-as-a-precaution-against-session-hijacking#), here (https://www.mediawiki.org/wiki/Topic:T7irqyk4rhfy3ohk) and here (https://www.mediawiki.org/wiki/Topic:Pjby0sdeg3e60rfy) you can find a possible solution (it seems you have to change $wgMainCacheType = CACHE_ACCEL; to $wgMainCacheType = CACHE_NONE; or changing it to $wgSessionCacheType = CACHE_DB; in the cache settings file, located in LocalSettings.php)

Cheers,
Leo.-