On Tue, 12 Jan 2010, Szak�ts Viktor wrote:
Hi,
> I went along implementing custom RPC filters (as .hrb
> modules) in hbnetiosrv, but I realized half-way that
> I totally misunderstood current implementation.
>
> I was under the impression that NETIO_RPCFUNC() is a server
> side feature (since it's implemented in netiosrv.c), but
> as far as I could derive from source and tests, it's
> a client-side one.
No, it's not client side function.
It's server side function only and it cannot work on client side.
> The idea is that I'm creating a server .exe (hbnetiosrv)
> with all functions linked in (like hbrun) and I load
> a filter .hrb which will process all incoming RPC requests
> and either answer them or deny them.
So you have to write your own version of NETIO_MTSERVER() or
change NETIO_MTSERVER() parameters and pass function symbol
to your RPC filter.
> This would ensure that only controlled set of functions
> are executed on server and it also makes it possible to
> use one generic hbnetiosrv executable to serve different
> apps with different needs by loading server-side
> functionality with: hbnetiosrv -rpc=mysrvmodul.hrb
>
> Is this possible to do, or am I missing something in
> my observations here?
Yes it's possible anyhow you may want to implement your own
custom version of NETIO_MTSERVER() function in hbnetiosrv.prg
or extend parameter list used by this function to pass such
filter, i.e. as 5-th parameter.
Below I'm attaching three functions which you can add to your
hbnetiosrv. They implement RPC filer.
BTW please remember that this functionality will be extended
yet and I add also support for using hash array as RPC wrapper.
See my and Mindaugas messages about it.
> [ Doing filtering on the client side looks like a very
> risky solution, since by getting hold of connection
> parameters (ip+port+pw), anyone can write an app to do
> anything on the server. ]
It's not risk but idiotic idea and believe me that I will
never try to implement anything like that :-)
best regards,
Przemek
STATIC FUNCTION NETIO_MTSERVER( nPort, cIfAddr, cRootDir, lRPC, ... )
LOCAL pListenSocket
IF hb_mtvm()
pListenSocket := netio_listen( nPort, cIfAddr, cRootDir, lRPC )
IF !Empty( pListenSocket )
hb_threadDetach( hb_threadStart( @netio_srvloop(), pListenSocket, ...
) )
ENDIF
ENDIF
RETURN pListenSocket
STATIC FUNCTION NETIO_SRVLOOP( pListenSocket, ... )
LOCAL pConnectionSocket
WHILE .T.
pConnectionSocket := netio_accept( pListenSocket,, ... )
IF Empty( pConnectionSocket )
EXIT
ENDIF
NETIO_RPCFUNC( pConnectionSocket, @MYRPC_FILTER() )
hb_threadDetach( hb_threadStart( @netio_server(), pConnectionSocket ) )
pConnectionSocket := NIL
ENDDO
RETURN NIL
STATIC FUNCTION MYRPC_FILTER( sFuncSym, ... )
STATIC s_hLegal := { "DATE"=>, "TIME"=> }
IF sFuncSym:name $ s_hLegal
RETURN sFuncSym:exec( ... )
ENDIF
RETURN "<<unsupported function>>"
_______________________________________________
Harbour mailing list (attachment size limit: 40KB)
[email protected]
http://lists.harbour-project.org/mailman/listinfo/harbour