rejetto forum
Software => HFS ~ HTTP File Server => Programmers corner => Topic started by: Oxyandy on May 30, 2013, 11:59:33 PM
-
[+request]
{.if not|{.pos|one|{.header|one.}.}|
{.if not|{.pos|two|{.header|two.}.}|
{.if not|{.pos|three|{.header|three.}.}|
{.if not|{.pos|four|{.header|four.}.}|
{:{.disconnect.}:}
.}.}.}.}
Any combination of 2 of the above works, but not 3 or 4 of them, limitation or am I doing it wrong ?
In windows batch, would be something like this
If %%a NEQ Google (
If %%b NEQ 192.168.1.1 (
If %%c NEQ rejetto (
If %%d NEQ patch (
echo Sorry if you made it here, you do not belong !
))))
-
Thanks for the replies :-X
I have it all worked out now.
-
select what you need AND or OR syntax
[+request]
{.if not|{.or|{.pos|one|{.header|one.}.}
|{.pos|two|{.header|two.}.}
|{.pos|three|{.header|three.}.}
|{.pos|four|{.header|four.}.}
/or.}
|{:{.disconnect.}:}
.}
or
[+request]
{.if not|{.and|{.pos|one|{.header|one.}.}
|{.pos|two|{.header|two.}.}
|{.pos|three|{.header|three.}.}
|{.pos|four|{.header|four.}.}
/and.}
|{:{.disconnect.}:}
.}
if A then if B then if C then ACTION
-->> {.if|{.and|A|B|C.}|ACTION.}
-
Hi Mars,
You should close those examples
[+request]
{.if not|
{.or
|{.pos|one|{.header|one.}.}
|{.pos|two|{.header|two.}.}
|{.pos|three|{.header|three.}.}
|{.pos|four|{.header|four.}.}
/or.}
|{:{.disconnect.}:}
.}
-
you are right ;)
-
Going another level deeper
[+request]
{.if|
{.or
|{.pos|one|{.header|one.}.}
|{.pos|two|{.header|two.}.}
|{.pos|three|{.header|three.}.}
|{.pos|four|{.header|four.}.} <-- {.or One or more of these 4=Yes ?... (With {.and ALL of these 4=Yes?)
/or.}
|{.if not|
{.match|this;this;or_this|%IN_THIS%.} <-- but none of these 3=Yes in IN_THIS ?
|{:{.exec|OK then ! DO THIS !.}:}
.}
.}
Now Mars, I did this for others because it has been really hard to find good examples of script snippets,
so go on & tell me if it's wrong ::)
-
Help Question
[+request]
{.set|agent|{.header|User-Agent.}.}
How do I check if it is Null ? if %agent% = ""
I am getting triggers to my rules from null results, which I want to block. (Such as port scans.)
Trial & Error is getting tiresome :'(
Thanks very much !
EDIT:
So it can be added to the rules like this -- {.match|NULL|{.^agent.}.}
How do I do this ?
EDIT2:
Ok, I thought of a 'work around' define NULL with something that could never exist,
LIKE SO = NULL could never exist in the header, lol
[+request]
{.set|NULL|{.header|NULL.}.}
SO, {.^NULL.} must always be "" (null) - must be an easier way, (waiting for a reply) but at least my learning can move forward !
{.match|{.^NULL.}|{.^agent.}.} <- half right, has one major flaw, do you know ? ;D
Gives me the condition if no User-Agent <- ^umm not exactly {whistle}
-
%IN_THIS% --> http://www.rejetto.com/wiki/index.php?title=HFS:_Template_symbols
{.match|this;this;or_this|%IN_THIS%.} --> http://www.rejetto.com/wiki/index.php?title=HFS:_scripting_commands
match | A | B
it is true if the content B is matched by the mask A.
{.match|this1;this2;this3|%IN_THIS%.} <-- but none of these 3=Yes in IN_THIS ?
--> {.or|{.match|this1|%IN_THIS%.}|{.match|this1|%IN_THIS%.}|{.match|this1|%IN_THIS%.}.}
[+request]
{.if|{.or
|{.pos|one|{.header|one.}.}
|{.pos|two|{.header|two.}.}
|{.pos|three|{.header|three.}.}
|{.pos|four|{.header|four.}.}
/or.}
|{:{.if not|
{.or
|{.match|this1|%IN_THIS%.}
|{.match|this1|%IN_THIS%.}
|{.match|this1|%IN_THIS%.}
/or.}
|{:{.exec|OK then ! DO THIS !.}:}
.}:}
.}
-
Gives me the condition if no User-Agent
--> {.if not|{.header|User-Agent.}| OK there is User-Agent.}
{.header|User-Agent.} return the content of User-Agent, if this last one is not set then {.header| .} give an empty string --> {.if not| .} return TRUE in this case
-
Nope I didn't want an answer to this, I needed help with NULL (Just read your reply -Thank You !)
Mars it seems you are doing it the hard way..
Below these 2 are EXACTLY SAME - they both work 8)
The top example is useful if you have - %IN_THIS_1%, %IN_THIS_2%,,,,,,,etc
[+request]
{.if|{.or
|{.pos|one|{.header|one.}.}
|{.pos|two|{.header|two.}.}
|{.pos|three|{.header|three.}.}
|{.pos|four|{.header|four.}.}
/or.}
|{:{.if not|
{.or
|{.match|this1|%IN_THIS%.}
|{.match|this2|%IN_THIS%.}
|{.match|this3|%IN_THIS%.}
/or.}
|{:{.exec|OK then ! DO THIS !.}:}
.}:}
.}
[+request]
{.if|{.or
|{.pos|one|{.header|one.}.}
|{.pos|two|{.header|two.}.}
|{.pos|three|{.header|three.}.}
|{.pos|four|{.header|four.}.}
/or.}
|{:{.if not|
{.match|this1;this2;this3|%IN_THIS%.}
|{:{.exec|OK then ! DO THIS !.}:}
.}:}
.}
A real example is this
{.match|192.168.1.1;192.168.1.104;127.0.0.1|%ip%.}
So I use this to ignore requests from my PC
-
Please Mars, help - lol
I just don't seem to be getting this right :o
Let's use a real example of NULL
{.comment| IF REFERER NEQ NULL - ADD REFERER to HFS INTERNAL LOG.}
[+request]
if Referer is NOT NULL
|{.add to log|Came From {.header|Referer.}
.}
I chose {.header|Referer.} because it's easy to test :)
EDIT: Gee, I was right in theory, but wrong in usage (syntax)..
Took a bit of work to stumble upon the 'right' usage, too.
So maybe these posts of mine maybe save some people a bit of time :)
-
Ok, based I what I said earlier, this WORKS
No Referer ?, no log entry.
Referer exists ?, log entry is made.
{.comment| IF REFERER NEQ NULL - ADD REFERER to HFS INTERNAL LOG.}
[+request]
{.if not|{.match|{.^from.}|{.^NULL.}.}|{:{.add to log|Came From {.^from.}.}:}.}
So unless someone can show me a simpler way, I will stick to this :)
-
Next, to able to make a log of 404 requests..
Haven't given this much thought yet, very happy to see any existing ideas..
Off to read a bit
-
Ok,
1. I am tired, have been reading for about a week.
2. I am stuck.
How do I get 404's to a string in Events ?
Can someone tell me please, if this is possible ?
I have a program which accesses files on the server, and if they are 404, then maybe they shouldn't be.
So a 404 log is very important..
I have ideas, but it keeps getting complex :(
Thanks !
EDIT_1
This is a shame
|{.exists|file:///Z:%url%.}
Wont work
Shorten folder path from URL to just filename ?
/Some_Path/Some_File.ext = %url%
to just
Some_File.ext
Cause then I could use {.exists|Z:\Some_Path\Some_File.ext.}
-
[SOLVED] Well finally...
I added a Header String into my program, from that in [request] I can
{.set|Header_String|{.header|My_Custom_Header_String.}.}
Then from that, I can manipulate the Output - in many different ways.
Including
{.exists|Z:\Some_Path\{.^Header_String.}.} = Is file 404 ?
### Sure there was probably an easier way,
but no amount of searching/reading/requesting help/advise could give me an answer to my question.
How do I get 404's to a string in Events ?
-
if Referer is NOT NULL
|{.add to log|Came From {.header|Referer.}
.}
{.if not|{.header|referer.}|{:
{.add to log|ciao.}
:}.}
-
sorry for the late reply
I added a Header String into my program, from that in [request] I can
{.set|Header_String|{.header|My_Custom_Header_String.}.}
Then from that, I can manipulate the Output - in many different ways.
Including
{.exists|Z:\Some_Path\{.^Header_String.}.} = Is file 404 ?
what you get by passing by the "header_string" variable?
you can {.exists|Z:\Some_Path\{.header|My_Custom_Header_String.}.}
How do I get 404's to a string in Events ?
i don't understand what you mean