r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[!Uniserve] Creating Uniserve processes

DideC
9-Mar-2005
[59]
I just encap Uniserve script 2 weeks ago.

Need some tricks to encap the protocols/services, that normally Uniserve 
loads from disk at startup.
JaimeVargas
9-Mar-2005
[60x2]
Thats what I thought?
DideC, Do you mind sharing?
Graham
9-Mar-2005
[62x3]
Didier, do you have an example of your encapped changes ?
I want to add database storage for my smtp service, and since I use 
odbc, I have to encap to distribute ...otherwise users have to purchase 
command
( and, no, I don't know anything about mysql .. )
DideC
9-Mar-2005
[65]
In short.

Protocols and services (or whatever else) are encapped as data in 
a block! (a cache sort-of).

instead of 'do/'load, you have to use 'do-cache/'load-cache in your 
script.


The cache functions are initialize differently either you are encapping 
or doing the script.
Graham
9-Mar-2005
[66]
if you do cgi, then you have to launch a new version of the encapped 
script for each cgi ?
DideC
9-Mar-2005
[67x4]
Here is an example of a starter that can be used for doing the script 
and to encap it :
Rebol [

 title: "example of starter script that act the same with View after 
 encap"
]

#include %/e/rebol/sdk/source/mezz.r
#include %/e/rebol/sdk/source/prot.r
#include %/e/rebol/sdk/source/view.r

;***** This is the function that make the tricks
#include %uniserve/libs/encap-fs.r 
if not value? 'encap-fs [do %uniserve/libs/encap-fs.r]

set-cache [
	%uniserve/uni-engine.r		[#include %uniserve/uni-engine.r]
	%uniserve/libs/headers.r	[#include %uniserve/libs/headers.r]
	%libs/log.r					[#include %uniserve/libs/log.r]
	%uniserve/protocols/HTTP.r	[#include %uniserve/protocols/HTTP.r]
	
	%your-file.r					[#include %path/to/your-file.r]
	;...
]

;***** Start
do-cache %uniserve/uni-engine.r
do-cache %uniserve/libs/headers.r

UniServe-path: %./uniserve/
logger/level: none


;***** You have to load protocols and services before starting Uniserve
do-cache %uniserve/protocols/HTTP.r

;***** Uniserve Initialise
; Require like this to not loading protocols/services from disk
uniserve/boot/no-loop/with []

;***** Your script initialise
;...
This is a strip down of the script I use for encaping lecture-forum.
I can also doing it with View.
Graham
9-Mar-2005
[71]
where's the encapped version of lecture-forum?
DideC
9-Mar-2005
[72]
Nowhere actually. Just on my disk.
Graham
9-Mar-2005
[73]
o :)
JaimeVargas
9-Mar-2005
[74]
Does encap-fs defines do-cache and set-cache?
DideC
9-Mar-2005
[75x4]
Yes, very short funcs...
encap-fs: context [
	cache: path: none
	root: system/script/path

	get-cache: func [file][
		path: parse file "/"	
		remove-each dir path [dir = ".."]
		file: to-file path	
		either file [
			either file: select cache file [file][load file]			
		][
			make error! join "Cannot access : " file
		]
	]
	
	set 'encap? to-logic select system/components 'decap

	either encap? [
		set 'set-cache func [list [block!] /local bin file][
			cache: list
			;cache: make block! 16
			;parse list [
			;	some [
			;		(bin: no) opt ['binary (bin: yes)]
			;		set file file! (
			;			repend cache [
			;				file
			;				either bin [read/binary file][read file]
			;			]
			;		)
			;	]
			;]
		]
		set 'do-cache func [file [file!]][do get-cache file]
		set 'load-cache func [file [file!]][load first get-cache file]
		set 'read-cache func [file [file!]][]
	][
		set-cache: none
		do-cache: :do
		load-cache: :load
		read-cache: :read
	]
]
Oups, forget the "Rebol [ ]" header
... and to remove the comments
Graham
9-Mar-2005
[79]
encap uses old core though ...
DideC
9-Mar-2005
[80]
I use enface 1.2.48.3.1
Graham
9-Mar-2005
[81]
I must try this out tonight :)
DideC
9-Mar-2005
[82]
Bed time here. I let you play with it.
Take care of paths, it's what doom me to trouble.
JaimeVargas
9-Mar-2005
[83]
Thanks. DideC I been looking for something like this for sometime. 
You should posted to the rebol.org
Graham
10-Mar-2005
[84]
More statistics .. over the last 12 hours, 3400 smtp connections 
from mainly spamming smtp servers.  62 of those were from trusted 
servers, and 37 were caught by spamcop.  21 mails were passed thru, 
but most of these were spam as well.  These ones would be subjected 
to Bayesian analysis etc.
DideC
10-Mar-2005
[85]
Jaime: not my code. Dockimbel's one. I let him do it if he wants.
Graham
11-Mar-2005
[86]
Got a working pop server now for uniserve .. connected to a firebird 
database.

Now to get the smtp service to save files to the database as well.
DideC
11-Mar-2005
[87]
cool
Graham
11-Mar-2005
[88x5]
I did very little testing so far ..
by using the session variables, I think it should be able to handle 
multiple pop connections concurrently.
if anyone uses, mysql, they can rewrite the sql statements.
http://www.compkarori.com/vanilla/display/popd.r
the delete on quit is not implemented yet ...
Graham
12-Mar-2005
[93x2]
I've further improved my spam busting mail service.  If I get an 
email from a new user, and that email passes all my spam tests, I 
now will send an smtp challenge to the mail server that should have 
sent that mail.  I know some mail servers will respond that every 
user combination exists, but others will not, and that will all help.
I've got to the point where I can receive mail from the smtp service, 
store it in a database, and retrieve it using pop3.
Will
13-Mar-2005
[95]
that sounds pretty cool Graham!
Graham
13-Mar-2005
[96x7]
even better still, I had over a 1000 smtp connections over night, 
and I caught all the spam :)
Does anyone want to try out some spam protection for their mailbox?
It will help me determine how effective this is.

I need people who get a fair bit of spam, and don't mind their mail 
sitting on my server.
I can give you an account, and you put your existing email account 
into vacation mode, redirecting all mail to the account on my server.

My smtp service will spam filter it for you, and you can pick up 
your mail as normal but from my Rebol pop server.
Just message me here ... and I'll set it up tonight when I get back 
home.
Let me know your userid and password you want.
*message me privately here.
Graham
16-Mar-2005
[103]
Can some of you lurkers help me test out my spam filtering?
I just need you to send me an email to [gchiu-:-compkarori-:-com].

I want to see how many get non delivered, or misclassified as spam.
Just post here if you send me an email.

Thanks,
Ammon
16-Mar-2005
[104]
Sent...
Graham
16-Mar-2005
[105]
ta.
Sunanda
16-Mar-2005
[106]
Sent...
Graham
16-Mar-2005
[107]
thanks.
DideC
16-Mar-2005
[108]
sent